pySW4.prep.material_model module

Python module to help specify the material properties and the grid parameters of the computational domain.

author:Shahar Shani-Kadmiel (s.shanikadmiel@tudelft.nl)
copyright:Shahar Shani-Kadmiel
license:This code is distributed under the terms of the GNU Lesser General Public License, Version 3 (https://www.gnu.org/copyleft/lesser.html)
class V_model(filename, calculate_missing_data=True)[source]

Bases: object

Class to handle Velocity models.

Uses read_Vfile() function to read Vfile format files.

Parameters:

filename : str

Path (relative or absolute) to the Vfile.

calculate_missing_data : bool

If True (default), any missing data is calculated based on Brocher (2008).

_calculate_missing_data()[source]

Looks for nan s in the data and trys to calculate and fill based on Brocher (2008).

get_depth(values, property='vp')[source]

This function linearly interpolats the data in the velocity model and then evaluates the depth corresponding to the value of the requested property.

Parameters:

values : sequence or int or float

The property for which to evaluate the depth of.

property : {‘vp’ (default), ‘vs’, ‘rho, ‘qp’, ‘qs’}

Property corresponding to value.

Returns:

sequence or float

Depth of the requested property.

get_properties(depth, k=0)[source]

This function first fits the data in the velocity model with an interpolation function using _sample_func() and then evaluates the properties at the requested depths. Interpolation can either be based on piecewise step functions that uses the nearest value or on a linear interpolation.

Parameters:

depth : sequence or int or float

Depths at which to evaluate the properties.

k : int

Interpolation method:

  • 0 - nearest value (default)
  • 1 - linear interpolation between data points
Returns:

array-like

vp, vs, rho, qp, qs

write2file(filename=None)[source]

Save Vfile for reading later into Vfile class.

_sample_func(x, y)[source]

Helper function to interpolate between discrete x, y points.

Used by the following methods - get_properties() and - get_depth()

get_qp(qs)[source]

Calculate Pressure-wave Quality Factor based on Brocher (2008).

Parameters:

qs : float or sequence

Shear-wave Quality Factor.

Returns:

float or sequence

Pressure-wave Quality Factor.

get_qs(vs)[source]

Calculate Shear-wave Quality Factor based on Brocher (2008).

Note

If Shear-wave velocity is less-than 0.3 km/s, Shear-wave Quality Factor is set to 13.

Parameters:

vs : float or sequence

Shear-wave velocity in km/s.

Returns:

float or sequence

Shear-wave Quality Factor.

get_rho(vp)[source]

Calculate \(\rho\) (density) based on Brocher (2008).

Parameters:

vp : float or sequence

Pressure-wave velocity in km/s.

Returns:

float or sequence

\(\rho\) (density) in gr/cm^3.

get_vmin(h, fmax, ppw=8)[source]

Calculate the minimum allowed velocity that meets the requirement that the shortest wavelength (\(\lambda=V_{min}/f_{max}\)) be sampled by a minimum points-per-wavelength (ppw).

Parameters:

h : float

Grid spacing of the computational doamin in meters.

fmax : float

Maximum frequency in the source-time function frequency content, Hz.

ppw :

Minimum points-per-wavelenght required for the computation. Set to 8 by default.

Returns:

float

The suggested grid spacing in meters.

get_vs(vp)[source]

Calculate Shear-wave velocity based on Brocher (2008).

Note

Shear-wave velocity is forced to be greater than \(V_P / \sqrt{2}\).

Parameters:

vp : float or sequence

Pressure-wave velocity in km/s.

Returns:

float or sequence

Shear-wave velocity in km/s.

grid_spacing(vmin, fmax, ppw=8)[source]

Calculate the h parameter (grid_spacing) based on the requirement that the shortest wavelength (\(\lambda=V_{min}/f_{max}\)) be sampled by a minimum points-per-wavelength (ppw).

Parameters:

vmin : float

Minimum seismic velocity in the computational doamin in m/s.

fmax : float

Maximum frequency in the source-time function frequency content, Hz.

ppw :

Minimum points-per-wavelenght required for the computation. Set to 8 by default.

Returns:

float

The suggested grid spacing in meters.

read_Vfile(filename)[source]

Read a Velocity Model file.

Vfile format has a flexible header (line starting with a ‘#’ character) and a comma separated values data section where each line has Depth, Vp, Vs, rho, Qp, Qs, Grp./Form./Mbr. values and ends with a line containing one word ‘end’. The values in each line are “true” to that specific depth-point.

Example Vfile:

# Just a simple made up velocity model
# Shani-Kadmiel (2016)
# Depth| Vp    | Vs    | rho   | Qp    | Qs    | Grp/Form./Mbr.
#   m  | m/s   | m/s   | kg/m^3|
      0,   1000,    500,   1000,     20,     10, Upper made up
   2000,   1500,    750,   1200,     30,     15, Middle made up
   5000,   2000,   1000,   1600,     70,     35, Lower made up
end
Parameters:

filename : str

Path (relative or absolute) to the Vfile.

Returns:

array-like

A list of header, depth, vp, vs, rho, qp, qs, gmf values.

See also

V_model