Velocity models#

Module to deal with velocity models.

class covseisnet.velocity.VelocityModel(velocity, **kwargs)[source]#

Bases: Regular3DGrid

Base class to create a velocity model.

Parameters:
  • extent (tuple) -- The geographical extent of the grid in the form (lon_min, lon_max, lat_min, lat_max, depth_min, depth_max). The longitudes and latitudes are in decimal degrees, and the depths in kilometers.

  • shape (tuple) -- The number of points in the grid in the form (n_lon, n_lat, n_depth).

  • fill_value (float or str, optional) -- The fill value of the grid. By default, it is set to np.nan.

resample(shape: tuple[int, int, int] | None = None, resolution: tuple[float, float, float] | None = None)[source]#

Resample the velocity model to the target shape or resolution.

Note that one, and only one, of shape or resolution must be prescribed.

Parameters:
  • shape (tuple, optional) -- The new shape of the grid in the form (n_lon, n_lat, n_depth). Defaults to None.

  • resolution (tuple, optional) -- The new resolution of the grid in the form (res_lon, res_lat, res_dep). Defaults to None.

Returns:

velocity_model (VelocityModel) -- The velocity model with the new resolution.

interpolate(lon, lat, depth, interpolation_method='linear', extrapolation_method='nearest')[source]#

Interpolate velocity model onto new grid.

Parameters:
  • lon (np.ndarray) -- The longitudes of the new grid in decimal degrees.

  • lat (np.ndarray) -- The latitudes of the new grid in decimal degrees.

  • depth (np.ndarray) -- The depths of the new grid in kilometers.

  • interpolation_method (str, optional) -- The interpolation method used by scipy.interpolate.RegularGridInterpolator. Default is 'linear'.

is_constant()[source]#

Check if the velocity model is constant.

property constant_velocity#

Return the constant velocity of the model.

covseisnet.velocity.model_from_grid(longitude, latitude, depth, velocity)[source]#

Create a velocity model from a grid of coordinates and velocities.

Parameters:
  • longitude (np.ndarray) -- The longitudes of the grid in decimal degrees.

  • latitude (np.ndarray) -- The latitudes of the grid in decimal degrees.

  • depth (np.ndarray) -- The depths of the grid in kilometers.

  • velocity (np.ndarray) -- The 3d velocity of the model in kilometers per second.

Returns:

velocity_model_3d (VelocityModel3D) -- Instance of VelocityModel3D built with the grid of coordinates and velocities.