List of all functions
Here an overview of all functions:
GeophysicalModelGenerator.BUNDLED_SERVER_INDEX Constant
The copy of the server's index that ships with the package, for when the server cannot be asked for the current one. It changes rarely (new sets are added now and then; the existing lines stay), so a stale copy is far better than none: without it a tiled resolution would be looked for as a single global file, which does not exist.
sourceGeophysicalModelGenerator.GMT_SERVERS Constant
The GMT data server mirrors. The first that answers is used; the others are tried in turn if a download fails, so one server being offline does not fail the import.
sourceGeophysicalModelGenerator.INDEX_TIMEOUT Constant
How long to wait for the server's index file, which is a hundred kilobytes: if that does not arrive within a few seconds the mirror is not going to deliver the tiles either.
sourceGeophysicalModelGenerator.SERVER_RETRY_AFTER Constant
Once every mirror has failed to deliver a file, how long (seconds) to leave the server alone before asking it again. Without this, every later call in the session – and in every other test worker, hence the marker file rather than a variable – waits out the full retry budget too, and a run that should fail in a minute takes hours.
sourceGeophysicalModelGenerator.TILE_TIMEOUT Constant
How long to wait for one tile before giving up on that mirror and trying the next. The transfers are a few megabytes, so a minute is generous; without a limit a throttled or stalled connection blocks indefinitely.
sourceGeophysicalModelGenerator.CartData Method
Data = CartData(Grid::CartGrid, fields::NamedTuple; y_val=0.0)Returns a CartData set given a 2D or 3D cartesian grid Grid and fields defined on that grid.
GeophysicalModelGenerator.CartData Method
CartData(Grid::LaMEM_grid, fields::NamedTuple)Creates a CartData struct from a LaMEM grid and from fields stored on that grid. Note that one needs to have a field Phases and optionally a field Temp to create LaMEM marker files.
GeophysicalModelGenerator.CartData Method
CartData(xyz::Tuple{Array,Array,Array})This creates a CartData struct if you have a Tuple with 3D coordinates as input.
Example
julia> data = CartData(xyz_grid(-10:10,-5:5,0))
CartData
size : (21, 11, 1)
x ϵ [ -10.0 km : 10.0 km]
y ϵ [ -5.0 km : 5.0 km]
z ϵ [ 0.0 km : 0.0 km]
fields : (:Z,)GeophysicalModelGenerator.CartGrid Type
Structure that holds data for an orthogonal cartesian grid, which can be described with 1D vectorsGeophysicalModelGenerator.GMG_Dataset Type
Structure that stores info about a GMG Dataset, which is useful to collect a wide variety of datasets.
Name :: String # Name of the dataset
Type :: String # Volume, Surface, Point, Screenshot or Topography (any other value throws an error)
DirName :: String # Directory name or url of dataset
active :: Bool # should this data be loaded or not?
GeophysicalModelGenerator.GeoData Method
GeoData(lld::Tuple{Array,Array,Array})This creates a GeoData struct if you have a Tuple with 3D coordinates as input.
Example
julia> data = GeoData(lonlatdepth_grid(-10:10,-5:5,0))
GeoData
size : (21, 11, 1)
lon ϵ [ -10.0 : 10.0]
lat ϵ [ -5.0 : 5.0]
depth ϵ [ 0.0 : 0.0]
fields : (:Z,)GeophysicalModelGenerator.LaMEMPartitioningInfo Type
Structure that holds information about the LaMEM partitioning
sourceGeophysicalModelGenerator.ParaviewData Method
ParaviewData(Grid::LaMEM_grid, fields::NamedTuple)Creates a ParaviewData struct from a LaMEM grid and from fields stored on that grid. Note that one needs to have a field Phases and optionally a field Temp to create LaMEM marker files.
GeophysicalModelGenerator.ParticlesDistribution Type
Structure that holds information about the LaMEM particles distribution for partitioning
sourceGeophysicalModelGenerator.ProfileData Type
Structure that holds profile data (interpolated/projected on the profile)
struct ProfileData
vertical :: Bool # vertical:true, horizontal:false
start_lonlat :: Union{Nothing,Tuple{Float64,Float64}}
end_lonlat :: Union{Nothing,Tuple{Float64,Float64}}
depth :: Union{Nothing,Float64}
VolData :: GeophysicalModelGenerator.GeoData
SurfData :: Union{Nothing, NamedTuple}
TopoData :: Union{Nothing, NamedTuple}
PointData :: Union{Nothing, NamedTuple}
ScreenshotData :: Union{Nothing, NamedTuple}
end
Structure to store cross section dataGeophysicalModelGenerator.ProjectionPoint Method
ProjectionPoint(EW::Float64, NS::Float64, Zone::Int64, isnorth::Bool)Defines a projection point used for map projections, by specifying UTM coordinates (EW/NS), UTM Zone and whether you are on the northern hemisphere
sourceGeophysicalModelGenerator.ProjectionPoint Method
ProjectionPoint(; Lat=49.9929, Lon=8.2473)Defines a projection point used for map projections, by specifying latitude and longitude
sourceGeophysicalModelGenerator.Q1Data Method
Q1Data(xyz::Tuple{Array,Array,Array})This creates a Q1Data struct if you have a Tuple with 3D coordinates as input.
Example
julia> data = Q1Data(xyz_grid(-10:10,-5:5,0))
Q1Data
size : (20, 10, 0)
x ϵ [ -10.0 : 10.0]
y ϵ [ -5.0 : 5.0]
z ϵ [ 0.0 : 0.0]
fields : (:Z,)
cellfields :GeophysicalModelGenerator.Create1D_grid_vector Method
Returns 1D coordinate vectors of grid points and of marker locations for a regular spacing
sourceGeophysicalModelGenerator.Create1D_grid_vector Method
Returns 1D coordinate vectors of grid points and of marker locations for a regular spacing
sourceGeophysicalModelGenerator.EGMS_on_grid Method
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 Method
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.EGMS_velocity Method
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.InterpolateDataFields2D_vecs Method
InterpolateDataFields2D_vecs(x_vec, y_vec, depth, fields_new, X, Y)Interpolates a data field V on a 2D grid defined by UTM. Typically used for horizontal surfaces
GeophysicalModelGenerator.ParseValue_CommandLineArgs Method
This parses a LaMEM command line argument string and checks if the keyword exists thereGeophysicalModelGenerator.ParseValue_LaMEM_InputFile Method
value = ParseValue_LaMEM_InputFile(file,keyword,type; args::String=nothing)Extracts a certain keyword from a LaMEM input file and convert it to a certain type. Optionally, you can also pass command-line arguments which will override the value read from the input file.
Example 1:
julia> nmark_z = ParseValue_LaMEM_InputFile("SaltModels.dat","nmark_z",Int64)Example 2:
julia> nmark_z = ParseValue_LaMEM_InputFile("SaltModels.dat","nmark_z",Int64, args="-nel_x 128 -coord_x -4,4")GeophysicalModelGenerator.PetscBinaryWrite_Vec Method
PetscBinaryWrite_Vec(filename, A)Writes a vector A to disk, such that it can be read with PetscBinaryRead (which assumes a Big Endian type)
GeophysicalModelGenerator.ReadCSV_LatLon Method
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.Rot3D Method
xrot, yrot, zrot = Rot3D(X::Number,Y::Number,Z::Number, cosStrikeAngle, sindStrikeAngle, cosDipAngle, sinDipAngle)
Perform rotation for a point in 3D spaceGeophysicalModelGenerator.above_surface Method
Above = above_surface(Grid::CartGrid, DataSurface_Cart::CartData; above=true, cell=false)Determines if points described by the Grid CartGrid structure are above the Cartesian surface DataSurface_Cart
GeophysicalModelGenerator.above_surface Method
above_surface(Data::GeoData, DataSurface::GeoData; above=true)Returns a boolean array of size(Data.Lon), which is true for points that are above the surface DataSurface (or for points below if above=false).
This can be used, for example, to mask points above/below the Moho in a volumetric dataset or in a profile.
Example
First we create a 3D data set and a 2D surface:
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,(-300:25:0)km);
julia> Data = Depth*2;
julia> Data_set3D = GeoData(Lon,Lat,Depth,(Depthdata=Data,LonData=Lon))
GeoData
size : (11, 11, 13)
lon ϵ [ 10.0 : 20.0]
lat ϵ [ 30.0 : 40.0]
depth ϵ [ -300.0 km : 0.0 km]
fields: (:Depthdata, :LonData)
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,-40km);
julia> Data_Moho = GeoData(Lon,Lat,Depth+Lon*km, (MohoDepth=Depth,))
GeoData
size : (11, 11, 1)
lon ϵ [ 10.0 : 20.0]
lat ϵ [ 30.0 : 40.0]
depth ϵ [ -30.0 km : -20.0 km]
fields: (:MohoDepth,)Next, we intersect the surface with the data set:
julia> Above = above_surface(Data_set3D, Data_Moho);Now, Above is a boolean array that is true for points above the surface and false for points below and at the surface.
GeophysicalModelGenerator.above_surface Method
Above = above_surface(Data_LaMEM::LaMEM_grid, DataSurface_Cart::CartData)Determines if points within the 3D LaMEM_grid structure are above the Cartesian surface DataSurface_Cart
GeophysicalModelGenerator.above_surface Method
Above = above_surface(Data_Cart::ParaviewData, DataSurface_Cart::ParaviewData; above=true)Determines if points within the 3D Data_Cart structure are above the Cartesian surface DataSurface_Cart
GeophysicalModelGenerator.above_surface Method
Above = above_surface(Data_Cart::Union{Q1Data,CartData}, DataSurface_Cart::CartData; above=true)Determines if points within the 3D Data_Cart structure are above the Cartesian surface DataSurface_Cart
GeophysicalModelGenerator.add_box! Method
add_box!(Phase, Temp, Grid::AbstractGeneralGrid,
bounds::AbstractVector{<:AbstractVector{<:Real}};
Origin = nothing, StrikeAngle = 0, DipAngle = 0,
phase = ConstantPhase(1),
T = nothing,
segments = nothing,
cell = false )Add box function but getting bounds as a vector bounds in a way of [[xmin,xmax],[ymin,ymax],[zmin,zmax]]. If bounds is empty return nothing
sourceGeophysicalModelGenerator.add_box! Method
add_box!(Phase, Temp, Grid::AbstractGeneralGrid; xlim::Tuple = (20,100), [ylim::Tuple = (1,10)], zlim::Tuple = (10,80),
Origin=nothing, StrikeAngle=0, DipAngle=0,
phase = ConstantPhase(1),
T=nothing,
segments=nothing,
cell=false )Adds a box with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models
Parameters
Phase- Phase array (consistent with Grid)Temp- Temperature array (consistent with Grid)Grid- grid structure (can be any of the grid types inGMG)xlim- left/right coordinates of boxylim- front/back coordinates of box [optional; if not specified we use the whole box]zlim- bottom/top coordinates of boxOrigin- the origin, used to rotate the box around. Default is the left-front-top corner. Depths of the phase and temperature structures are measured from the top of the box, whereverOriginliesStrikeAngle- strike angle of slabDipAngle- dip angle of slabphase- specifies the phase of the box. SeeConstantPhase(),LithosphericPhases();nothingkeeps the phasesT- specifies the temperature of the box. SeeConstantTemp(),LinearTemp(),HalfspaceCoolingTemp(),SpreadingRateTemp(),LithosphericTemp()segments- optional parameter to define multiple ridge segments within the box, forT = SpreadingRateTemp()cell- if true,PhaseandTempare defined on centers
Examples
Example 1) Box with constant phase and temperature & a dip angle of 10 degrees:
julia> Grid = read_LaMEM_inputfile("test_files/SaltModels.dat")
LaMEM Grid:
nel : (32, 32, 32)
marker/cell : (3, 3, 3)
markers : (96, 96, 96)
x ϵ [-3.0 : 3.0]
y ϵ [-2.0 : 2.0]
z ϵ [-2.0 : 0.0]
julia> Phases = zeros(Int32, size(Grid.X));
julia> Temp = zeros(Float64, size(Grid.X));
julia> add_box!(Phases,Temp,Grid, xlim=(0,500), zlim=(-50,0), phase=ConstantPhase(3), DipAngle=10, T=ConstantTemp(1000))
julia> Model3D = ParaviewData(Grid, (Phases=Phases,Temp=Temp)); # Create Cartesian model
julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to paraview
1-element Vector{String}:
"LaMEM_ModelSetup.vts"Example 2) Box with halfspace cooling profile
julia> Grid = CartData(xyz_grid(-1000:10:1000,0,-660:10:0))
julia> Phases = zeros(Int32, size(Grid));
julia> Temp = zeros(Float64, size(Grid));
julia> add_box!(Phases,Temp,Grid, xlim=(0,500), zlim=(-50,0), phase=ConstantPhase(3), DipAngle=10, T=HalfspaceCoolingTemp(Age=30))
julia> Grid = addfield(Grid, (;Phases,Temp)); # Add to Cartesian model
julia> write_paraview(Grid,"LaMEM_ModelSetup") # Save model to paraview
1-element Vector{String}:
"LaMEM_ModelSetup.vts"Example 3) Box with ridge thermal structure ```julia-repl julia> Grid = CartData(xyz_grid(-1000:10:1000, -1000:10:1000, -660:5:0)) julia> Phases = fill(2, size(Grid)); julia> Temp = fill(1350.0, size(Grid)); julia> segments = [((-500.0, -1000.0), (-500.0, 0.0)), ((-250.0, 0.0), (-250.0, 200.0)), ((-750.0, 200.0), (-750.0, 1000.0))]; julia> lith = LithosphericPhases(Layers=[15 55], Phases=[1 2], Tlab=1250); julia> add_box!(Phases, Temp, Grid; xlim=(-1000.0, 0.0), ylim=(-500.0, 500.0), zlim=(-80.0, 0.0), phase=lith, T=SpreadingRateTemp(SpreadingVel=3), segments=segments) julia> Grid = addfield(Grid, (; Phases, Temp)); # Add to Cartesian model julia> write_paraview(Grid, "Ridge_Thermal_Structure") # Save model to Paraview 1-element Vector{String}: "Ridge_Thermal_Structure.vts"
sourceGeophysicalModelGenerator.add_cylinder! Method
add_cylinder!(Phase, Temp, Grid::AbstractGeneralGrid; base::Tuple = (-1,-1,-1.5), cap::Tuple = (-1,-1,-0.5), radius::Number,
phase = ConstantPhase(1),
T=nothing, cell=false )Adds a cylinder with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models. Depths in phase and T are measured below the top of the cylinder.
Parameters
Phase- Phase array (consistent with Grid)Temp- Temperature array (consistent with Grid)Grid- Grid structure (usually obtained withread_LaMEM_inputfile)base- center coordinate of bottom of cylindercap- center coordinate of top of cylinderradius- radius of the cylinderphase- specifies the phase of the box. SeeConstantPhase(),LithosphericPhases();nothingkeeps the phasesT- specifies the temperature of the box. SeeConstantTemp(),LinearTemp(),HalfspaceCoolingTemp(),SpreadingRateTemp()cell- if true,PhaseandTempare defined on cell centers
Example
Cylinder with constant phase and temperature:
julia> Grid = read_LaMEM_inputfile("test_files/SaltModels.dat")
LaMEM Grid:
nel : (32, 32, 32)
marker/cell : (3, 3, 3)
markers : (96, 96, 96)
x ϵ [-3.0 : 3.0]
y ϵ [-2.0 : 2.0]
z ϵ [-2.0 : 0.0]
julia> Phases = zeros(Int32, size(Grid.X));
julia> Temp = zeros(Float64, size(Grid.X));
julia> add_cylinder!(Phases,Temp,Grid, base=(-1,-1,-1.5), cap=(1,1,-0.5), radius=0.25, phase=ConstantPhase(4), T=ConstantTemp(400))
julia> Model3D = ParaviewData(Grid, (Phases=Phases,Temp=Temp)); # Create Cartesian model
julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to paraview
1-element Vector{String}:
"LaMEM_ModelSetup.vts"GeophysicalModelGenerator.add_ellipsoid! Method
add_ellipsoid!(Phase, Temp, Grid::AbstractGeneralGrid; cen::Tuple = (-1,-1,-1), axes::Tuple = (0.2,0.1,0.5),
Origin=nothing, StrikeAngle=0, DipAngle=0,
phase = ConstantPhase(1).
T=nothing, cell=false )Adds an Ellipsoid with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models. Depths in phase and T are measured below the top of the ellipsoid.
Parameters
Phase- Phase array (consistent with Grid)Temp- Temperature array (consistent with Grid)Grid- LaMEM grid structure (usually obtained with read_LaMEM_inputfile)cen- center coordinates of sphereaxes- semi-axes of ellipsoid in X,Y,ZOrigin- the origin, used to rotate the box around. Default is the left-front-top cornerStrikeAngle- strike angle of slabDipAngle- dip angle of slabphase- specifies the phase of the box. SeeConstantPhase(),LithosphericPhases();nothingkeeps the phasesT- specifies the temperature of the box. SeeConstantTemp(),LinearTemp(),HalfspaceCoolingTemp(),SpreadingRateTemp()cell- if true,PhaseandTempare defined on cell centers
Example
Ellipsoid with constant phase and temperature, rotated 90 degrees and tilted by 45 degrees:
julia> Grid = read_LaMEM_inputfile("test_files/SaltModels.dat")
LaMEM Grid:
nel : (32, 32, 32)
marker/cell : (3, 3, 3)
markers : (96, 96, 96)
x ϵ [-3.0 : 3.0]
y ϵ [-2.0 : 2.0]
z ϵ [-2.0 : 0.0]
julia> Phases = zeros(Int32, size(Grid.X));
julia> Temp = zeros(Float64, size(Grid.X));
julia> add_ellipsoid!(Phases,Temp,Grid, cen=(-1,-1,-1), axes=(0.2,0.1,0.5), StrikeAngle=90, DipAngle=45, phase=ConstantPhase(3), T=ConstantTemp(600))
julia> Model3D = ParaviewData(Grid, (Phases=Phases,Temp=Temp)); # Create Cartesian model
julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to paraview
1-element Vector{String}:
"LaMEM_ModelSetup.vts"GeophysicalModelGenerator.add_fault! Method
add_fault!(Phase, Temp, Grid::AbstractGeneralGrid;
Start=(20,100), End=(10,80),
Trace=nothing,
Fault_thickness=10.0,
Depth_extent=nothing,
DipAngle=0e0,
DetachmentDepth=nothing,
phase=ConstantPhase(1),
T=nothing,
cell=false)Adds a fault to the given 3D grid by modifying the Phase and Temp arrays. For a 2D grid, use add_box instead. Depths in phase and T are measured below the top of the fault's Depth_extent.
Arguments
Phase: Phase arrayTemp: Temp arrayGrid: The grid on which the fault is to be added.Start: Tuple representing the starting coordinates of the fault (X, Y).End: Tuple representing the ending coordinates of the fault (X, Y).Trace: If notnothing, the surface trace of the fault as a polyline of two or more points(X, Y), which replacesStartandEnd. The fault follows the curved trace, and its dip is perpendicular to it.Fault_thickness: Thickness of the fault.Depth_extent: Depth extent of the fault. Ifnothing, the fault extends through the entire domain.DipAngle: Dip angle of the fault, measured from the vertical. A positive angle dips to the right of the direction fromStarttoEnd(or alongTrace).DetachmentDepth: Ifnothing, the fault is planar. Otherwise, the fault is listric: it starts withDipAngleatz = 0and flattens with depth into a horizontal detachment atz = -DetachmentDepth, followingz = -DetachmentDepth * (1 - exp(-h / (DetachmentDepth * tand(DipAngle))))at a horizontal distancehfrom the trace. The thickness is accurate where the curvature radius exceedsFault_thickness.phase: Phase to be assigned to the fault;nothingkeeps the phasesT: Temperature to be assigned to the fault. Ifnothing, the temperature is not modified.
Example
add_fault!(Phase, Temp, Grid;
Start=(20,100), End=(10,80),
Fault_thickness=10.0,
Depth_extent=(-25.0, 0.0),
DipAngle=-10.0,
phase=ConstantPhase(1)
)Listric normal fault that flattens into a detachment at 15 km depth:
add_fault!(Phase, Temp, Grid;
Start=(50,0), End=(50,100),
Fault_thickness=2.0,
DipAngle=30.0,
DetachmentDepth=15.0,
phase=ConstantPhase(1)
)Fault with a curved surface trace, dipping towards the center of the arc:
add_fault!(Phase, Temp, Grid;
Trace=[(50 + 40cosd(a), 50 + 40sind(a)) for a in 0:10:180],
Fault_thickness=2.0,
DipAngle=-30.0,
phase=ConstantPhase(1)
)GeophysicalModelGenerator.add_layer! Method
add_layer!(Phase, Temp, Grid::AbstractGeneralGrid; xlim::Tuple = (1,100), [ylim::Tuple = (0,20)], zlim::Tuple = (0,-100),
phase = ConstantPhase(1),
T=nothing, cell=false )Adds a layer with phase & temperature structure to a 3D model setup. The most common use would be to add a lithospheric layer to a model setup. This simplifies creating model geometries in geodynamic models
Parameters
Phase- Phase array (consistent with Grid)Temp- Temperature array (consistent with Grid)Grid- grid structure (usually obtained with read_LaMEM_inputfile, but can also be other grid types)xlim- left/right coordinates of boxylim- front/back coordinates of boxzlim- bottom/top coordinates of box. Each bound is either a number, a functionz(x, y), or a surfaceCartData(e.g. imported topography or a Moho map), which gives a layer with a curved or perturbed bottom or top surface. A surface must coverxlimandylim.phase- specifies the phase of the box. SeeConstantPhase(),LithosphericPhases();nothingkeeps the phasesT- specifies the temperature of the box. SeeConstantTemp(),LinearTemp(),HalfspaceCoolingTemp(),SpreadingRateTemp()
Numeric limits may be given in either order. Thermal and phase structures see the vertical coordinate z - top(x, y), the (negative) depth below the top of the layer, so that the layers of LithosphericPhases and the profile of HalfspaceCoolingTemp start at the top of the layer, whether it is a number or a curved surface. LinearTemp goes from Ttop at the top to Tbot at the bottom of the layer at every (x, y).
Examples
Example 1) Layer with constant phase and temperature
julia> Grid = read_LaMEM_inputfile("test_files/SaltModels.dat")
LaMEM Grid:
nel : (32, 32, 32)
marker/cell : (3, 3, 3)
markers : (96, 96, 96)
x ϵ [-3.0 : 3.0]
y ϵ [-2.0 : 2.0]
z ϵ [-2.0 : 0.0]
julia> Phases = zeros(Int32, size(Grid.X));
julia> Temp = zeros(Float64, size(Grid.X));
julia> add_layer!(Phases,Temp,Grid, zlim=(-50,0), phase=ConstantPhase(3), T=ConstantTemp(1000))
julia> Model3D = ParaviewData(Grid, (Phases=Phases,Temp=Temp)); # Create Cartesian model
julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to paraview
1-element Vector{String}:
"LaMEM_ModelSetup.vts"Example 2) Box with halfspace cooling profile
julia> Grid = read_LaMEM_inputfile("test_files/SaltModels.dat")
julia> Phases = zeros(Int32, size(Grid.X));
julia> Temp = zeros(Float64, size(Grid.X));
julia> add_layer!(Phases,Temp,Grid, zlim=(-50,0), phase=ConstantPhase(3), T=HalfspaceCoolingTemp())
julia> Model3D = ParaviewData(Grid, (Phases=Phases,Temp=Temp)); # Create Cartesian model
julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to paraview
1-element Vector{String}:
"LaMEM_ModelSetup.vts"Example 3) Layer with a sinusoidal bottom surface, as for a Rayleigh-Taylor instability
julia> Grid = CartData(xyz_grid(-3:0.05:3, 0, -2:0.05:0))
julia> Phases = zeros(Int32, size(Grid));
julia> Temp = zeros(Float64, size(Grid));
julia> add_layer!(Phases, Temp, Grid, zlim=((x, y) -> -0.5 + 0.05cospi(x), 0), phase=ConstantPhase(1))GeophysicalModelGenerator.add_plate! Method
add_plate!(Phase, Temp, Grid::AbstractGeneralGrid,
bounds::AbstractVector{<:AbstractVector{<:Real}};
phase = ConstantPhase(1),
T = nothing,
segments = nothing,
cell = false )Add plate function but getting bounds as a vector bounds in a way of [[xmin,xmax],[ymin,ymax],[zmin,zmax]]. If bounds is empty return nothing
sourceGeophysicalModelGenerator.add_plate! Method
add_plate!(Phase, Temp, Grid::AbstractGeneralGrid; xlim=(), ylim=(), zlim::Tuple = (0.0,0.8), phase = ConstantPhase(1), T=nothing, segments=nothing, cell=false )Adds a tectonic plate with phase and temperature structure to a 3D model setup. Depths in phase and T are measured below the top of the plate (the maximum of zlim). This function enables the definition of tectonic plates in the xy plane and projects them along the z-axis, providing a flexible approach to model complex plate geometries. Parameters ==========
Phase- Phase array (consistent with Grid)Temp- Temperature array (consistent with Grid)Grid- Grid structure (usually obtained with read_LaMEM_inputfile)xlim-x-coordinate of the polygon points, same ordering as ylim, number of points unlimitedylim-y-coordinate of the polygon points, same ordering as xlim, number of points unlimitedzlim-z-coordinate range for projecting the polygon (start and stop, two values)phase- Specifies the phase of the plate. SeeConstantPhase();nothingkeeps the phasesT- Specifies the temperature of the plate. SeeConstantTemp(),LinearTemp(),HalfspaceCoolingTemp(),SpreadingRateTemp()segments- Optional. Ridge segments forT = SpreadingRateTemp(), from which the plate age is measured.cell- If true,PhaseandTempare defined on cell centers
Example
Tectonic plate in the xy plane with phase and temperature structure: ```julia-repl julia> x, y, z = -1000.0:4:0.0, -1000.0:4:1000.0, -660.0:5:0.0; julia> Grid = CartData(xyz_grid(x, y, z)) Grid: nel : (512, 512, 128) marker/cell : (1, 1, 1) markers : (512, 512, 128) x ϵ [-1000.0 : 0.0] y ϵ [-1000.0 : 1000.0] z ϵ [-660.0 : 0.0] julia> Phases = zeros(Int32, size(Grid.X)) julia> Temp = zeros(Float64, size(Grid.X)) julia> segments = [ ((-500.0, -1000.0), (-500.0, 0.0)), # Segment 1 ((-250.0, 0.0), (-250.0, 200.0)), # Segment 2 ((-750.0, 200.0), (-750.0, 1000.0)) # Segment 3 ] julia> lith = LithosphericPhases(Layers=[15 55], Phases=[1 2], Tlab=1250) julia> add_plate!(Phases, Temp, Grid; xlim=(-1000.0, -750.0, -250.0, 0.0, -250.0, -750.0), ylim=(0.0, 500.0, 500.0, 0.0, -500.0, -500.0), zlim=(-150.0, 0.0), phase=lith, T=SpreadingRateTemp(SpreadingVel=3), segments=segments) julia> Grid = addfield(Grid, (; Phases, Temp)) # Add fields julia> write_paraview(Grid, "Plate") # Save model to Paraview 1-element Vector{String}: "Plate.vts"
sourceGeophysicalModelGenerator.add_polygon! Method
add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid,
bounds::AbstractVector{<:AbstractVector{<:Real}};
phase = ConstantPhase(1),
T = nothing,
cell = false )Add polygon function but getting bounds as a vector bounds in a way of [[xmin,xmax],[ymin,ymax],[zmin,zmax]]. If bounds is empty return nothing
sourceGeophysicalModelGenerator.add_polygon! Method
add_polygon!(Phase, Temp, Grid::AbstractGeneralGrid; xlim=(), ylim=(0.0,0.8), zlim=(), phase = ConstantPhase(1), T=nothing, cell=false )Adds a polygon with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models. Depths in phase and T are measured below the top of the polygon (the maximum of zlim).
Parameters
Phase- Phase array (consistent with Grid)Temp- Temperature array (consistent with Grid)Grid- Grid structure (usually obtained with read_LaMEM_inputfile)xlim-x-coordinate of the polygon points, same ordering as zlim, number of points unlimitedylim-y-coordinate, limitation in length possible (two values (start and stop))zlim-z-coordinate of the polygon points, same ordering as xlim, number of points unlimitedphase- specifies the phase of the box. SeeConstantPhase();nothingkeeps the phasesT- specifies the temperature of the box. SeeConstantTemp(),LinearTemp(),HalfspaceCoolingTemp(),SpreadingRateTemp()cell- if true,PhaseandTempare defined on cell centers
Example
Polygon with constant phase and temperature:
julia> Grid = read_LaMEM_inputfile("test_files/SaltModels.dat")
LaMEM Grid:
nel : (32, 32, 32)
marker/cell : (3, 3, 3)
markers : (96, 96, 96)
x ϵ [-3.0 : 3.0]
y ϵ [-2.0 : 2.0]
z ϵ [-2.0 : 0.0]
julia> Phases = zeros(Int32, size(Grid.X));
julia> Temp = zeros(Float64, size(Grid.X));
julia> add_polygon!(Phase, Temp, Cart; xlim=(0,0, 1.6, 2.0),ylim=(0,0.8), zlim=(0,-1,-2,0), phase = ConstantPhase(8), T=ConstantTemp(30))
julia> Model3D = ParaviewData(Grid, (Phases=Phases,Temp=Temp)); # Create Cartesian model
julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to paraview
1-element Vector{String}:
"LaMEM_ModelSetup.vts"GeophysicalModelGenerator.add_slab! Method
add_slab!(Phase, Temp, Grid::AbstractGeneralGrid, slab::BezierSlab; phase = ConstantPhase(1), T = nothing, cell = false)Adds a slab whose top is a Bézier surface, see BezierSlab.
GeophysicalModelGenerator.add_slab! Method
add_slab!(Phase, Temp, Grid::AbstractGeneralGrid, trench::Trench; phase = ConstantPhase(1), T = nothing, cell=false)Adds a curved slab with phase & temperature structure to a 3D model setup.
Parameters
Phase- Phase array (consistent with Grid)Temp- Temperature array (consistent with Grid)Grid- grid structure (can be any of the grid types inGMG)trench- Trench structurephase- specifies the phase of the box. SeeConstantPhase(),LithosphericPhases();nothingkeeps the phasesT- specifies the temperature of the box. SeeConstantTemp(),LinearTemp(),HalfspaceCoolingTemp(),SpreadingRateTemp(),LithosphericTemp()cell- if true,PhaseandTempare defined on cells
Examples
Example 1) Slab
julia> x = LinRange(0.0,1200.0,128);
julia> y = LinRange(0.0,1200.0,128);
julia> z = LinRange(-660,50,128);
julia> Cart = CartData(xyz_grid(x, y, z));
julia> Phase = ones(Int64,size(Cart));
julia> Temp = fill(1350.0,size(Cart));
# Define the trench:
julia> trench= Trench(Start = (400.0,400.0), End = (800.0,800.0), θ_max = 45.0, direction = 1.0, n_seg = 50, Length = 600.0, Thickness = 80.0, Lb = 500.0, d_decoupling = 100.0, type_bending =:Ribe)
julia> phase = LithosphericPhases(Layers=[5 7 88], Phases = [2 3 4], Tlab=nothing)
julia> TsHC = HalfspaceCoolingTemp(Tsurface=20.0, Tmantle=1350, Age=30, Adiabat=0.4)
julia> add_slab!(Phase, Temp, Cart, trench, phase = phase, T = TsHC)GeophysicalModelGenerator.add_sphere! Method
add_sphere!(Phase, Temp, Grid::AbstractGeneralGrid; cen::Tuple = (0,0,-1), radius::Number,
phase = ConstantPhase(1).
T=nothing, cell=false )Adds a sphere with phase & temperature structure to a 3D model setup. This simplifies creating model geometries in geodynamic models. Depths in phase and T are measured below the top of the sphere.
Parameters
Phase- Phase array (consistent with Grid)Temp- Temperature array (consistent with Grid)Grid- LaMEM grid structure (usually obtained with read_LaMEM_inputfile)cen- center coordinates of sphereradius- radius of spherephase- specifies the phase of the box. SeeConstantPhase(),LithosphericPhases();nothingkeeps the phasesT- specifies the temperature of the box. SeeConstantTemp(),LinearTemp(),HalfspaceCoolingTemp(),SpreadingRateTemp()cell- if true,PhaseandTempare defined on cell centers
Example
Sphere with constant phase and temperature:
julia> Grid = read_LaMEM_inputfile("test_files/SaltModels.dat")
LaMEM Grid:
nel : (32, 32, 32)
marker/cell : (3, 3, 3)
markers : (96, 96, 96)
x ϵ [-3.0 : 3.0]
y ϵ [-2.0 : 2.0]
z ϵ [-2.0 : 0.0]
julia> Phases = zeros(Int32, size(Grid.X));
julia> Temp = zeros(Float64, size(Grid.X));
julia> add_sphere!(Phases,Temp,Grid, cen=(0,0,-1), radius=0.5, phase=ConstantPhase(2), T=ConstantTemp(800))
julia> Model3D = ParaviewData(Grid, (Phases=Phases,Temp=Temp)); # Create Cartesian model
julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to paraview
1-element Vector{String}:
"LaMEM_ModelSetup.vts"GeophysicalModelGenerator.add_stripes! Method
add_stripes!(Phase, Grid::AbstractGeneralGrid;
stripAxes = (1,1,0),
stripeWidth = 0.2,
stripeSpacing = 1,
Origin = nothing,
StrikeAngle = 0,
DipAngle = 0,
phase = ConstantPhase(3),
stripePhase = ConstantPhase(4),
cell = false)Adds stripes to a pre-defined phase (e.g. added using add_box!)
Parameters
Phase- Phase array (consistent with Grid)Grid- grid structure (usually obtained with read_LaMEM_inputfile, but can also be other grid types)stripAxes- sets the axis for which we want the stripes. Default is (1,1,0) i.e. X, Y and not ZstripeWidth- width of the stripestripeSpacing- space between two stripesOrigin- the origin, used to rotate the stripes around. Default is the corner of the grid with the maximum x, y and zStrikeAngle- strike angleDipAngle- dip anglephase- specifies the phase we want to apply stripes tostripePhase- specifies the stripe phasecell- if true,PhaseandTempare defined on centers
Example
Example: Box with striped phase and constant temperature & a dip angle of 10 degrees:
julia> Grid = read_LaMEM_inputfile("test_files/SaltModels.dat")
LaMEM Grid:
nel : (32, 32, 32)
marker/cell : (3, 3, 3)
markers : (96, 96, 96)
x ϵ [-3.0 : 3.0]
y ϵ [-2.0 : 2.0]
z ϵ [-2.0 : 0.0]
julia> Phases = zeros(Int32, size(Grid.X));
julia> Temp = zeros(Float64, size(Grid.X));
julia> add_box!(Phases,Temp,Grid, xlim=(0,500), zlim=(-50,0), phase=ConstantPhase(3), DipAngle=10, T=ConstantTemp(1000))
julia> add_stripes!(Phases, Grid, stripAxes=(1,1,1), stripeWidth=0.2, stripeSpacing=1, Origin=nothing, StrikeAngle=0, DipAngle=10, phase=ConstantPhase(3), stripePhase=ConstantPhase(4))
julia> Model3D = ParaviewData(Grid, (Phases=Phases,Temp=Temp)); # Create Cartesian model
julia> write_paraview(Model3D,"LaMEM_ModelSetup") # Save model to paraview
1-element Vector{String}:
"LaMEM_ModelSetup.vts"GeophysicalModelGenerator.add_volcano! Method
add_volcano!( Phases, Temp, Grid::CartData; volcanic_phase, center, height, radius, crater, base, background, T, )
Adds a volcano topography (cones and truncated cones)
Parameters
Phases - Phase array (consistent with Grid)
Temp - Temperature array (consistent with Grid)
Grid - CartData
Optional Parameters
volcanic_phase - phase number of the volcano,
center - x- and -coordinates of center of volcano
height - height of volcano
radius - radius of volcano
T - temperature structure, applied to every point with a phase > 0 (all rock, not only the volcano; phase 0 is taken as air), with depth measured from the new topography, so that isotherms follow the volcano surface
crater - this will create a truncated cone and the option defines the radius of the flat top
base - this sets the flat topography around the volcano
background - this allows loading in a topography and only adding the volcano on top (also allows stacking of several cones to get a volcano with different slopes)
GeophysicalModelGenerator.addfield Method
V = addfield(V::AbstractGeneralGrid,field_name::String,data::Any)Add Fields Data to GeoData or CartData
sourceGeophysicalModelGenerator.addfield Method
V = addfield(V::CartData,new_fields::NamedTuple)Add new_fields fields to a CartData dataset
GeophysicalModelGenerator.addfield Method
V = addfield(V::FEData,new_fields::NamedTuple; cellfield=false)Add new_fields fields to a FEData dataset; set cellfield to true if the field is a cell field; otherwise it is a vertex field
GeophysicalModelGenerator.addfield Method
V = addfield(V::GeoData,new_fields::NamedTuple)Add new_fields fields to a GeoData dataset
GeophysicalModelGenerator.addfield Method
V = addfield(V::Q1Data,new_fields::NamedTuple; cellfield=false)Add new_fields fields to a Q1Data dataset; set cellfield to true if the field is a cell field; otherwise it is a vertex field
GeophysicalModelGenerator.average_q1 Method
out = average_q1(d::Array)3D linear averaging of a 3D array
sourceGeophysicalModelGenerator.below_surface Method
Below = below_surface(Grid::CartGrid, DataSurface_Cart::CartData; cell=false)Determines if points described by the Grid CartGrid structure are below the Cartesian surface DataSurface_Cart. If cell=true, the cell centers of Grid are used instead of its vertices.
GeophysicalModelGenerator.below_surface Method
Below = below_surface(Data::GeoData, DataSurface::GeoData)Determines if points within the 3D Data structure are below the GeoData surface DataSurface
GeophysicalModelGenerator.below_surface Method
Below = below_surface(Data_LaMEM::LaMEM_grid, DataSurface_Cart::CartData)Determines if points within the 3D LaMEM_grid structure are below the Cartesian surface DataSurface_Cart
GeophysicalModelGenerator.below_surface Method
Below = below_surface(Data_Cart::ParaviewData, DataSurface_Cart::ParaviewData)Determines if points within the 3D Data_Cart structure are below the Cartesian surface DataSurface_Cart
sourceGeophysicalModelGenerator.below_surface Method
Below = below_surface(Data_Cart::Union{CartData,Q1Data}, DataSurface_Cart::CartData; cell=false)Determines if points within the 3D Data_Cart structure are below the Cartesian surface DataSurface_Cart. If cell=true, the cell centers of Data_Cart are used instead of its vertices.
GeophysicalModelGenerator.bezier_curve Function
bezier_curve(points, n = 100)Returns n points along the Bézier curve with control points points, such as [(x1, y1), (x2, y2), ...]. The curve starts at the first and ends at the last control point; its degree is one less than the number of control points. The result can be used wherever a polyline is expected, e.g. as Trace of a Trench or of add_fault!, or as polygon of add_plate!. Curves joined end to end form a path; drop the first point of every following curve, as consecutive points of a trace must differ.
Example
julia> trace = bezier_curve([(400.0, 0.0), (400.0, 500.0), (700.0, 500.0), (700.0, 1000.0)], 50);
julia> trench = Trench(Trace = trace, Thickness = 80.0, θ_max = 45.0, Length = 400, Lb = 200);GeophysicalModelGenerator.bilinear Method
bilinear(xs, ys, A, x, y)Sample A at (x, y) by interpolating between the four surrounding points, which is what GMT does when it resamples a coarser set into a finer grid. Falls back to the nearest edge value outside the grid.
GeophysicalModelGenerator.bouguer_correction Method
bc = bouguer_correction(topo; density = 2670, density_water = 1040)Simple Bouguer correction [mGal]: the attraction 2πGρh of an infinite slab with the thickness of the topography topo [km] (a number or an array). For negative topo (oceans), the water is replaced by rock, i.e. the correction is 2πG(density_water - density)|topo|. Subtract it from the free-air anomaly to get the simple Bouguer anomaly. topographic_effect includes the terrain.
GeophysicalModelGenerator.box_field Method
gz, ge, gn = box_field(c, t1, t2, h, m11, m22, m33, m12, m13, m23)As box_field(c, t1, t2, h, m11, m22, m33), for a cell with the full tensor of second moments (per unit volume, about its centroid), e.g. a hexahedron whose top and bottom are inclined. With m12 = m13 = m23 = 0 it equals the box version.
GeophysicalModelGenerator.box_field Method
gz, ge, gn = box_field(c, t1, t2, h, m1, m2, m3)Attraction of a homogeneous box with mass factor c (G * mGal * density * volume) and second moments m1, m2, m3 (L²/12 of its edges along east, north and up), at a station at offset (t1, t2, h) (east, north, up; station - box centre): the point mass plus the quadrupole term of the box, whose error decreases with the fourth power of size/distance. Returns the downward component and its derivatives towards east and north.
GeophysicalModelGenerator.cell_area Method
area_m2 = cell_area(Topo::GeoData)Returns the cell area for a Topographic dataset in m² (required for upstream area calculation)
sourceGeophysicalModelGenerator.check_multigrid_compatibility Function
check_multigrid_compatibility(nx::Int, ny::Int, nz::Int, total_ranks::Int)Check if the model resolution and MPI ranks are optimal for multigrid methods.
sourceGeophysicalModelGenerator.combine_vol_data Method
VolData_combined = combine_vol_data(VolData::NamedTuple; lat=nothing, lon=nothing, depth=nothing, dims=(100,100,100), dataset_preferred = 1)This takes different volumetric datasets (specified in VolData) & merges them into a single one. You need to either provide the "reference" dataset within the NamedTuple (dataset_preferred), or the lat/lon/depth and dimensions of the new dataset. VolData must contain at least one dataset.
GeophysicalModelGenerator.compute_bending_angle Method
θ = compute_bending_angle(θ_max,Lb,l,type)function that computes the bending angle θ as a function of length along the slab l.
Parameters
θ_max = maximum bending angle Lb = length at which the function of bending is applied (Lb<=Length) l = current position within the slab type = type of bending [:Ribe,:Linear]
GeophysicalModelGenerator.compute_phase Method
Phase = compute_phase(Phase, Temp, X, Y, Z, s::LithosphericPhases; Ztop = 0)or
Phase = compute_phase(Phase, Temp, Grid::LaMEM_grid, s::LithosphericPhases)This copies the layered lithosphere onto the Phase matrix.
Parameters
Phase - Phase array
Temp - Temperature array
X - x-coordinate array (consistent with Phase and Temp)
Y - y-coordinate array (consistent with Phase and Temp)
Z - Vertical coordinate array (consistent with Phase and Temp)
s - LithosphericPhases
Ztop - Vertical coordinate of top of model box
Grid - LaMEM grid (usually obtained with read_LaMEM_inputfile);
Ztopis the top of the grid
GeophysicalModelGenerator.compute_slab_surface Method
Top, Bot = compute_slab_surface(trench::Trench)Computes the (x,z) coordinates of the slab top, bottom surface using the mid surface of the slab as reference.
Parameters
trench-Trenchstructure that contains the relevant parameters
Method
It computes it by discretizing the slab surface in n_seg segments, and computing the average bending angle (which is a function of the current length of the slab). Next, it compute the coordinates assuming that the trench is at 0.0, and assuming a positive θ_max angle.
GeophysicalModelGenerator.compute_thermal_structure Method
compute_thermal_structure(Temp, X, Y, Z, Phase, s::LinearWeightedTemperature)Weight average along distance
Do a weight average between two field along a specified direction
Given a distance (could be any array, from X,Y) -> the weight of F1 increase from the origin, while F2 decreases.
This function has been conceived for averaging the solution of McKenzie and half space cooling models, but it can be used to smooth the temperature field from continent ocean:
Select the boundary to apply;
transform the coordinate such that dist represent the perpendicular direction along which you want to apply this smoothening and in a such way that 0.0 is the point in which the weight of F1 is equal to 0.0;
Select the points that belongs to this area
compute the thermal fields
then modify F.
GeophysicalModelGenerator.compute_thermal_structure Method
compute_thermal_structure(Temp, X, Y, Z, Phase, s::McKenzie_subducting_slab)Compute the temperature field of a McKenzie_subducting_slab. Uses the analytical solution of McKenzie (1969) ["Speculations on the consequences and causes of plate motions"]. Depth is measured from the top of the region, and the slab thickness is the height of the region.
Parameters
=============================
Temp: Temperature arrayX: X ArrayY: Y ArrayZ: Z ArrayPhase: Phase arrays:McKenzie_subducting_slab
GeophysicalModelGenerator.compute_thermal_structure Method
compute_thermal_structure(Temp, X, Y, Z, Phase, s::SpreadingRateTemp, segments)Calculates the temperature distribution across the plate considering multiple ridge segments.
This function computes the thermal structure based on the perpendicular distance from each point to its corresponding ridge segment, and applies a thermal model using a spreading velocity and thermal age.
Parameters
Temp : Temperature field to be updated (array)
X, Y, Z : Coordinates of the points (arrays)
Phase : Phase of the material (unused)
s : SpreadingRateTemp object containing the thermal and spreading parameters
segments : List of ridge segments, where each segment is defined by two tuples representing the start and end coordinates (x1, y1) and (x2, y2) for each segment.
Note
The temperature at each point is calculated using the thermal age, which is determined by the spreading velocity and the distance from the point to the ridge segment that produced it. Consecutive segments are joined by transform faults, from the end of one segment to the start of the next; the fracture zones continue the transform faults as straight lines and separate the regions of the segments. The segments are therefore ordered along the ridge, and each pair of consecutive segments must lie on opposite sides of their transform fault.
The function works with one or more segments, and the ridge can be placed at any position within the box, not only at its boundary.
The thermal age is capped at maxAge years, and the temperature is adjusted based on the distance to the ridge and the corresponding thermal gradient.
GeophysicalModelGenerator.convert2CartData Method
convert2CartData(d::GeoData, proj::ProjectionPoint)Converts a GeoData structure to a CartData structure, which essentially transfers the dimensions to km
GeophysicalModelGenerator.convert2CartData Method
convert2CartData(d::UTMData, proj::ProjectionPoint)Converts a UTMData structure to a CartData structure, which essentially transfers the dimensions to km
GeophysicalModelGenerator.convert2FEData Method
fe_data::FEData = convert2FEData(d::Q1Data)Creates a Q1 FEM mesh from the Q1Data data which holds the vertex coordinates and cell/vertex fields
GeophysicalModelGenerator.convert2UTMzone Method
convert2UTMzone(d::CartData, proj::ProjectionPoint)This transfers a CartData dataset to a UTMData dataset, that has a single UTM zone. The point around which we project is ProjectionPoint
GeophysicalModelGenerator.convert2UTMzone Method
convert2UTMzone(d::GeoData, p::ProjectionPoint)Converts a GeoData structure to fixed UTM zone, around a given ProjectionPoint This useful to use real data as input for a cartesian geodynamic model setup (such as in LaMEM). In that case, we need to project map coordinates to cartesian coordinates. One way to do this is by using UTM coordinates. Close to the ProjectionPoint the resulting coordinates will be rectilinear and distance in meters. The map distortion becomes larger the further you are away from the center.
GeophysicalModelGenerator.coordinate_grids Method
X,Y,Z = coordinate_grids(Data::CartGrid; cell=false)Returns 3D coordinate arrays
sourceGeophysicalModelGenerator.coordinate_grids Method
X,Y,Z = coordinate_grids(Data::LaMEM_grid; cell=false)Returns 3D coordinate arrays
sourceGeophysicalModelGenerator.coordinate_grids Method
X,Y,Z = coordinate_grids(Data; cell=false)Returns 3D coordinate arrays of a GeoData (lon, lat, depth), UTMData (EW, NS, depth), CartData, ParaviewData or Q1Data (x, y, z) set.
GeophysicalModelGenerator.countmap Method
DatasetcountMap = countmap(DataSet::GeoData,field::String,stepslon::Int64,stepslat::Int64)Takes a 2D GeoData struct and counts entries of field per predefined control area. field should only consist of 1.0s and 0.0s. The control area is defined by steplon and steplat. steplon is the number of control areas in longitude direction and steplat the number of control areas in latitude direction. The counts per control area are normalized by the highest count.
julia> Data_Faults = GeoData(Lon3D,Lat3D,Faults,(Faults=Faults,))
GeoData
size : (375, 208, 1)
lon ϵ [ -9.932408319802885 : 34.93985125012068]
lat ϵ [ 35.086096468211394 : 59.919210145128545]
depth ϵ [ 0.0 : 1.0]
fields : (:Faults,)
julia> steplon = 125
julia> steplat = 70
julia> countmap = countmap(Data_Faults,"Faults",steplon,steplat)
GeoData
size : (124, 69, 1)
lon ϵ [ -9.751471789279 : 34.75891471959677]
lat ϵ [ 35.26604656731949 : 59.73926004602028]
depth ϵ [ 0.0 : 1.0]
fields : (:countmap,)julia
sourceGeophysicalModelGenerator.create_CartGrid Method
Grid = create_CartGrid(; size=(), x = nothing, z = nothing, y = nothing, extent = nothing, CharDim = nothing)Creates a 1D, 2D or 3D cartesian grid of given size. Grid can be created by defining the size and either the extent (length) of the grid in all directions, or by defining start & end points (x,y,z). If you specify CharDim (a structure with characteristic dimensions created with GeoParams.jl), we will nondimensionalize the grd before creating the struct.
Spacing is assumed to be constant in a given direction
This can also be used for staggered grids, as we also create 1D vectors for the central points. The points you indicate in size are the corner points.
Note: since this is mostly for solid Earth geoscience applications, the second dimension is called z (vertical). The extent is therefore given as (Lx, Lz) in 2D and (Lx, Lz, Ly) in 3D, while size is (nx, nz) in 2D and (nx, ny, nz) in 3D.
Examples
====
A basic case with non-dimensional units:
julia> Grid = create_CartGrid(size=(10,20),x=(0.,10), z=(2.,10))
Grid{Float64, 2}
size: (10, 20)
length: (10.0, 8.0)
domain: x ∈ [0.0, 10.0], z ∈ [2.0, 10.0]
grid spacing Δ: (1.1111111111111112, 0.42105263157894735)An example with dimensional units:
julia> CharDim = GEO_units()
julia> Grid = create_CartGrid(size=(10,20),x=(0.0km, 10km), z=(-20km, 10km), CharDim=CharDim)
CartGrid{Float64, 2}
size: (10, 20)
length: (0.01, 0.03)
domain: x ∈ [0.0, 0.01], z ∈ [-0.02, 0.01]
grid spacing Δ: (0.0011111111111111111, 0.0015789473684210528)GeophysicalModelGenerator.create_partitioning_file Method
create_partitioning_file(LaMEM_input::String, NumProc::Int64; LaMEM_dir::String=pwd(), LaMEM_options::String="", MPI_dir="", verbose=true)This executes LaMEM for the input file LaMEM_input & creates a parallel partitioning file for NumProc processors. The directory where the LaMEM binary is can be specified; if not it is assumed to be in the current directory. Likewise for the mpiexec directory (if not specified it is assumed to be available on the command line).
GeophysicalModelGenerator.create_profile_volume! Method
create_profile_volume!(Profile::ProfileData, VolData::AbstractGeneralGrid; DimsVolCross::NTuple=(100,100), Depth_extent=nothing)Creates a cross-section through a volumetric 3D dataset VolData with the data supplied in Profile. Depth_extent can be the minimum & maximum depth for vertical profiles.
GeophysicalModelGenerator.create_profile_volume! Method
create_profile_volume!(Profile::ProfileData, VolData; DimsVolCross::NTuple=(100,100), Depth_extent=nothing)Fallback that normalizes VolData: nothing and empty containers (NamedTuple(), ()) are treated as "no volume data" and leave Profile unchanged. Any other unsupported type throws an ArgumentError.
GeophysicalModelGenerator.create_profile_volume! Method
create_profile_volume!(Profile::ProfileData, VolData::NamedTuple; DimsVolCross::NTuple=(100,100), Depth_extent=nothing)Creates a cross-section through a volumetric 3D dataset VolData with the data supplied in Profile. Depth_extent can be the minimum & maximum depth for vertical profiles. This function allows to pass the data as NamedTuples instead of a GeoData object.
GeophysicalModelGenerator.crop_bounds Method
crop_bounds(uncropped_bounds, proc_bounds, x, y, z)
Crop boundaries from the whole model to only the extent of the current processor
uncropped_bounds: 3 element vector with maximum and minimum values[[x_min, x_max],[y_min, y_max],[z_min, z_max]] for the whole model
proc_bounds: 3 element vector with maximum and minimum values[[x_min, x_max],[y_min, y_max],[z_min, z_max]] for the current processor
x,y,z: 3 element vector with maximum and minimum values[[x_min, x_max],[y_min, y_max],[z_min, z_max]] for the current processor
Returns a 3 element vector with maximum and minimum values[[x_min, x_max],[y_min, y_max],[z_min, z_max]] for the current processorGeophysicalModelGenerator.cross_section Method
cross_section(DataSet::AbstractGeneralGrid; dims=(100,100), Interpolate=nothing, Depth_level=nothing, Lat_level=nothing, Lon_level=nothing, Start=nothing, End=nothing, Depth_extent=nothing, section_width=50km)Creates a cross-section through a GeoData object.
Cross-sections can be horizontal (map view at a given depth), if
Depth_levelis specifiedThey can also be vertical, either by specifying
Lon_levelorLat_level(for a fixed lon/lat), or by defining bothStart=(lon,lat)&End=(lon,lat)points.Depending on the type of input data (volume, surface or point data), cross sections will be created in a different manner:
Volume data: data will be interpolated or directly extracted from the data set.
Surface data: surface data will be interpolated
Point data: data will be projected to the chosen profile. Only data within a chosen distance (default is 50 km) will be used
Interpolateindicates whether we want to simply extract the data from a volumetric data set (default) or whether we want to linearly interpolate it on a new grid, which has dimensions as specified indims. Surface data are always interpolated (Interpolate=falsethrows an error); point data ignoreInterpolate.section_widthis the width of the band around the profile within which point data are projected onto it. It can be given with length units; a plain number is in km.Depth_levelandDepth_extentcan be given with length units; plain numbers are in km.
Example:
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,(-300:25:0)km);
julia> Data = Depth*2; # some data
julia> Vx,Vy,Vz = ustrip(Data*3),ustrip(Data*4),ustrip(Data*5);
julia> Data_set3D = GeoData(Lon,Lat,Depth,(Depthdata=Data,LonData=Lon, Velocity=(Vx,Vy,Vz)));
julia> Data_cross = cross_section(Data_set3D, Depth_level=-100km)
GeoData
size : (11, 11, 1)
lon ϵ [ 10.0 : 20.0]
lat ϵ [ 30.0 : 40.0]
depth ϵ [ -100.0 km : -100.0 km]
fields: (:Depthdata, :LonData, :Velocity)GeophysicalModelGenerator.cross_section_points Method
cross_section_points(P::GeoData; Depth_level=nothing, Lat_level=nothing, Lon_level=nothing, Start=nothing, End=nothing, section_width=10km)Creates a projection of separate points (saved as a GeoData object) onto a chosen plane. Only points within a band of width section_width centered on the plane are taken into account (for Start/End, also only points between them). Exactly one of Depth_level, Lat_level, Lon_level, or Start & End has to be given. Returns nothing if no point is selected. Depth_level and section_width can be given with length units (e.g. 10km or 10000m); plain numbers are in km.
GeophysicalModelGenerator.cross_section_surface Method
cross_section_surface(Surface::AbstractGeneralGrid; dims=(100,), Interpolate=true, Depth_level=nothing, Lat_level=nothing, Lon_level=nothing, Start=nothing, End=nothing)Creates a cross-section through a surface (2D) GeoData object. The surface is always interpolated onto the profile; Interpolate=false throws an error.
Cross-sections can be horizontal (map view at a given depth), if
Depth_levelis specifiedThey can also be vertical, either by specifying
Lon_levelorLat_level(for a fixed lon/lat), or by defining bothStart=(lon,lat)&End=(lon,lat)points. Start and End points will be in km!IMPORTANT: The surface to be extracted has to be given as a gridded GeoData object. It may also contain NaNs where it is not defined. Any points lying outside of the defined surface will be considered NaN.
Example:
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,-50km);
julia> Data = Depth*2; # some data
julia> Vx,Vy,Vz = ustrip(Data*3),ustrip(Data*4),ustrip(Data*5);
julia> Data_set2D = GeoData(Lon,Lat,Depth,(Depth=Depth,));
julia> Data_cross = cross_section_surface(Data_set2D, Lat_level =15)
GeoData
size : (100,)
lon ϵ [ 10.0 : 20.0]
lat ϵ [ 15.0 : 15.0]
depth ϵ [ NaN : NaN]
fields : (:Depth,)
attributes: ["note"]GeophysicalModelGenerator.cross_section_volume Method
cross_section_volume(Volume::AbstractGeneralGrid; dims=(100,100), Interpolate=false, Depth_level=nothing; Lat_level=nothing; Lon_level=nothing; Start=nothing, End=nothing, Depth_extent=nothing )
Creates a cross-section through a volumetric (3D) GeoData object.
Cross-sections can be horizontal (map view at a given depth), if
Depth_levelis specifiedThey can also be vertical, either by specifying
Lon_levelorLat_level(for a fixed lon/lat), or by defining bothStart=(lon,lat)&End=(lon,lat)points.When both
Start=(lon,lat)&End=(lon,lat)are given, one can also provide a the depth extent of the profile by providing Depth_extent=(depth_min,depth_max)Interpolateindicates whether we want to simply extract the data from the 3D volume (default) or whether we want to linearly interpolate it on a new grid, which has dimensions as specified indimsDepth_extentis an optional parameter that can indicate the depth extent over which you want to interpolate the vertical cross-section. Default is the full vertical extent of the 3D datasetDepth_levelandDepth_extentcan be given with length units (e.g.-100km); plain numbers are in km.
Example:
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,(-300:25:0)km);
julia> Data = Depth*2; # some data
julia> Vx,Vy,Vz = ustrip(Data*3),ustrip(Data*4),ustrip(Data*5);
julia> Data_set3D = GeoData(Lon,Lat,Depth,(Depthdata=Data,LonData=Lon, Velocity=(Vx,Vy,Vz)));
julia> Data_cross = cross_section_volume(Data_set3D, Depth_level=-100km)
GeoData
size : (11, 11, 1)
lon ϵ [ 10.0 : 20.0]
lat ϵ [ 30.0 : 40.0]
depth ϵ [ -100.0 km : -100.0 km]
fields: (:Depthdata, :LonData, :Velocity)GeophysicalModelGenerator.curvilinear_grid Function
Grid = curvilinear_grid(x, y, surfaces, nz; spacing = :uniform, min_thickness = 0.0)
Grid = curvilinear_grid(x, y, surfaces; dz, spacing = :uniform, min_thickness = 0.0)Creates a curvilinear grid with the columns at x and y (vectors or ranges, in km; a single y, e.g. 0, gives a 2D grid of size (nx, 1, nz)), whose layers are bounded by surfaces, given from the top to the bottom. One grid level lies exactly on every surface. A surface can be a CartData surface (with any resolution that covers x and y), a number for a flat surface, or a function z(x, y) (or z(x) for a 2D grid); the bottom is usually a number. The heights increase with the third index.
Layer i, between surfaces[i] and surfaces[i+1], has nz[i] cells in every column. Alternatively, dz [km] gives the target vertical spacing where a layer is thickest, and the number of cells of each layer follows from it. The points of a layer are distributed between its bounding surfaces in every column:
spacing = :uniform: with equal spacing;spacing = :sbp: at the nodes of a summation-by-parts (SBP) grid, seesbp_nodes; every layer then has at least 13 points.
Surfaces must not cross. Where a surface lies above the one above it (for example, a basin that pinches out), it is moved down such that each cell of the layer in between has a thickness of at least min_thickness (in km).
Examples
A grid with 10 cells between the topography and the base of a sedimentary basin, and 20 cells down to 30 km depth:
julia> Grid = curvilinear_grid(-20:0.5:20, -20:0.5:20, (Topo, Basin, -30.0), (10, 20); min_thickness = 0.01)A 2D mesh for an SBP finite-difference code (e.g. SeismicWavePC.jl), with the columns at the SBP nodes, a grid line along the topography and along the Moho, and a flat bottom at 40 km depth:
julia> topo(x) = 1.5 * exp(-x^2 / 50); moho(x) = -30 + 3 * tanh(x / 10);
julia> Mesh = curvilinear_grid(sbp_nodes(-50, 50, 401), 0, (topo, moho, -40.0); dz = 0.25, spacing = :sbp)The Z field of Grid holds the height of each point.
GeophysicalModelGenerator.dataset_scale Method
dataset_scale(dataset, res, reg)The scale factor and offset that turn the integers in a tile into metres. The server publishes these in gmt_data_server.txt, one line per set: earth_relief_15s_p is stored in half metres, for instance, while the SRTM sets are stored directly in metres. Reading them rather than assuming keeps this correct if a set is ever re-encoded.
Falls back to (1, 0) for a set that the index does not list, which is right for every set that is not scaled.
GeophysicalModelGenerator.decode_jp2 Method
decode_jp2(file, n)Decode a JPEG2000 tile into an n x n matrix of Int16 elevations, using the decoder that comes with OpenJpeg_jll. The file stores its rows from north to south.
GeophysicalModelGenerator.decompose_mpi_ranks Method
decompose_mpi_ranks(total_ranks::Int, nx::Int, ny::Int, nz::Int) -> Tuple{Int,Int,Int}Decompose total number of MPI ranks into a 3D processor grid (px, py, pz), optimizing for cell aspect ratio closest to 1.0.
sourceGeophysicalModelGenerator.deform_grid Method
Grid_new = deform_grid(Grid::CartData, surfaces; levels = nothing, min_thickness = 0.0)Deforms the 3D grid Grid vertically, such that its horizontal grid levels follow surfaces, for example the topography and internal interfaces. This creates a curvilinear (structured) grid, as required by many seismic wave propagation codes. The x and y coordinates and all fields of Grid are kept; only z changes.
Each surface can be:
a
CartDatasurface (of size(nx, ny, 1)), which may have a different resolution thanGridbut must cover it;a number, for a flat surface;
a function
z(x, y), orz(x)for a 2D grid (of size(nx, 1, nz)).
Surface i is placed on the grid level levels[i] (the third index of Grid). By default, each surface is placed on the level whose mean height is closest to the mean height of the surface. The bottom and top levels of Grid stay where they are, unless a surface is placed on them. In every column, the points between two such fixed levels are stretched linearly, so the relative spacing of Grid is kept within each layer.
Surfaces must not cross. Where a surface lies above the surface on the next higher level (for example, a basin that pinches out), it is moved down such that each cell in between has a thickness of at least min_thickness (in km). The heights of the result are strictly monotonic in every column; otherwise (e.g. surfaces that touch with min_thickness = 0) an error is thrown.
Example
A grid that follows the topography at the top and becomes flat at a depth of 10 km:
julia> x, y = range(-20, 20, 81), range(-20, 20, 81);
julia> X, Y, _ = xyz_grid(x, y, 0);
julia> H = 2 .* exp.(-(X .^ 2 .+ Y .^ 2) ./ 50);
julia> Topo = CartData(X, Y, H, (Topography = H,));
julia> X, Y, Z = xyz_grid(-20:0.5:20, -20:0.5:20, -30:0.5:0);
julia> Grid = CartData(X, Y, Z, (Z = Z,));
julia> Grid_topo = deform_grid(Grid, (Topo, -10.0))
CartData
size : (81, 81, 61)
x ϵ [ -20.0 : 20.0]
y ϵ [ -20.0 : 20.0]
z ϵ [ -30.0 : 2.0]
fields : (:Z,)GeophysicalModelGenerator.distance_to_linesegment Method
distance_to_linesegment(p, v, w)Computes the distance normal distance from a point p to a line segment defined by the points v and w.
GeophysicalModelGenerator.download_data Function
download_data(url::String, local_filename="temp.dat"; dir=pwd(), maxattempts=5 )Downloads a remote dataset with name url from a remote location and saves it to the current directory. The destination is replaced only by a download that is not empty and not an HTML page. If download fails, we make maxattempts attempts before giving up.
Example
julia> url = "https://seafile.rlp.net/f/10f867e410bb4d95b3fe/?dl=1";
julia> download_data(url)
"/Users/kausb/.julia/dev/GeophysicalModelGenerator/temp.dat"GeophysicalModelGenerator.download_tile Method
download_tile(url, dest)Fetch one file, trying each mirror in turn. Returns true if it was downloaded, false if the file is not on the server – which is not an error: the 3 arcsecond set covers land only, so a tile that is entirely ocean simply does not exist.
GeophysicalModelGenerator.download_validated Method
download_validated(url, dest; timeout=Inf, valid=is_valid_download)Download url to dest. The transfer goes to a temporary file of its own beside dest and is moved into place only once valid(file) accepts it, so an existing dest survives a failed download, concurrent processes never see each other's partial files and a corrupt download never enters the cache.
GeophysicalModelGenerator.drape_on_topo Method
drape_on_topo(Topo::CartData, Data::CartData)Drapes Cartesian Data on topography
sourceGeophysicalModelGenerator.drape_on_topo Method
Topo = drape_on_topo(Topo::GeoData, Data::GeoData)This drapes fields of a data set Data on the topography Topo, using the nearest point of Data. Outside the lon/lat extent of Data, vector (tuple) fields are NaN and scalar fields take the value of the nearest point.
GeophysicalModelGenerator.extract_ProfileData! Function
extract_ProfileData!(Profile::ProfileData, VolData=nothing, SurfData=nothing, PointData=nothing; DimsVolCross=(100,100), Depth_extent=nothing, DimsSurfCross=(100,), section_width=50km, ScreenshotData=nothing, TopoData=nothing)Extracts data along a vertical or horizontal profile. VolData can be a GeoData/AbstractGeneralGrid or a NamedTuple of those; the other data sets are NamedTuples. Any data argument can be nothing or empty (NamedTuple() or ()), in which case it is skipped.
GeophysicalModelGenerator.extract_ProfileData Method
extract_ProfileData(ProfileCoordFile::String,ProfileNumber::Int64,DataSetFile::String; DimsVolCross=(100,100),DepthVol=nothing,DimsSurfCross=(100,),WidthPointProfile=50km)This is a convenience function (used by the MATLAB GUI) that loads the data from file & projects it onto a profile. The first volumetric dataset is cut along the profile and the others are interpolated at its points, with fields named <dataset>_<field>; surface, point, screenshot and topography datasets are projected as well. If the dataset file lists no volumetric dataset, VolData of the returned profile remains nothing.
GeophysicalModelGenerator.extract_subvolume Method
extract_subvolume(V::CartData; Interpolate=true, X_level=nothing, Y_level=nothing, Z_level=nothing, dims=(50,50,50))Extract or "cuts-out" a piece of a 2D or 3D CartData set, defined by X, Y and Z coordinates.
This is useful if you are only interested in a part of a much bigger larger data set.
X_level,Y_levelandZ_levelshould be tuples that indicate(minimum_value, maximum_value)along the respective direction. If not specified we use the full range. They can be given with length units (e.g.(-20km, -5km)); plain numbers are in km.By default,
Interpolate=trueand we interpolate the data onto a new grid that has dimensionsdims. This can be useful to compare data sets that are originally given in different resolutions.Alternatively, if
Interpolate=falsewe find the closest indices within the data set (so your new data set will not go exactly from minimum to maximum).For a vertical cross-section computed with
cross_section(V, Start=.., End=..),X_levelis the distance along the profile and the data are always interpolated.
3D Example with no interpolation:
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,(-300:25:0)km);
julia> Data = Depth*2; # some data
julia> Vx,Vy,Vz = ustrip(Data*3),ustrip(Data*4),ustrip(Data*5);
julia> Data_set3D = GeoData(Lon,Lat,Depth,(Depthdata=Data,LonData=Lon, Velocity=(Vx,Vy,Vz)))
GeoData
size : (11, 11, 13)
lon ϵ [ 10.0 : 20.0]
lat ϵ [ 30.0 : 40.0]
depth ϵ [ -300.0 km : 0.0 km]
fields: (:Depthdata, :LonData, :Velocity)
julia> Data_extracted = extract_subvolume(Data_set3D,Lon_level=(10,12),Lat_level=(35,40))
GeoData
size : (3, 6, 13)
lon ϵ [ 10.0 : 12.0]
lat ϵ [ 35.0 : 40.0]
depth ϵ [ -300.0 km : 0.0 km]
fields: (:Depthdata, :LonData, :Velocity)By default it extracts the data points closest to the area defined by Lon_level/Lat_level/Depth_level.
2D Example along a cross-section through 3D data:
julia> X,Y,Z = xyz_grid(10:20,30:40,-300:25:0);
julia> Data = Z.*2
julia> Data_Int = Int64.(Data)
julia> DataSet_Cart = CartData(X,Y,Z,(Data=Data,Data_Int=Data_Int, Velocity=(X,Y,Z)))
julia> Data_cross = cross_section(DataSet_Cart, Start=(11.0,35), End=(19, 39.0))
CartData
size : (100, 100, 1)
x ϵ [ 11.0 : 19.0]
y ϵ [ 35.0 : 39.0]
z ϵ [ -300.0 : 0.0]
fields : (:Data, :Data_Int, :Velocity, :FlatCrossSection)
attributes: ["note"]
julia> Data_extracted = extract_subvolume(Data_cross, X_level=(1,7), Z_level=(-200,-100))
CartData
size : (50, 50, 1)
x ϵ [ 11.894427190999917 : 17.260990336999413]
y ϵ [ 35.44721359549995 : 38.130495168499706]
z ϵ [ -200.0 : -100.0]
fields : (:FlatCrossSection, :Data, :Data_Int, :Velocity)
attributes: ["note"]
julia> typeof(Data_extracted.fields.Data_Int)
Array{Int64, 3}GeophysicalModelGenerator.extract_subvolume Method
extract_subvolume(V::GeoData; Interpolate=false, Lon_level=nothing, Lat_level=nothing, Depth_level=nothing, dims=(50,50,50))Extract or "cuts-out" a piece of a 2D or 3D GeoData set, defined by Lon, Lat and Depth coordinates.
This is useful if you are only interested in a part of a much bigger larger data set.
Lon_level,Lat_levelandDepth_levelshould be tuples that indicate(minimum_value, maximum_value)along the respective direction. If not specified we use the full range.Depth_levelcan be given with length units (e.g.(-200km, -100km)); plain numbers are in km.By default,
Interpolate=falseand we find the closest indices within the data set (so your new data set will not go exactly from minimum to maximum).Alternatively, if
Interpolate=truewe interpolate the data onto a new grid that has dimensionsdims. This can be useful to compare data sets that are originally given in different resolutions.
3D Example with no interpolation:
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,(-300:25:0)km);
julia> Data = Depth*2; # some data
julia> Vx,Vy,Vz = ustrip(Data*3),ustrip(Data*4),ustrip(Data*5);
julia> Data_set3D = GeoData(Lon,Lat,Depth,(Depthdata=Data,LonData=Lon, Velocity=(Vx,Vy,Vz)))
GeoData
size : (11, 11, 13)
lon ϵ [ 10.0 : 20.0]
lat ϵ [ 30.0 : 40.0]
depth ϵ [ -300.0 km : 0.0 km]
fields: (:Depthdata, :LonData, :Velocity)
julia> Data_extracted = extract_subvolume(Data_set3D,Lon_level=(10,12),Lat_level=(35,40))
GeoData
size : (3, 6, 13)
lon ϵ [ 10.0 : 12.0]
lat ϵ [ 35.0 : 40.0]
depth ϵ [ -300.0 km : 0.0 km]
fields: (:Depthdata, :LonData, :Velocity)By default it extracts the data points closest to the area defined by Lon_level/Lat_level/Depth_level.
3D Example with interpolation:
Alternatively, you can also interpolate the data onto a new grid:
julia> Data_extracted = extract_subvolume(Data_set3D,Lon_level=(10,12),Lat_level=(35,40), Interpolate=true, dims=(50,51,52))
GeoData
size : (50, 51, 52)
lon ϵ [ 10.0 : 12.0]
lat ϵ [ 35.0 : 40.0]
depth ϵ [ -300.0 km : 0.0 km]
fields: (:Depthdata, :LonData, :Velocity)GeophysicalModelGenerator.fill_gaps! Method
fill_gaps!(Z, lon, lat, filler)Replace the cells of Z that carry no data – the flat zeros that SRTM writes for the sea, and whatever a missing tile left behind – with values interpolated from the coarser filler set that the server names for the purpose.
GeophysicalModelGenerator.filler_dataset Method
filler_dataset(dataset, res, reg)Some sets cover only part of the globe and are published with a coarser set to fill the rest: the 3 arcsecond relief is SRTM, which is land only, and the server names earth_relief_15s_p as what belongs in the sea. GMT resamples that filler into the gaps, and so do we – otherwise the ocean comes out flat at zero.
Returns nothing when a set needs no filler.
GeophysicalModelGenerator.fit_surface_to_points Method
surf_new = fit_surface_to_points(surf::CartData, X_pt::Vector, Y_pt::Vector, Z_pt::Vector)This fits the z values of the surface surf to the z value of the closest-by-points in (X_pt, Y_pt, Z_pt)
GeophysicalModelGenerator.fit_surface_to_points Method
surf_new = fit_surface_to_points(surf::GeoData, lon_pt::Vector, lat_pt::Vector, depth_pt::Vector)This fits the depth values of the surface surf to the depth value of the closest-by-points in (lon_pt,lat_pt, depth_pt)
GeophysicalModelGenerator.flatten_cross_section Method
flatten_cross_section(V::CartData)Takes a diagonal 3D cross_section and flattens it to be converted to a 2D Grid by create_CartGrid
Example
Grid = create_CartGrid(size=(100,100,100), x=(0.0km, 99.9km), y=(-10.0km, 20.0km), z=(-40km,4km));
X,Y,Z = xyz_grid(Grid.coord1D...);
DataSet = CartData(X,Y,Z,(Depthdata=Z,));
Data_Cross = cross_section(DataSet, dims=(100,100), Interpolate=true, Start=(ustrip(Grid.min[1]),ustrip(Grid.max[2])), End=(ustrip(Grid.max[1]), ustrip(Grid.min[2])))
x_new = flatten_cross_section(Data_Cross)
# This flattened cross_section can be added to original Data_Cross by addfield()
Data_Cross = addfield(Data_Cross,"FlatCrossSection", x_new)
CartData
size : (100, 100, 1)
x ϵ [ 0.0 : 99.9]
y ϵ [ -10.0 : 20.0]
z ϵ [ -40.0 : 4.0]
fields : (:Depthdata, :FlatCrossSection)
attributes: ["note"]GeophysicalModelGenerator.flatten_cross_section Method
flatten_cross_section(V::GeoData)
This function takes a 3D cross section through a GeoData structure and computes the distance along the cross section for later 2D processing/plotting
```julia-repl
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,(-300:25:0)km);
julia> Data = Depth*2; # some data
julia> Vx,Vy,Vz = ustrip(Data*3),ustrip(Data*4),ustrip(Data*5);
julia> Data_set3D = GeoData(Lon,Lat,Depth,(Depthdata=Data,LonData=Lon, Velocity=(Vx,Vy,Vz)));
julia> Data_cross = cross_section(Data_set3D, Start=(10,30),End=(20,40))
julia> x_profile = flatten_cross_section(Data_cross)
julia> Data_cross = addfield(Data_cross,"x_profile",x_profile)
```GeophysicalModelGenerator.flip Function
Data = flip(Data::GeoData, dimension=3)This flips the data in the structure in a certain dimension (default is z [3])
sourceGeophysicalModelGenerator.generate_valid_rank_sequence Function
generate_valid_rank_sequence(max_value::Int = 196608, multipliers::Vector{Int} = [3])Generate sequence of valid MPI ranks up to max_value. Sequence includes powers of 2 and their multiples by specified multipliers.
sourceGeophysicalModelGenerator.get_LaMEM_grid_info Method
Grid = get_LaMEM_grid_info(file; args=nothing)Create a LaMEM_grid from the marker, element, and coordinate settings of a LaMEM input file (multi-segment grids are summed).
GeophysicalModelGenerator.get_particles_distribution Method
p_dist = get_particles_distribution(Grid, P)Get the distribution of particles in the grid Grid: LaMEM_grid P: LaMEMPartitioningInfo Returns a LaMEMPartitioningInfo object with the distribution of particles in the grid
sourceGeophysicalModelGenerator.get_proc_bound Method
proc_bounds = get_proc_bound(Grid, p_dist, proc_num) Get the bounds of the current processor in x, y, z direction Grid: LaMEM_grid p_dist: LaMEMPartitioningInfo proc_num: processor number Returns a 3 element vector with maximum and minimum values[[x_min, x_max],[y_min, y_max],[z_min, z_max]] for current processor proc_num
Example for a model with 8 MPI ranks for current processor number 2
And gives us coordinates for the current processor
Grid_example = LaMEM_grid(
3, 3, 3,
12, 12, 12,
4, 4, 4,
10, 5, 5,
[10.0, 18.0], [20,28], [30,38],
[],[],[],
[],[],[],
[],[],[],
[],[],[]
)
P_example = setup_model_domain(Grid_example.coord_x, Grid_example.coord_y, Grid_example.coord_z, Grid_example.nel_x, Grid_example.nel_x, Grid_example.nel_x, 8)
p_dist_example = get_ParticlesDistribution(Grid_example,P_example)
proc_bounds = get_proc_bound(Grid_example,p_dist_example,2)GeophysicalModelGenerator.get_proc_grid Method
Grid = get_proc_grid(Grid_info, p_dist, proc_bounds, proc_num, RandomNoise)Get the local grid for the current processor Grid_info: LaMEM_grid p_dist: LaMEMPartitioningInfo proc_bounds: bounds of the current processor proc_num: processor number RandomNoise: must be 0; random noise is not supported Returns a LaMEM_grid object with the local grid for the current processor
sourceGeophysicalModelGenerator.get_processor_partitioning Method
nProcX,nProcY,nProcZ, xc,yc,zc, nNodeX,nNodeY,nNodeZ = get_processor_partitioning(filename; is64bit=false)Reads a LaMEM processor partitioning file, used to create marker files, and returns the parallel layout. By default this is done for a 32bit PETSc installation, which will fail if you actually use a 64bit version.
sourceGeophysicalModelGenerator.getlonlatdepthmag_QuakeML Method
Data = getlonlatdepthmag_QuakeML(filename::String)Extracts longitude, latitude, depth and magnitude from a QuakeML file that has been e.g. downloaded from ISC. The data is then returned in GeoData format.
sourceGeophysicalModelGenerator.grid_from_single_file Method
grid_from_single_file(limits, dataset, res, reg)The coarse resolutions are published as one NetCDF file for the whole globe, which is small enough to download and cut down here. Reading it needs NCDatasets, which is a weak dependency – the tiled resolutions, which are the interesting ones, need nothing extra.
GeophysicalModelGenerator.grid_from_tiles Method
grid_from_tiles(limits, dataset, res, reg)Assemble the tiles that cover limits and cut out the requested region. Tiles that are not on the server are taken to be at sea level, which is what the land-only 3 arcsecond set needs.
GeophysicalModelGenerator.import_EGMS Method
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.import_topo Method
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.inpoly Method
inpoly(PolyX::AbstractVector, PolyY::AbstractVector, x, y)Checks if a point given by x and y is in or on (both cases return true) a polygon given by PolyX and PolyY. This function should be used through inpolygon!().
sourceGeophysicalModelGenerator.inpoly_fast Method
inpoly_fast(PolyX::Vector, PolyY::Vector, x::Number, y::Number, iSteps::Vector, jSteps::)Faster version of inpoly() but will miss some points that are on the edge of the polygon.
sourceGeophysicalModelGenerator.inpolygon! Method
inpolygon!(INSIDE::Matrix, PolyX::Vector, PolyY::Vector, X::Matrix, Y::Matrix; fast=false)Checks if points given by matrices X and Y are in or on (both cases return true) a polygon given by PolyX and PolyY. Boolean fast will trigger faster version that may miss points that are exactly on the edge of the polygon. Speedup is a factor of 3.
GeophysicalModelGenerator.inpolygon! Method
inpolygon!(inside::Vector, PolyX::Vector, PolyY::Vector, x::Vector, y::Vector; fast=false)Same as above but inside, X and Y and are vectors.
GeophysicalModelGenerator.insert_cpu_lines_after_nelz Method
insert_cpu_lines_after_nelz(filename::String, P) Inserts or updates CPU lines in a LaMEM input file after the nel_z line. If CPU lines already exist, they are replaced with the new values from P. If they do not exist, new lines are inserted. Usage:
- Generate LaMEM model and save it to a setup file, and update to correct target resolution after saving.
Target resolution is 256x256x256 and we want to run on 128 processors n_ranks
nx = 256; ny = 256; nz = 256; n_ranks = 128 ParamFile_name = "LaMEM_setup.txt" model = Model( LaMEM.Grid(x=[-80.,80.], y=[-95.,100.], z=[-60.0,10.0] , nel=(8,8,8)),Output(param_file_name = ParamFile_name,)) write_LaMEM_inputFile(model,ParamFile_name). update_nel_xyz_in_file(ParamFile_name, nx, ny, nz)
- Create a partitioning info object
Pwith the number of processes.
Grid_info = get_LaMEM_grid_info(ParamFile_name) P = setup_model_domain(Grid_info.coord_x, Grid_info.coord_y, Grid_info.coord_z, nx, ny, nz, n_ranks)
- Then we can use this function to insert or update CPU lines in the setup file.
insert_cpu_lines_after_nelz(ParamFile_name, P)
Use-case:This allows to run correctly LaMEM simulation with the correct number of processes on each direction if partitioning file is generated by julia routine: part_filename = write_processor_partitioning_LaMEM(P) # is64bit=false (default) matches a LaMEM built with 32-bit PetscInt insert_cpu_lines_after_nelz(ParamFile_name, P) Grid_o = read_LaMEM_inputfile(ParamFile_name); Phase_o = zeros(UInt8, size(Grid_o.X)); Temp_o = zeros(size(Phase_o)); Model3D_o = CartData(Grid_o, (Phases=Phase_o,Temp=Temp_o)) save_LaMEM_markers_parallel(Model3D_o, PartitioningFile=part_filename,verbose = true) run_lamem(ParamFile_name,n_ranks)
sourceGeophysicalModelGenerator.interpolate_data_fields_cross_section Method
interpolate_data_fields_cross_section(V::CartData, X,Y,Z,Xcross)Interpolates data fields along a cross-section defined by Xcross and Z
GeophysicalModelGenerator.interpolate_data_surface Method
Surf_interp = interpolate_data_surface(V::GeoData, Surf::GeoData)Interpolates a 3D data set V on a surface defined by Surf
GeophysicalModelGenerator.interpolate_data_surface Method
Surf_interp = interpolate_data_surface(V::ParaviewData, Surf::ParaviewData)Interpolates a 3D data set V on a surface defined by Surf.
Example
julia> Data
ParaviewData
size : (33, 33, 33)
x ϵ [ -3.0 : 3.0]
y ϵ [ -2.0 : 2.0]
z ϵ [ -2.0 : 0.0]
fields: (:phase, :density, :visc_total, :visc_creep, :velocity, :pressure, :temperature, :dev_stress, :strain_rate, :j2_dev_stress, :j2_strain_rate, :plast_strain, :plast_dissip, :tot_displ, :yield, :moment_res, :cont_res)
julia> surf
ParaviewData
size : (96, 96, 1)
x ϵ [ -2.9671875 : 3.2671875]
y ϵ [ -1.9791666666666667 : 1.9791666666666667]
z ϵ [ -1.5353766679763794 : -0.69925457239151]
fields: (:Depth,)
julia> Surf_interp = interpolate_data_surface(Data, surf)
ParaviewData
size : (96, 96, 1)
x ϵ [ -2.9671875 : 3.2671875]
y ϵ [ -1.9791666666666667 : 1.9791666666666667]
z ϵ [ -1.5353766679763794 : -0.69925457239151]
fields: (:phase, :density, :visc_total, :visc_creep, :velocity, :pressure, :temperature, :dev_stress, :strain_rate, :j2_dev_stress, :j2_strain_rate, :plast_strain, :plast_dissip, :tot_displ, :yield, :moment_res, :cont_res)GeophysicalModelGenerator.interpolate_datafields Method
Data_interp = interpolate_datafields(V::AbstractGeneralGrid, Lon, Lat, Depth)Interpolates a data field V (GeoData, CartData or UTMData) on a grid defined by Lon,Lat,Depth, given in the coordinates of V (EW,NS,Depth for UTMData). Floating-point fields are interpolated linearly and are NaN outside V; Int64 fields (such as phases) take the value of the nearest point.
Example
julia> x = 0:2:10
julia> y = -5:5
julia> z = -10:2:2
julia> X,Y,Z = xyz_grid(x, y, z);
julia> Data = Z
julia> Data_set1= CartData(X,Y,Z, (FakeData=Data,Data2=Data.+1.))
CartData
size : (6, 11, 7)
x ϵ [ 0.0 km : 10.0 km]
y ϵ [ -5.0 km : 5.0 km]
z ϵ [ -10.0 km : 2.0 km]
fields : (:FakeData, :Data2)
attributes: ["note"]
julia> X,Y,Z = xyz_grid(0:4:10, -1:.1:1, -5:.1:1 );
julia> Data_set2= interpolate_datafields(Data_set1, X,Y,Z)GeophysicalModelGenerator.interpolate_datafields_2D Method
interpolate_datafields_2D(V::CartData, X, Y)Interpolates a data field V on a 2D CartData grid defined by X,Y. Typically used for horizontal surfaces. Returns the interpolated depth and fields; points outside V take the value at the nearest edge of V.
GeophysicalModelGenerator.interpolate_datafields_2D Method
interpolate_datafields_2D(Original::CartData, New::CartData; Rotate=0.0, Translate=(0,0,0), Scale=(1.0,1.0,1.0))Interpolates a data field Original on a 2D CartData grid New. Typically used for horizontal surfaces. Points of New outside Original take the value at the nearest edge of Original.
Note: Original should have orthogonal coordinates. If it has not, e.g., because it was rotated, you'll have to specify the angle Rotate that it was rotated by
GeophysicalModelGenerator.interpolate_datafields_2D Method
Surf_interp = interpolate_datafields_2D(V::GeoData, x::AbstractRange, y::AbstractRange; Lat::Number, Lon::Number)Interpolates a 3D data set V with a projection point proj=(Lat, Lon) on a plane defined by x and y, where x and y are uniformly spaced. Returns the 2D array Surf_interp.
GeophysicalModelGenerator.interpolate_datafields_2D Method
interpolate_datafields_2D(V::GeoData, Lon, Lat)Interpolates a data field V on a 2D grid defined by Lon,Lat. Typically used for horizontal surfaces. Returns the interpolated depth and fields; points outside V take the value at the nearest edge of V.
GeophysicalModelGenerator.interpolate_datafields_2D Method
interpolate_datafields_2D(Original::GeoData, New::GeoData; Rotate=0.0, Translate=(0,0,0), Scale=(1.0,1.0,1.0))Interpolates a data field Original on a 2D GeoData grid New. Typically used for horizontal surfaces. Points of New outside Original take the value at the nearest edge of Original.
Note: Original should have orthogonal coordinates. If it has not, e.g., because it was rotated, you'll have to specify the angle Rotate that it was rotated by
GeophysicalModelGenerator.interpolate_datafields_2D Method
interpolate_datafields_2D(V::UTMData, EW, NS)Interpolates a data field V on a 2D grid defined by UTM. Typically used for horizontal surfaces. Returns the interpolated depth and fields; points outside V take the value at the nearest edge of V.
GeophysicalModelGenerator.is_surface Method
issurf = is_surface(surf::AbstractGeneralGrid)Returns true if surf is a horizontal 3D surface.
GeophysicalModelGenerator.is_valid_download Method
is_valid_download(file)Whether file holds what its name says it does: a JPEG2000 image for .jp2, a NetCDF (classic or HDF5-based) grid for .grd, and a server index with its tab-separated lines for .txt. An error page that the server delivers with status 200 fails this check, so it is never mistaken for a tile.
GeophysicalModelGenerator.isinside_closed_STL Function
inside = isinside_closed_STL(mesh::Mesh, Pt, eps=1e-3)Determine whether a point Pt is inside a 3D closed triangular *.stl surface or not.
This implements the winding number method, following the python code: https://github.com/marmakoide/inside-3d-mesh
This again is described in the following paper by Alec Jacobson, Ladislav Kavan and Olga Sorkine-Hornung.
sourceGeophysicalModelGenerator.laea_to_lonlat Method
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.lithostatic_pressure! Method
lithostatic_pressure!(Plithos::Array, Density::Array, dz::Number; g=9.81)Computes lithostatic pressure from a 3D density array, assuming constant soacing dz in vertical direction. Optionally, the gravitational acceleration g can be specified.
GeophysicalModelGenerator.load_GMG Function
load_GMG(filename::String, dir=pwd(); maxattempts=5)Loads a GeoData/CartData/UTMData data set from jld2 file filename Note: the filename can also be a remote url, in which case the file is downloaded to a temporary file, loaded and the temporary file removed again. We make maxattempts attempts to download it before giving up.
Example 1 - Load local file
julia> data = load_GMG("test")
GeoData
size : (4, 3, 3)
lon ϵ [ 1.0 : 10.0]
lat ϵ [ 11.0 : 19.0]
depth ϵ [ -20.0 : -10.0]
fields : (:DataFieldName,)
attributes: ["note"]Example 2 - remote download
julia> url = "https://seafile.rlp.net/f/10f867e410bb4d95b3fe/?dl=1"
julia> load_GMG(url)
GeoData
size : (149, 242, 1)
lon ϵ [ -24.875 : 35.375]
lat ϵ [ 34.375 : 71.375]
depth ϵ [ -11.76 : -34.7]
fields : (:MohoDepth,)
attributes: ["author", "year"]GeophysicalModelGenerator.load_GMG Method
data::NamedTuple = load_GMG(data::GMG_Dataset)Loads a dataset specified in GMG_Dataset data and returns it as a named tuple
GeophysicalModelGenerator.load_GMG Method
Data = load_GMG(Datasets::Vector{GMG_Dataset})This loads all the active datasets in Datasets, and returns a NamedTuple with Volume, Surface, Point, Screenshot and Topography data
GeophysicalModelGenerator.load_dataset_file Method
Datasets = load_dataset_file(file_datasets::String)This loads a CSV textfile that lists datasets, which is expected to have the following format:
Name,Location,Type,[Active]AlpArray,./Seismicity/ALPARRAY/AlpArraySeis.jld2,Point, true
Plomerova2022,https://seafile.rlp.net/f/abccb8d3302b4ef5af17/?dl=1,Volume
Note that the first line of the file is skipped.
Here, the meaning of the variables is:
Name: The name of the dataset to be loadedLocation: the location of the file (directory and filename) on your local machine, or an url where we can download the file from the web. The url is expected to start with "http".Type: type of the dataset (Volume, Surface, Point, Screenshot, Topography)Active: Do we want this file to be loaded or not? Optional parameter that defaults totrue
A file with fewer than 3 or more than 4 columns throws an error.
sourceGeophysicalModelGenerator.load_sea_level Method
Load the built-in sea-level curve name (a key of sea_level_files) as a SeaLevel.
GeophysicalModelGenerator.lonlat_to_laea Method
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.
GeophysicalModelGenerator.lonlatdepth_grid Method
Lon, Lat, Depth = lonlatdepth_grid(Lon::Any, Lat::Any, Depth:Any)Creates 3D arrays of Lon, Lat, Depth from 1D vectors or numbers
Example 1: Create 3D grid
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,(-10:-1)km);
julia> size(Lon)
(11, 11, 10)Example 2: Create 2D lon/lat grid @ a given depth
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,-50km);
julia> size(Lon)
(11, 11)Example 3: Create 2D lon/depth grid @ a given lat
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30,(-10:-1)km);
julia> size(Lon)
(11, 11)Example 4: Create 1D vertical line @ a given lon/lat point
julia> Lon,Lat,Depth = lonlatdepth_grid(10,30,(-10:-1)km);
julia> size(Lon)
(10, )GeophysicalModelGenerator.make_paraview_collection Method
make_paraview_collection(pvd_name::String, files::Vector{String}, time::AbstractVector)This function makes a *.pvd file from a provided list of *.vtk files and time steps.
Inputs are:
pvd_name: filename of the resulting*.pvdfile without extension.files: Vector of desired files to be included in the*.pvdfile.time: Vector of time steps (numbers or strings) corresponding to thefilesvector.
GeophysicalModelGenerator.make_paraview_collection Method
make_paraview_collection(; dir=pwd(), pvd_name=nothing, files=nothing, file_extension = ".vts", time = nothing)In case one has a list of *.vtk files, this routine creates a *.pvd file that can be opened in Paraview. This is useful if you previously saved vtk files but didnt save it as a collection in the code itself.
Optional options
dir: directory where the*.vtkare stored.pvd_name: filename of the resulting*.pvdfile without extension; if not specified,full_simulationis used.files: Vector of the*.vtkfile names, including extension and used exactly as given (so includedirif needed); if not specified, all*.vtkfiles in the directory are used.file_extension: file extension of the vtk files. Default is.vtsbut allvt*work.time: Vector of the timesteps (numbers or strings); if not specified, pseudo time steps are assigned.
GeophysicalModelGenerator.make_volc_topo Method
make_volc_topo(Grid::Union{LaMEM_grid, CartData}; center, height, radius, crater=0.0, base=0.0, background=nothing)
Creates a generic volcano topography (cones and truncated cones). For a LaMEM_grid it returns a CartData with the topography as field Topography; for a CartData it returns the topography as a Matrix.
Parameters
Grid - LaMEM grid (created by read_LaMEM_inputfile)
center - x- and -coordinates of center of volcano
height - height of volcano
radius - radius of volcano
Optional Parameters
crater - this will create a truncated cone and the option defines the radius of the flat top
base - this sets the flat topography around the volcano
background - this allows loading in a topography and only adding the volcano on top (also allows stacking of several cones to get a volcano with different slopes)
Example
Cylinder with constant phase and temperature:
julia> Grid = read_LaMEM_inputfile("test_files/SaltModels.dat")
LaMEM Grid:
nel : (32, 32, 32)
marker/cell : (3, 3, 3)
markers : (96, 96, 96)
x ϵ [-3.0 : 3.0]
y ϵ [-2.0 : 2.0]
z ϵ [-2.0 : 0.0]
julia> Topo = make_volc_topo(Grid, center=[0.0,0.0], height=0.4, radius=1.5, crater=0.5, base=0.1)
CartData
size : (33, 33, 1)
x ϵ [ -3.0 : 3.0]
y ϵ [ -2.0 : 2.0]
z ϵ [ 0.1 : 0.4]
fields : (:Topography,)
attributes: ["note"]
julia> Topo = make_volc_topo(Grid, center=[0.0,0.0], height=0.8, radius=0.5, crater=0.0, base=0.4, background=Topo.fields.Topography)
CartData
size : (33, 33, 1)
x ϵ [ -3.0 : 3.0]
y ϵ [ -2.0 : 2.0]
z ϵ [ 0.1 : 0.8]
fields : (:Topography,)
attributes: ["note"]
julia> write_paraview(Topo,"VolcanoTopo") # Save topography to paraview
Saved file: VolcanoTopo.vtsGeophysicalModelGenerator.meshgrid Method
meshgrid(vx,vy,vz)Computes an (x,y,z)-grid from the vectors (vx,vy,vz). For more information, see the MATLAB documentation.
sourceGeophysicalModelGenerator.movie_from_images Method
movie_from_images(; dir=pwd(), file=nothing, outfile=nothing, framerate=10, copy_to_current_dir=true, type=:mp4_default, gif=false)The typical way to create animations with Paraview is to use the Save Animation option to save a series of *.png images.
This function combines these images to an *.mp4 movie (default) or a *.gif animation.
Optional options
dir: directory where the images are stored.file: filename of the image series without extension and numbers. Required if >1 image series is stored in the same directory. By default we reconstruct this name from the available files.outfile: filename of the resulting movie without extension; if not specified,fileis used.framerate: number of frames/second.copy_to_current_dir: copies the final movie to the current directory iftrue(default); otherwise it will be stored indir.type: type of movie that is created; possible options are::mp4_default: Default option that saves a well-compressedmp4movie that works well for us on ipad and embedded in a powerpoint presentation.:mov_hires: Higher-resolution quicktime movie (larger filesize & not compatible with windows):gif: Animated GIF (same as passinggif=true).
gif: iftrue, creates a*.gifanimation in addition to themp4movie. Iftype=:gif, only a gif is created.
Returns the path of the created movie (or gif): relative to the current directory if copy_to_current_dir=true, and inside dir otherwise.
GeophysicalModelGenerator.movie_paraview Method
pvd = movie_paraview(; name="Movie", pvd=pvd, Finalize::Bool=false, Initialize::Bool=true)If you want to make a movie of your data set, you can use this routine to initialize and to finalize the movie-file. It will create a *.pvd file, which you can open in Paraview
Individual timesteps are added to the movie by passing pvd and the time of the timestep to the write_paraview routine.
Example
Usually this is used inside a *.jl script, as in this pseudo-example:
movie = movie_paraview(name="Movie", Initialize=true)
for itime=1:10
name = "test"*string(itime)
movie = write_paraview(Data, name, pvd=movie, time=itime)
end
movie_paraview(pvd=movie, Finalize=true)GeophysicalModelGenerator.native_registration Method
native_registration(dataset, res, reg)Which registration this set is actually published in. Most come in both, and then the caller's reg is used; the SRTM-derived sets are gridline only and 15s is pixel only, so asking for the other one would 404 on every tile.
GeophysicalModelGenerator.nearest_point_indices Method
ind = nearest_point_indices(X::Array,Y::Array,Z::Array, X_pt::Vector,Y_pt::Vector,Z_pt::Vector)Returns the index of the nearest point in (X_pt,Y_pt,Z_pt) to (X,Y,Z) and returns the index
GeophysicalModelGenerator.nearest_point_indices Method
ind = nearest_point_indices(X::Array,Y::Array, X_pt::Vector, Y_pt::Vector)Returns the index of the nearest point in (X_pt,Y_pt) to (X,Y) and returns the index
GeophysicalModelGenerator.nearest_point_indices Method
ind = nearest_point_indices(X::Array, X_pt::Vector)Returns the index of the nearest point in (X_pt) to (X) and returns the index
GeophysicalModelGenerator.normal_gravity Function
γ = normal_gravity(lat, h = 0; ellipsoid = GRS80)Normal gravity [mGal] of the reference ellipsoid (GRS80 by default) at geodetic latitude lat [°] and height h [km] above the ellipsoid: Somigliana's formula with the second-order height correction (Hofmann-Wellenhof & Moritz, 2006, eq. 2-215). Subtracting it from observed (absolute) gravity gives the gravity disturbance (with ellipsoidal heights) or, approximately, the free-air anomaly (with heights above sea level). ellipsoid is a NamedTuple with fields a, f, γe, γp, m.
GeophysicalModelGenerator.parse_columns_CSV Method
parse_columns_CSV(data_file, num_columns)This parses numbers from CSV file that is read in with CSV.File. That is useful in case the CSV files has tables that contain both strings (e.g., station names) and numbers (lat/lon/height) and you are only interested in the numbers
Example
This example assumes that the data starts at line 18, that the columns are separated by spaces, and that it contains at most 4 columns with data:
julia> using CSV
julia> data_file = CSV.File("FileName.txt",datarow=18,header=false,delim=' ')
julia> data = parse_columns_CSV(data_file, 4)GeophysicalModelGenerator.parse_topo_file Method
parse_topo_file(file)Take apart the "@earth_relief_01m" spelling into the dataset, resolution and registration that name it on the server.
GeophysicalModelGenerator.particle_grid Function
pg = particle_grid(particles::Particles; length_unit)Returns the coordinates of the JustPIC particles, in km, that the geometry routines (add_box!, add_sphere!, ...) accept in place of a grid. length_unit is the length of one unit of the particle coordinates, for example 1m, or the characteristic length of a nondimensional model.
On the CPU, pg is a live view: it reads the particle coordinates and active flags when it is used, so it follows later changes to particles. On a GPU, pg is a snapshot of the host copies of the coordinates made when particle_grid is called, so it must be recreated after the particles move. The geometry routines process particle arrays on a GPU in host copies and write the result back.
Requires loading JustPIC.
GeophysicalModelGenerator.point_in_tetrahedron Method
inside = point_in_tetrahedron(p::_T, a::_T, b::_T, c::_T, d::_T, tol=1e-10)Determines if a point p is inside a tetrahedron specified by a,b,c,d or not
GeophysicalModelGenerator.point_to_nearest_grid Method
count = point_to_nearest_grid(pt_x,pt_y,pt_z, X,Y,Z; radius_factor=1)This uses nearest neighbour interpolation to count how many points (given by pt_x,pt_y,pt_z coordinate vectors) are in the vicinity of 3D grid point specified by X,Y,Z 3D coordinate arrays. The search radius is R = radius_factor * sqrt(Δx² + Δy² + Δz²), radius_factor times the diagonal of the first grid cell, where Δx, Δy and Δz are the lengths of its edges along the three grid directions (zero along a direction in which the grid has a single point).
GeophysicalModelGenerator.point_to_nearest_grid Method
Grid_counts = point_to_nearest_grid(pt_x,pt_y,pt_z, Grid::CartData; radius_factor=1)Uses nearest neighbour interpolation to count how many points (given by pt_x,pt_y,pt_z coordinate vectors) are in the vicinity of 3D CartGrid specified by Grid. The search radius is R = radius_factor * sqrt(Δx² + Δy² + Δz²), radius_factor times the diagonal of a grid cell
Grid_counts is Grid but with an additional field Count that has the number of hits
GeophysicalModelGenerator.point_to_nearest_grid Method
Grid_counts = point_to_nearest_grid(pt_lon,pt_lat,pt_depth, Grid::GeoData; radius_factor=1)Uses nearest neighbour interpolation to count how many points (given by longitude pt_lon and latitude pt_lat in degrees and depth pt_depth in km) are in the vicinity of 3D GeoData specified by Grid. Distances are measured in km, in Earth-centered Cartesian (ECEF, WGS84) coordinates. The search radius is radius_factor times the diagonal of the first grid cell, computed from the lengths of its three edges
Grid_counts is Grid but with an additional field Count that has the number of hits
GeophysicalModelGenerator.point_to_nearest_grid Method
Grid_counts = point_to_nearest_grid(Point::CartData, Grid::CartData; radius_factor=1)Uses nearest neighbour interpolation to count how many points (given by Point) are in the vicinity of a 3D Grid. The search radius is R = radius_factor * sqrt(Δx² + Δy² + Δz²), radius_factor times the diagonal of a grid cell
Point should have 1D coordinate vectors
Grid_counts is Grid but with an additional field Count that has the number of hits
GeophysicalModelGenerator.point_to_nearest_grid Method
Grid_counts = point_to_nearest_grid(Point::GeoData, Grid::GeoData; radius_factor=1)Uses nearest neighbour interpolation to count how many points (given by Point) are in the vicinity of a 3D Grid. Distances are measured in km, in Earth-centered Cartesian (ECEF, WGS84) coordinates. The search radius is radius_factor times the diagonal of the first grid cell, computed from the lengths of its three edges
Point should have 1D coordinate vectors
Grid_counts is Grid but with an additional field Count that has the number of hits
GeophysicalModelGenerator.project_CartData Method
d_cart = project_CartData(d_cart::CartData, d_cart_data0::CartData)Projects all datafields from the CartData struct d_cart_data0 to the CartData struct d_cart. d_cart_data0 must be an orthogonal cartesian grid.
Note:
If
d_cartis a horizontal surface (3rd dimension has size==1), the depth coordinate ofd_cart_data0is interpolated as well.Points of
d_cartoutsided_cart_data0take the value at the nearest edge ofd_cart_data0for surfaces; for 3D grids, floating-point fields areNaNthere andInt64fields take the value of the nearest point.
GeophysicalModelGenerator.project_CartData Method
d_cart = project_CartData(d_cart::CartData, d::GeoData, p::ProjectionPoint)Projects all datafields from the GeoData struct d to the CartData struct d_cart, around the projection point p. d_cart must be an orthogonal cartesian grid (deformed doesn't work; use convert2CartData(d, proj), where proj is a projection point in that case).
Note:
If
d_cartanddare horizontal surfaces (3rd dimension has size==1), it also interpolates the depth coordinate.Points of
d_cartoutsidedtake the value at the nearest edge ofdfor surfaces; for 3D grids, floating-point fields areNaNthere andInt64fields take the value of the nearest point.dmay use longitudes in 0..360° or in -180..180°.
GeophysicalModelGenerator.project_CartData Method
d_cart = project_CartData(d_cart::CartData, d::UTMData, p::ProjectionPoint)Projects all datafields from the UTMData struct d to the CartData struct d_cart, around the projection point p. d_cart must be an orthogonal cartesian grid (deformed doesn't work; use convert2CartData(d, proj), where proj is a projection point in that case).
Note:
If
d_cartanddare horizontal surfaces (3rd dimension has size==1), it also interpolates the depth coordinate.Points of
d_cartoutsidedtake the value at the nearest edge ofdfor surfaces; for 3D grids, floating-point fields areNaNthere andInt64fields take the value of the nearest point.
GeophysicalModelGenerator.project_FEData_CartData Method
data_cart = project_FEData_CartData(data_cart::CartData, data_fe::FEData)Projects a FEData object with tetrahedrons (e.g., from Gmsh) to a Cartesian grid
sourceGeophysicalModelGenerator.read_LaMEM_inputfile Method
Grid::LaMEM_grid = read_LaMEM_inputfile(file, args::Union{String,Nothing}=nothing)Parses a LaMEM input file and stores grid information in the Grid structure. Optionally, you can pass LaMEM command-line arguments as well.
Example 1
julia> Grid = read_LaMEM_inputfile("SaltModels.dat")
LaMEM Grid:
nel : (32, 32, 32)
marker/cell : (3, 3, 3)
markers : (96, 96, 96)
x ϵ [-3.0 : 3.0]
y ϵ [-2.0 : 2.0]
z ϵ [-2.0 : 0.0]Example 2 (with command-line arguments)
julia> Grid = read_LaMEM_inputfile("SaltModels.dat", args="-nel_x 64 -coord_x -4,4")
LaMEM Grid:
nel : (64, 32, 32)
marker/cell : (3, 3, 3)
markers : (192, 96, 96)
x ϵ [-4.0 : 4.0]
y ϵ [-2.0 : 2.0]
z ϵ [-2.0 : 0.0]GeophysicalModelGenerator.read_data_PVTR Method
Data::ParaviewData = read_data_PVTR(fname, dir)Reads a parallel, rectilinear, *.pvtr file with the name fname and located in dir and create a 3D Data struct from it.
Example
julia> Data = read_data_PVTR("Haaksbergen.pvtr", "./Timestep_00000005_3.35780500e-01/")
ParaviewData
size : (33, 33, 33)
x ϵ [ -3.0 : 3.0]
y ϵ [ -2.0 : 2.0]
z ϵ [ -2.0 : 0.0]
fields: (:phase, :density, :visc_total, :visc_creep, :velocity, :pressure, :temperature, :dev_stress, :strain_rate, :j2_dev_stress, :j2_strain_rate, :plast_strain, :plast_dissip, :tot_displ, :yield, :moment_res, :cont_res)GeophysicalModelGenerator.read_data_VTR Method
coord_x, coord_y, coord_z, Data_3D_Arrays, Name_Vec, NumComp_Vec, ix, iy, iz = read_data_VTR(fname, FullSize; origin=(1, 1, 1))Reads a VTR (rectilinear grid) VTK file fname with raw appended binary data, as LaMEM writes it, and returns the coordinates, the point data and the names and number of components of the data arrays. In general, the file contains only one piece of the data, and one should open a *.pvtr file with read_data_PVTR to retrieve the full data.
The coordinates and data are placed into arrays of the full grid size FullSize, which are zero outside this piece; ix, iy, iz are the indices of the piece in the full grid. The Piece Extent of the file counts nodes of the full grid from origin, the start of the WholeExtent of the *.pvtr file (LaMEM starts at 1). Cell data is not supported.
GeophysicalModelGenerator.read_outlines Method
outlines = read_outlines(filename; tolerance = 1.0, bounds = nothing, reference = nothing)Reads named map-view outlines, such as plate boundaries, weak zones and trenches, from a file. Returns a vector of named tuples (; name, closed, x, y) in the order of the file, which is the drawing order of an SVG file, so that later outlines can be painted over earlier ones. A closed outline is a polygon, e.g. for add_plate!(Phase, Temp, Grid; xlim = o.x, ylim = o.y, ...); only an open outline is valid as Trace of add_fault! or of a Trench, which also reject traces that turn by more than 90° between consecutive segments.
The format follows from the extension of filename:
.csv: one row per vertex with the columnsid,name,closed,x,y, as written bywrite_outlines; the rows of an outline share itsid, andclosedis 0 or 1. Lines starting with#are comments..svg: every visible shape (path,rect,circle,ellipse,line,polyline,polygon) outsidedefs, clip paths, masks, patterns, symbols and markers is an outline, so that drawings from any vector graphics program (Inkscape, Affinity, Illustrator, ...) can be read. Elements hidden bydisplay: none, such as hidden Inkscape layers, give no outlines, though they may hold the reference shape, and shapes exported as images, e.g. because they are semi-transparent, are not read. An outline is named by its attributelabel(geomIO, or Inkscape'sinkscape:label) ordata-name(Illustrator), else by the label of its closest labeled group or Inkscape layer (or the layer'sid), else by its ownid, else by theidof its closest group (the layer name in Affinity). A<use>with a label names its copy. A path with several subpaths, e.g. a polygon with holes, gives one outline of the same name per subpath. A subpath that ends at its start is closed. Curves and arcs are flattened into polylines that deviate less thantolerancefrom them, in model units. Drawing coordinates are mapped to model coordinates by one ofreference = name => ((X0, Y0), (X1, Y1)): the shapename, typically a straight line, starts at the model coordinates(X0, Y0)and ends at(X1, Y1);bounds = (xmin, xmax, ymin, ymax): the model coordinates of theviewBoxof the drawing (its page);a shape with an attribute
CoordRef = "X0,Y0 X1,Y1", as in geomIO, used if neither keyword is given.
The reference shape is not returned as an outline and must span a nonzero extent in x and y. Lengths with units (e.g.
width="10mm"of arect), arc flags written without a separator before the next number (a 5 5 0 0110 0) and<use>of a<symbol>with aviewBoxare not supported and throw an error.
Example
julia> outlines = read_outlines("MapviewSetup.svg"; tolerance = 4.0);
julia> adria = only(filter(o -> o.name == "Adria", outlines));
julia> add_plate!(Phases, Temp, Grid; xlim = adria.x, ylim = adria.y, zlim = (-110, 0), phase = LithosphericPhases(Layers = [30, 80], Phases = [10, 3, 1]))GeophysicalModelGenerator.read_picked_profiles Method
This reads the picked profiles from disk and returns a vector of ProfileData
sourceGeophysicalModelGenerator.read_topo_netcdf Function
read_topo_netcdf(file)Read a global .grd grid, returning (lon, lat, z). Filled in by the NCDatasets extension; the tiled resolutions do not go through here.
GeophysicalModelGenerator.remove_NaN_surface! Method
remove_NaN_surface!(Z::Array,X::Array,Y::Array)Removes NaN's from a grid Z by taking the closest points as specified by X and Y.
GeophysicalModelGenerator.removefield Method
V = removefield(V::AbstractGeneralGrid,field_name::String)Removes the field with name field_name from the GeoData or CartData dataset
GeophysicalModelGenerator.removefield Method
V = removefield(V::AbstractGeneralGrid,field_name::Symbol)Removes the field with name field_name from the GeoData or CartData dataset
GeophysicalModelGenerator.removefield Method
V = removefield(V::AbstractGeneralGrid,field_name::NTuple{N,Symbol})Removes the fields in the tuple field_name from the GeoData or CartData dataset
GeophysicalModelGenerator.reset_topo_server Method
reset_topo_server()Forget that the GMT data server was unreachable, so that the next import_topo asks it again right away rather than after SERVER_RETRY_AFTER seconds, and forget the tiles it answered with 404 (the *.absent markers), so that those are requested again too.
GeophysicalModelGenerator.rotate_translate_scale Method
Data_R = rotate_translate_scale(Data::Union{ParaviewData, CartData}; Rotate=0, Translate=(0,0,0), Scale=(1.0,1.0,1.0), Xc=(0.0,0.0))Returns a copy of the Cartesian dataset Data that is scaled, rotated and translated; Data is not modified.
Parameters
Note that we apply the transformations in exactly this order:
Scale: scaling applied to thex,y,zcoordinates of the data setRotate: rotation around thex/yaxis, around the pointXcTranslate: translationXc: center of rotation (default: the origin)
Example
julia> X,Y,Z = xyz_grid(10:20,30:40,-50:-10);
julia> Data_C = CartData(X,Y,Z,(Depth=Z,));
julia> Data_R = rotate_translate_scale(Data_C, Rotate=30)
CartData
size : (11, 11, 41)
x ϵ [ -11.339745962155614 : 2.320508075688771]
y ϵ [ 30.980762113533157 : 44.64101615137754]
z ϵ [ -50.0 : -10.0]
fields : (:Depth,)GeophysicalModelGenerator.save_GMG Method
save_GMG(filename::String, data::Union{GeoData, CartDat, UTMData}; dir=pwd())Saves the dataset data to a JLD2 file (name without extension) in the directory dir
Example
julia> Lon3D,Lat3D,Depth3D = lonlatdepth_grid(1.0:3:10.0, 11.0:4:20.0, (-20:5:-10)*km);
julia> Data_set = GeophysicalModelGenerator.GeoData(Lon3D,Lat3D,Depth3D,(DataFieldName=Depth3D,))
julia> save_GMG("test",Data_set)GeophysicalModelGenerator.save_LaMEM_markers_parallel Method
save_LaMEM_markers_parallel(Grid::CartData; PartitioningFile=empty, directory="./markers", verbose=true, is64bit=false, add_APS=false)Saves a LaMEM marker file from the CartData structure Grid. It must have a field called Phases, holding phase information (as integers) and optionally a field Temp with temperature info. It is possible to provide a LaMEM partitioning file PartitioningFile. If not, output is assumed to be for one processor. By default it is assumed that the partitioning file was generated on a 32bit PETSc installation. If Int64 was used instead, set the flag. if add_APS is true it will add a new field to all particles (needed in newer versions of LaMEM, but not supported in LaMEM 2.2.0 or before)
The size of Grid should be consistent with what is provided in the LaMEM input file. In practice, the size of the mesh can be retrieved from a LaMEM input file using read_LaMEM_inputfile.
Example
julia> Grid = read_LaMEM_inputfile("LaMEM_input_file.dat")
julia> Phases = zeros(Int32,size(Grid.X));
julia> Temp = ones(Float64,size(Grid.X));
julia> Model3D = CartData(Grid, (Phases=Phases,Temp=Temp))
julia> save_LaMEM_markers_parallel(Model3D)
Writing LaMEM marker file -> ./markers/mdb.00000000.datIf you want to create a LaMEM input file for multiple processors:
julia> save_LaMEM_markers_parallel(Model3D, PartitioningFile="ProcessorPartitioning_4cpu_1.2.2.bin")
Writing LaMEM marker file -> ./markers/mdb.00000000.dat
Writing LaMEM marker file -> ./markers/mdb.00000001.dat
Writing LaMEM marker file -> ./markers/mdb.00000002.dat
Writing LaMEM marker file -> ./markers/mdb.00000003.datGeophysicalModelGenerator.save_LaMEM_topography Method
save_LaMEM_topography(Topo::CartData, filename::String)This writes a topography file Topo for use in LaMEM, which should have size (nx,ny,1) and contain the field :Topography
GeophysicalModelGenerator.sbp_nodes Method
x = sbp_nodes(a, b, n; P = (0.0, 0.4796891391869102, 1.3753231251827358, 2.3753231251827374, 3.3753231251827396, 4.375323125182741))The n nodes on [a, b] of a summation-by-parts (SBP) finite-difference grid: equidistant with spacing h in the interior, except the outermost length(P) nodes on either side, which lie at a + h P[j] and b - h P[j], with h = (b - a) / (2P[end] + n - 2length(P) + 1). The default P are the boundary nodes of the SBP operators of SeismicWavePC.jl; n must be at least 2length(P) + 1 (13). Use them as the x (and y) of curvilinear_grid.
GeophysicalModelGenerator.screenshot_to_CartData Method
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_GeoData Method
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_UTMData Method
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.server_down_for Method
server_down_for()How many seconds are left of leaving the server alone after every mirror failed to deliver a file, or 0.0 if it may be asked. The marker is a file in the cache rather than a variable so that separate processes – the parallel test workers – share it.
GeophysicalModelGenerator.server_entry Method
server_entry(dataset, res, reg)The line that gmt_data_server.txt holds for this set, as a named tuple. Everything that varies from set to set – how large a tile is, how the integers in it scale to metres, which coarser set fills the gaps – is published there, so it is read rather than assumed.
GeophysicalModelGenerator.server_index_file Method
server_index_file()The server's own index of its datasets: downloaded once into the cache and read from there after that. If it cannot be downloaded, the copy bundled with the package is used instead. The download is attempted once per session, not once per call: the index is consulted several times per import, and with the server down each attempt would cost a full round of the mirrors.
sourceGeophysicalModelGenerator.setup_model_domain Method
setup_model_domain(coord_x::Vector{Float64},
coord_y::Vector{Float64},
coord_z::Vector{Float64},
nx::Int, ny::Int, nz::Int,
n_ranks::Int) -> ModelDomainSetup model domain decomposition using domain boundaries and resolution.
Parameters:
coord_x, coord_y, coord_z: 2-element vectors specifying [min, max] for each direction
nx, ny, nz: Number of cells in each direction
n_ranks: Total number of MPI ranks
Returns:
- LaMEMPartitioningInfo struct containing all domain decomposition information
GeophysicalModelGenerator.spacing Method
dlon, dlat = spacing(lon,lat)Computes the spacing with central differences
sourceGeophysicalModelGenerator.subset_indices Method
subset_indices(coords, lo, hi, px)The samples that make up lo..hi, following what GMT returns. With gridline registration the samples are the cell corners and GMT widens the request out to the nodes that enclose it; with pixel registration they are the cell centres and a cell belongs to the region when its centre does.
GeophysicalModelGenerator.subtract_horizontalmean Method
V_sub = subtract_horizontalmean(V::AbstractArray{T, 3}; Percentage=false)Subtracts the horizontal average of the 3D data array V.
If Percentage=true, the result is given as percentage; otherwise absolute values are returned
GeophysicalModelGenerator.subtract_horizontalmean Method
V_sub = subtract_horizontalmean(V::AbstractArray{T, 2}; Percentage=false)Subtracts the horizontal average of the 2D data array V.
If Percentage=true, the result is given as percentage; otherwise absolute values are returned
GeophysicalModelGenerator.swap_yz_dims Method
fe_swap = swap_yz_dims(fe_data::FEData)This swaps the y and z dimensions of the FEData object, which is useful for pTatin as it uses y for what is z in GMG.
Swapping two axes mirrors the mesh, so the vertices of each cell are reordered to keep the cells' orientation. This is supported for 3D tetrahedra and for 3D hexahedra whose vertices are numbered lexicographically (x fastest, then y, then z), as convert2FEData does.
GeophysicalModelGenerator.tile_directory Method
tile_directory(dataset, res, reg)The directory on the server that holds the tiles of this set.
sourceGeophysicalModelGenerator.tile_filename Method
tile_filename(lat, lon, dataset, res, reg)The name of the tile whose south-west corner is at (lat, lon).
The 3 arcsecond set is the odd one out: it is SRTM repackaged, and is named after that rather than after the dataset it is served under.
sourceGeophysicalModelGenerator.tile_size_deg Method
tile_size_deg(dataset, res, reg)The width and height, in degrees, of one tile of this set, or nothing if the set is published as a single global file rather than as tiles.
GeophysicalModelGenerator.tile_size_px Method
tile_size_px(res, deg, reg)How many pixels a tile has along each side: the tile width in degrees divided by the spacing that res names (m = arcminutes, s = arcseconds), plus one for gridline registration.
GeophysicalModelGenerator.tile_url Method
tile_url(name, dataset, res, reg)The path of tile name relative to the server's earth directory. The SRTM sets are published only under earth_relief, whichever dataset they are requested through.
GeophysicalModelGenerator.topo_cache_dir Method
topo_cache_dir()Where downloaded tiles are kept, so that repeated imports of the same region do not download them again. Uses a scratch space, which is removed when the package is.
sourceGeophysicalModelGenerator.topographic_effect Method
te = topographic_effect(Topo; density = 2670, density_water = 1040, cutoff = 166.7, stations = nothing, kwargs...)Complete Bouguer correction [mGal]: the attraction of the topography between sea level and the surface Topo with the density density (and of the oceans, as density_water - density between the sea floor and sea level), computed with voxel_grav at stations on the topography (or at sea level for the oceans), or at stations. Unlike bouguer_correction, this includes the terrain correction. Subtract it from the free-air anomaly (or gravity disturbance) to get the complete Bouguer anomaly.
Topo is a GeoData surface (computed on the ellipsoid) or a CartData surface (flat Earth), with the topography in km as depth/z, e.g. from import_topo. The masses are a single layer of cells between sea level and the topography, whose top follows the topography (bilinear between the points of Topo), so there is no staircase approximation; cells close to a station are subdivided. Cells beyond the horizontal distance cutoff [km] are ignored; 166.7 km is the standard outer radius of terrain corrections (Hayford-Bowie zone O). Further keyword arguments (e.g. backend, float_type, gradients, subdivide) are passed on to voxel_grav. Returns the result of voxel_grav, i.e. (te, dtedx, dtedy).
GeophysicalModelGenerator.update_nel_xyz_in_file Method
update_nel_xyz_in_file(ParamFile_name, nx, ny, nz) Generates or updates CPU lines in a LaMEM input file after the nel_z line. Usage:
- Generate LaMEM model
Target resolution is 256x256x256.
nx = 256; ny = 256; nz = 256 ParamFile_name = "LaMEM_setup.txt" model = Model( LaMEM.Grid(x=[-80.,80.], y=[-95.,100.], z=[-60.0,10.0] , nel=(8,8,8)),Output(param_file_name = ParamFile_name,)) Notice that here nel is a very small number. Thick hacky way prevents us to generate huge grid at this stage.
- Once populated model with information, we save model as setup file in text.
write_LaMEM_inputFile(model,ParamFile_name).
- Then we can use this function to update back amount of elements of each direction to the target one, so setup file is correct.
update_nel_xyz_in_file(ParamFile_name, nx, ny, nz)
sourceGeophysicalModelGenerator.velocity_spherical_to_cartesian! Method
velocity_spherical_to_cartesian!(Data::GeoData, Velocity::Tuple)In-place conversion of velocities in spherical velocities [Veast, Vnorth, Vup] to cartesian coordinates (for use in paraview).
NOTE: the magnitude of the vector will be the same, but the individual [Veast, Vnorth, Vup] components will not be retained correctly (as a different [x,y,z] coordinate system is used in paraview). Therefore, if you want to display or color that correctly in Paraview, you need to store these magnitudes as separate fields
GeophysicalModelGenerator.visualise Function
fig = visualise(DataSet; Topography=nothing, Topo_range=nothing)Starts an interactive widget that allows you to explore the 3D data set DataSet (a GeoData set or an orthogonal CartData set) and returns the Figure, which can be saved with save("file.png", fig). All fields of the data set can be explored. CartData sets that are not on an orthogonal grid need to be projected first with project_CartData. The isosurface is off by default and can be toggled in the widget. Vector fields (tuples) are not offered.
Keywords:
Topography: optional topography data set that is drawn on top ofDataSet(default=nothing)Topo_range: optional range of the topography color scale (default: symmetric about 0, ± the largest absolute topography)
Requires loading GLMakie.
GeophysicalModelGenerator.votemap Method
votemap(DataSets::Vector{GeoData}, criteria::Vector{String}, dims=(50,50,50))Creates a Vote map which shows consistent features in different 2D/3D tomographic datasets.
The way it works is:
Find a common region between the different GeoData sets (overlapping lon/lat/depth regions)
Interpolate the fields of all DataSets to common coordinates
Filter data points in one model (e.g., areas with a velocity anomaly > 2 percent). Set everything that satisfies this criteria to 1 and everything else to 0.
Sum the results of the different datasets
If a feature is consistent between different datasets, it will have larger values.
Example
We assume that we have 2 seismic velocity datasets Data_Zhao_Pwave and DataKoulakov_Alps:
julia> Data_Zhao_Pwave
GeoData
size : (121, 94, 101)
lon ϵ [ 0.0 : 18.0]
lat ϵ [ 38.0 : 51.95]
depth ϵ [ -1001.0 km : -1.0 km]
fields: (:dVp_Percentage,)
julia> DataKoulakov_Alps
GeoData
size : (108, 81, 35)
lon ϵ [ 4.0 : 20.049999999999997]
lat ϵ [ 37.035928143712574 : 49.01197604790419]
depth ϵ [ -700.0 km : -10.0 km]
fields: (:dVp_percentage, :dVs_percentage)You can create a votemap which combines the two data sets with:
julia> Data_VoteMap = votemap([Data_Zhao_Pwave,DataKoulakov_Alps],["dVp_Percentage>2.5","dVp_percentage>3.0"])
GeoData
size : (50, 50, 50)
lon ϵ [ 4.0 : 18.0]
lat ϵ [ 38.0 : 49.01197604790419]
depth ϵ [ -700.0 km : -10.0 km]
fields: (:votemap,)You can also create a votemap of a single dataset:
julia> Data_VoteMap = votemap(Data_Zhao_Pwave,"dVp_Percentage>2.5", dims=(50,51,52))
GeoData
size : (50, 51, 52)
lon ϵ [ 0.0 : 18.0]
lat ϵ [ 38.0 : 51.95]
depth ϵ [ -1001.0 km : -1.0 km]
fields: (:votemap,)GeophysicalModelGenerator.voxel_grav Method
voxel_grav(X::Array{Float64, 3}, Y::Array{Float64, 3}, Z::Array{Float64, 3}, RHO::Array{<:Real, 3};
refMod="AVG", lengthUnit="m", rhoTol=1e-9, Topo=[], outName="Bouguer", printing=true, zRef=0,
backend=nothing, float_type=Float64, gradients=true, cutoff=Inf, subdivide=2.5)Computes Bouguer anomalies and gradients
Required arguments:
X,Y,Z: 3D matrices with the coordinates of the grid (X should vary in the first dimension, Y in the second, Z (vertical) in the third). The spacing may vary along each direction.RHO: 3D matrix with the density at each grid point [kg/m^3]. Any number type works, so thatvoxel_gravcan be differentiated with ForwardDiff (withoutName = nothing).
Optional arguments:
refMod: 1D vector with the reference density for each depth. Alternatively, the strings "NE", "SE", "SW", "NW", "AVG" can be used. In that case, one of the corners ofRHOis used as reference model.In case of "AVG" the reference model is the average of each depth slice.lengthUnit: The unit of the coordinates and topography file. Either "m" or "km"rhoTol: density differences smaller thanrhoTolwill be ignored [kg/m^3]Topo: 2D matrix with the topography of the surface, of sizesize(X)[1:2](only relevant for the paraview output)outName: name of the paraview output (do not include file type);nothingwrites no file (e.g. inside an inversion loop)printing: activate printing of additional information [trueorfalse]zRef: height of the stations at which the anomaly is computed (same unit asZ): a number, or an array of sizesize(X)[1:2]with the height of every surface point (e.g. the topography, see the free-air and Bouguer examples in the documentation). Only the part of the model belowmaximum(zRef)is taken into account.backend:nothing(default) computes on one CPU core. A KernelAbstractions.jl backend computes in parallel, e.g.CPU()(all threads),MetalBackend()(Apple GPU, needsfloat_type = Float32) orCUDABackend(). Requiresusing KernelAbstractions(or a GPU package that loads it).float_type: number type of the computation with abackend;Float32is faster on GPUs but less accurate (relative error ≈ 1e-5).gradients: compute the horizontal gradients of the anomaly;falsesaves time and returnsnothingfor them.cutoff: ignore cells whose horizontal distance from a station is larger thancutoff(same unit as the coordinates); e.g. 166.7 km is the standard outer radius of terrain corrections. Default: all cells.subdivide: cells closer to a station thansubdividetimes their size are split recursively into smaller point masses, which keeps the result accurate close to the stations;0switches this off.
Returns the anomaly dg [mGal] and its horizontal gradients gradX = ∂dg/∂x, gradY = ∂dg/∂y [mGal/m] at the surface grid points (x, y of the grid, z = zRef), computed analytically from the point masses. dg is linear in the density; voxel_grav_adjoint gives its adjoint (sensitivity).
GeophysicalModelGenerator.voxel_grav Method
dg, dgdx, dgdy = voxel_grav(Grid::CartData, RHO; stations = nothing, gradients = false, kwargs...)Flat-Earth gravity anomaly [mGal] and, with gradients = true, its horizontal gradients [mGal/m] of the density RHO given at the points of the Cartesian grid Grid (coordinates in km). Without stations, this is voxel_grav(X, Y, Z, RHO; lengthUnit = "km", gradients, kwargs...) (zRef and cutoff in km) without file output. stations (CartData, in km) gives arbitrary station positions instead of the grid columns; refMod, rhoTol, cutoff, subdivide, backend and float_type work as for GeoData.
Grid may also be a curvilinear grid whose levels follow surfaces such as the topography (see deform_grid and curvilinear_grid). Its cells are hexahedra with vertical edges, and the stations are by default on top of the grid columns (zRef gives other heights); all cells are used.
GeophysicalModelGenerator.voxel_grav Method
dg, dgdx, dgdy = voxel_grav(Grid::GeoData, RHO; refMod = "AVG", zRef = nothing, stations = nothing, rhoTol = 1e-9, gradients = false, cutoff = Inf,
subdivide = 2.5, ellipsoid = (a = 6378137.0, f = 1 / 298.257223563), backend = nothing, float_type = Float64)Gravity anomaly [mGal] of the density RHO [kg/m³], given at the points of the regular geographic grid Grid (as created by lonlatdepth_grid), or of a curvilinear grid whose depth levels follow surfaces such as the topography (a 3D Depth array with monotonic columns, as built in topographic_effect).
The computation is done on the reference ellipsoid (WGS84 by default; ellipsoid = (a = 6371e3, f = 0) is a sphere). Depths and heights are heights above the ellipsoid in km; heights relative to sea level are used as such, i.e. the geoid undulation is ignored. Every cell is a point mass at its position on the ellipsoid (subdivided close to the stations), and dg is the component of its attraction along the ellipsoid normal at the station (downwards positive), i.e. the gravity disturbance caused by RHO - refMod.
refMod: reference density for every depth level, or"NE","SE","SW","NW","AVG"as invoxel_grav.zRef: height of the stations above every grid column [km]: a number, or an array of sizesize(Grid.lon)[1:2], e.g. the topography. By default 0 (sea level), or the top of the grid for a curvilinear grid.stations:GeoDatawith arbitrary station positions (e.g. measurement points;depthis their height in km), instead of the grid columns.zRefis then ignored.gradients: also compute the horizontal gradients ofdgtowards east (dgdx) and north (dgdy) [mGal/m]; otherwise they arenothing.cutoff: ignore cells whose horizontal distance from a station is larger thancutoff[km]; e.g. 166.7 km is the standard outer radius of terrain corrections. Default: all cells.subdivide: cells closer to a station thansubdividetimes their size are split recursively into smaller point masses (0switches this off).rhoTol,backend,float_type: as invoxel_grav.
On a regular grid, only the part of the model below the highest station is used. The cells of a curvilinear grid are hexahedra with vertical edges, whose inclined top and bottom are taken into account by the full tensor of their second moments. dg, dgdx and dgdy have size size(Grid.lon)[1:2], or the size of stations.lon. voxel_grav_adjoint gives the adjoint of dg.
GeophysicalModelGenerator.voxel_grav_adjoint Method
sens = voxel_grav_adjoint(X, Y, Z, R; lengthUnit = "m", zRef = 0, backend = nothing, float_type = Float64, cutoff = Inf, subdivide = 2.5)Adjoint of voxel_grav. Returns sens, of the same size as X, with
sens[i, j, k] = ∂(sum(R .* dg)) / ∂RHO[i, j, k] [mGal per kg/m³]where dg is the anomaly computed by voxel_grav(X, Y, Z, RHO; refMod, zRef) for a fixed reference-model vector refMod and R is a weight for every surface point (same size as dg). Since dg is linear in RHO, sens does not depend on RHO.
R = ones(size(dg)): sensitivity of the summed anomaly to the density of every grid point.R= 1 at one station and 0 elsewhere: change of the anomaly at that station,δg ≈ sum(sens .* δRHO).R = dg - dg_obs: gradient of the misfitsum((dg - dg_obs) .^ 2) / 2with respect toRHO, for gradient-based inversion.
Grid points above maximum(zRef) have zero sensitivity. The cost is that of one call to voxel_grav with rhoTol = 0; backend, float_type, cutoff and subdivide work as there.
GeophysicalModelGenerator.voxel_grav_adjoint Method
sens = voxel_grav_adjoint(Grid::CartData, R; stations = nothing, kwargs...)Adjoint of voxel_grav(Grid::CartData, RHO; ...)[1] (flat Earth, coordinates in km).
GeophysicalModelGenerator.voxel_grav_adjoint Method
sens = voxel_grav_adjoint(Grid::GeoData, R; zRef = nothing, stations = nothing, cutoff = Inf, subdivide = 2.5, ellipsoid = (a = 6378137.0, f = 1 / 298.257223563),
backend = nothing, float_type = Float64)Adjoint of voxel_grav(Grid::GeoData, RHO; ...)[1]: sens[i, j, k] = ∂(sum(R .* dg)) / ∂RHO[i, j, k] [mGal per kg/m³], for a fixed reference-model vector. R has the size of dg. See voxel_grav_adjoint for the Cartesian version.
GeophysicalModelGenerator.write_FEmesh_fields Method
write_FEmesh_fields(data::FEData; dir=".")Writes cell and vertex fields to <name>_cell.bin and <name>_vertex.bin in directory dir, to be read by pTatin
GeophysicalModelGenerator.write_FEmesh_mesh Method
write_FEmesh_mesh(vdata::FEData; out_file="md.bin", connectivity_zero_based=true)Writes a binary file with the mesh information for pTatin
sourceGeophysicalModelGenerator.write_outlines Method
write_outlines(filename, outlines; comment = nothing)Writes outlines, a vector of named tuples (; name, closed, x, y) as returned by read_outlines, to the CSV file filename, with one row per vertex and the columns id,name,closed,x,y. comment is written as # lines at the top, e.g. to record the source and units of the outlines.
GeophysicalModelGenerator.write_pTatin_mesh Method
write_pTatin_mesh(fe_mesh::FEData; out_file="md.bin", connectivity_zero_based=true)Write a binary file with the mesh information for pTatin, and one file per field (<name>_cell.bin, <name>_vertex.bin) in the same directory as out_file.
GeophysicalModelGenerator.write_pTatin_mesh Method
write_pTatin_mesh(q1_mesh::Q1Data; out_file="md.bin", connectivity_zero_based=true)Write a binary file with the mesh information for pTatin, and one file per field in the same directory as out_file.
GeophysicalModelGenerator.write_paraview Function
pvd = write_paraview(DataSet::ParaviewData, filename="test"; PointsData=false, pvd=nothing, time=nothing, directory=nothing, verbose=true)Writes a structure with Geodata to a paraview (or VTK) file. If you have unstructured points (e.g., earthquake data), set PointsData=true. In case you want to create a movie in Paraview, and this is a timestep of that movie you also have to pass time and pvd
Example 1: Write a 3D volume
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,(-300:25:0)km);
julia> Data_set = GeoData(Lat,Lon,Depth,(Depthdata=Depth,LonData=Lon))
julia> write_paraview(Data_set, "test_depth3D")Example 2: Horizontal slice @ given depth
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,10km);
julia> Data_set = GeoData(Lat,Lon,Depth,(Topography=Depth,))
julia> write_paraview(Data_set, "test")Example 3: Case with topography
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,10km);
julia> Depth[2:4,2:4,1] .= 25km
julia> Data_set = GeoData(Lat,Lon,Depth,(Topography=Depth,))
julia> write_paraview(Data_set, "test2")Example 4: Profile
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,35,(-300:25:0)km);
julia> Data_set = GeoData(Lat,Lon,Depth,(DataSet=Depth,Depth=Depth))
julia> write_paraview(Data_set, "test")Example 5: Velocity vectors
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,10km);
julia> Ve, Vn, Vz = ones(size(Depth)), ones(size(Depth))*0.5, zeros(size(Depth));
julia> Data_set = GeoData(Lat,Lon,Depth,(DataSet=Depth, Velocity=(Ve,Vn,Vz)))
GeoData
size : (11, 11, 1)
lon ϵ [ 30.0 - 40.0]
lat ϵ [ 10.0 - 20.0]
depth ϵ [ 10.0 km - 10.0 km]
fields: (:DataSet, :Velocity)
julia> write_paraview(Data_set, "test_Velocity")Example 6: Unconnected points (e.g., earthquake locations)
Note that these points should be 1D vectors.
julia> Lon,Lat,Depth = lonlatdepth_grid(10:5:20,35:2:40,(-300:50:0)km);
julia> Lon=Lon[:]; Lat=Lat[:]; Depth=Depth[:];
julia> Data_set = GeoData(Lat,Lon,Depth,(DataSet=Depth[:],Depth=Depth*10));
julia> write_paraview(Data_set, "test_Points", PointsData=true)GeophysicalModelGenerator.write_paraview Function
write_paraview(DataSet::Q1Data, filename="test"; directory=nothing, pvd=nothing, time=nothing, verbose=true)Writes a Q1Data dataset to disk, which has cell and vertex field
GeophysicalModelGenerator.write_paraview Function
write_paraview(DataSet::FEData, filename="test"; directory=nothing, pvd=nothing, time=nothing, verbose=true)Writes a FEData dataset (general finite element) to disk, which has cell and vertex field
GeophysicalModelGenerator.write_paraview Method
write_paraview(DataSet::CartData, filename::Any; PointsData=false, pvd=nothing, time=nothing, directory=nothing, verbose=true)Writes a CartData structure to paraview.
GeophysicalModelGenerator.write_paraview Method
write_paraview(DataSet::UTMData, filename::Any; PointsData=false, pvd=nothing, time=nothing, directory=nothing, verbose=true)Writes a UTMData structure to paraview. Note that this data is not transformed into an Earth-like framework, but remains cartesian instead.
GeophysicalModelGenerator.write_processor_partitioning_LaMEM Method
write_processor_partitioning_LaMEM(P::LaMEMPartitioningInfo; is64bit::Bool = false)
Writes the processor partitioning information P to a binary file in the format used by LaMEM. The file is named ProcessorPartitioning_(P.nProcX*P.nProcY*P.nProcZ)cpu_(P.nProcX).(P.nProcY).(P.nProcZ).bin and returned as string. The coordinates are written as Float64, and the processor counts and node counts as Int64 or Int32, depending on the is64bit flag. is64bit must match the PetscInt width of the LaMEM build (default: 32-bit).
GeophysicalModelGenerator.xyz_grid Method
X,Y,Z = xyz_grid(X_vec::Any, Y_vec::Any, Z_vec::Any)Creates a X,Y,Z grid. It works just as lonlatdepth_grid apart from the better suited name.
Example 1: Create 3D grid
julia> X,Y,Z = xyz_grid(10:20,30:40,(-10:-1)km);
julia> size(X)
(11, 11, 10)See lonlatdepth_grid for more examples.
WhereTheWaterFlows.waterflows Function
Topo_water, sinks, pits, bnds = waterflows(Topo::GeoData;
flowdir_fn=WhereTheWaterFlows.d8dir_feature, feedback_fn=nothing, drain_pits=true, bnd_as_sink=true,
rainfall = nothing,
minsize=300)Takes a GMG GeoData object of a topographic map and routes water through the grid. Optionally, you can specify rainfall in which case we accumulate the rain as specified in this 2D array instead of the cellarea. This allows you to, for example, sum, up water if you have variable rainfall in the area. The other options are as in the waterflows function of the package WhereTheWaterFlows.
Example
# Download some topographic data
julia> Topo = import_topo([6.5,7.3,50.2,50.6], file="@earth_relief_03s");
# Flow the water through the area:
julia> Topo_water, sinks, pits, bnds = waterflows(Topo)
julia> Topo_water
GeoData
size : (961, 481, 1)
lon ϵ [ 6.5 : 7.3]
lat ϵ [ 50.2 : 50.59999999999999]
depth ϵ [ 0.045 : 0.724]
fields : (:Topography, :area, :slen, :dir, :nout, :nin, :c)