PyFWI package

acquisition

PyFWI.acquisition.AcqParameters(ns, rec_dis, offsetx, depth, dh, sdo, acq_type)

A function to define the acquisition based on user’s demand

Parameters

INPA (dictionary) –

A dictionnary containing required parameters for iversion, at least:
  • ns: Number of sources

  • rec_dis: Distance between receivers

  • offsetx: Length of acquisition in x-direction

  • depth: Depth of acquisition

  • dh: spatial sampling rate

  • sdo: Spatial differentiation order

  • acq_type: Type of acquisition (0: crosswell, 1: surface, 2: both)

Returns

  • src_loc (float32) – Location of sources

  • rec-loc (float32) – Location of receivers

class PyFWI.acquisition.Source(src_loc, dh, dt)

Bases: object

A class for defining different types of sources.

Parameters
  • src_loc (float32) – location of sources.

  • dh (float) – Spatial sampling rate.

  • dt (float) – Temporal sampling rate

Ricker(fdom)

Amethod to generate Ricker wavelet.

Parameters

fdom (float32) – Dominant frequency of wavelet

delta()

A method to generate spike.

Parameters

fdom (float32) – Dominant frequency of wavelet

PyFWI.acquisition.SurfaceSeismic(ns, rec_dis, offsetx, offsetz, dh, sdo)

A function to design a surface seismic acquisition

Parameters
  • ns (int) – Number of sources

  • rec_dis (float32) – Distance between receivers

  • offsetx (flloat32) – Length of survey in x-direction

  • offsetz (float32) – Depth of survey

  • dh (float32) – Spatial sampling rate

  • sdo ({2, 4, 8}) – Spatial order of finite difference method

Returns

  • src_loc (float32) – Location of sources

  • rec_loc (float32) – Location of receivers

PyFWI.acquisition.acquisition_plan(ns, nr, src_loc, rec_loc, acq_type, n_well_rec, dh)

acquisition_plan generates the matrix of acquisition plan

[extended_summary]

Parameters
  • ns ([type]) – [description]

  • nr ([type]) – [description]

  • src_loc ([type]) – [description]

  • rec_loc ([type]) – [description]

  • acq_type ([type]) – [description]

  • n_well_rec ([type]) – [description]

  • dh ([type]) – [description]

Returns

[description]

Return type

[type]

PyFWI.acquisition.crosswell(ns, rec_dis, offsetx, offsetz, dh, sdo)

A function to design a crosswell acquisition

Parameters
  • ns (int) – Number of sources

  • rec_dis (float32) – Distance between receivers

  • offsetx (flloat32) – Length of survey in x-direction

  • offsetz (float32) – Depth of survey

  • dh (float32) – Sampling rate

  • sdo ({2, 4, 8}) – Spatial order of finite difference method

Returns

  • src_loc (float32) – Location of sources

  • rec_loc (float32) – Location of receivers

PyFWI.acquisition.discretized_acquisition_plan(data_guide, dh, npml=0)

discretized_acquisition_plan discretizes the matrix of acquisition plan

[extended_summary]

Parameters
  • data_guide ([type]) – [description]

  • dh ([type]) – [description]

  • npml (int, optional) – [description]. Defaults to 0.

Returns

[description]

Return type

[type]

PyFWI.acquisition.prepare_residual(res, s)
PyFWI.acquisition.seismic_section(seismo, components=0)

fwi

class PyFWI.fwi.FWI(d_obs, inpa, src, rec_loc, model_size, n_well_rec, chpr, components, param_functions=None)

Bases: PyFWI.wave_propagation.wave_propagator

FWI implement full-waveform inversion (FWI) This class implement the FWI using the class ‘wave_propagator’ in ‘PyFWI.wave_propagation’.

Parameters
  • d_obs (dict) – Observed data

  • inpa (dict) – Dictionary containg required parameters

  • src (class) – Source

  • rec_loc (ndarray) – Location of the receivers

  • model_size (ndarray) – Size of the model

  • n_well_rec ([type]) – Number of receivers in the well in INPA[‘acq_type’] !=1

  • chpr (int) – Percentage of specify how much wavefield should be saved.

  • components ([type]) – Components of the operation

  • param_functions ([type], optional) – A list containg four function in case if the inversion is not happenning in DV parameterization. Defaults to None.

