cf.Field.del_construct¶
-
Field.
del_construct
(identity, default=ValueError())[source]¶ Remove a metadata construct.
If a domain axis construct is selected for removal then it can’t be spanned by any metdata construct data, nor the field construct’s data; 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. In this case the reference is replace with
None
.New in version 3.0.0.
See also
Parameters: - identity:
Select the construct to removed. Must be
- The identity or key of a metadata construct.
A construct identity is specified by a string (e.g.
'latitude'
,'long_name=time'
,'ncvar%lat'
, etc.); aQuery
object (e.g.cf.eq('longitude')
); or a compiled regular expression (e.g.re.compile('^atmosphere')
) that selects the relevant constructs whose identities match viare.search
.A construct has a number of identities, and is selected if any of them match any of those provided. A construct’s identities are those returned by its
identities
method. In the following example, the constructx
has six identities:>>> x.identities() ['time', 'long_name=Time', 'foo=bar', 'standard_name=time', 'ncvar%t', T']
A construct key may optionally have the
'key%'
prefix. For example'dimensioncoordinate2'
and'key%dimensioncoordinate2'
are both acceptable keys.Note that in the output of a
print
call ordump
method, a construct is always described by one of its identities, and so this description may always be used as an identity argument.- Parameter example:
identity='measure:area'
- Parameter example:
identity='cell_area'
- Parameter example:
identity='long_name=Cell Area'
- Parameter example:
identity='cellmeasure1'
- default: optional
Return the value of the default parameter if the construct can not be removed, or does not exist. If set to an
Exception
instance then it will be raised instead.
Returns: The removed metadata construct.
Examples:
>>> f.del_construct('X') <CF DimensionCoordinate: grid_latitude(111) degrees>