libera_utils.io.netcdf.field_valid_range#

libera_utils.io.netcdf.field_valid_range(variable: Variable, *, source: str) → tuple[float, float]#

Return a field’s own valid_range attribute.

The range comes from the file rather than a hard-coded value, so a range the producer revises is applied as distributed, and a field with none raises rather than being checked against a guess. The pair is returned in the file’s order, which may be descending; apply_fill_and_valid_range() accepts either order.

Parameters:
  • variable (netCDF4.Variable) – The field being read.

  • source (str) – Name used in the error message (reader key and file).

Returns:

The two valid_range values, as floats.

Return type:

tuple[float, float]

Raises:

ValueError – If the field has no valid_range attribute, or it does not hold two values.