fprime(m0, freq)
fprime_single(m0, m_1, m1, freq)
lbfgs(m0, ITER, freqs, n_params=1, k0=0, k_end=1)
run(m0, method, iter, freqs, n_params, k_0, k_end)

run implement the FWI

Parameters
  • m0 (dict) – The initial model

  • method (int, str) – The optimization method

  • iter (ndarray) – An array of iteration for each frequency

  • freqs (float) – Frequencies for multi-scale inversion.

  • n_params (int) – Number of parameter to invert for in each time

  • k_0 (int) – The first parameter of interest

  • k_end (int) – The last parameter of interest

Returns

  • m_est (dict) – The estimated model

  • rms (ndarray) – The rms error

fwi_tools

class PyFWI.fwi_tools.CPML(dh, dt, N, nd=2.0, Rc=0.001, nu0=2.0, nnu=2.0, alpha0=62.83185307179586, nalpha=1.0)

Bases: object

pml_prepare(V)
psi_reset(TNz, TNx)
class PyFWI.fwi_tools.CostFunction(cost_function_type='l2')

Bases: object

This class provide different cost functions.

exponential_cost(dest, dobs)

based on https://stats.stackexchange.com/questions/154879/a-list-of-cost-functions-used-in-neural-networks-alongside-applications

l1(dest, dobs)
l2(dest0, dobs0)
l2_envelope(dest, dobs)

based on Wu et al., 2014, Seismic envelope inversion and modulation signal model Geiophysics

l2_hilbert(dest, dobs)
l2_intensity(dest, dobs)
static list2dict(x)
plot_amp_spectrum(case_a, case_b, dt, case_a_label=None, case_b_label=None)

to compare two amplitude spectrum

plot_trace(case_a, case_b, case_a_label=None, case_b_label=None)

to compare two trace

PyFWI.fwi_tools.adj_cost_preparation(res, fn, freq=False, order=None, axis=None, params_oh=None)
PyFWI.fwi_tools.adj_grad_lmd_to_vd(gvp, gvs, grho, lam, mu, rho)

grad_lmr_to_vd [summary]

[extended_summary]

Parameters
  • glam ([type]) – [description]

  • gmu ([type]) – [description]

  • grho ([type]) – [description]

  • lam ([type]) – [description]

  • mu ([type]) – [description]

  • rho ([type]) – [description]

Refrences:
  1. Hu et al, 2021, Direct updating of rock-physics properties using elastice full-waveform inversion

  2. Zhou and Lumely, 2021, Central-difference time-lapse 4D seismic full-waveform inversion

PyFWI.fwi_tools.adj_lowpass(x, highcut, fn, order, axis=1)
PyFWI.fwi_tools.cost_function(d_est, d_obs)
PyFWI.fwi_tools.cost_preparation(dpre, dobs, fn, freq=None, order=None, axis=None, params_oh=None)

cost_preparation prepare the data for calculating the cost function

This function prepare the data for calculating the cost function. This preparation is based on multi-scale inversion strategy (Bunks et al., 1995).

Parameters
  • dpre ([type]) – Predicted data

  • dobs ([type]) – Observed data

  • fn (float) – Nyquist frequency

  • freq (float, optional) – Desire frequency for filtering. Defaults to None.

  • order (int, optional) – Order of the filter. Defaults to None.

  • axis (int, optional) – Axis of the filter. Defaults to None.

  • params_oh ([type], optional) – Parameter to prepare the data for different offsets. Defaults to None.

Returns

[description]

Return type

[type]

PyFWI.fwi_tools.cost_seismic(d_pre0, d_obs0, fun, fn=None, freq=None, order=None, axis=None, sourc_weight=False, ns=None, nr=None, params_oh=None)

cost_seismic calculates the cost between estimated and observed data.

This function calculates the cost between estimated and observed data by applying desired filters and returns the cost and the adjoint of the residual.

