CFA Datastore in Xarray

class cfapyx.datastore.CFADataStore(manager, group=None, mode=None, lock=CombinedLock([<SerializableLock: 09a3bd0a-976e-4e5e-9461-1374c163b681>, <SerializableLock: 9e3813d2-ee0a-485f-b4a1-8093662ae8c8>]), autoclose=False)[source]

DataStore container for the CFA-netCDF loaded file. Contains all unpacking routines directly related to the specific variables and attributes. The NetCDF4Datastore Xarray class from which this class inherits, has an __init__ method which cannot easily be overriden, so properties are used instead for specific variables that may be un-set at time of use.

property cfa_options

Property of the datastore that relates private option variables to the standard cfa_options parameter.

perform_decoding(array_shape, agg_data)[source]

Public method perform_decoding involves extracting the aggregated information parameters and assembling the required information for actual decoding.

get_variables()[source]

Fetch the netCDF4.Dataset variables and perform some CFA decoding if necessary.

ds is now a GroupedDatasetWrapper object from CFAPyX.group which has flattened the group structure and allows fetching of variables and attributes from the whole group tree from which a specific group may inherit.

Returns:

A FrozenDict Xarray object of the names of all variables, and methods to fetch those variables, depending on if those variables are standard NetCDF4 or CFA Aggregated variables.

get_attrs()[source]

Produce the FrozenDict of attributes from the NetCDF4.Dataset or CFAGroupWrapper in the case of using a group or nested group tree.

open_variable(name: str, var)[source]

Open a CFA-netCDF variable as either a standard NetCDF4 Datastore variable or as a CFA aggregated variable which requires additional decoding.

Parameters:
  • name – (str) A named NetCDF4 variable.

  • var – (obj) The NetCDF4.Variable object or a tuple with the contents (NetCDF4.Variable, cfa) where cfa is a bool that determines if the variable is a CFA or standard variable.

Returns:

The variable object opened as either a standard store variable or CFA aggregated variable.

open_cfa_variable(name: str, var)[source]

Open a CFA Aggregated variable with the correct parameters to create an Xarray Variable instance.

Parameters:
  • name – (str) A named NetCDF4 variable.

  • var – (obj) The NetCDF4.Variable object or a tuple with the contents (NetCDF4.Variable, cfa) where cfa is a bool that determines if the variable is a CFA or standard variable.

Returns:

An xarray Variable instance constructed from the attributes provided here, and data provided by a FragmentArrayWrapper which is indexed by Xarray’s LazilyIndexedArray class.