Write a space, or sequence of spaces, to a CF compliant netCDF file.
NetCDF dimension and variable names will be taken from variables’ private attributes ncvar and the grid attribute nc_dimensions if present, otherwise they are inferred from standard names 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 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.
Parameters: |
|
---|---|
Returns: | None |
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')