Parameters
  • d_pre0 (dict) – Estimated data

  • d_obs0 (dict) – Observed data

  • fun (function) – The function to calculate the cost. This could be “CF = tools.CostFunction(‘l2’)”

  • fn (float, optional) – Nyquist frequency. Defaults to None.

  • freq (float, optional) – Desired frequency to implement the lowpass filter. Defaults to None.

  • order ([type], optional) – [description]. Defaults to None.

  • axis ([type], optional) – [description]. Defaults to None.

  • sourc_weight (bool, optional) – [description]. Defaults to False.

  • ns (int, optional) – Number of the sources. Defaults to None.

  • nr (int, optional) – Number of the receivers. Defaults to None.

  • params_oh ([type], optional) – [description]. Defaults to None.

Returns

The cost adj_src: Adjoint source to propagate through the model in adjoint wave equation

Return type

rms (float)

PyFWI.fwi_tools.dict_diff(dict1, dict2, positivity=False)

dict_diff subtracts the contents of two dictionaries

This function is used to subtract the parameters of a dictionary with the same parameter in another dictionary.

Parameters
  • dict1 (dict) – The first dictionary

  • dict2 (dict) – The second dictionary

  • positivity (boolean, optional) – A boolean variable to specify if the used wants

  • False. (to filter out the negative differences. Defaults to) –

Returns

A dictionary containing the common parameters of `dict1` and `dict2`, but their difference.

Return type

dic

PyFWI.fwi_tools.dict_summation(dict1, dict2, division=1.0)

dict_summation add the contents of two dictionaries

This function is used to add the parameters of a dictionary with the same parameter in another dictionary.

Parameters
  • dict1 (dict) – The first dictionary

  • dict2 (dict) – The second dictionary

  • division (float, optional) – In cas if user wants to devide the summation to a number (e.g. averaging)

  • 1.0. (of amplifying the result. Defaults to) –

Returns

A dictionary containing the common parameters of `dict1` and `dict2`, but their summation.

Return type

dic

PyFWI.fwi_tools.expand_model(parameter, TNz, TNx, n_pml=10)

This function make room around the ‘parameter’ to stick the pml layer.

Parameters
  • parameter (float) – Matrix of property that we are going to consider pml around.

  • TNz (int) – Number of samples in z-direction (n_z + 2 * n_pml).

  • TNx (int) – Number of samples in x-direction (n_x + 2 * n_pml).

  • n_pml (int, optional = 10) – Number of pml layer

Returns

nu – A matrix with the size of [TNz, TNx] with zero value everywhere excpet in center which consisting the model.

Return type

float

PyFWI.fwi_tools.grad_lmd_to_vd(glam, gmu, grho, lam, mu, rho)

grad_lmr_to_vd switch the gradient.

This function witch the gradient from (lambda, mu, rho) to (vp, vs, rho).

Parameters
  • glam (ndarray) – Gradient w.r.t. lambda

  • gmu (ndarray) – Gradient w.r.t. mu

  • grho (ndarray) – Gradient w.r.t. density

  • lam (ndarray) – Gradient w.r.t. lambda

  • mu (ndarray) – Gradient w.r.t. mu

  • rho (ndarray) – Gradient w.r.t. density

Refrences:
  1. Hu et al, 2021, Direct updating of rock-physics properties using elastice full-waveform inversion

  2. Zhou and Lumely, 2021, Central-difference time-lapse 4D seismic full-waveform inversion

PyFWI.fwi_tools.inpa_generator(vp, sdo, fn, **kwargs)
PyFWI.fwi_tools.inpa_loading(path)

inpa_loading lad the INPA file

[extended_summary]

Parameters

path ([type]) – [description]

Returns

input of FWI program

Return type

inpa (dict)

PyFWI.fwi_tools.lowpass(x1, highcut, fn, order=1, axis=1, show=False)
PyFWI.fwi_tools.modeling_model(model, med_type)
PyFWI.fwi_tools.pcs_dict2vec(m0)

pcs_dict2vec converts a dictionary of PCS to a vector

This function converts a dictionary of PCS to vector which is used during the inversion.

Parameters

m0 (dictionary) – A dictionary ccontaining ‘phi’, ‘cc’, ‘sw’.

Returns

A vector containg the whole parameters of the model.

Return type

m (dictionary)

PyFWI.fwi_tools.pml_counstruction(TNz, TNx, dh, n_pml=10, pml_r=1e-5)

