hydro.utils

Functions

_is_all_dataarray(val)

all_same(ndarr)

Test if all the values of an ndarray are the same value

add_profile_type(dataset, ftype)

Adds a profile_type string variable to the dataset.

add_geometry_var(dataset)

Adds a CF-1.8 Geometry container variable to the dataset

add_cdom_coordinate(dataset)

Find all the paraters in the cdom group and add their wavelength in a new coordinate

flatten_cdom_coordinate(dataset)

Takes the a dataset with a CDOM wavelength and explocdes it back into individual variables

extract_numeric_precisions(data)

Get the numeric precision of a printed decimal number

set_axis_attrs(dataset)

Set the CF axis attribute on our axis variables (XYZT)

set_coordinate_encoding_fill(dataset)

Sets the _FillValue encoidng to None for 1D coordinate vars

Module Contents

hydro.utils._is_all_dataarray(val)[source]
Parameters:

val (list[Any])

Return type:

TypeGuard[list[xarray.DataArray]]

hydro.utils.all_same(ndarr)[source]

Test if all the values of an ndarray are the same value

Parameters:

ndarr (numpy.ndarray)

Return type:

numpy.bool_

hydro.utils.add_profile_type(dataset, ftype)[source]

Adds a profile_type string variable to the dataset.

This is for ODV compatability

Warning

Currently mixed profile types are not supported

Parameters:
Return type:

xarray.Dataset

hydro.utils.add_geometry_var(dataset)[source]

Adds a CF-1.8 Geometry container variable to the dataset

This allows for compatabiltiy with tools like gdal

Parameters:

dataset (xarray.Dataset)

Return type:

xarray.Dataset

hydro.utils.add_cdom_coordinate(dataset)[source]

Find all the paraters in the cdom group and add their wavelength in a new coordinate

Parameters:

dataset (xarray.Dataset)

Return type:

xarray.Dataset

hydro.utils.flatten_cdom_coordinate(dataset)[source]

Takes the a dataset with a CDOM wavelength and explocdes it back into individual variables

Parameters:

dataset (xarray.Dataset)

Return type:

xarray.Dataset

hydro.utils.extract_numeric_precisions(data)[source]

Get the numeric precision of a printed decimal number

Parameters:

data (list[str] | numpy.typing.NDArray[numpy.str_])

Return type:

numpy.typing.NDArray[numpy.int_]

hydro.utils.set_axis_attrs(dataset)[source]

Set the CF axis attribute on our axis variables (XYZT)

  • longitude = “X”

  • latitude = “Y”

  • pressure = “Z”, addtionally, positive is down

  • time = “T”

Parameters:

dataset (xarray.Dataset)

Return type:

xarray.Dataset

hydro.utils.set_coordinate_encoding_fill(dataset)[source]

Sets the _FillValue encoidng to None for 1D coordinate vars

Parameters:

dataset (xarray.Dataset)

Return type:

xarray.Dataset