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

salvus.mesh.layered_meshing.interface

Classes for different types of interfaces.

Functions

extend_flat()

def extend_flat(
    da: xarray.core.dataarray.DataArray,
    extend_to: xarray.core.dataarray.DataArray,
) -> xarray.core.dataarray.DataArray:
    ...

Extend an interface past its bounds via the extrusion of its boundaries.

Parameters
  • da xarray.core.dataarray.DataArray — The DataArray representing the interface to extend.
  • extend_to xarray.core.dataarray.DataArray — Either a 1- or 2-D tuple of coordinates representing the new bounds.
Returns xarray.core.dataarray.DataArray — The extended DataArray.

extend_spline()

def extend_spline(
    da: xarray.core.dataarray.DataArray,
    extend_to: xarray.core.dataarray.DataArray,
    straight: float = 0.05,
    flat: float = 0.95,
    throw: float = 0.2,
) -> xarray.core.dataarray.DataArray:
    ...

Extend an interface past its original bounds via a cubic Hermite spline.

This is useful when a smooth transition to a flat interface is desired. Hermite splines preserve C1 continuity at their boundaries, so extending an interface via this function should result in a minimization of reflections from an abrupt change in tangents.

Parameters
  • da xarray.core.dataarray.DataArray — The DataArray representing the interface to extend.
  • extend_to xarray.core.dataarray.DataArray — Either a 1- or 2-D tuple of coordinates representing the new bounds.
  • straight float — Percentage of the extended domain where the slope of the extension matches the slope of the curve at its original edge. Defaults to 0.05.
  • flat float — Percentage of the extended domain after which the slope of the extension is 0.0 (flat). Defaults to 0.95.
  • throw float — Parameter controlling the maximum vertical extent of the extended shape; the vertical extent will be capped at where a perfectly straight extension would be after spanning “throw” percent of the extended domain. Defaults to 0.2.
Returns xarray.core.dataarray.DataArray — The extended DataArray.

Classes

Depth

class Depth(salvus.mesh.layered_meshing.interface._ElevationAlgebra):
    def __init__(self, value: float) -> None:
        ...

Declare that a coordinate should be interpreted as depth below a domain’s top surface.

Parameters
  • value float — The depth value.

Height

class Height(salvus.mesh.layered_meshing.interface._ElevationAlgebra):
    def __init__(self, value: float) -> None:
        ...

Declare that a coordinate should be interpreted as height above a domain’s bottom surface.

Parameters
  • value float — The height value.

Interface

class Interface(builtins.object):
    def __init__(
        self,
        da: xarray.core.dataarray.DataArray,
        extender: Callable[
            [xarray.core.dataarray.DataArray, xarray.core.dataarray.DataArray],
            xarray.core.dataarray.DataArray,
        ] = salvus.utils.xarray_tools.extrude_like_and_pad,
        interpolation_method: Literal[("nearest", "linear")] = "linear",
    ) -> None:
        ...

Encapsulation of an interface dividing that can be used to divide layers.

Parameters
  • da xarray.core.dataarray.DataArray — The interface represented as a DataArray.
  • extender Callable[[xarray.core.dataarray.DataArray, xarray.core.dataarray.DataArray], xarray.core.dataarray.DataArray] — A function that can be used extend the boundaries of the interface past its defined extents.
  • interpolation_method Literal[('nearest', 'linear')] — The interpolation method used to evaluate the interface between grid points.
Attributes
da_absolute xarray.core.dataarray.DataArray

Get the DEM in absolute coordinates.

is_flat bool

Query whether the interface is flat.

max_elevation float

Get the interface’s maximum elevation.

min_elevation Union[float, salvus.mesh.layered_meshing.interface.Depth, salvus.mesh.layered_meshing.interface.Height]

Get the interface’s minimum elevation.

reference_elevation Union[float, salvus.mesh.layered_meshing.interface.Depth, salvus.mesh.layered_meshing.interface.Height]

Get the interface’s reference elevation.

Methods
from_dataarray()
def from_dataarray(
    da: xarray.core.dataarray.DataArray,
    extender: Callable[
        [xarray.core.dataarray.DataArray, xarray.core.dataarray.DataArray],
        xarray.core.dataarray.DataArray,
    ] = salvus.utils.xarray_tools.extrude_like_and_pad,
    interpolation_method: Literal[("nearest", "linear")] = "linear",
) -> Interface:
    ...

Construct a generic interface from an xarray DataArray.

Will dispatch to the appropriate interface type based on the DataArray’s dimension and heterogeneity (of lack thereof).

Parameters
  • da xarray.core.dataarray.DataArray — The data array.
  • extender Callable[[xarray.core.dataarray.DataArray, xarray.core.dataarray.DataArray], xarray.core.dataarray.DataArray] — A function that can be used extend the boundaries of the interface past its defined extents.
  • interpolation_method Literal[('nearest', 'linear')] — The interpolation method used to evaluate the interface between grid points.
Returns Interface — A new interface.
extrude_like_and_pad()
def extrude_like_and_pad(
    data: salvus.utils.xarray_tools.XrType,
    like: xarray.core.dataarray.DataArray,
) -> salvus.utils.xarray_tools.XrType:
    ...

Extrude like another data array and pad if necessary.

Parameters
  • data salvus.utils.xarray_tools.XrType — The input data array or set.
  • like xarray.core.dataarray.DataArray — The data array to extrude and pad like.
Returns salvus.utils.xarray_tools.XrType
interp_like()
def interp_like(
    self, like: xarray.core.dataarray.DataArray
) -> typing_extensions.Self:
    ...

Interpolate this interface onto another DataArray’s coordinates.

Will call the interface’s extend method to ensure that it spans the coordinates spanned by other with the desired expansion behavior.

Parameters
  • like xarray.core.dataarray.DataArray — The DataArray on which to interpolate this interface.
Returns typing_extensions.Self — A new interpolated interface.
map()
def map(
    self,
    f: Callable[
        [xarray.core.dataarray.DataArray], xarray.core.dataarray.DataArray
    ],
    as_type: Optional[Type] = None,
) -> Interface:
    ...

Apply a function that modifies the DataArray representation.

All attributes of the DataArray will be kept as is.

Parameters
  • f Callable[[xarray.core.dataarray.DataArray], xarray.core.dataarray.DataArray] — The function used to modify the DataArray. Must take and return a DataArray.
  • as_type Optional[Type] — Modify the type of the mapped DataArray. Useful for upcasting from a Hyperplane to a heterogeneous container, or vice versa.
Returns Interface — A new interface with a (potentially) modified DataArray representation.
map_representation()
def map_representation(
    self,
    f: Callable[
        [xarray.core.dataarray.DataArray], xarray.core.dataarray.DataArray
    ],
) -> typing_extensions.Self:
    ...

Transform this interface’s DataArray representation.

Parameters
  • f Callable[[xarray.core.dataarray.DataArray], xarray.core.dataarray.DataArray] — Function transform with.
Returns typing_extensions.Self — A new, transformed interface.

Relative

class Relative(builtins.float):
    def __init__(self):
        ...

Declare that a coordinate should be interpreted relative to its bounding interfaces.

Initialize self. See help(type(self)) for accurate signature.

Submodules