PML construction generate two matrices for x- and z-directions with the size of velocity model plus number of pml samples in each direction.

dx_pml and dz_pml are obtained based on Gao et al., 2017, Comparison of artificial absorbing boundaries for acoustic wave equation modelling.

Parameters
  • TNz (int) – Number of samples in z-direction (n_z + 2 * n_pml).

  • TNx (int) – Number of samples in x-direction (n_x + 2 * n_pml).

  • dh (float) – Spatial ampling rate in x-direction.

  • n_pml (int, optional = 10) – Number of pml layer

  • pml_r (float, optional = 1e-5) – Theoretical reflection coefficient.

Returns

  • dx_pml (float) – A matrix with the size of [TNz, TNx] with zero value everywhere excpete inside PML in right and left of model.

  • dz_pml (float) – A matrix with the size of [TNz, TNx] with zero value everywhere excpet inside PML in above and bottom of model.

References

[1] Gao et al., 2017, Comparison of artificial absorbing boundaries for acoustic wave equation modelling, Exploration Geophysics, 2017, 48, 76–93.

[2] Araujo and Pestana, 2020, Perfectly matched layer boundary conditions for the second-order acoustic wave equation solved by the rapid expansion method, Geophysical Prospecting, 2020, 68, 572–590.

PyFWI.fwi_tools.pml_delta_calculation(n_pml, dh, pml_r)

This function generates delta vector for PML construction function which put this vector around the model matrices.

dx_pml and dz_pml are obtained based on Gao et al., 2017, Comparison of artificial absorbing boundaries for acoustic wave equation modelling.

Warns

TODO (I have to add dz as well)

Parameters
  • dh (float) – Sampling rate in x-direction.

  • n_pml (int, optional = 10) – Number of pml layers

  • pml_r (float, optional = 1e-5) – Theoretical reflection coefficient.

Returns

delta – A vector containing the absorbant value for putting in absorbant layer

Return type

float

References

[1] Gao et al., 2017, Comparison of artificial absorbing boundaries for acoustic wave equation modelling, Exploration Geophysics, 2017, 48, 76–93.

[2] Araujo and Pestana, 2020, Perfectly matched layer boundary conditions for the second-order acoustic wave equation solved by the rapid expansion method, Geophysical Prospecting, 2020, 68, 572–590.

class PyFWI.fwi_tools.recorder(nt, rec_loc, ns, dh)

Bases: object

acquire()
PyFWI.fwi_tools.residual(d_est, d_obs)
PyFWI.fwi_tools.source_weighting(d_pre, d_obs, ns, nr)
PyFWI.fwi_tools.svd_reconstruction(m, begining_component, num_components)
PyFWI.fwi_tools.vec2pcs_dict(m0, nz, nx)

vec2pcs_dict converts a vector of PCS to dictionary

This function converts a vector of PCS to dictionary which is used during the inversion.

Parameters
  • m0 (1-d ndarray) – a vector containg the whole parameters of the model

  • nz ([type]) – Number of samples of the model in z-direction

  • nx ([type]) – Number of samples of the model in x-direction

Returns

A dictionary ccontaining ‘phi’, ‘cc’, ‘sw’.

Return type

m (dictionary)

PyFWI.fwi_tools.vec2vel_dict(m0, nz, nx)

vec2vel_dict converts a vector of DV to dictionary

This function converts a vector of DV to dictionary which is used during the inversion.

Parameters
  • m0 (1-d ndarray) – a vector containg the whole parameters of the model

  • nz ([type]) – Number of samples of the model in z-direction

  • nx ([type]) – Number of samples of the model in x-direction

Returns

A dictionary ccontaining ‘vp’, ‘vs’, ‘rho’.

Return type

m (dictionary)

PyFWI.fwi_tools.vel_dict2vec(m0)

model_dataset

class PyFWI.model_dataset.Circular(name)

Bases: object

Hu_circles(vintage, smoothing)

Hu_circles a model including porosity, clay content, and saturation.

This method creates a model including porosity, clay content, and saturation. It is used in a paper published in 2021 in Geophysics by Qi Qu and his collegues. If you use non-default values, new model with the same structure and new values will be generated.

