Mondaic
This API reference is not for the latest stable Salvus version.

salvus.mesh.layered_meshing.layered_model.filters

Built-in partitioning filters.

Functions

enclosing_elements()

def enclosing_elements(
    um: UnstructuredMesh, p: np.ndarray
) -> npt.NDArray[np.bool_]: ...

Get the unique elements in um that enclose the points p.

No points outside the mesh will be considered, and are removed from the results of salvus_mesh_utils.get_enclosing_elements. Duplicates are also removed from the element list.

Kwargs is a list of keyword arguments to pass to `get_enclosing_elements.

Parameters
  • um UnstructuredMesh — The unstructured mesh.
  • p np.ndarray — The points.
Returns npt.NDArray[np.bool_]

first_and_last()

def first_and_last(i: Interface) -> Interface: ...

Create a new interface containing only the first and last DEM values.

Parameters
  • i Interface — The interface.
Returns Interface — A new interface with only the first and last values.

force_monotonic_top_down()

def force_monotonic_top_down(transform: ModelPredicate) -> ModelPredicate: ...

Ensure that a transformed model is monotonic in the negative vertical direction.

This is useful when the partitioning field is known a-priori to be primarily monotonically increasing in the negative vertical direction, especially when slight variations in the model lead to local deviations from monotonicity. Without applying this transform a naive partitioning may behave unexpectedly as variations in monotonicity can cause holes in simple predicates (i.e., those based on threshold velocity values) which will in turn prevent the partitioning algorithms from forming a clean partition.

Note: This function assumes that a material has been realized, that is expanded across all dimensions in a domain and sorted by dimension name.

Parameters
  • transform ModelPredicate — A function transforming a material to a xarray.DataArray, to be used as a partitioning predicate.
Returns ModelPredicate — The result of transform applied to a material and subsequently made monotonic along the vertical direction by performing a rolling minimum reduction along the positive vertical axis.

generate_vp_vs_ratio_filter()

def generate_vp_vs_ratio_filter(
    alpha: float,
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = "remove-components",
    compute_vp_via: (
        typing.Callable[[Material], _pd.GenericParameterType] | None
    ) = None,
) -> OracleFilter: ...

Generate a filter to compute the Vp/Vs ratio from the Vp and Vs oracles.

Parameters
  • alpha float — Interpolation factor between Vp and Vs oracles. When alpha is 0, return Vp, and when alpha is 1, return Vs. Value between 0 and 1 return a linear blend between the two oracle values, with the endpoints 0 only resolving Vs and 1 fully resolving Vs.
  • reduction_method typing.Literal['remove-components', 'force'] | None — A method to reduce anisotropic P-wave velocities to their hexagonal (TTI) values. Only used if compute_vp_via is None.
  • compute_vp_via typing.Callable[[Material], _pd.GenericParameterType] | None — A function that computes Vp, or a proxy for Vp, from a material.
Returns OracleFilter — The filter.

no_filter()

def no_filter(
    p: _pd.GenericParameterType, material: Material | None = None
) -> _pd.GenericParameterType: ...

Identity function returning the oracle as-is.

Parameters
  • p _pd.GenericParameterType — The oracle.
  • material Material | None — The material. Ignored in this case.
Returns _pd.GenericParameterType

remove_consecutive_duplicates()

def remove_consecutive_duplicates(i: Interface) -> Interface: ...

Remove consecutive duplicate DEM values from an interface.

Parameters
  • i Interface — The interface.
Returns Interface — An interface with consecutive duplicates removed.

Classes

OracleFilter

class OracleFilter(typing.Protocol):
    def __init__(self):
        ...

A protocol which wavelength oracle filter callbacks must respect.