ncdata.dataset_like module#
An adaptor layer making a NcData appear like a netCDF4.Dataset
.
Allows an NcData
to masquerade as a
netCDF4.Dataset
object.
Note
This is a low-level interface, exposed publicly for extended experimental uses.
If you only want to convert Iris data to+from NcData
,
please use the functions in ncdata.iris
instead.
These classes contain NcData
and NcVariable
\s, but
emulate the access APIs of a netCDF4.Dataset
/ netCDF4.Variable
.
This is provided primarily to support a re-use of the iris.fileformats.netcdf
file format load + save, to convert cubes to+from ncdata objects (and hence, especially,
convert Iris Cube
\s to+from an Xarray Dataset
).
Notes
Currently only supports what is required for Iris load/save capability.
It should be possible to use these objects with other packages expecting a
netCDF4.Dataset
object, however the API simulation is far from complete, so
this may need to be extended, in future, to support other such uses.
- class ncdata.dataset_like.Nc4DatasetLike#
Bases:
_Nc4DatalikeWithNcattrs
An object which emulates a
netCDF4.Dataset
.It can be both read and written (modified) via its emulated
netCDF4.Dataset
-like API.The core NcData content, ‘self._ncdata’, is a
ncdata.NcData
. This completely defines the parent object state. If not provided on init, a new, empty dataset is created.- file_format = 'NETCDF4'#
- property groups#
- createVariable(varname, datatype, dimensions=(), fill_value=None, **kwargs)#
- sync()#
- close()#
- class ncdata.dataset_like.Nc4VariableLike#
Bases:
_Nc4DatalikeWithNcattrs
An object which contains a
ncdata.NcVariable
and emulates anetCDF4.Variable
.The core NcData content, ‘self._ncdata’, is a
NcVariable
. This completely defines the parent object state.The property “_data_array” is detected by Iris to do direct data transfer (copy-free and lazy-preserving). At present, this object emulates only the default read/write behaviour of a netCDF4 Variable, i.e. the underlying NcVariable contains a ‘raw’ data array, and the _data_array property interface applies/removes any scaling and masking as it is “seen” from the outside. That suits how Iris reads netCFD4 data, but it won’t work if the user wants to control the masking/saving behaviour, as you can do in netCDF4. Thus, at present, we do not provide any of set_auto_mask/scale/maskandscale.
- __init__(ncvar, datatype)#
- Parameters:
ncvar (NcVariable) –
datatype (dtype) –
- group()#
- property dtype#
- property dims#
- property ndim#
- property shape#
- property size#
- chunking()#
Return chunk sizes.
Actual datasets return a list of sizes by dimension, or ‘contiguous’.
For now, simply returns
None
. Could be replaced when required.
- class ncdata.dataset_like.Nc4DimensionLike#
Bases:
object
An object which emulates a
netCDF4.Dimension
object.The core NcData content, ‘self._ncdata’, is a
ncdata.NcDimension
. This completely defines the parent object state.- __init__(ncdim)#
- Parameters:
ncdim (NcDimension) –
- property name#
- property size#
- isunlimited()#
- group()#