ADFWI.fwi
ADFWI.fwi.misfit
- ADFWI.fwi.misfit
- ADFWI.fwi.misfit.base
- ADFWI.fwi.misfit.L1
- ADFWI.fwi.misfit.L2
- ADFWI.fwi.misfit.SmoothL1
- ADFWI.fwi.misfit.Envelope
- ADFWI.fwi.misfit.GlobalCorrelation
- ADFWI.fwi.misfit.StudentT
- ADFWI.fwi.misfit.SoftDTW
- ADFWI.fwi.misfit.Wasserstein_sinkhorn
- ADFWI.fwi.misfit.Normalized_Integration_method
- ADFWI.fwi.misfit.Weci
- ADFWI.fwi.misfit.Weighted_L1_L2
- ADFWI.fwi.misfit.WDGC
ADFWI.fwi.regularization
ADFWI.fwi.acoustic_fwi
- class ADFWI.fwi.acoustic_fwi.AcousticFWI(propagator: ~ADFWI.propagator.acoustic_propagator.AcousticPropagator, model: ~ADFWI.model.base.AbstractModel, optimizer: ~torch.optim.optimizer.Optimizer, scheduler: <module 'torch.optim.lr_scheduler' from '/ailab/group/groups/ai4earth/liufeng1/.conda/envs/ADinversion/lib/python3.8/site-packages/torch/optim/lr_scheduler.py'>, loss_fn: ~ADFWI.fwi.misfit.base.Misfit | ~torch.autograd.function.Function, obs_data: ~ADFWI.survey.data.SeismicData, gradient_processor: ~ADFWI.propagator.gradient_process.GradProcessor | ~typing.List[~ADFWI.propagator.gradient_process.GradProcessor] | None = None, regularization_fn: ~ADFWI.fwi.regularization.base.Regularization | None = None, regularization_weights_x: ~typing.List[float] | None = [0, 0], regularization_weights_z: ~typing.List[float] | None = [0, 0], waveform_normalize: bool | None = True, waveform_mute_late_window: float | None = None, waveform_mute_offset: float | None = None, cache_result: bool | None = True, save_fig_epoch: int | None = -1, save_fig_path: str | None = '')[source]
Bases:
Module
Acoustic Full waveform inversion class.
This class implements an acoustic Full Waveform Inversion (FWI) method for seismic imaging. It optimizes velocity and density models by comparing the simulated waveforms with observed seismic data.
- Parameters:
propagator (AcousticPropagator) – The propagator used for simulating acoustic wave propagation.
model (AbstractModel) – The model class representing the velocity or acoustic property structure.
optimizer (torch.optim.Optimizer) – The optimizer used for parameter optimization (e.g., SGD, Adam).
scheduler (torch.optim.lr_scheduler) – The learning rate scheduler for adjusting the learning rate during training.
loss_fn (Union[Misfit, torch.autograd.Function]) – The loss function or misfit function used to compute the difference between predicted and observed data.
obs_data (SeismicData) – The observed seismic data for comparison against the model predictions.
gradient_processor (Union[GradProcessor, List[GradProcessor]], optional) – The gradient processor or list of processors for handling gradients, applied to different parameters if specified. Default is None.
regularization_fn (Optional[Regularization], optional) – The regularization function for model parameters (e.g., for smoothing or penalty terms). Default is None.
regularization_weights_x (Optional[List[Union[float]]], optional) – Regularization weights for the x direction (e.g., vp/rho regularization). Default is [0, 0].
regularization_weights_z (Optional[List[Union[float]]], optional) – Regularization weights for the z direction (e.g., vp/rho regularization). Default is [0, 0].
waveform_normalize (Optional[bool], optional) – Whether to normalize the waveform during inversion. Default is True (waveforms are normalized).
waveform_mute_late_window (Optional[float], optional) – Clipping data after picking the first arrival with the given window size.
waveform_mute_offset (Optional[float], optional) – Clipping data larger than the given offset threshold.
cache_result (Optional[bool], optional) – Whether to cache intermediate inversion results for later use. Default is True.
save_fig_epoch (Optional[int], optional) – The interval (in epochs) at which to save the inversion result as a figure. Default is -1 (no figure saved).
save_fig_path (Optional[str], optional) – The path where to save the inversion result figure. Default is an empty string (no path specified).
- calculate_loss(synthetic_waveform, observed_waveform, normalization, loss_fn, cutoff_freq=None, propagator_dt=None, shot_index=None)[source]
- Calculates the misfit loss between synthetic and observed waveforms.
first arrival picking
mute data by first arrival & giving window
mute data by offset
low-pass filter
normalizing data
- Parameters:
synthetic_waveform (torch.Tensor) – The predicted waveform data.
observed_waveform (torch.Tensor) – The observed waveform data.
normalization (bool) – Whether to normalize the waveform.
loss_fn (Union[Misfit, Misfit_NIM, torch.autograd.Function]) – The loss function to calculate the misfit.
cutoff_freq (Optional[float], optional) – The cutoff frequency for the low-pass filter. Default is None.
propagator_dt (Optional[float], optional) – The time step used by the propagator. Default is None.
shot_index (Optional[int], optional) – The index of the shot for processing. Default is None.
- Returns:
The calculated loss between the synthetic and observed waveforms.
- Return type:
torch.Tensor
- calculate_regularization_loss(model_param, weight_x, weight_z, regularization_fn)[source]
Generalized function to calculate regularization loss for a given parameter.
- forward(iteration: int, batch_size: int | None = None, checkpoint_segments: int | None = 1, start_iter=0, cutoff_freq=None)[source]
Iteration of full waveform inversion.
- Parameters:
iteration (int) – The maximum iteration number in the inversion process.
batch_size (Optional[int], optional) – The number of shots (data samples) in each batch. Default is None, meaning use all available shots.
checkpoint_segments (Optional[int], optional) – The number of segments into which the time series should be divided for memory efficiency. Default is 1, which means no segmentation.
start_iter (int, optional) – The starting iteration for the optimization process (e.g., for optimizers like Adam/AdamW, and learning rate schedulers like step_lr). Default is 0.
cutoff_freq (Optional[float], optional) – The cutoff frequency for low-pass filtering, if specified. Default is None (no filtering applied).
- forward_closure(iteration: int, batch_size: int | None = None, checkpoint_segments: int | None = 1, start_iter=0, cutoff_freq=None)[source]
inversion using closure version ==> LBFGS
- Parameters:
iteration (int) – The maximum iteration number in the inversion process.
batch_size (Optional[int], optional) – The number of shots (data samples) in each batch. Default is None, meaning use all available shots.
checkpoint_segments (Optional[int], optional) – The number of segments into which the time series should be divided for memory efficiency. Default is 1, which means no segmentation.
start_iter (int, optional) – The starting iteration for the optimization process (e.g., for optimizers like Adam/AdamW, and learning rate schedulers like step_lr). Default is 0.
cutoff_freq (Optional[float], optional) – The cutoff frequency for low-pass filtering, if specified. Default is None (no filtering applied).
- training: bool
ADFWI.fwi.elastic_fwi
- class ADFWI.fwi.elastic_fwi.ElasticFWI(propagator: ~ADFWI.propagator.elastic_propagator.ElasticPropagator, model: ~ADFWI.model.base.AbstractModel, loss_fn: ~ADFWI.fwi.misfit.base.Misfit | ~torch.autograd.function.Function, obs_data: ~ADFWI.survey.data.SeismicData, optimizer: ~torch.optim.optimizer.Optimizer | ~typing.List[~torch.optim.optimizer.Optimizer] = None, scheduler: <module 'torch.optim.lr_scheduler' from '/ailab/group/groups/ai4earth/liufeng1/.conda/envs/ADinversion/lib/python3.8/site-packages/torch/optim/lr_scheduler.py'> = None, gradient_processor: ~ADFWI.propagator.gradient_process.GradProcessor | ~typing.List[~ADFWI.propagator.gradient_process.GradProcessor] = None, regularization_fn: ~ADFWI.fwi.regularization.base.Regularization | None = None, regularization_weights_x: ~typing.List[float] | None = [0, 0, 0, 0, 0, 0], regularization_weights_z: ~typing.List[float] | None = [0, 0, 0, 0, 0, 0], waveform_normalize: bool | None = True, waveform_mute_late_window: float | None = None, waveform_mute_offset: float | None = None, cache_result: bool | None = True, cache_gradient: bool | None = False, save_fig_epoch: int | None = -1, save_fig_path: str | None = '', inversion_component: ~numpy.array | None = ['pressure'])[source]
Bases:
Module
Elastic Full Waveform Inversion class.
- Parameters:
propagator (ElasticPropagator) – The propagator used for simulating elastic wave propagation.
model (AbstractModel) – The model class representing the velocity structure.
loss_fn (Union[Misfit, torch.autograd.Function]) – The loss function used to compute the misfit between observed and predicted data.
obs_data (SeismicData) – The observed seismic data.
optimizer (Union[torch.optim.Optimizer, List[torch.optim.Optimizer]], optional) – The optimizer or list of optimizers for model parameters. Default is None.
scheduler (torch.optim.lr_scheduler, optional) – The learning rate scheduler for optimizing the model parameters. Default is None.
gradient_processor (Union[GradProcessor, List[GradProcessor]], optional) – Processor(s) for handling gradients (e.g., vp/vs/rho, epsilon/delta/gamma). Default is None.
regularization_fn (Optional[Regularization], optional) – Regularization function(s) applied to parameters like vp/vs/rho/epsilon/delta/gamma. Default is None.
regularization_weights_x (Optional[List[Union[float]]], optional) – Regularization weights for the x-axis. Default is [0, 0, 0, 0, 0, 0].
regularization_weights_z (Optional[List[Union[float]]], optional) – Regularization weights for the z-axis. Default is [0, 0, 0, 0, 0, 0].
waveform_normalize (Optional[bool], optional) – Whether to normalize the waveforms during inversion. Default is True.
waveform_mute_late_window (Optional[float], optional) – Late window mute applied to waveform data. Default is None.
waveform_mute_offset (Optional[float], optional) – Offset mute applied to waveform data. Default is None.
cache_result (Optional[bool], optional) – Whether to save intermediate results during the inversion. Default is True.
cache_gradient (Optional[bool], optional) – Whether to save model variations (not gradients) during inversion. Default is False.
save_fig_epoch (Optional[int], optional) – The interval (in epochs) at which to save the inversion result figure. Default is -1 (no figure saved).
save_fig_path (Optional[str], optional) – The path where to save the inversion result figure. Default is an empty string (no save path).
inversion_component (Optional[np.array], optional) – The components of the inversion (e.g., [“pressure”]). Default is [“pressure”].
- calculate_loss(synthetic_waveform, observed_waveform, normalization, loss_fn, cutoff_freq=None, propagator_dt=None, shot_index=None)[source]
Generalized function to calculate misfit loss for a given component.
- calculate_regularization_loss(model_param, weight_x, weight_z, regularization_fn)[source]
Generalized function to calculate regularization loss for a given parameter.
- forward(iteration: int, fd_order: int = 4, batch_size: int | None = None, checkpoint_segments: int | None = 1, start_iter=0, cutoff_freq=None)[source]
iteration of full waveform inversion
- Parameters:
iteration (int) – The maximum iteration number in the inversion process.
fd_order (int, optional) – The order of the finite difference scheme for wave propagation. Default is 4.
batch_size (Optional[int], optional) – The number of shots (data samples) in each batch. Default is None, meaning use all available shots.
checkpoint_segments (Optional[int], optional) – The number of segments into which the time series should be divided for memory efficiency. Default is 1, which means no segmentation.
start_iter (int, optional) – The starting iteration for the optimization process (e.g., for optimizers like Adam/AdamW, and learning rate schedulers like step_lr). Default is 0.
cutoff_freq (Optional[float], optional) – The cutoff frequency for low-pass filtering, if specified. Default is None (no filtering applied).
- training: bool
ADFWI.fwi.multiScaleProcessing
- class ADFWI.fwi.multiScaleProcessing.Lfilter(*args, **kwargs)[source]
Bases:
Function
A custom autograd function for applying low-pass filtering to two signals in the forward pass and computing the adjoint of the low-pass filter in the backward pass.
- static backward(ctx, adj1, adj2)[source]
Backward pass of the low-pass filter for computing the gradients.
- Parameters:
adj1 (torch.Tensor) – The gradient with respect to the first input signal (3D tensor: [nsrc, nt, nrcv]).
adj2 (torch.Tensor) – The gradient with respect to the second input signal (3D tensor: [nsrc, nt, nrcv]).
- Returns:
The gradients with respect to the inputs x1 and x2.
- Return type:
torch.Tensor, torch.Tensor, None, None
- static forward(ctx, x1, x2, highcut, fn)[source]
Forward pass of the low-pass filter.
- Parameters:
x1 (torch.Tensor) – First input signal (3D tensor: [nsrc, nt, nrcv]).
x2 (torch.Tensor) – Second input signal (3D tensor: [nsrc, nt, nrcv]).
highcut (float) – High cutoff frequency for the low-pass filter in Hz.
fn (float) – Sampling frequency in Hz.
- Returns:
Filtered versions of x1 and x2.
- Return type:
torch.Tensor, torch.Tensor
- ADFWI.fwi.multiScaleProcessing.adj_lowpass(x, highcut, fn, order=1, axis=1)[source]
Apply adjoint low-pass filter in the time domain.
- Parameters:
x (np.ndarray) – Input signal (3D array: [nsrc, nt, nrcv]).
highcut (float) – High cutoff frequency in Hz.
fn (float) – Sampling frequency in Hz.
order (int, optional) – Order of the Butterworth filter. Default is 1.
axis (int, optional) – Axis along which to apply the filter. Default is 1 (time axis).
- Returns:
Adjoint low-pass filtered signal.
- Return type:
np.ndarray
- ADFWI.fwi.multiScaleProcessing.lowpass(x, highcut, fn, order=1, axis=1)[source]
Apply low-pass filter in the time domain using filtfilt (zero-phase filtering).
- Parameters:
x (np.ndarray) – Input signal (3D array: [nsrc, nt, nrcv]).
highcut (float) – High cutoff frequency in Hz.
fn (float) – Sampling frequency in Hz.
order (int, optional) – Order of the Butterworth filter. Default is 1.
axis (int, optional) – Axis along which to apply the filter. Default is 1 (time axis).
- Returns:
Low-pass filtered signal.
- Return type:
np.ndarray
- ADFWI.fwi.multiScaleProcessing.lpass(x1, x2, highcut, fn)[source]
Apply low-pass filtering to two signals using a Butterworth filter.
- Parameters:
x1 (np.ndarray) – First input signal to be filtered.
x2 (np.ndarray) – Second input signal to be filtered.
highcut (float) – High cutoff frequency in Hz for the low-pass filter.
fn (float) – Sampling frequency in Hz.
- Returns:
The filtered versions of x1 and x2.
- Return type:
np.ndarray, np.ndarray