Write a space, or sequence of spaces, to a CF compliant netCDF file.
NetCDF dimension and variable names will be taken from the attributes ncvar and nc_dimensions if present, otherwise they are inferred from standard_name attributes or set to defaults. NetCDF names may be automatically given a numerical suffix to avoid duplication.
Output netCDF file global attributes are those which occur in the set of CF global attributes and non-standard data variable attributes and which have equal values across all input spaces.
It is possible to write only a subset of the input spaces by providing phenomena conditions with **kwargs parameters.
It does not matter if an input space’s data has not yet been read into memory. The write operation will automatically read the data array from disk if required, but the default is for it not to be saved in the input space if it had to be read during the write operation. However, if the data argument equals True then any input spaces which didn’t contain their full data arrays in memory will be changed in place so that they do. For example, for a space, s:
>>> s.type
<type 'netCDF4.Variable'>
>>> write(s, 'filename')
>>> s.type
<type 'netCDF4.Variable'>
>>> write(s, 'filename', data=True)
>>> s.type
<type 'numpy.ndarray'>
Identical grid components (as determined by their numerically tolerant equals() methods) are only written to the file once, apart from when they need to fulfil both dimension coordinate and auxiliary coordinate roles for different data variables.
If a coordinate with a transform attribute is fully specified by another coordinate’s transformation then it will be not written to the file.
Parameters: |
|
---|
Examples
>>> s
[<CF Space: air_pressure(30, 24)>,
<CF Space: u_compnt_of_wind(19, 29, 24)>,
<CF Space: v_compnt_of_wind(19, 29, 24)>,
<CF Space: potential_temperature(19, 30, 24)>]
>>> write(s, 'file')
>>> write(s, 'file', standard_name = 'air_pressure')
See also
cf.Space.extract() for more examples of space selection by phenomena criteria.