hydro.accessors#

Module Contents#

Classes#

CCHDOAccessorBase

Class base for CCHDO accessors

MatlabAccessor

Accessor containing the experimental matlab machinery

LegacyFormatAccessor

Accessor containing legacy format outputs (coards, woce)

GeoAccessor

Accessor providing geo_interface machinery

MiscAccessor

Accessor with misc functions that don't fit in some other category

ExchangeAccessor

Class containing the to_exchange functionn

WHPIndxer

MergeFQAccessor

Class base for CCHDO accessors

CCHDOAccessor

Collect all the accessors into a single class

Functions#

write_or_return(data[, path_or_fobj])

Attributes#

hydro.accessors.FLAG_NAME = 'cchdo.hydro._qc'[source]#
hydro.accessors.ERROR_NAME = 'cchdo.hydro._error'[source]#
hydro.accessors.PathType[source]#
hydro.accessors.write_or_return(data, path_or_fobj=None)[source]#
Parameters:
Return type:

Optional[bytes]

class hydro.accessors.CCHDOAccessorBase(xarray_obj)[source]#

Class base for CCHDO accessors

saves the xarray object to self._obj for all the subclasses

Parameters:

xarray_obj (Union[xarray.DataArray, xarray.Dataset]) –

class hydro.accessors.MatlabAccessor(xarray_obj)[source]#

Bases: CCHDOAccessorBase

Accessor containing the experimental matlab machinery

Parameters:

xarray_obj (Union[xarray.DataArray, xarray.Dataset]) –

to_mat(fname)[source]#

Experimental Matlab .mat data file generator

The support for netCDF files in Matlab is really bad. Matlab also has no built in support for the standards we are trying to follow (CF, ACDD), the most egregious lack of support is how to deal with times in netCDF files. This was an attempt to make a mat file which takes care of some of the things matlab won’t do for you. It requires scipy to function.

The file it produces is in no way stable.

class hydro.accessors.LegacyFormatAccessor(xarray_obj)[source]#

Bases: CCHDOAccessorBase

Accessor containing legacy format outputs (coards, woce)

Parameters:

xarray_obj (Union[xarray.DataArray, xarray.Dataset]) –

to_coards(path=None)[source]#
to_woce(path=None)[source]#
to_sum(path=None)[source]#

netCDF to WOCE sumfile maker

This is missing some information that is not included anymore (wire out, height above bottom). It is especially lacking in including woce parameter IDs

class hydro.accessors.GeoAccessor(xarray_obj)[source]#

Bases: CCHDOAccessorBase

Accessor providing geo_interface machinery

Parameters:

xarray_obj (Union[xarray.DataArray, xarray.Dataset]) –

property __geo_interface__[source]#

The station positions as a MultiPoint geo interface

See https://gist.github.com/sgillies/2217756

property track[source]#

A dict which can be dumped to json which conforms to the expected structure for the CCHDO website

class hydro.accessors.MiscAccessor(xarray_obj)[source]#

Bases: CCHDOAccessorBase

Accessor with misc functions that don’t fit in some other category

Parameters:

xarray_obj (Union[xarray.DataArray, xarray.Dataset]) –

static _gen_fname(expocode, station, cast, profile_type, profile_count=1, ftype='cf')[source]#
Parameters:
Return type:

str

gen_fname(ftype='cf')[source]#

Generate a human friendly netCDF filename for this object

Return type:

str

compact_profile()[source]#

Drop the trailing empty data from a profile.

Because we use the incomplete multidimensional array representation of profiles there is often “wasted space” at the end of any profile that is not the longest one. This accessor drops that wasted space for xr.Dataset objects containing a single profile

class hydro.accessors.ExchangeAccessor(xarray_obj)[source]#

Bases: CCHDOAccessorBase

Class containing the to_exchange functionn

Parameters:

xarray_obj (Union[xarray.DataArray, xarray.Dataset]) –

property file_type[source]#
date_names[source]#
time_names[source]#
static cchdo_c_format_precision(c_format)[source]#
Parameters:

c_format (str) –

Return type:

Optional[int]

_make_params_units_line(params)[source]#
Parameters:

params (Dict[cchdo.params.WHPName, xarray.DataArray]) –

static _whpname_from_attrs(attrs)[source]#
Return type:

List[cchdo.params.WHPName]

_make_ctd_headers(params)[source]#
Return type:

List[str]

_make_data_block(params)[source]#
Return type:

List[str]

_get_comments()[source]#
to_whp_columns(compact=False)[source]#
to_exchange(path=None)[source]#

Convert a CCHDO CF netCDF dataset to exchange

class hydro.accessors.WHPIndxer(obj)[source]#
Parameters:

obj (xarray.Dataset) –

__getitem__(key)[source]#
class hydro.accessors.MergeFQAccessor(xarray_obj)[source]#

Bases: CCHDOAccessorBase

Class base for CCHDO accessors

saves the xarray object to self._obj for all the subclasses

Parameters:

xarray_obj (Union[xarray.DataArray, xarray.Dataset]) –

merge_fq(fq, *, check_flags=True)[source]#
class hydro.accessors.CCHDOAccessor(xarray_obj)[source]#

Bases: ExchangeAccessor, GeoAccessor, LegacyFormatAccessor, MatlabAccessor, MiscAccessor, MergeFQAccessor

Collect all the accessors into a single class

Parameters:

xarray_obj (Union[xarray.DataArray, xarray.Dataset]) –