Write a field, or sequence of fields, to a CF compliant netCDF file.
NetCDF dimension and variable names will be taken from variables’ private attributes ncvar and the space 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 fields.
It does not matter if an input field’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 field if it had to be read during the write operation. However, if the repoint argument equals True then any data array elements of an input field and its components which are specified as file pointers (as opposed to arrays in memory) will be changed in place so that they are arrays in memory. For example, for a field, f:
>>> f.type()
[<type 'netCDF4.Variable'>]
>>> write(f, 'filename', repoint=True)
>>> f.type()
[<type 'netCDF4.Variable'>]
>>> write(f, 'filename', repoint=False)
>>> f.type()
[<type 'numpy.ndarray'>]
Identical field 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:
>>> f
[<CF Field: air_pressure(30, 24)>,
<CF Field: u_compnt_of_wind(19, 29, 24)>,
<CF Field: v_compnt_of_wind(19, 29, 24)>,
<CF Field: potential_temperature(19, 30, 24)>]
>>> write(f, 'file')