Mondaic

salvus.mesh.layered_meshing.interface.detail

salvus.mesh.layered_meshing.interface.detail salvus mesh layered_meshing interface detail

Implementation details for interfaces.

Functions

compute_reference_elevation()

def compute_reference_elevation(
    da: xr_tools.XrType, extents: tuple[float, float]
) -> xr_tools.XrType: ...

Compute the absolute reference elevations from depths or heights.

Parameters
  • da xr_tools.XrType — A dataset to compute the absolute coordinates for.
  • extents tuple[float, float] — The extents to concretize the reference coordinates against. Tuple should be (bottom, top).
Returns xr_tools.XrType — A new xarray representation with absolute coordinates.

compute_relative_coordinates()

def compute_relative_coordinates(
    da: xr_tools.XrType,
    extents: tuple[float, float],
    c: str,
    vb: tuple[float, float],
) -> xr_tools.XrType: ...

Expand relative coordinates to fill a layer.

The relative vertical coordinates for models should be specified in the range [0, 1] with 0 corresponding to the bottom interface and 1 to the top. This function serves to expand the vertical coordinates across the layer. It set the reference coordinate to the elevation of the bottom interface, and flags this value with _R as a message to future interpolation routines.

Parameters
  • da xr_tools.XrType — The model data array in relative coordinates.
  • extents tuple[float, float] — The extents of the target layer.
  • c str — The vertical coordinate.
  • vb tuple[float, float] — The vertical bounds of the entire domain.
Returns xr_tools.XrType — xarray_tools.XrType: description

get_bounds()

def get_bounds(
    i0: Interface, i1: Interface, db: domain.DomainBounds
) -> dict[str, tuple[float, float]]: ...

Get a dictionary with the bounds of the current layer.

The top and bottom bounds will be taken as the maximum / minimum extent of the interfaces, and the horizontal boundaries will be taken from the domain bounds.

Parameters
  • i0 Interface — The bottom interface.
  • i1 Interface — The top interface.
  • db domain.DomainBounds — The bounds of the domain.
Returns dict[str, tuple[float, float]] — The bounds of the layer as a dictionary.

interpolate()

def interpolate(i: Interface, hc: np.ndarray) -> np.ndarray: ...

Interpolate an interface onto horizontal coordinates.

Parameters
  • i Interface — The interface.
  • hc np.ndarray — The horizontal coordinates.
Returns np.ndarray — The interpolated interface relative to the reference elevation.

is_flat()

def is_flat(i: Interface) -> bool: ...

Determine whether or not an interface is flat.

Always returns true for Hyperplanes, returns True based on numpy’s isclose for other interface types.

Parameters
  • i Interface — The interface.
Returns bool — True if the interface is flat.

max_bounds_da()

def max_bounds_da(i0: Interface, i1: Interface, vc: str) -> xr.DataArray: ...

Given two interfaces, return their max bounds as a DataArray.

Parameters
  • i0 Interface — The lower interface.
  • i1 Interface — The upper interface.
  • vc str — The coordinate to compute the bounds over.
Returns xr.DataArray — An empty DataArray with the bounds.

thickness()

def thickness(
    bot: Interface,
    top: Interface,
    crd: np.ndarray,
    allow_crossing: bool = False,
) -> np.ndarray: ...

Compute the thickness between two interfaces.

Both interfaces will be interpolated onto a common grid before thickness is computed. Will throw if thickness is ever less than or equal to 0.0.

Parameters
  • bot Interface — The bottom interface.
  • top Interface — The top interface.
  • crd np.ndarray — The coordinates to interpolate onto.
  • allow_crossing bool — Don’t throw if thickness is less than or equal to 0.0.
Returns np.ndarray — An array with the thickness at each point in the passed coordinates.

thickness_ref()

def thickness_ref(bot: Interface, top: Interface) -> float: ...

Compute the distance between the reference elevations of two interfaces.

Parameters
  • bot Interface — The bottom interface.
  • top Interface — The top interface.
Returns float — The distance between the reference coordinates.

validate_interfaces()

def validate_interfaces(
    dim: types.Dim, interfaces: list[Interface]
) -> list[Interface]: ...

Ensure that an interface is consistent with a domain’s dimension.

Parameters
  • dim types.Dim — The domain’s dimension.
  • interfaces list[Interface] — The list of interfaces to validate.
Returns list[Interface] — A list of validated interfaces.