Version:

salvus.data.io

salvus.data.io salvus data io
Functions for data I/O.

Functions

external_data_to_hdf5()

Write an xarray.Dataset to a Salvus compatible HDF5 file that can be added to a project.
SIGNATURE
def external_data_to_hdf5(
    data: xr.Dataset | xr.DataArray,
    receivers: list[_Base] | list[_BaseReceiver] | list[ReceiverChannel],
    output_filename: pathlib.Path | str,
) -> None: ...
ARGUMENTS
Required
data
Type:xr.Dataset | xr.DataArray
Description:
The data to write to the file.
Required
receivers
Type:list[_Base] | list[_BaseReceiver] | list[ReceiverChannel]
Description:
The corresponding Salvus receivers or receiver channels in the same order as the data (the first dimension in the data is the receiver index).
Required
output_filename
Type:pathlib.Path | str
Description:
Where to store the file.

get_built_in_topo_dataset_name()

Choose a dataset from Mondaic's built-in Earth topography files.
The dataset chosen will have the highest angular order available, with the caveat that at least 4 points in the mesh should sample the topography's highest wavenumber.
SIGNATURE
def get_built_in_topo_dataset_name(
    file_name: str | pathlib.Path,
    radius: float,
    edge_length: float,
    model_order: int,
) -> str: ...
ARGUMENTS
Required
file_name
Type:str | pathlib.Path
Description:
The name of the topography file.
Required
radius
Type:float
Description:
The radius of the planet.
Required
edge_length
Type:float
Description:
The maximum edge length at the mesh's top surface.
Required
model_order
Type:int
Description:
The order of the model representation.
RETURNS
Return type: str

get_dem()

Get the DEM from a hierarchical HDF5 file.
SIGNATURE
def get_dem(
    scale: float,
    varname: str,
    fname: str | pathlib.Path,
    min_phi: float | None = None,
    max_phi: float | None = None,
    min_theta: float | None = None,
    max_theta: float | None = None,
) -> tuple[npt.NDArray, npt.NDArray, npt.NDArray]: ...
ARGUMENTS
Required
scale
Type:float
Description:
Radius scale.
Required
varname
Type:str
Description:
Variable to get.
Required
fname
Type:str | pathlib.Path
Description:
The filename.
Optional
min_phi
Type:float | None
Default value:None
Description:
Minimum phi value.
Optional
max_phi
Type:float | None
Default value:None
Description:
Maximum phi value
Optional
min_theta
Type:float | None
Default value:None
Description:
Minimum theta value.
Optional
max_theta
Type:float | None
Default value:None
Description:
Maximum theta value.
RETURNS
Return type: tuple[npt.NDArray, npt.NDArray, npt.NDArray]

manage_topo_bounds()

Reset topography bounds if the 1st euler angle is nonzero.
A subtle issue exists in the computation of the domain for partial reads of topography files when euler angles are nonzero. In such cases we reset topographic bounds to their default value (None) which instructs the subsequent call to get_dem to ignore the partial read optimization and instead consider the entire file.
SIGNATURE
def manage_topo_bounds(
    euler_angles: tuple[typing.Any, typing.Any, typing.Any],
    min_phi: float | None,
    max_phi: float | None,
    min_theta: float | None,
    max_theta: float | None,
) -> tuple[float | None, float | None, float | None, float | None]: ...
ARGUMENTS
Required
euler_angles
Type:tuple[typing.Any, typing.Any, typing.Any]
Description:
The euler angles provided by the user.
Required
min_phi
Type:float | None
Description:
The computed minimum phi value of the bounding box.
Required
max_phi
Type:float | None
Description:
The computed maximum phi value of the bounding box.
Required
min_theta
Type:float | None
Description:
The computed minimum theta value of the bounding box.
Required
max_theta
Type:float | None
Description:
The computed maximum theta value of the bounding box.
RETURNS
Return type: tuple[float | None, float | None, float | None, float | None]
If the last euler angle is not None, or if it nonzero, reset the phi / theta values to None as well, otherwise return the phi / theta values as they were.

read_built_in_topo_dataset()

Read one of Mondaic's built-in topography datasets.
Generic implementation for surface topography, moho topography, and ocean bathymetry.
SIGNATURE
def read_built_in_topo_dataset(
    d: domain.dim3.SphericalDomain,
    file_name: str | pathlib.Path,
    dataset_name: str,
    radius: float,
) -> xr.DataArray: ...
ARGUMENTS
Required
d
Type:domain.dim3.SphericalDomain
Description:
The domain.
Required
file_name
Type:str | pathlib.Path
Description:
The topography file name.
Required
dataset_name
Type:str
Description:
The dataset name in the file.
Required
radius
Type:float
Description:
The radius of the spherical domain.
RETURNS
Return type: xr.DataArray

validate_external_data()

Validate an xarray.Dataset to ensure it can be written to a Salvus compatible HDF5 file.
SIGNATURE
def validate_external_data(data: xr.Dataset) -> xr.Dataset: ...
ARGUMENTS
Required
data
Type:xr.Dataset
Description:
Dataset to validate.
RETURNS
Return type: xr.Dataset

Used in tutorials

Functionality from this module is used in the following tutorials.
PAGE CONTENTS