cf.Field.nc_set_global_attributes¶
-
Field.
nc_set_global_attributes
(properties, copy=True)[source]¶ Set properties to be written as netCDF global attributes.
When multiple field constructs are being written to the same file, it is only possible to create a netCDF global attribute from a property that has identical values for each field construct. If any field construct’s property has a different value then the property will not be written as a netCDF global attribute, even if it has been selected as such, but will appear instead as attributes on the netCDF data variables corresponding to each field construct.
The standard description-of-file-contents properties are always written as netCDF global attributes, if possible, so selecting them is optional.
New in version (cfdm): 1.7.10
- Parameters
- properties:
dict
Set the properties be written as a netCDF global attribute from the dictionary supplied. The value of a netCDF global attribute, which will be created (if possible) in addition to the property as written to a netCDF data variable. If a value of
None
is used then this acts as an instruction to write the property (if possible) to a netCDF global attribute instead of to a netCDF data variable.- Parameter example:
properties={'Conventions': None, 'project': 'research'}
- copy:
bool
, optional If False then any property values provided by the properties parameter are not copied before insertion. By default they are deep copied.
- properties:
- Returns
Examples
>>> f.nc_global_attributes() {'Conventions': None, 'comment': None} >>> f.nc_set_global_attributes({}) >>> f.nc_set_global_attributes({'foo': None}) >>> f.nc_global_attributes() {'Conventions': None, 'comment': None, 'foo': None} >>> f.nc_set_global_attributes('comment', 'global comment') >>> f.nc_global_attributes() {'Conventions': None, 'comment': 'global_comment', 'foo': None} >>> f.nc_set_global_attributes('foo', 'bar') >>> f.nc_global_attributes() {'Conventions': None, 'comment': 'global_comment', 'foo': 'bar'}