Parameters
  • rho (dictionary, optional) – A dictionary containing the density of quartz, clay, water, and hydrocarbon. Defaults to None.

  • prop_back (dictionary, optional) – A dictionary containing background properties (porosity, clay content, and saturation). Defaults to None.

  • prop_circle (dictionary, optional) – A dictionary containing properties in the circles (porosity, clay content, and saturation). Defaults to None.

  • nz (int, optional) – Number of saples in z-direction (rows). Defaults to 100.

  • nx (int, optional) – Number of saples in x-direction (column). Defaults to 100.

  • r (int, optional) – Radius of the circles. Defaults to 8.

  • monitor (bool, optional) – Specify if you are looking for monitor model. Defaults to False.

Returns

A dictionary containing the created model.

Return type

model (dictionary)

Reference:

Hu, Q., S. Keating, K. A. Innanen, and H. Chen, 2021, Direct updating of rock-physics properties using elastic full-waveform inversion: Geophysics, 86, 3, MR117-MR132, doi: 10.1190/GEO2020-0199.1.

louboutin(vintage, smoothing)

louboutin Generate perturbation model based on only vp.

[extended_summary]

Returns

[description]

Return type

[type]

perturbation_dv(vintage, smoothing)

perturbation_dv creates perturbation model in different locations

perturbation_dv creates perturbation model in different locations based on vp, vs, density

Returns

[description]

Return type

[type]

yang(vintage, smoothing)

Yang et al., 2018 for Truncated Newton method.

[extended_summary]

Returns

[description]

Return type

[type]

class PyFWI.model_dataset.Laminar(name)

Bases: object

Hu_laminar(vintage, smoothing)
dupuy(vintage, smoothing)
class PyFWI.model_dataset.ModelGenerator(name)

Bases: PyFWI.model_dataset.Circular, PyFWI.model_dataset.Laminar

marmousi(vintage, smoothing)
show(property=['vp'])
PyFWI.model_dataset.add_anomaly(model, anomaly, x, z, dx, dz, height, type='circle')

add_anomaly adds anomaly to the previously created model.

This mathod add an anomally to the Earth mode that is already createad.

Parameters
  • model (float) – The previously created model.

  • anomaly (float) – The properties of the anomaly

  • x ([type]) – x-location of the anomaly

  • z ([type]) – z-location of the anomaly

  • width ([type]) – Width of the anomaly

  • height ([type]) – Height of the anomaly

  • type (str, optional) – The shape of the anomaly. Defaults to “circle”.

Returns

The new model.

Return type

model (dict)

PyFWI.model_dataset.add_circle(model, circle_prop, r, cx, cz)

add_circle adds a circle to the model

This function generates a circle in the model.

Parameters
  • model (float) – Already created model.

  • circle_prop (float) – Property of the circle.

  • r (int) – Radius of the circle

  • cx (int) – x_location of the center

  • cz (int) – z-location of the center

Returns

Return the model.

Return type

model(dict)

PyFWI.model_dataset.add_layer(model, property, lt, lb, rt=None, rb=None)

add_layer add alyer to the model

This function add a layer to the mdoel

Parameters
  • model (dict) – Already created model.

  • property (dict) – Property of the new layer

  • lt (array, int) – Sample number ([x ,z]) of the top of the layer in the most left part

  • lb (array, int) – Sample number ([x ,z]) of the bottom of the layer in the most left part

  • rt (array, int) – Sample number ([x ,z]) of the top of the layer in the most right part

  • rb (array, int) – Sample number ([x ,z]) of the bottom of the layer in the most right part

  • #TODO – to develop for dipping layers

Returns

Return the model.

Return type

model(dict)

PyFWI.model_dataset.background(size, params)

add_layer genearte a layer of property.

This method generates one layer with property “bp”

Parameters

bp (dict) – Background property

PyFWI.model_dataset.model_resizing(model0, bx=None, ex=None, bz=None, ez=None, ssr=(1, 1))
PyFWI.model_dataset.model_smoother(model, smooting_value)
PyFWI.model_dataset.pcs_perturbation(rho=None, prop_back=None, prop_circle=None, nz=100, nx=100, r=8, monitor=False)

pcs_perturbation a model including porosity, clay content, and saturation.

