cf.Field.del_construct¶
-
Field.del_construct(*identity, default=ValueError(), **filter_kwargs)[source]¶ Remove a metadata construct.
If a domain axis construct is selected for removal then it can’t be spanned by any data arrays of the field nor metadata constructs, nor be referenced by any cell method constructs. However, a domain ancillary construct may be removed even if it is referenced by coordinate reference construct.
New in version (cfdm): 1.7.0
See also
- Parameters
- identity:
Select the unique construct that has the identity, defined by its
identitiesmethod, that matches the given values.Additionally, the values are matched against construct identifiers, with or without the
'key%'prefix.A value may be any object that can match via the
==operator, or are.Patternobject that matches via itssearchmethod.Note that in the output of a
dumpmethod orprintcall, a construct is always described by an identity that will select it.- default: optional
Return the value of the default parameter if the data axes have not been set.
If set to an
Exceptioninstance then it will be raised instead.- filter_kwargs: optional
Keyword arguments as accepted by
Constructs.filterthat define additional construct selection criteria.New in version (cfdm): 1.8.9.0
- Returns
The removed metadata construct.
Examples
>>> f = cf.example_field(0) >>> print(f) Field: specific_humidity (ncvar%q) ---------------------------------- Data : specific_humidity(latitude(5), longitude(8)) 1 Cell methods : area: mean Dimension coords: latitude(5) = [-75.0, ..., 75.0] degrees_north : longitude(8) = [22.5, ..., 337.5] degrees_east : time(1) = [2019-01-01 00:00:00] >>> f.del_construct('time') <CF DimensionCoordinate: time(1) days since 2018-12-01 > >>> f.del_construct('time') Traceback (most recent call last): ... ValueError: Can't remove non-existent construct 'ti >>> f.del_construct('time', default='No time') 'No time' >>> f.del_construct('dimensioncoordinate1') <CF DimensionCoordinate: longitude(8) degrees_east> >>> print(f) Field: specific_humidity (ncvar%q) ---------------------------------- Data : specific_humidity(latitude(5), ncdim%lon(8)) 1 Cell methods : area: mean Dimension coords: latitude(5) = [-75.0, ..., 75.0] degrees_north