seisflows.solver.specfem2d

This class provides utilities for the Seisflows solver interactions with Specfem2D. It builds upon the base Specfem class which generalizes all solver interactions with various versions of Specfem.

TODO

Internal paramater f0 is not currently used. Can we remove or integrate?

Classes

Specfem2D

Solver SPECFEM2D

Module Contents

class seisflows.solver.specfem2d.Specfem2D(source_prefix='SOURCE', multiples=False, **kwargs)

Bases: seisflows.solver.specfem.Specfem

Solver SPECFEM2D

SPECFEM2D-specific alterations to the base SPECFEM module

Parameters

type source_prefix:

str

param source_prefix:

Prefix of source files in path SPECFEM_DATA. Defaults to ‘SOURCE’

type multiples:

bool

param multiples:

set an absorbing top-boundary condition

Paths

***

__doc__ = Multiline-String
Show Value
"""
    Solver SPECFEM [Solver Base]
    ----------------------------
    Defines foundational structure for Specfem-based solver module.
    Generalized SPECFEM interface to manipulate SPECFEM2D/3D/3D_GLOBE w/ Python

    Parameters
    ----------
    :type syn_data_format: str
    :param syn_data_format: data format for reading synthetic traces into memory.
        Available: ['SU': seismic unix format, 'ASCII': human-readable ascii]
    :type materials: str or list
    :param materials: Material name used to define the model parameters that
        will be updated during an Inversion workflow. Available options
        (case-insensitive):
        - `type: list` (2D, 3D, 3D_GLOBE): User-defined list of lower-case
            parameters (e.g., ['vp', 'vs'] to mimic 'ELASTIC')
            NOTE: User is responsible for understanding if their chosen
            parameters are actually represented in SPECFEM, there are no guard
            rails here to protect incorrect parameter naming
        - ACOUSTIC (2D, 3D, 3D_GLOBE): vp
        - ELASTIC (2D, 3D, 3D_GLOBE): vp, vs
        - TRANSVERSE_ISOTROPIC (3D, 3D_GLOBE): vpv, vph, vsv, vsh, eta
        - 2D_ANISOTROPIC (2D): c11 c13 c15 c33 c35 c55 c12 c23 c25 c22
        - ANISOTROPIC (3D, 3D_GLOBE): c_ij  (21 parameter anisotropy)

    :type update_density: bool
    :param update_density: How to treat density during inversion. If True,
        updates density during inversion. If False, keeps it constant.
        TODO allow density scaling during an inversion
    :type attenuation: bool
    :param attenuation: How to treat attenuation during inversion.
        if True, turns on attenuation during forward simulations only. If
        False, attenuation is always set to False. Requires underlying
        attenution (Q_mu, Q_kappa) model
    :type smooth_h: float
    :param smooth_h: Gaussian half-width for horizontal smoothing in units
        of meters. If 0., no smoothing applied. Only applicable for workflows:
        ['migration', 'inversion'], ignored for 'forward' workflow.
        SPECFEM3D_GLOBE only: if `smooth_type`=='laplacian' then this is just
        the X and Y extent of the applied smoothing
    :type smooth_v: float
    :param smooth_v: Gaussian half-width for vertical smoothing in units
        of meters. Only applicable for workflows: ['migration', 'inversion'],
        ignored for 'forward' workflow.
        SPECFEM3D_GLOBE only: if `smooth_type`=='laplacian' then this is just
        the Z extent of the applied smoothing
    :type smooth_type: str
    :param smooth_type: choose how smoothing is performed for gradients.
        these are tied to the internal smoothing functions available, and only
        certain code flavors have certain smoothing functions available:
        - 'gaussian' [2D/3D/3D_GLOBE]: Default, convolve with a 3D gaussian,
            slow and computationally intensive. Only option for 2D.
        - 'laplacian' [3D_GLOBE]: RECOMMENDED FOR 3D_GLOBE. Average points
            around vertex to smooth. Much faster than Gaussian.
        - 'pde' [3D]: RECOMMENDED for 3D. Diffusion-based PDE smoothing.
            Much faster than Gaussian. See SPECFEM3D PR#1725
    :type components: str
    :param components: components to search for synthetic data with. None by
        default which uses a wildcard when searching for synthetics. If
        provided, User only wants to use a subset of components generated by
        SPECFEM. In that case, `components` should be string of letters such
        as 'ZN' (for up and north components)
    :type solver_io: str
    :param solver_io: format of model/kernel/gradient files expected by the
        numerical solver. Available: ['fortran_binary': default .bin files].
        TODO: ['adios': ADIOS formatted files]
    :type source_prefix: str
    :param source_prefix: prefix of source/event/earthquake files. If None,
        will attempt to guess based on the specific solver chosen.
    :type mpiexec: str
    :param mpiexec: MPI executable used to run parallel processes. Should also
        be defined for the system module

    Paths
    -----
    :type path_data: str
    :param path_data: path to any externally stored waveform data required for
        data-synthetic comparison
    :type path_specfem_bin: str
    :param path_specfem_bin: path to SPECFEM bin/ directory which
        contains binary executables for running SPECFEM
    :type path_specfem_data: str
    :param path_specfem_data: path to SPECFEM DATA/ directory which must
        contain the CMTSOLUTION, STATIONS and Par_file files used for
        running SPECFEM
    ***

This class provides utilities for the Seisflows solver interactions with
Specfem2D. It builds upon the base Specfem class which generalizes all solver
interactions with various versions of Specfem.

TODO
    Internal paramater f0 is not currently used. Can we remove or integrate?
"""
multiples = False
_f0 = None
_available_materials = ['ACOUSTIC', 'ELASTIC', '2D_ANISOTROPIC']
setup()

Setup the SPECFEM2D solver interface in a SeisFlows workflow Append coordinate files to exported model files so that we can use them for plotting later

smooth(input_path, output_path, parameters=None, span_h=None, span_v=None, use_gpu=False)

Specfem2D requires additional model parameters in directory to perform the xsmooth_sem task. This function will copy these files into the directory before performing the base smooth operations.

Kwargs should match arguments of solver.base.smooth()

Note

This operation is usually run with run(single=True) so only one task will be performing these operations.

Parameters:
  • input_path (str) – path to data

  • output_path (str) – path to export the outputs of xcombine_sem

  • parameters (list) – optional list of parameters, defaults to self._parameters

  • span_h (float) – horizontal smoothing length in meters

  • span_v (float) – vertical smoothing length in meters

  • use_gpu (bool) – whether to use GPU acceleration for smoothing. Requires GPU compiled binaries and GPU compute node.