This function creates a model including porosity, clay content, and saturation. It is used in a paper published in 2021 in Geophysics by Qi Qu and his collegues. If you use non-default values, new model with the same structure and new values will be generated.

Parameters
  • rho (dictionary, optional) – A dictionary containing the density of quartz, clay, water, and hydrocarbon. Defaults to None.

  • prop_back (dictionary, optional) – A dictionary containing background properties (porosity, clay content, and saturation). Defaults to None.

  • prop_circle (dictionary, optional) – A dictionary containing properties in the circles (porosity, clay content, and saturation). Defaults to None.

  • nz (int, optional) – Number of saples in z-direction (rows). Defaults to 100.

  • nx (int, optional) – Number of saples in x-direction (column). Defaults to 100.

  • r (int, optional) – Radius of the circles. Defaults to 8.

  • monitor (bool, optional) – Specify if you are looking for monitor model. Defaults to False.

Returns

A dictionary containing the created model.

Return type

model (dictionary)

Reference:

Hu, Q., S. Keating, K. A. Innanen, and H. Chen, 2021, Direct updating of rock-physics properties using elastic full-waveform inversion: Geophysics, 86, 3, MR117-MR132, doi: 10.1190/GEO2020-0199.1.

optimization

class PyFWI.optimization.FWI(d_obs, inpa, src, rec_loc, model_size, n_well_rec, chpr, components)

Bases: PyFWI.wave_propagation.wave_propagator

fprime(m0, m1, freq)
fprime_single(m0, m_1, m1, freq)
gauss_newton(m0, iter, freqs)
parameter_optimization(m_opt, m1, p, rms, grad, alpha, freq)
steepest_descent(m0, iter, freqs)
PyFWI.optimization.linesearch(fun, fprime, xk, pk, gk=None, fval_old=None, f_max=50, alpha0=None, show=False, min=1e-08, bond=[- inf, inf], args=())
PyFWI.optimization.truncated(FO_waves, W, m0, grad0, m1, iter)

processing

class PyFWI.processing.Gain(t, dt, nt)

Bases: object

property test
time_linear(show_gain=False)

time_linear generates a linear gain function related to time

This function generates a linear gain function with time

Parameters

show_gain (bool, optional) – If we need to plot the gain function. Defaults to False.

Returns

A class for applying the processing method.

Return type

GF (class)

class PyFWI.processing.Gain_function(t, dt, nt)

Bases: PyFWI.processing.Gain

apply(data, show=False)

apply applies the gain function on the data

apply applies the made gain on the data. It can show the original and gained data as well.

Parameters
  • data (list) – A list containing the seismic datafor different component

  • show (bool, optional) – The option to let user to ask to show the seismic sections before and after gain. Defaults to False.

Returns

Gained data

Return type

gained_data [list]

class PyFWI.processing.derivatives(order)

Bases: object

property c1
property c2
property c3
property c4
dot_product_test_derivatives()
dt_computation(vp_max, dx, dz=None)

ref: Bai et al, 2013

dxm(x, dx)
dxp(x, dx)
dzm(x, dx)
dzp(x, dx)
property order

rock_physics

class PyFWI.rock_physics.Density

Bases: object

static effective_density(phi, rho_f, rho_s)
static fluid(r_hydro, rho_w, sw)

fluid [summary]

[extended_summary]

Parameters
  • r_hydro ([type]) – [description]

  • rho_w ([type]) – [description]

  • sw ([type]) – [description]

Returns

Density of fluid

Return type

rho_f [type]

gardner(vp, units='metric')

gardner method to estimate the density

This mdethod estimate density of a model based on P-wave velocity. It uses the Gardner’s eqution.

Parameters
  • vp (float) – P-wave velocity

  • units (str, optional) – Specify the system of the units fo measurements (Metric or Imperial) . Defaults to “metric”.

Returns

density

Return type

rho

static matrix(rho_clay, cc, rho_q, **kwargs)

matrix [summary]

[extended_summary]

Parameters
  • rho_clay ([type]) – [description]

  • cc ([type]) – [description]

  • rho_q ([type]) – [description]

Returns

rho_m – Density of matrix

Return type

ndarray

