tremelique.Acoustic#

class tremelique.Acoustic(velocity, density, spacing, cachefile=None, dt=None, padding=50, taper=0.005, verbose=True)[source]#

Simulate the propagation of acoustic waves in 2D.

Solves the pressure wave equation using the equivalent staggered grid finite-difference method of [DiBartolo2012]. Uses a damping scheme to suppress reflections from the left, right, and bottom boundaries. The top boundary has a free-surface boundary condition.

Methods

add_point_source(position, wavelet)

Add a point source of energy to this simulation.

animate([every, cutoff, ax, cmap, embed, ...])

Create a 2D animation from the current state of the simulation.

explore([every])

Interactive visualization of simulation results.

from_cache(fname[, verbose])

Create a simulation object from a pre-existing HDF5 file.

maxdt()

Calculate the maximum allowed time interval that is safe to use.

run(iterations)

Run this simulation given the number of iterations.

snapshot(frame[, embed, raw, ax])

Create an image of the 2D wavefield simulation at given frame.

Methods#

Acoustic.add_point_source(position, wavelet)[source]#

Add a point source of energy to this simulation.

Parameters:
* positiontuple

The (x, z) coordinates of the source

* sourcesource function

(see Ricker for an example source)

Acoustic.animate(every=1, cutoff=None, ax=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, embed=False, fps=10, dpi=70, **kwargs)[source]#

Create a 2D animation from the current state of the simulation.

Acoustic.explore(every=1, **kwargs)#

Interactive visualization of simulation results.

Allows to move back and forth on simulation frames using the IPython widgets feature.

Warning

Only works when running in an IPython notebook.

static Acoustic.from_cache(fname, verbose=True)[source]#

Create a simulation object from a pre-existing HDF5 file.

Parameters:
* fname: str

HDF5 file path containing a previous simulation stored

* verbose: bool

Progress status shown or not

Returns:
* simulationtremelique.Acoustic

The simulation class instance.

Acoustic.maxdt()[source]#

Calculate the maximum allowed time interval that is safe to use.

Acoustic.run(iterations)#

Run this simulation given the number of iterations.

Parameters:
* iterations: int

Number of time step iterations to run.

Acoustic.snapshot(frame, embed=False, raw=False, ax=None, **kwargs)#

Create an image of the 2D wavefield simulation at given frame.

The image can be returned as a raw PNG or embedded into an IPython.display.Image.

Parameters:
* frameint

The time step iteration number.

* embedbool

True to plot it inline.

* rawbool

True for raw byte image.

* axNone or matplotlib Axes

If not None, will assume this is a matplotlib Axes and make the plot on it.

Returns:
* imagebytes-array or IPython.display.Image or None

Raw byte image if raw=True PNG picture if embed=True or None.