API, exported functions
EikonalSolvers.EikonalSolvers
— ModuleEikonalSolvers
EikonalSolvers module, 2D and 3D traveltime and gradient computations in Cartesian and spherical coordinates. Computes seismic traveltimes by solving the eikonal equation in two and three dimensions with the possibility of computing the gradient of the misfit function with respect to the velocity model. Both forward and gradient computations are parallelised using Julia's distributed computing functions and the parallelisation is "by source", distributing calculations for different sources to different processors.
Exports
Cartesian/spherical grids structures
EikonalSolvers.Grid2DCart
— Typestruct Grid2DCart <: EikonalSolvers.AbstractGridEik2D
A structure holding the 2D grid parameters, geometry and size.
hgrid::Float64
: Spacing of the grid nodescooinit::Tuple{Float64, Float64}
: Origin of the coodinates of the gridcooend::Tuple{Float64, Float64}
: End of the coodinates of the gridgrsize::Tuple{Int64, Int64}
: Number of grid nodes along x and yx::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}
: x coordinates of the grid nodesy::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}
: y coordinates of the grid nodes
The constructor requires three arguments (see the example):
hgrid
: spacing of the grid nodescooinit
: origin of the coordinate systemgrsize
: number of grid nodes along x and y
Example
julia> Grid2DCart(hgrid=5.0,cooinit=(0.0,0.0),grsize=(300,250))
EikonalSolvers.Grid3DCart
— Typestruct Grid3DCart <: EikonalSolvers.AbstractGridEik3D
A structure holding the 3D grid parameters, geometry and size.
Fields
hgrid::Float64
: Spacing of the grid nodescooinit::Tuple{Float64, Float64, Float64}
: Origin of the coodinates of the gridcooend::Tuple{Float64, Float64, Float64}
: End of the coodinates of the gridgrsize::Tuple{Int64, Int64, Int64}
: Number of grid nodes along x, y and zx::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}
: x coordinates of the grid nodesy::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}
: y coordinates of the grid nodesz::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}
: z coordinates of the grid nodes
The constructor requires three arguments (see the example):
hgrid
: spacing of the grid nodescooinit
: origin of the coordinate systemgrsize
: number of grid nodes along x, y and z
Example
julia> Grid3DCart(hgrid=5.0,cooinit=(0.0,0.0,0.0),grsize=(60,60,40))
EikonalSolvers.Grid2DSphere
— TypeA structure holding the 2D SPHERICAL grid parameters, geometry and size.
Δr::Float64
: Spacing of the grid nodes along the radius (r)Δθ::Float64
: Spacing of the grid nodes along the angle θcooinit::Tuple{Float64, Float64}
: Origin of the coodinates of the gridcooend::Tuple{Float64, Float64}
: End of the coodinates of the gridgrsize::Tuple{Int64, Int64}
: Number of grid nodes along r and θr::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}
: r coordinates of the grid nodesθ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}
: θ coordinates of the grid nodes
The fields are:
Δr
: spacing of the grid nodes along the radial coordinate rΔθ
: spacing of the grid nodes along the θ coordinatecooinit
: origin of the coordinate systemgrsize
: number of grid nodes along r and θ
Example
julia> Grid2DSphere(Δr=15.0,Δθ=2.0,grsize=(10,15),cooinit=(500.0,0.0))
EikonalSolvers.Grid3DSphere
— TypeA structure holding the 3D SPHERICAL grid parameters, geometry and size.
Δr::Float64
: Spacing of the grid nodes along the radius (r)Δθ::Float64
: Spacing of the grid nodes along the angle θΔφ::Float64
: Spacing of the grid nodes along the angle φcooinit::Tuple{Float64, Float64, Float64}
: Origin of the coodinates of the gridcooend::Tuple{Float64, Float64, Float64}
: End of the coodinates of the gridgrsize::Tuple{Int64, Int64, Int64}
: Number of grid nodes along r, θ and φr::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}
: r coordinates of the grid nodesθ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}
: θ coordinates of the grid nodesφ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}
: φ coordinates of the grid nodes
The fields are:
Δr
: spacing of the grid nodes along the radial coordinate rΔθ
: spacing of the grid nodes along the θ coordinateΔφ
: spacing of the grid nodes along the θ coordinatecooinit
: origin of the coordinate systemgrsize
: number of grid nodes along r, θ and φ
Example
julia> Grid3DSphere(Δr=15.0,Δθ=2.0,Δφ=1.5,grsize=(10,15,12),cooinit=(500.0,20.0,0.0))
Forward, gradient and misfit calculation functions
EikonalSolvers.eiktraveltime
— Functioneiktraveltime(
vel::Array{Float64, N},
grd::EikonalSolvers.AbstractGridEik,
coordsrc::Matrix{Float64},
coordrec::Vector{Matrix{Float64}};
returntt,
extraparams
) -> Any
Calculate the traveltime for 2D or 3D velocity models at requested receivers locations. Optionally return the array(s) of traveltime on the entire gridded model.
Arguments
vel
: the 2D or 3D velocity modelgrd
: a struct specifying the geometry and size of the model (e.g., Grid3DCart)coordsrc
: the coordinates of the source(s) (x,y), a 2-column arraycoordrec
: the coordinates of the receiver(s) (x,y) for each single source, a vector of 2-column arraysreturntt
: a boolean (default false) specifying whether to retur the array(s) of traveltime on the entire gridded model or notextraparams
(optional): a struct containing some "extra" parameters, namelyparallelkind
: serial, Threads or Distributed run? (:serial, :sharedmem, :distribmem)refinearoundsrc
: whether to perform a refinement of the grid around the source locationgrdrefpars
: refined grid around the source parameters (downscalefactor
andnoderadius
)radiussmoothgradsrc
: radius for smoothing each individual gradient only around the source. Zero means no smoothing.smoothgradkern
: smooth the final gradient with a kernel of sizesmoothgradkern
(in grid nodes). Zero means no smoothing.manualGCtrigger
: trigger garbage collector (GC) manually at selected points.
Returns
- A vector of vectors containing traveltimes at the receivers for each source
- If
returntt==true
, additionally returns the array(s) of traveltime on the entire gridded model
EikonalSolvers.eikgradient
— Functioneikgradient(
vel::Array{Float64, N},
grd::EikonalSolvers.AbstractGridEik,
coordsrc::Matrix{Float64},
coordrec::Vector{Matrix{Float64}},
pickobs::Vector{Vector{Float64}},
stdobs::Vector{Vector{Float64}},
whichgrad::Symbol;
extraparams
) -> Union{Nothing, Tuple{Any, Any}, Tuple{Any, Any, Any}}
Calculate the gradient of the misfit function w.r.t. either velocity or source location (or both) using the adjoint state method for 2D or 3D problems.
The computations may be run in parallel depending on the value of extraparams.parallelkind
.
Arguments
vel
: the 2D or 3D velocity modelgrd
: a struct specifying the geometry and size of the model (e.g., Grid3DCart)coordsrc
: the coordinates of the source(s) (x,y), a 2-column arraycoordrec
: the coordinates of the receiver(s) (x,y) for each single source, a vector of 2-column arrayspickobs
: observed traveltime picksstdobs
: standard deviation of error on observed traveltime picks, an array with same shape thanpickobs
whichgrad
: one of :gradvel, :gradsrcloc, :gradvelandsrcloc, specifies which gradient should be computedextraparams
(optional): a struct containing some "extra" parameters, namelyparallelkind
: serial, Threads or Distributed run? (:serial, :sharedmem, :distribmem)refinearoundsrc
: whether to perform a refinement of the grid around the source locationgrdrefpars
: refined grid around the source parameters (downscalefactor
andnoderadius
)radiussmoothgradsrc
: radius for smoothing each individual gradient only around the source. Zero means no smoothing.smoothgradkern
: smooth the final gradient with a kernel of sizesmoothgradkern
(in grid nodes). Zero means no smoothing.manualGCtrigger
: trigger garbage collector (GC) manually at selected points.
Returns
- The gradient w.r.t. velocity as a 2D or 3D array and the gradient w.r.t source location. In case only one of them is requested with
whichgrad
, the other one will not be returned. - The value of the misfit functional for the given input velocity model.
EikonalSolvers.eikttimemisfit
— Functioneikttimemisfit(
velmod::Array{Float64, N},
grd::EikonalSolvers.AbstractGridEik,
coordsrc::AbstractMatrix,
coordrec::AbstractVector{<:AbstractArray},
ttpicksobs::AbstractArray,
stdobs::AbstractArray;
extraparams
) -> Float64
Calculate the Gaussian misfit functional
\[ S = \dfrac{1}{2} \sum_i \dfrac{\left( \mathbf{u}_i^{\rm{calc}}(\mathbf{v})-\mathbf{u}_i^{\rm{obs}} \right)^2}{\sigma_i^2} \, .\]
Arguments
velmod
: velocity model, either a 2D or 3D array.grd
: the struct holding the information about the grid, one ofGrid2D
,Grid3D
,Grid2Dsphere
,Grid3Dsphere
coordsrc
: the coordinates of the source(s) (x,y), a 2-column arraycoordrec
: the coordinates of the receiver(s) (x,y) for each single source, a vector of 2-column arraysttpicksobs
: a vector of vectors of the traveltimes at the receivers.stdobs
: a vector of vectors standard deviations representing the error on the measured traveltimes.extraparams
(optional): a struct containing some "extra" parameters, namelyparallelkind
: serial, Threads or Distributed run? (:serial, :sharedmem, :distribmem)refinearoundsrc
: whether to perform a refinement of the grid around the source locationgrdrefpars
: refined grid around the source parameters (downscalefactor
andnoderadius
)manualGCtrigger
: trigger garbage collector (GC) manually at selected points.
Returns
The value of the misfit functional (L2-norm), the same used to compute the gradient with adjoint methods.
Extra parameters
EikonalSolvers.ExtraParams
— Typestruct ExtraParams
Fields
refinearoundsrc::Bool
: refine grid around source?manualGCtrigger::Bool
: trigger GC manually at selected pointsparallelkind::Symbol
: Serial, Threads or Distributed run? Either :serial, :sharedmem or :distribmemradiussmoothgradsrc::Int64
: Radius for smoothing the gradient around the source. Zero means no smoothing.smoothgradkern::Int64
: Smooth the gradient with a kernel of size (in pixels). Zero means no smoothing.grdrefpars::GridRefinementPars
: Downscaling factor and node radius for refined grid creation
EikonalSolvers.GridRefinementPars
— Typestruct GridRefinementPars
Fields
downscalefactor::Int64
: Downscaling factor for refined grid around the sourcenoderadius::Int64
: Number of (coarse) grid nodes (radius) within which to refine the grid
Ray tracing
EikonalSolvers.tracerays
— Functiontracerays(
grd::EikonalSolvers.AbstractGridEik,
ttime::Vector{Array{Float64}},
coordsrc::Matrix{Float64},
coordrec::Vector{Matrix{Float64}};
steplen
) -> Vector{Vector{Matrix{Float64}}}
Ray tracing utility. Given a traveltime grid and source and receiver positions, trace the rays.
HMCsampler wrapper
EikonalSolvers.HMCtraveltimes
— ModuleHMCtraveltimes
A convenience module to facilitate the use of EikonalSolvers
within the framework of Hamiltonian Monte Carlo inversion by employing the package HMCsampler
.
Exports
EikonalSolvers.HMCtraveltimes.EikonalProbVel
— Typestruct EikonalProbVel
Fields
grd::Union{Grid2DCart, Grid3DCart}
dobs::Vector{Vector{Float64}}
stdobs::Vector{Vector{Float64}}
coordsrc::Matrix{Float64}
coordrec::Vector{Matrix{Float64}}
whichgrad::Symbol
logVel::Bool
extraparams::Union{Nothing, ExtraParams}
EikonalSolvers.HMCtraveltimes.EikonalProbSrcLoc
— Typestruct EikonalProbSrcLoc
Fields
grd::Union{Grid2DCart, Grid3DCart}
dobs::Vector{Vector{Float64}}
stdobs::Vector{Vector{Float64}}
coordrec::Vector{Matrix{Float64}}
velmod::Matrix{Float64}
whichgrad::Symbol
extraparams::Union{Nothing, ExtraParams}
Extensions
EikonalSolvers.savemodelvtk
— FunctionThis function requires the package WriteVTK to be loaded first in order to work.