cfdm.Field.nc_global_attributes

Field.nc_global_attributes(values=False)[source]

Returns properties to write 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.0

Parameters
values: bool, optional

Return the value (rather than None) for any global attribute that has, by definition, the same value as a construct property.

New in version (cfdm): 1.8.2

Returns
dict

The selection of properties requested for writing to netCDF global attributes.

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_global_attributes(values=True)
{'Conventions': 'CF-1.9', 'comment': 'global_comment', 'foo': 'bar'}
>>> f.nc_clear_global_attributes()
{'Conventions': None, 'comment': 'global_comment', 'foo': None}
>>> f.nc_global_attributes()
{}