Handling netCDF4 Groups in cfapyx

Note

The Xarray package currently does not handle multiple NetCDF groups in the same way as other packages like cf-python. In Xarray, a group can be extracted from a NetCDF file as an enclosed Dataset object, but typically only the group content is retrieved. Any so-called global dimensions/attributes are not loaded.

In cfapyx, the global and group parameters are both loaded into the final dataset, such that any parameters which are shared between groups can be accessed. This is vital in particular for decoding grouped aggregated variables, where the aggregated variables link to global parameters.

In order to facilitate loading both global and group parameters from the CFA dataset, a small change to the standard NetCDF4ArrayWrapper class from Xarray, where an attempt is made to load the variable from the group dataset first, but if this is unsuccessful then the global dataset is used.

class cfapyx.group.VariableWrapper(prop_sets)[source]

Wrapper object for the ds.variables and ds.attributes objects which can handle either global or group based variables .

keys()[source]

Requesting the set of keys should return the set of both keys combined in a dict_keys object.

class cfapyx.group.CFAGroupWrapper(var_sets, ds_sets)[source]

Wrapper object for the CFADataStore ds parameter, required to bypass the issue with groups in Xarray, where all variables outside the group are ignored.