rho_from_pcs(rho_c, rho_q, rho_w, rho_g, cc, sw, phi)

This function calculate density from Porosity, clay content, and water Saturation

Parameters
  • rho_c – Density of clay

  • rho_q – Density of quartz

  • rho_w – Density of water

  • rho_g – Density of gas

  • cc – clay content

  • sw – water saturation

  • phi – Porosity

Returns

rho – Effective density

Return type

float

PyFWI.rock_physics.Han(phi, cc, a1=5.5, a2=6.9, a3=2.2, b1=3.4, b2=4.7, b3=1.8)

Han estimates velocity based on porosity and clasy content

Han found empirical regressions relating ultrasonic (laboratory) velocities to porosity and clay content

Parameters
  • phi ([type]) – [porosity

  • cc ([type]) – clay content

  • a1 (float, optional) – Constant value for Vp. Defaults to 5.77.

  • a2 (float, optional) – Constant value for Vp. Defaults to 6.94.

  • a3 (float, optional) – Constant value for Vp. Defaults to 1.728.

  • b1 (float, optional) – Constant value for Vs. Defaults to 5.77.

  • b2 (float, optional) – Constant value for Vs. Defaults to 6.94.

  • b3 (float, optional) – Constant value for Vs. Defaults to 1.728.

Returns

P-wave velocity (km/s) vs = S-wave velocity (km/s)

Return type

vp

References

  1. Hu et al, 2021, Direct updating of rock-physics properties using elastice full-waveform inversion

  2. Mavko, G., Mukerji, T., & Dvorkin, J., 2020, The rock physics handbook. Cambridge university press.

class PyFWI.rock_physics.Lamb

Bases: object

vp_rho_mu(rho, vp=None, mu=None)
class PyFWI.rock_physics.Mu

Bases: object

vs_rho(vs, rho=None)

vs_rho generate mu

This function add mu to to the imported model based on S-wave velocity and density.

Parameters
  • vs (float or dict) – S-wave velocity. if dict, it has to contain value for density.

  • rho (float, option) – Density

Returns

Shear modulus

Return type

mu

class PyFWI.rock_physics.ShearVelocity

Bases: object

Han(phi, cc, **kwargs)

Han calulates vs based on Han empirical model.

Han calulates vs based on Han empirical model.

Parameters
  • phi ([type]) – Porosity

  • cc ([type]) – Clay content

Returns

S-wave velocity

Return type

vp

poisson_ratio_vs(vp, sigma=0.25)

poisson_ratio_vs calculates the shear velocity.

Calculates the shear velocity based on Poisson’s ration.

Parameters
  • vp (float) – P-wave velocity.

  • sigma (float, optional) – Poisson’s ration. It could be None if parameter “model” has this property. Defaults to None.

Returns

The input model and shear velocity is added.

Return type

vs

PyFWI.rock_physics.biot_gassmann(phi, k_f, k_s, k_d)
PyFWI.rock_physics.delta_biot_gassmann(phi, k_f, k_s, k_d)
PyFWI.rock_physics.drained_moduli(phi, k_s, g_s, cs)
PyFWI.rock_physics.error_lack_of_data()
PyFWI.rock_physics.lmd2vd(lam, mu, rho)

lmd2vd switches Lama modulus and density to vp, vs, density

[extended_summary]

Parameters
  • lam ([type]) – [description]

  • mu ([type]) – [description]

  • rho ([type]) – [description]

Returns

[description]

Return type

[type]

class PyFWI.rock_physics.p_velocity

Bases: object

Han(phi, cc, **kwargs)

Han calulates vp based on Han empirical model.

Han calulates vp based on Han empirical model.

Parameters
  • phi ([type]) – Porosity

  • cc ([type]) – Clay content

Returns

P-wave velocity

Return type

vp

gardner(units='metric')
lam_mu_rho(lam, mu, rho)
PyFWI.rock_physics.reverse_Han(vp, vs, a1=5.5, a2=6.9, a3=2.2, b1=3.4, b2=4.7, b3=1.8)
PyFWI.rock_physics.vd2lmd(vp, vs, rho)

vd2lmd switches vp, vs, density to Lame modulus and density to

[extended_summary]

Parameters
  • vp ([type]) – [description]

  • vs ([type]) – [description]

  • rho ([type]) – [description]

Returns

[description]

Return type

[type]

PyFWI.rock_physics.voigt_berie(k_l, rho_l, k_g, rho_g, s_g)

seiplot

PyFWI.seiplot.earth_model(model, keys=[], offset=None, depth=None, **kwargs)

earth_model show the earth model.

This function is provided to show the earth models.

Parameters
  • model (Dictionary) – A dictionary containing the earth model.

  • keys (list, optional) – List of parameters you want to show. Defaults to [].

Returns

The figure class to which the images are added for furthur settings like im.set-clim().

Return type

fig (class)

PyFWI.seiplot.gn_plot(p, grad, nz, nx)
PyFWI.seiplot.seismic_section(ax, data, x_axis=None, t_axis=None, aspect_preserving=False, **kargs)

seismic_io

PyFWI.seismic_io.load_mat(path)

This function load python dictionary as a .mat file.

Parameters

path (String) – The path to save the data.

PyFWI.seismic_io.load_pkl(file_path)

load_pkl loads pkl file.

load_pkl loads pkl file.

Parameters

file_path (string) – Path of file to be loaded.

Returns

Loaded file.

Return type

output

PyFWI.seismic_io.read_segy(path)

A function to load segy file.

Parameters

path – The path of segy file.

Returns

The data stored in segy.

Return type

data

PyFWI.seismic_io.save_mat(path, **kwargs)

This function save python dictionary as a .mat file.

Parameters
  • path (String) – The path to save the data.

  • unique (Boolean) – If true, it will add current date and time to the name of folder

  • **kwargs (type) – Dictionaries containing the data.

PyFWI.seismic_io.save_pkl(path, **kwargs)

save_pkl saves pkl file.

save_pkl saves file with pkl format. That is better than .mat file for preserving the structure of dictionaries.

Parameters
  • path (string) – path to save the file(s).

  • **kwargs (data) – Variable(s) to be saved.

  • the (A boolean argument with name of "unique" can be given to make) –

  • data. (path based on the) –

wave_propagation

class PyFWI.wave_propagation.wave_preparation(inpa, src, rec_loc, model_size, n_well_rec=0, chpr=10, components=0)

Bases: object

adjoint_buffer_preparing()
elastic_buffers(model)

Model hast contain vp, vs, and rho

gradient_reading()
initial_wavefield_plot(model, plot_type='Forward')

A function to initialize the the plot for wave propagation visulizing

Parameters

plot_type (string optional = "Forward") – Specify if we want to show Forward modelloing or Backward.

kernel_caller()

This function is used to specify the constants for use in openCl’s files and choose the asked openCl source to run based on the assumptions of problem.

The coeeficients are based on Lavendar, 1988 and Hasym et al., 2014.

Returns

kernel_source – macro plus the openCl’s source.

Return type

str

make_residual(res, s, t)

This function reads the inject the residual to residual buffer based on source and the time step.

Parameters
  • res (list) – list containing the residual of all parameters

  • s (int) – Number of current acive source.

  • t (float) – Current time step.

make_seismogram(s, t)

This function read the seismogram buffer and put its value in the right place in main seismogram matrix based on source and the time step.

Parameters
  • s (int) – Number of current acive source.

  • t (float) – Current time step.

plot_propagation(wave1, t, wave2=None)

This function is used to shpw the propagation wave with time.

Parameters
  • wave1 (float32) – The wave that we are going to show

  • t (float32) – Time step

  • wave2 (flaot32, optional = None) – The second wave which is used when we want to show the propagation of backward wave as wave1 and adjoint wave as wave2.

pml_preparation(v_max)
class PyFWI.wave_propagation.wave_propagator(inpa, src, rec_loc, model_size, n_well_rec=None, chpr=10, components=4)

Bases: PyFWI.wave_propagation.wave_preparation

forward_modeling(model0, show=False, W=None, grad=None)
forward_propagator(model, W=None, grad=None)

This function is in charge of forward modelling for acoustic case

Parameters

model (dictionary) – A dictionary containing p-wave velocity and density

gradient(res, show=False, Lam=None, grad=None, parameterization='dv')

Module contents