# examples.seismic package¶

## examples.seismic.benchmark module¶

examples.seismic.benchmark.bench(problem, **kwargs)[source]

Complete benchmark with multiple simulation and performance parameters.

examples.seismic.benchmark.get_ob_bench(problem, resultsdir, parameters)[source]

Return a special opescibench.Benchmark to manage performance runs.

examples.seismic.benchmark.get_ob_exec(func)[source]

Return a special opescibench.Executor to execute performance runs.

examples.seismic.benchmark.get_ob_plotter()[source]
examples.seismic.benchmark.option_performance(f)[source]

Defines options for all aspects of performance tuning

examples.seismic.benchmark.option_simulation(f)[source]
examples.seismic.benchmark.plot(problem, **kwargs)[source]

Plotting mode to generate plots for performance analysis.

examples.seismic.benchmark.run(problem, **kwargs)[source]

A single run with a specific set of performance parameters.

examples.seismic.benchmark.test(problem, **kwargs)[source]

Test numerical correctness with different parameters.

## examples.seismic.model module¶

class examples.seismic.model.Model(origin, spacing, shape, space_order, vp, nbpml=20, dtype=<class 'numpy.float32'>, epsilon=None, delta=None, theta=None, phi=None, **kwargs)[source]

Bases: examples.seismic.model.Pysical_Model

The physical model used in seismic inversion processes.

