hydro.exchange¶
Submodules¶
Attributes¶
Classes¶
Dataclass containing exchange data which has been parsed into ndarrays |
|
Low level dataclass containing the parts of an exchange file |
|
Flags and config that controll how strict the file checks are |
Functions¶
|
|
|
|
|
|
|
|
|
Turn the ancillary variable attr into a space seperated string |
|
Combine the bottle dates and times if present |
|
Ensure that the shape of the data in a2 is a subset (or strict subset) of the data shape of a1 |
|
|
|
|
|
|
|
Loads the data from filename_or_obj and returns a xr.Dataset with the CCHDO |
|
Package Contents¶
- hydro.exchange._get_params(params_units, ignore_params=None)[source]¶
- Parameters:
params_units (collections.abc.Iterable[str])
ignore_params (collections.abc.Iterable[str] | None)
- Return type:
tuple[WHPNameIndex, WHPNameIndex, WHPNameIndex]
- hydro.exchange.finalize_ancillary_variables(dataset)[source]¶
Turn the ancillary variable attr into a space seperated string
It is nice to have the ancillary variable be a list while things are being read into it
- Parameters:
dataset (xarray.Dataset)
- hydro.exchange.combine_bottle_time(dataset)[source]¶
Combine the bottle dates and times if present
Raises if only one is present
- Parameters:
dataset (xarray.Dataset)
- hydro.exchange.check_is_subset_shape(a1, a2, strict='disallowed')[source]¶
Ensure that the shape of the data in a2 is a subset (or strict subset) of the data shape of a1
For a given set of param, flag, and error arrays you would want to ensure that:
errors are a subset of params (strict is allowed)
params are a subset of flags (strict is allowed)
For string vars, the empty string is considered the “nothing” value. For woce flags, flag 9s should be converted to nans (depending on scheme flag 5 and 1 may not have param values)
Return a boolean array of invalid locations
- Parameters:
a1 (numpy.typing.NDArray)
a2 (numpy.typing.NDArray)
- Return type:
numpy.typing.NDArray[numpy.bool_]
- class hydro.exchange._ExchangeData[source]¶
Dataclass containing exchange data which has been parsed into ndarrays
- set_expected(params, flags, errors)[source]¶
Puts fill columns for expected params which are missing
This can occur when there are disjoint columns in CTD files
- class hydro.exchange._ExchangeInfo[source]¶
Low level dataclass containing the parts of an exchange file
- _ignore_columns: collections.abc.Iterable[str] = ()[source]¶
- property units[source]¶
Returns a list of all the units in the file (including CTD “headers”)
Will have the same shape as params
- property data[source]¶
Returns the data block of an exchange file as a tuple of strs. One line per entry.
- property _whp_param_info[source]¶
Parses the params and units for base parameters
Returns a dict with a WHPName to column index mapping
- property whp_flags[source]¶
Parses the params and units for flag values
returns a dict with a WHPName to column index of flags mapping
- property whp_errors[source]¶
Parses the params and units for uncertanty values
returns a dict with a WHPName to column index of errors mapping
- hydro.exchange._is_valid_exchange_numeric(data)[source]¶
- Parameters:
data (numpy.typing.NDArray[numpy.str_])
- Return type:
numpy.bool_
- hydro.exchange._load_raw_exchange(filename_or_obj, *, file_seperator=None, keep_seperator=True, encoding='utf8')[source]¶
- class hydro.exchange.CheckOptions[source]¶
Bases:
TypedDictFlags and config that controll how strict the file checks are
- hydro.exchange.read_csv(filename_or_obj, *, fill_values=('-999',), ftype=FileType.BOTTLE, checks=None, precision_source=PrecisionSource.FILE, encoding='utf8', ignore_columns=None)[source]¶
- Parameters:
filename_or_obj (ExchangeIO)
ftype (cchdo.hydro.types.FileTypeType)
checks (CheckOptions | None)
precision_source (cchdo.hydro.types.PrecisionSourceType)
ignore_columns (collections.abc.Iterable[str] | None)
- Return type:
- hydro.exchange.read_exchange(filename_or_obj, *, fill_values=('-999',), checks=None, precision_source=PrecisionSource.FILE, file_seperator=None, keep_seperator=True, encoding='utf8', ignore_columns=None)[source]¶
Loads the data from filename_or_obj and returns a xr.Dataset with the CCHDO CF/netCDF structure
- Parameters:
filename_or_obj (ExchangeIO)
checks (CheckOptions | None)
precision_source (cchdo.hydro.types.PrecisionSourceType)
ignore_columns (collections.abc.Iterable[str] | None)
- Return type:
- hydro.exchange._from_exchange_data(exchange_data, *, ftype=FileType.BOTTLE, checks=None)[source]¶
- Parameters:
exchange_data (list[_ExchangeData])
ftype (cchdo.hydro.types.FileTypeType)
checks (CheckOptions | None)
- Return type: