Developer zone
All members including private ones
Calculate travel time from source to receiver on rectilinear grid
- pestoseis.ttimerays.traveltime_rays.__bilinear_interp(f, hgrid, pt)[source]
Bilinear interpolation.
- pestoseis.ttimerays.traveltime_rays.__findcelledge(xmin, ymin, dx, dy, nx, ny, pt, endptgrad, source=False)[source]
Find the corners defining the cell where ray will propagate next
- pestoseis.ttimerays.traveltime_rays.__globgrad(gridpar, ttime)[source]
Calculate interpolant functions for the gradient of the traveltime array.
- pestoseis.ttimerays.traveltime_rays.__gradatpt(fxgrad, fygrad, pt)[source]
Compute gradient at point pt.
- pestoseis.ttimerays.traveltime_rays.__ijinvelgrid(segment, gridpar)[source]
Get the indices of the velocity cell related to a given segment.
- pestoseis.ttimerays.traveltime_rays.__isonsrccelledge(srccell, curpt)[source]
Is the point on a cell edge?
- pestoseis.ttimerays.traveltime_rays.__nextptgrad(fxgrad, fygrad, steplen, pt)[source]
Calculate target point using negative gradient of traveltime increment
- pestoseis.ttimerays.traveltime_rays.__pointisonLINE(a, b, pointc)[source]
Check if point is on LINE
- pestoseis.ttimerays.traveltime_rays.__pointisonSEGMENT(seg, pt)[source]
Is point on a segment?
- pestoseis.ttimerays.traveltime_rays.__ptinbounds(gridpar, pt)[source]
Is the point within bounds?
- pestoseis.ttimerays.traveltime_rays.__seg_intersect(a1, a2, b1, b2)[source]
Determine the intersection of two segments
- pestoseis.ttimerays.traveltime_rays.__segintersRECT(rect, seg, rectangle=True)[source]
Find intersection of a segment and a polygon or rectangle if ‘rectangle=True’.
- pestoseis.ttimerays.traveltime_rays._trace_straight_ray(gridpar, srcpos, recpos)[source]
Trace a straight ray, from receiver to source.
- pestoseis.ttimerays.traveltime_rays._traceray(gridpar, recpos, coordsrc, ttime)[source]
Back-trace a single ray using negative gradient of traveltime direction
- Parameters:
gridpar (dict) – grid parameters dictionary (as defined by setupgrid())
recpos (ndarray) – position of the receiver
coordsrc (ndarray) – position of the source
ttime (ndarray) – traveltime array (2D)
- Returns:
the traced ray as an array of coordinates
- Return type:
(ndarray)
- pestoseis.ttimerays.traveltime_rays.buildtomomat(gridpar, rays, ttpick)[source]
Build forward matrix from rays for traveltime tomography.
- Parameters:
gridpar (dict) – grid parameters dictionary (as defined by setupgrid())
rays (ndarray of ndarrays) – seismic rays, as outputted by traceallrays()
ttpick (ndarray) – traveltime picks at the receivers. [These are needed only to provide the vector of traveltime picks flattened for performing tomography in the same order than the tomography matrix]
- Returns:
- the ‘tomography’ matrix and the vector of traveltime picks
(flattened for performing tomography)
- Return type:
(ndarray)
- pestoseis.ttimerays.traveltime_rays.lininv(G, cov_m, cov_d, mprior, dobs)[source]
Linear inversion under Gaussian assumptions.
- Parameters:
G – forward model matrix (d=Gm)
cov_m,cov_d – covariances for model parameters and observed data, respectively
mprior – prior model
dobs – obsrved data
- Returns:
the posterior mean model and the posterior covariance matrix
- pestoseis.ttimerays.traveltime_rays.plotgrid(gridpar)[source]
Plot staggered grid edges: traveltime at nodes and velocity in cells
- Parameters:
gridpar – grid parameters dictionary (as defined by setupgrid())
- pestoseis.ttimerays.traveltime_rays.plotrays(src, rec, rays)[source]
Plot rays as polylines.
- Parameters:
src (ndarray) – coordinates of the sources
rec (ndarray) – coordinates of the receivers
rays (narray of arrays) – seismic rays, as outputted by traceallrays()
- pestoseis.ttimerays.traveltime_rays.plotttimemod(gridpar, ttime, units='')[source]
Plot traveltime array as an image.
- Parameters:
gridpar (dict) – grid parameters dictionary (as defined by setupgrid())
ttime (ndarray) – traveltime array
units (str) – optional string to specify the units of measurement for traveltime
- pestoseis.ttimerays.traveltime_rays.plotvelmod(gridpar, velmod, vmin=None, vmax=None, units='', cmap=<matplotlib.colors.LinearSegmentedColormap object>)[source]
Plot velocity model as an image.
- Parameters:
gridpar (dict) – grid parameters dictionary (as defined by setupgrid())
velmod (ndarray) – velocity model
vmin (float,float) – optional values to clip the colorbar min and max values
vmax (float,float) – optional values to clip the colorbar min and max values
units (str) – optional string to specify the units of measurement for velocity
cmap (colormap) – optional parameter to specify a colormap. Defaults to “rainbow”.
- pestoseis.ttimerays.traveltime_rays.rollmod(mod, nx, ny)[source]
Reshape a flattened (a vector) model to 2D (an array).
- Parameters:
mod (ndarray) – input flattened model
nx (float,float) – sizes of the input 2D model
ny (float,float) – sizes of the input 2D model
- Returns:
the reshaped model as a 2D array
- Return type:
(ndarray)
- pestoseis.ttimerays.traveltime_rays.setupgrid(nx, ny, dh, xinit, yinit)[source]
Setup grid parameters.
- Parameters:
nx,ny – grid dimensions in x and y
dx,dy – grid spacing (cell size) in x and y
xinit,yinit – x and y axes origin
- pestoseis.ttimerays.traveltime_rays.traceall_straight_rays(gridpar, srccoo, reccoo)[source]
Trace multiple straight rays.
- Parameters:
gridpar (dict) – grid parameters dictionary (as defined by setupgrid())
srccoo (ndarray) – position of the source, a 2D array with two columns, representing x and y
reccoo (ndarray) – position of the receiver, a 2D array with two columns, representing x and y
- Returns:
the coordinates of the ray paths
- Return type:
(ndarray)
- pestoseis.ttimerays.traveltime_rays.traceallrays(gridpar, srccoo, reccoo, grdsttime)[source]
Trace multiple rays, for all sources and receivers.
- Parameters:
gridpar (dict) – grid parameters dictionary (as defined by setupgrid())
srccoo (ndarray) – position of the source, a 2D array with two columns, representing x and y
reccoo (ndarray) – position of the receiver, a 2D array with two columns, representing x and y
grdsttime (list of ndarrays) – array of traveltime arrays [list of 2D arrays, one per source]
- Returns:
the traced rays as (x,y) coordinates of the points defining the segments
- Return type:
(ndarray of ndarrays)
- pestoseis.ttimerays.traveltime_rays.traveltime(velmod, gridpar, srcs, recs)[source]
Calculate traveltime for all sources and receivers.
- Parameters:
velmod – input velocity model
gridpar – grid parameters dictionary (as defined by setupgrid())
srcs – coordinates of sources
recs – coordinates of receivers
- Returns:
traveltimes at the receivers and traveltime arrays
- Return type:
ndarray,ndarray
- pestoseis.ttimerays.traveltime_rays.unrollmod(mod)[source]
Flatten a 2D model to a vector, using column-major Fortran order.
- Parameters:
mod (ndarray) – input 2D model (probably velocity)
- Returns:
the flattened model as a vector (1D)
- Return type:
(ndarray)
- class pestoseis.ttimerays.fmm2D.Grid2D(nx, ny, h, xinit, yinit)[source]
Class containing the info of a 2D grid for traveltime calculations.
- Parameters:
nx (int) – number of points/cells in the x direction
ny (int) – number of points/cells in the y direction
h (float) – grid spacing (same for x and y)
xinit (float) – grid origin for the x direction
yinit (float) – grid origin for the y direction
- pestoseis.ttimerays.fmm2D.__bilinear_interp(f, hgrid, xinit, yinit, xreq, yreq)[source]
Bilinear interpolation (2D).
- pestoseis.ttimerays.fmm2D.__fmm_findclosestnode(x, y, xinit, yinit, h)[source]
Find closest grid node to given coordinates.
- pestoseis.ttimerays.fmm2D._calcttpt(ttime, ttlocmin, inittt, slowness, grd, cooa, coob, coovin, coovadj, i, j)[source]
Calculate the traveltime for a given point in the grid.
- pestoseis.ttimerays.fmm2D._ttFMM(vel, src, grd)[source]
Fast marching method to compute traveltimes in 2D. Uses a staggered grid, time array is bigger than velocity array, following Podvin & Lecompte scheme.
- Args
vel: input velocity model src: source position grd: grid parameters
- Returns:
array of traveltimes
- Return type:
ttime
- pestoseis.ttimerays.fmm2D.ttimefmm(vel, grdh, xinit, yinit, coordsrc, coordrec, ttarrout=False)[source]
Traveltimes calculation given a velocity model, position of sources and receivers.
- Parameters:
vel (ndarray) – input velocity model
grdh (float) – grid spacing
xinit (float) – x axis origin coordinate
yinit (float) – y axis origin coordinate
coordsrc (ndarray) – coordinates of the sources
coordred (ndarray) – coordinates of the receivers
ttarrout (bool) – optional, returns the full array of traveltimes
- Returns:
- the traveltimes at the
receivers and, optionally, the traveltime array(s)
- Return type:
ttpicks (ndarray), ttarr (ndarray,optional)
Binary heap trees (min/max).
- class pestoseis.ttimerays.binheap.BinHeapMax(values, Nmax, handles)[source]
Max heap binary tree.
- class pestoseis.ttimerays.binheap.BinHeapMin(values, Nmax, handles)[source]
Min heap binary tree.