Parameters: origin – Origin of the model in m as a tuple in (x,y,z) order spacing – Grid size in m as a Tuple in (x,y,z) order shape – Number of grid points size in (x,y,z) order space_order – Order of the spatial stencil discretisation vp – Velocity in km/s nbpml – The number of PML layers for boundary damping epsilon – Thomsen epsilon parameter (0

The Model provides two symbolic data objects for the creation of seismic wave propagation operators:

Parameters: m – The square slowness of the wave damp – The damping field for absorbing boundarycondition
critical_dt

Critical computational time step value from the CFL condition.

vp

numpy.ndarray holding the model velocity in km/s. .. note:: Updating the velocity field also updates the square slowness self.m. However, only self.m should be used in seismic operators, since it is of type Function.

class examples.seismic.model.ModelElastic(origin, spacing, shape, space_order, vp, vs, rho, nbpml=20, dtype=<class 'numpy.float32'>)[source]

Bases: examples.seismic.model.Pysical_Model

The physical model used in seismic inversion processes. :param origin: Origin of the model in m as a tuple in (x,y,z) order :param spacing: Grid size in m as a Tuple in (x,y,z) order :param shape: Number of grid points size in (x,y,z) order :param space_order: Order of the spatial stencil discretisation :param vp: P-wave velocity in km/s :param vs: S-wave velocity in km/s :param nbpml: The number of PML layers for boundary damping :param rho: Density in kg/cm^3 (rho=1 for water) The ModelElastic provides a symbolic data objects for the creation of seismic wave propagation operators: :param damp: The damping field for absorbing boundarycondition

critical_dt

Critical computational time step value from the CFL condition.

examples.seismic.model.demo_model(preset, **kwargs)[source]

Utility function to create preset Model objects for demonstration and testing purposes. The particular presets are

* constant-isotropic : Constant velocity (1.5km/sec) isotropic model
* constant-tti : Constant anisotropic model. Velocity is 1.5 km/sec and

Thomsen parameters are epsilon=.3, delta=.2, theta = .7rad and phi=.35rad for 3D. 2d/3d is defined from the input shape
• ‘layers-isotropic’: Simple two-layer model with velocities 1.5 km/s
and 2.5 km/s in the top and bottom layer respectively. 2d/3d is defined from the input shape
• ‘layers-tti’: Simple two-layer TTI model with velocities 1.5 km/s
and 2.5 km/s in the top and bottom layer respectively. Thomsen parameters in the top layer are 0 and in the lower layer are epsilon=.3, delta=.2, theta = .5rad and phi=.1 rad for 3D. 2d/3d is defined from the input shape
• ‘circle-isotropic’: Simple camembert model with velocities 1.5 km/s
and 2.5 km/s in a circle at the center. 2D only.
• ‘marmousi2d-isotropic’: Loads the 2D Marmousi data set from the given
filepath. Requires the opesci/data repository to be available on your machine.
• ‘marmousi2d-tti’: Loads the 2D Marmousi data set from the given
filepath. Requires the opesci/data repository to be available on your machine.
• ‘marmousi3d-tti’: Loads the 2D Marmousi data set from the given
filepath. Requires the opesci/data repository to be available on your machine.

## examples.seismic.plotting module¶

examples.seismic.plotting.plot_image(data, vmin=None, vmax=None, colorbar=True, cmap='gray')[source]

Plot image data, such as RTM images or FWI gradients.

Parameters: data – Image data to plot cmap – Choice of colormap, default is gray scale for images as a

seismic convention

examples.seismic.plotting.plot_perturbation(model, model1, colorbar=True)[source]

Plot a two-dimensional velocity difference from two seismic Model objects.

Parameters: model – Model object of first velocity model. model1 – Model object of the second velocity model. source – Coordinates of the source point. receiver – Coordinates of the receiver points.
examples.seismic.plotting.plot_shotrecord(rec, model, t0, tn, colorbar=True)[source]

Plot a shot record (receiver values over time).

Parameters: rec – Receiver data with shape (time, points) model – Model object that holds the velocity model. t0 – Start of time dimension to plot tn – End of time dimension to plot
examples.seismic.plotting.plot_velocity(model, source=None, receiver=None, colorbar=True)[source]

Plot a two-dimensional velocity field from a seismic Model object. Optionally also includes point markers for sources and receivers.

Parameters: model – Model object that holds the velocity model. source – Coordinates of the source point. receiver – Coordinates of the receiver points.

## examples.seismic.source module¶

class examples.seismic.source.PointSource(*args, **kwargs)[source]

Symbolic data object for a set of sparse point sources

Parameters: name – Name of the symbol representing this source. grid – Grid object defining the computational domain. time_range – TimeAxis TimeAxis(start, step, num) object. npoint – (Optional) number of sparse points represented by this source. data – (Optional) data values to initialise point data. coordinates – (Optional) point coordinates for this source. space_order – (Optional) space discretization order. time_order – (Optional) time discretization order (defaults to 2). dtype – (Optional) data type of the buffered data. dimension – (Optional) class:Dimension object for representing the number of points in this source.
default_assumptions = {}
resample(dt=None, num=None, rtol=1e-05, order=3)[source]
time_range
time_values
examples.seismic.source.Receiver
examples.seismic.source.Shot
class examples.seismic.source.WaveletSource(*args, **kwargs)[source]

Abstract base class for symbolic objects that encapsulate a set of sources with a pre-defined source signal wavelet.

Parameters: name – Name for the resulting symbol grid – Grid object defining the computational domain. f0 – Peak frequency for Ricker wavelet in kHz time_values – Discretized values of time in ms
default_assumptions = {}
show(idx=0, wavelet=None)[source]

Plot the wavelet of the specified source.

Parameters: idx – Index of the source point for which to plot wavelet wavelet – Prescribed wavelet instead of one from this symbol time – Prescribed time instead of time from this symbol
wavelet(f0, t)[source]

Defines a wavelet with a peak frequency f0 at time t.

Parameters: f0 – Peak frequency in kHz t – Discretized values of time in ms
class examples.seismic.source.RickerSource(*args, **kwargs)[source]

Symbolic object that encapsulate a set of sources with a pre-defined Ricker wavelet:

http://subsurfwiki.org/wiki/Ricker_wavelet

Parameters: name – Name for the resulting symbol grid – Grid object defining the computational domain. f0 – Peak frequency for Ricker wavelet in kHz time – Discretized values of time in ms
default_assumptions = {}
wavelet(f0, t)[source]

Defines a Ricker wavelet with a peak frequency f0 at time t.

Parameters: f0 – Peak frequency in kHz t – Discretized values of time in ms
class examples.seismic.source.GaborSource(*args, **kwargs)[source]

Symbolic object that encapsulate a set of sources with a pre-defined Gabor wavelet:

https://en.wikipedia.org/wiki/Gabor_wavelet

Parameters: name – Name for the resulting symbol grid – Grid object defining the computational domain. f0 – Peak frequency for Ricker wavelet in kHz time – Discretized values of time in ms
default_assumptions = {}
wavelet(f0, t)[source]

Defines a Gabor wavelet with a peak frequency f0 at time t.

Parameters: f0 – Peak frequency in kHz t – Discretized values of time in ms
class examples.seismic.source.TimeAxis(start=None, step=None, num=None, stop=None)[source]

Bases: object

Data object to store the time axis. Exactly three of the four key arguments

must be prescribed. Because of remainder values it is not possible to create a time axis that exactly adhears to the inputs therefore start, stop, step and num values should be taken from the TimeAxis object rather than relying upon the input values.

The four possible cases are: start is None: start = step*(1 - num) + stop step is None: step = (stop - start)/(num - 1) num is None: num = ceil((stop - start + step)/step);

because of remainder stop = step*(num - 1) + start

stop is None: stop = step*(num - 1) + start

:param start:(Optional) Start of time axis. :param step: (Optional) Time interval. :param: num: (Optional) Number of values (Note: this is the number of intervals + 1).

stop value is reset to correct for remainder.
Parameters: stop – (Optional) End time.
time_values

## examples.seismic.utils module¶

examples.seismic.utils.smooth(dest, f)[source]

Run an n-point moving average kernel over f and store the result into dest. The average is computed along the innermost f dimension.

examples.seismic.utils.scipy_smooth(img, sigma=5)[source]

Smooth the input with scipy ndimage utility