Skip to content

redplanet.Crust.topo.get

get(
    lon: float | numpy.ndarray,
    lat: float | numpy.ndarray,
    as_xarray: bool = False,
) -> (
    float | numpy.ndarray | xarray.core.dataarray.DataArray
)

Get topography values at the specified coordinates. Dataset must be loaded first, see redplanet.Crust.topo.load(...).

Parameters:

Name Type Description Default
lon float | np.ndarray

Longitude coordinate(s) in range [-180, 360].

required
lat float | np.ndarray

Latitude coordinate(s) in range [-90, 90].

required
as_xarray bool

If True, return the data as an xarray.DataArray. Default is False.

False

Returns:

Type Description
float | np.ndarray | xr.DataArray

Data values at the the input coordinates. The return type is determined as follows:

  • float: if both lon and lat are floats.
  • numpy.ndarray (1D): if one of lon or lat is a numpy 1D array and the other is a float.
  • numpy.ndarray (2D): if both lon and lat are numpy 1D arrays. The first dimension of output array corresponds to lat values.
  • xarray.DataArray: see as_xarray parameter (this takes precedence over the above types).

Units are meters [m].

Source code in src/redplanet/Crust/topo/getter.py
@substitute_docstrings
def get(
    lon       : float | np.ndarray,
    lat       : float | np.ndarray,
    as_xarray : bool = False
) -> float | np.ndarray | xr.DataArray:
    """
    Get topography values at the specified coordinates. Dataset must be loaded first, see `redplanet.Crust.topo.load(...)`.

    Parameters
    ----------
    {param.lon}
    {param.lat}
    {param.as_xarray}

    Returns
    -------
    {return.GriddedData}

        Units are meters [m].
    """

    dat_topo = get_dataset()

    return dat_topo.get_values(
        lon = lon,
        lat = lat,
        var = 'topo',
        as_xarray = as_xarray,
    )