cfdm.Domain.nc_set_global_attribute¶
-
Domain.
nc_set_global_attribute
(prop, value=None)[source]¶ Select a property to be written as a netCDF global attribute.
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.0
- Parameters
- prop:
str
Select the property to be written (if possible) as a netCDF global attribute.
- value: optional
The value of the netCDF global attribute, which will be created (if possible) in addition to the property as written to a netCDF data variable. If unset (or
None
) then this acts as an instruction to write the property (if possible) to a netCDF global attribute instead of to a netCDF data variable.
- prop:
- Returns
Examples
>>> f.nc_global_attributes() {'Conventions': None, 'comment': None} >>> f.nc_set_global_attribute('foo') >>> f.nc_global_attributes() {'Conventions': None, 'comment': None, 'foo': None} >>> f.nc_set_global_attribute('comment', 'global comment') >>> f.nc_global_attributes() {'Conventions': None, 'comment': 'global_comment', 'foo': None} >>> f.nc_clear_global_attributes() {'Conventions': None, 'comment': 'global_comment', 'foo': None} >>> f.nc_global_attributes() {}