Mondaic

salvus.mesh.layered_meshing.interface.hyperplane

salvus.mesh.layered_meshing.interface.hyperplane salvus mesh layered_meshing interface hyperplane

An axis-aligned hyperplane.

Classes

Hyperplane

class Hyperplane(salvus.mesh.layered_meshing.interface.Interface):
    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: ...

An interface with a constant depth value.

If a standard float is used as the reference coordinate, its interpretation will be tied to the domain the interface is being applied to. For cartesian domains, a standard float defines a planar discontinuity perpendicular to the vertical coordinate (“y” in 2-D, “z” in 3-D) and located “c” meters away its origin. For spherical domains, it instead defines a spherical shell at radius “c”.

If one is instead interested in specifying a reference coordinate relative to the domain’s top surface, the “Depth” type can be passed instead. For example, in a 3-D Cartesian domain, calling interface.Hyperplane.at(1.0) will place an interface at z = 1.0, while calling interface.Hyperplane.at(Depth(1.0)) will place an interface 1.0 meters below the domain’s top surface. Behavior in spherical domains follow similarly, with the radial (“r”) coordinate acting as the vertical direction.

Parameters
  • da xr.DataArray — The interface represented as a DataArray.
  • extender typing.Callable[[xr.DataArray, xr.DataArray], xr.DataArray] — A function that can be used extend the boundaries of the interface past its defined extents.
  • interpolation_method typing.Literal['nearest', 'linear'] — The interpolation method used to evaluate the interface between grid points.
Attributes
attrs dict[str, str]

The hyperplane is fully determined by its xarray representation.

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.

Methods
at()
def at(c: float | Depth | Height) -> Hyperplane: ...

Specify a hyperplane interface at a vertical coordinate position.

Parameters
  • c float | Depth | Height — Hyperplane coordinate (absolute, height, or depth).
Returns Hyperplane — A new hyperplane.
from_dataarray()
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: ...

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 xr.DataArray — The data array.
  • extender typing.Callable[[xr.DataArray, xr.DataArray], xr.DataArray] — A function that can be used extend the boundaries of the interface past its defined extents.
  • interpolation_method typing.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: XrType,
    like: xr.Dataset | xr.DataArray,
    rel_tol: float = 0.0001,
    update_bounds: bool = False,
) -> XrType: ...

Extrude like another data array and pad if necessary.

Parameters
  • data XrType — The input data array or set.
  • like xr.Dataset | xr.DataArray — The data array to extrude and pad like.
  • rel_tol float — 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.
  • update_bounds bool — 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.
Returns XrType
interp_like()
def interp_like(self, like: xr.DataArray) -> typing.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 xr.DataArray — The DataArray on which to interpolate this interface.
Returns typing.Self — A new interpolated interface.
map()
def map(
    self,
    f: typing.Callable[[xr.DataArray], xr.DataArray],
    as_type: type | None = None,
) -> Interface: ...

Apply a function that modifies the DataArray representation.

All attributes of the DataArray will be kept as is.

Parameters
  • f typing.Callable[[xr.DataArray], xr.DataArray] — The function used to modify the DataArray. Must take and return a DataArray.
  • as_type type | None — 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: typing.Callable[[xr.DataArray], xr.DataArray]
) -> typing.Self: ...

Transform this interface’s DataArray representation.

Parameters
  • f typing.Callable[[xr.DataArray], xr.DataArray] — Function transform with.
Returns typing.Self — A new, transformed interface.