seispy.core.velocity

This module facilitates access to velocity model data.

Todo

Make a ScalarField class to abstract behaviour in this class.

class seispy.core.velocity.VelocityModel(inf=None, fmt=None, topo=None, **kwargs)[source]

A callable class providing a queryable container for seismic velocities in a 3D volume.

Parameters:
  • inf (str) – path to input file containing phase velocity data
  • fmt (str) – format of input file
__call__(phase, lat, lon, depth)[source]

Return phase-velocity at given coordinates. A NULL value (-1) is returned for points above the surface.

Parameters:
  • phase (str) – phase
  • lat (float) – latitude
  • lon (float) – longitude
  • depth (float) – depth
Returns:

phase-velocity at (lat, lon, depth)

Return type:

float

__init__(inf=None, fmt=None, topo=None, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__weakref__

list of weak references to the object (if defined)

from_DataFrame(df)[source]

Initialize VelocityModel from a pandas.DataFrame. Input DataFrame must have lat, lon, depth, Vp, and Vs, fields.

Parameters:df (pandas.DataFrame) – DataFrame with velocity data
slice(phase, lat0, lon0, azimuth, length, dmin, dmax, nx, nd)[source]

Return a vertical slice from velocity model with section-parallel offset and depth coordinates.

Parameters:
  • phase (str) – phase velocity to retrieve
  • lat0 (float) – latitude of center point of section trace {Units: degrees, Range: [-90, 90] }
  • lon0 (float) – longitude of center point of section trace {Units: degrees, Range: [-180, 180]}
  • azimuth (float) – azimuth of section trace {Units: degrees, Range: (-inf, inf)}
  • length (float) – length of section trace {Units: degrees}
  • dmin (float) – minimum depth of section {Units: km }
  • dmax (float) – maximum depth of section {Units: km }
  • nx (int) – number of nodes in section-parallel direction
  • nd (int) – number of nodes in depth
Returns:

phase velocity values and coordinates of vertical section

Return type:

(numpy.ndarray, numpy.ndarray, numpy.ndarray)

import matplotlib.pyplot as plt
topo = seispy.topography.Topography("data/anza.xyz")
vm = seispy.velocity.VelocityModel("data/vmodel.dat",
                                   "FANG",
                                   topo=topo)
X, Y, V = vm.slice("P", 33.5, -116.0, 302, 150/111, -5, 25, 100, 100)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
im = ax.pcolormesh(X, Y, V, cmap=plt.get_cmap("hsv"))
ax.set_xlabel("Section-parallel offset [degrees]")
ax.set_ylabel("Depth [km]")
ax.invert_yaxis()
cbar = ax.get_figure().colorbar(im, ax=ax)
cbar.set_label("Vp [km/s]")
plt.show()
api/core/VelocityModel.png