Data importing
We have a number of ways to import data, besides using any of the additional packages in julia to read files.
GeophysicalModelGenerator.screenshot_to_GeoData Function
screenshot_to_GeoData(filename::String, Corner_LowerLeft, Corner_UpperRight; Corner_LowerRight=nothing, Corner_UpperLeft=nothing, Cartesian=false, UTM=false, UTMzone, isnorth=true, fieldname::Symbol=:colors)Take a screenshot of Georeferenced image either a lat/lon, x,y (if Cartesian=true) or in UTM coordinates (if UTM=true) at a given depth or along profile and converts it to a GeoData, CartData or UTMData struct, which can be saved to Paraview
The lower left and upper right coordinates of the image need to be specified in tuples of (lon,lat,depth) or (UTM_ew, UTM_ns, depth), where depth is negative inside the Earth (and in km).
The lower right and upper left corners can be specified optionally (to take non-orthogonal images into account). If they are not specified, the image is considered orthogonal and the corners are computed from the other two.
Note: if your data is in UTM coordinates you also need to provide the UTMzone and whether we are on the northern hemisphere or not (isnorth).
GeophysicalModelGenerator.screenshot_to_CartData Function
Data = screenshot_to_CartData(filename::String, Corner_LowerLeft, Corner_UpperRight; Corner_LowerRight=nothing, Corner_UpperLeft=nothing)Does the same as screenshot_to_GeoData, but returns a CartData structure
GeophysicalModelGenerator.screenshot_to_UTMData Function
Data = screenshot_to_UTMData(filename::String, Corner_LowerLeft, Corner_UpperRight; Corner_LowerRight=nothing, Corner_UpperLeft=nothing, UTMzone=nothing, isnorth::Bool=true, fieldname=:colors)Does the same as screenshot_to_GeoData, but returns for UTM data Note that you have to specify the UTMzone and isnorth
GeophysicalModelGenerator.import_topo Function
import_topo(limits; dataset="earth_relief", res="01m", reg="g")Download topography (and bathymetry) for the region limits = [lonmin, lonmax, latmin, latmax] from the GMT data server, and return it as GeoData whose Topography field is in km. Longitudes are in -180..180 with lonmin < lonmax; regions that cross the antimeridian (±180°) are not supported and raise an error.
This does not require GMT: the grids are fetched over HTTP and decoded here.
Datasets
"earth_relief"(the default) blends land topography with ocean bathymetry"earth_gebco"is GEBCO bathymetry"earth_synbath"is GEBCO with synthetic bathymetry where the sea floor is unsurveyed
Resolutions
"01d", "30m", "20m", "15m", "10m", "06m" come as one file for the globe; "05m" through "01m", "30s", "15s" and "03s" are tiled.
Note that "03s" is SRTM, which covers land only – the sea is flat zero there, and the finest resolution that carries real bathymetry is "15s".
Example
julia> Topo = import_topo([-18.7, -17.1, 28.0, 29.2], res="03s")
julia> Topo = import_topo(lon=[4,20], lat=[37,49])Tiles are cached, so importing the same region again does not download them a second time.
sourceGeophysicalModelGenerator.import_GeoTIFF Function
data_GMT = import_GeoTIFF(fname::String; fieldname=:layer1, negative=false, iskm=true, NorthernHemisphere=true, constantDepth=false, removeNaN_z=false, removeNaN_field=false)Imports a GeoTIFF dataset (usually containing a surface of some sort) using GMT and returns it as a GeoData or UTMData set. The file should have either UTM or longlat coordinates. If it does not, use QGIS to convert it to longlat coordinates.
Keywords:
fieldname: name of the field (default=:layer1)negative: if true, the depth is multiplied by -1 (default=false)iskm: if true, the depth is multiplied by 1e-3 (default=true)NorthernHemisphere: if true, the UTM zone is set to be in the northern hemisphere (default=true); only relevant if the data uses UTM projectionconstantDepth: if true, the surface is not warped by the z-values, but a constant value is used instead (default=false)removeNaN_z: if true, NaN values are removed from the z-dataset (default=false)removeNaN_field: if true, NaN values are removed from the field (default=false)
Requires loading GMT.
GeophysicalModelGenerator.tomo_2_GeoData Function
data::GeoData = tomo_2_GeoData(filename::String; vel_type::String="vs")Reads a seismic tomography dataset from a NetCDF file and returns a GeoData set. The file must contain variables for depth, longitude, latitude, and the velocity type vel_type (default "vs", the shear wave velocity). Velocities that the file marks as missing (its fill value) are returned as NaN. Requires loading NCDatasets.
GeophysicalModelGenerator.ReadCSV_LatLon Function
Data = ReadCSV_LatLon(filename::AbstractString, DepthCon::AbstractString)Reads a comma-separated file with a one-line header and returns it as GeoData. Lines starting with # are comments. The columns whose header contains lon, lat and depth give the coordinates; a unit may follow the name in brackets, e.g. depth(km), and a depth in m is converted to km. DepthCon states the sign convention of the depth column in the file: "positive" (depth increases downward; it is negated, since GeoData depth is negative below the surface) or "negative" (taken as is). Every other column becomes a field named name_unit (name_percentage for a % unit, name_none without a unit).
GeophysicalModelGenerator.SeaLevel Type
SeaLevel(name::Symbol; flip_elevation=false, flip_age=false)Sea-level curve name (a key of sea_level_files) with fields elevation and age (ka). flip_elevation and flip_age must be given together: each reverses its vector, and reversing only one would mispair ages and elevations.
GeophysicalModelGenerator.load_sea_level Function
Load the built-in sea-level curve name (a key of sea_level_files) as a SeaLevel.
GeophysicalModelGenerator.sea_level_files Constant
Maps each built-in sea-level curve name to its data file.
sourceInSAR ground motion (EGMS)
The European Ground Motion Service provides InSAR-derived ground motion for Europe. The files have to be downloaded by hand from the EGMS Explorer (which requires a free EU Login account), after which they can be read, converted to velocities over a period of choice, and put on a topography or a regular grid. See the EGMS tutorial for the download instructions and a worked example for Etna.
GeophysicalModelGenerator.import_EGMS Function
data = import_EGMS(file; limits = nothing)
data = import_EGMS(files::Vector; limits = nothing)
data = import_EGMS(directory; limits = nothing)Reads one or more .csv files of the European Ground Motion Service (EGMS), which provides InSAR-derived ground motion for Europe, into an EGMSData structure. Unzip the files that you downloaded from the EGMS Explorer first. If a directory is given, all EGMS_*.csv files in it are read.
All three product levels can be read: Basic (L2a) and Calibrated (L2b), which give the motion along the line of sight of the satellite, and Ortho (L3), which gives the vertical (_U_ in the file name) or east-west (_E_) component on a 100 m grid.
Optionally, only the points within limits = [lon_min, lon_max, lat_min, lat_max] are kept. An error is thrown if no points are read at all, for example because the limits do not overlap with the data.
Several files can only be combined if they have the same acquisition dates, which is the case for the Ortho tiles of one release and one component.
Example
julia> using Dates
julia> limits = [14.7, 15.3, 37.5, 38.0] # Etna
julia> data = import_EGMS("EGMS_L3_E47N16_100km_U_2020_2025_1.csv", limits = limits)
julia> vel = EGMS_velocity(data) # mm/yr, over the whole period
julia> vel = EGMS_velocity(data, from = Date(2021, 1, 1), to = Date(2021, 12, 31)) # mm/yr, over 2021
julia> Topo = import_topo(limits, res = "03s")
julia> Surf = EGMS_on_grid(data, Topo)
julia> write_paraview(Surf, "Etna_EGMS")See also EGMS_velocity, EGMS_points and EGMS_on_grid.
GeophysicalModelGenerator.EGMSData Type
EGMSDataInSAR measurement points of the European Ground Motion Service, as read by import_EGMS.
lon,lat: position of every point [degrees]height: height of every point above the geoid [m]dates: the acquisition dates of the time seriesdisplacement: displacement [mm], of which only the change with time is meaningful;displacement[i, p]is the value atdates[i]for pointpfields: the other numerical columns of the file, such asmean_velocity[mm/yr] (the velocity EGMS computed over the full period)
GeophysicalModelGenerator.EGMS_velocity Function
vel = EGMS_velocity(data::EGMSData; from = first(data.dates), to = last(data.dates), seasonal = nothing)Computes the average velocity [mm/yr] of every point between the dates from and to, by fitting a straight line through the displacement time series within that period. Points with too few measurements in the period get NaN.
Many points move up and down with the seasons, which would bias the velocity, in particular over short periods. With seasonal = true a yearly signal is therefore fitted together with the straight line, as EGMS does for its own mean_velocity (data.fields.mean_velocity), which covers the full period of the file. That needs at least a year of data, so by default it is done if the period is at least one year long. Points whose own measurements span less than a year within the period then get NaN.
Example
julia> using Dates
julia> vel = EGMS_velocity(data, from = Date(2021, 1, 1), to = Date(2022, 12, 31))GeophysicalModelGenerator.EGMS_on_grid Function
Grid_vel = EGMS_on_grid(data::EGMSData, Grid::GeoData; from = first(data.dates), to = last(data.dates), seasonal = nothing, radius = nothing, smooth = false, minpoints = 50, east = nothing)
Grid_vel = EGMS_on_grid(data::EGMSData, lon::AbstractRange, lat::AbstractRange; kwargs...)Puts the velocity [mm/yr] between the dates from and to (see EGMS_velocity) on a surface Grid, for example a topography that was loaded with import_topo, or on a regular grid at sea level that is spanned by the ranges lon and lat.
Every grid point gets the average velocity of the measurement points that are within radius [km] of it, and NaN if there are none: InSAR has no data over water, vegetation or snow, and those gaps are kept rather than filled. By default radius is half the diagonal of a grid cell, but at least 0.1 km (the spacing of the EGMS Ortho product).
With smooth = true the points are weighted with a Gaussian of their distance (of width radius/3) instead of equally, which gives a smooth field; radius is then three times larger by default. Being a weighted average, the result never exceeds the range of the data.
Where there is a lot of data, such a radius would average over more than needed and blur sharp steps in the velocity, such as across a fault. The radius is therefore reduced locally to the smallest one that still holds minpoints measurement points, but not below the size of a grid cell. So radius is only used in full where data is sparse. Set minpoints = Inf to always use the full radius.
Grid_vel is Grid with the additional fields velocity, npoints (the number of measurement points that were averaged) and the vector Velocity = (Ve, Vn, Vz), which can be shown as arrows in Paraview with the Glyph filter. For this, data should be the vertical component (the _U_ file of the Ortho level), which becomes Vz. Pass the east-west component (the _E_ file) as east to fill Ve, which is also added as the field velocity_east; without it Ve is zero. Vn is always zero, as EGMS has no north-south component.
GeophysicalModelGenerator.EGMS_points Function
Points = EGMS_points(data::EGMSData; from = first(data.dates), to = last(data.dates), seasonal = nothing)Returns the measurement points as a GeoData set of points, located at their own height, with the velocity [mm/yr] between from and to (see EGMS_velocity) and the other columns of the file as fields. Save it with write_paraview(Points, "name", PointsData = true).
GeophysicalModelGenerator.laea_to_lonlat Function
lon, lat = laea_to_lonlat(easting, northing)Converts ETRS89-LAEA Europe (EPSG:3035) coordinates in meters, as used by EGMS, to longitude and latitude in degrees.
sourceGeophysicalModelGenerator.lonlat_to_laea Function
easting, northing = lonlat_to_laea(lon, lat)Converts longitude and latitude in degrees to ETRS89-LAEA Europe (EPSG:3035) coordinates in meters. The inverse of laea_to_lonlat.