ADFWI.dip
ADFWI.dip.model
ADFWI.dip.dip_acoustic_fwi
- class ADFWI.dip.dip_acoustic_fwi.DIP_AcousticFWI(propagator: ~ADFWI.propagator.acoustic_propagator.AcousticPropagator, 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], 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.
- Parameters:
propagator (AcousticPropagator) – The propagator used for simulating acoustic wave propagation.
model (AbstractModel) – The model class representing the velocity or acoustic property structure.
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.
optimizer (Union[torch.optim.Optimizer, List[torch.optim.Optimizer]], optional) – The optimizer used for parameter optimization (e.g., SGD, Adam). Default is None.
scheduler (torch.optim.lr_scheduler, optional) – The learning rate scheduler for adjusting the learning rate during training. Default is None.
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) – 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 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).
- training: bool
ADFWI.dip.dip_acoustic_model
- class ADFWI.dip.dip_acoustic_model.DIP_AcousticModel(ox: float, oz: float, nx: int, nz: int, dx: float, dz: float, DIP_model_vp=None, DIP_model_rho=None, reparameterization_strategy='vel', vp_init: array | Tensor | None = None, rho_init: array | Tensor | None = None, vp_bound: Tuple[float, float] | None = None, rho_bound: Tuple[float, float] | None = None, water_layer_mask: array | Tensor | None = None, auto_update_rho: bool | None = True, auto_update_vp: bool | None = False, free_surface: bool | None = False, abc_type: str | None = 'PML', abc_jerjan_alpha: float | None = 0.0053, nabc: int | None = 20, device='cpu', dtype=torch.float32)[source]
Bases:
AbstractModel
Acoustic Velocity model with deep parameterization of vp or rho.
- Parameters:
ox (float) – Not used. The origin coordinates of the model in the x-direction (meters).
oz (float) – Not used. The origin coordinates of the model in the z-direction (meters).
nx (int) – The number of grid points in the x-direction.
nz (int) – The number of grid points in the z-direction.
dx (float) – The grid spacing in the x-direction (meters).
dz (float) – The grid spacing in the z-direction (meters).
DIP_model_vp (Optional[torch.nn.Module]) – Reparameterized vp using a deep neural network, by default None.
DIP_model_rho (Optional[torch.nn.Module]) – Reparameterized rho using a deep neural network, by default None.
reparameterization_strategy (str) – Reparameterization strategy (‘vel’ for generating velocity model, ‘vel_diff’ for generating velocity variation).
vp_init (Optional[torch.Tensor]) – The initial vp model (must be provided when using the ‘vel_diff’ strategy).
rho_init (Optional[torch.Tensor]) – The initial rho model (must be provided when using the ‘vel_diff’ strategy).
vp_bound (Optional[Tuple[float, float]], default=None) – The lower and upper bounds for the P-wave velocity model.
rho_bound (Optional[Tuple[float, float]], default=None) – The lower and upper bounds for the density model.
auto_update_rho (Optional[bool], default=True) – Whether to automatically update the density model during inversion.
auto_update_vp (Optional[bool], default=False) – Whether to automatically update the P-wave velocity model during inversion.
water_layer_mask (Optional[Union[np.array, Tensor]], default=None) – A mask for the water layer (not updated), if applicable.
free_surface (Optional[bool], default=False) – Indicates whether a free surface is present in the model.
abc_type (Optional[str], default='PML') – The type of absorbing boundary condition used in the model. Options: ‘PML’ or ‘Jerjan’.
abc_jerjan_alpha (Optional[float], default=0.0053) – The attenuation factor for the Jerjan boundary condition.
nabc (Optional[int], default=20) – The number of grid cells dedicated to the absorbing boundary.
device (str, default='cpu') – The device on which to run the model (‘cpu’ or ‘cuda’).
dtype (torch.dtype, default=torch.float32) – The data type for PyTorch tensors.
- training: bool