Version:

salvus.mesh.layered_meshing.interface

salvus.mesh.layered_meshing.interface salvus mesh layered_meshing interface
Classes for different types of interfaces.

Functions

extend_flat()

Extend an interface past its bounds via the extrusion of its boundaries.
SIGNATURE
def extend_flat(da: xr.DataArray, extend_to: xr.DataArray) -> xr.DataArray: ...
ARGUMENTS
Required
da
Type:xr.DataArray
Description:
The DataArray representing the interface to extend.
Required
extend_to
Type:xr.DataArray
Description:
Either a 1- or 2-D tuple of coordinates representing the new bounds.
RETURNS
Return type: xr.DataArray
The extended DataArray.

extend_spline()

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.
SIGNATURE
def extend_spline(
    da: xr.DataArray,
    extend_to: xr.DataArray,
    straight: float = 0.05,
    flat: float = 0.95,
    throw: float = 0.2,
) -> xr.DataArray: ...
ARGUMENTS
Required
da
Type:xr.DataArray
Description:
The DataArray representing the interface to extend.
Required
extend_to
Type:xr.DataArray
Description:
Either a 1- or 2-D tuple of coordinates representing the new bounds.
Optional
straight
Type:float
Default value:0.05
Description:
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.
Optional
flat
Type:float
Default value:0.95
Description:
Percentage of the extended domain after which the slope of the extension is 0.0 (flat). Defaults to 0.95.
Optional
throw
Type:float
Default value:0.2
Description:
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
Return type: xr.DataArray
The extended DataArray.

Classes

Depth

Declare that a coordinate should be interpreted as depth below a domain's top surface.
SIGNATURE
class Depth(salvus.mesh.layered_meshing.interface._ElevationAlgebra):
    def __init__(self, value: float) -> None: ...
ARGUMENTS
Required
value
Type:float
Description:
The depth value.

Height

Declare that a coordinate should be interpreted as height above a domain's bottom surface.
SIGNATURE
class Height(salvus.mesh.layered_meshing.interface._ElevationAlgebra):
    def __init__(self, value: float) -> None: ...
ARGUMENTS
Required
value
Type:float
Description:
The height value.

Interface

Encapsulation of an interface dividing that can be used to divide layers.
SIGNATURE
class Interface(builtins.object):
    def __init__(
        self,
        da: xr.DataArray,
        extender: typing.Callable[
            [xr.DataArray, xr.DataArray], xr.DataArray
        ] = salvus.utils.xarray_tools.extrude_like_and_pad,
        interpolation_method: typing.Literal["nearest", "linear"] = "linear",
    ) -> None: ...
ARGUMENTS
Required
da
Type:xr.DataArray
Description:
The interface represented as a DataArray.
Optional
extender
Type:typing.Callable[[xr.DataArray, xr.DataArray], xr.DataArray]
Default value:salvus.utils.xarray_tools.extrude_like_and_pad
Description:
A function that can be used extend the boundaries of the interface past its defined extents.
Optional
interpolation_method
Type:typing.Literal['nearest', 'linear']
Default value:'linear'
Description:
The interpolation method used to evaluate the interface between grid points.

Properties

  • da_absolute(xr.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(float)-Get the interface's minimum elevation.
  • reference_elevation(float)-Get the interface's reference elevation.

Class Methods

Interface.from_dataarray()
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).
SIGNATURE
def from_dataarray(
    da: xr.DataArray,
    extender: typing.Callable[
        [xr.DataArray, xr.DataArray], xr.DataArray
    ] = salvus.utils.xarray_tools.extrude_like_and_pad,
    interpolation_method: typing.Literal["nearest", "linear"] = "linear",
) -> Interface: ...
ARGUMENTS
Required
da
Type:xr.DataArray
Description:
The data array.
Optional
extender
Type:typing.Callable[[xr.DataArray, xr.DataArray], xr.DataArray]
Default value:salvus.utils.xarray_tools.extrude_like_and_pad
Description:
A function that can be used extend the boundaries of the interface past its defined extents.
Optional
interpolation_method
Type:typing.Literal['nearest', 'linear']
Default value:'linear'
Description:
The interpolation method used to evaluate the interface between grid points.

Methods

Interface.extrude_like_and_pad()
Extrude like another data array and pad if necessary.
SIGNATURE
def extrude_like_and_pad(
    data: XrType,
    like: xr.Dataset | xr.DataArray,
    rel_tol: float = 0.0001,
    update_bounds: bool = False,
) -> XrType: ...
ARGUMENTS
Required
data
Type:XrType
Description:
The input data array or set.
Required
like
Type:xr.Dataset | xr.DataArray
Description:
The data array to extrude and pad like.
Optional
rel_tol
Type:float
Default value:0.0001
Description:
This tolerance is used to determine whether extrusion needs to occur. It will be multiplied by the smallest difference between coordinate value in data. If data does not fully enclose like, but the difference in extents is less than this tolerance, then no extrusion will occur.
Optional
update_bounds
Type:bool
Default value:False
Description:
If True, adjust the coordinate bounds of data so that, for each coordinate, the minimum and maximum values are set to the most extreme values found in either data or like. This is useful for ensuring that small numerical differences (less than the threshold set by rel_tol) do not prevent the coordinates from being treated as matching, effectively "snapping" the bounds to a common range.
Interface.interp_like()
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.
SIGNATURE
def interp_like(self, like: xr.DataArray) -> typing.Self: ...
ARGUMENTS
Required
like
Type:xr.DataArray
Description:
The DataArray on which to interpolate this interface.
Interface.map()
Apply a function that modifies the DataArray representation.
All attributes of the DataArray will be kept as is.
SIGNATURE
def map(
    self,
    f: typing.Callable[[xr.DataArray], xr.DataArray],
    as_type: type | None = None,
) -> Interface: ...
ARGUMENTS
Required
f
Type:typing.Callable[[xr.DataArray], xr.DataArray]
Description:
The function used to modify the DataArray. Must take and return a DataArray.
Optional
as_type
Type:type | None
Default value:None
Description:
Modify the type of the mapped DataArray. Useful for upcasting from a Hyperplane to a heterogeneous container, or vice versa.
Interface.map_representation()
Transform this interface's DataArray representation.
SIGNATURE
def map_representation(
    self, f: typing.Callable[[xr.DataArray], xr.DataArray]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[xr.DataArray], xr.DataArray]
Description:
Function transform with.

Relative

Declare that a coordinate should be interpreted relative to its bounding interfaces.
SIGNATURE
class Relative(builtins.float):
    def __init__(self): ...

Submodules

PAGE CONTENTS