cf.Domain.del_domain_axis

Domain.del_domain_axis(identity=None, squeeze=False, default=ValueError())[source]

Remove a domain axis construct.

In general, a domain axis construct can only be removed if it is not spanned by any construct’s data. However, a size 1 domain axis construct can be removed in any case if the squeeze parameter is set to True. In this case, a metadata construct whose data spans only the removed domain axis construct will also be removed.

New in version 3.6.0.

See also

del_construct

Parameters
identity: optional

Select the domain axis construct by one of:

  • An identity or key of a 1-d dimension or auxiliary coordinate construct that whose data spans the domain axis construct.

    A construct has a number of string-valued identities

defined by its identities method, and is selected if any of them match the identity parameter. identity may be a string that equals one of a construct’s identities; or a re.Pattern object that matches one of a construct’s identities via re.search.

Note that in the output of a dump method or print call, a metadata construct is always described by one of its identities, and so this description may always be used as an identity value.

  • A domain axis construct identity.

    A domain axis construct has a number of string-valued

identities (defined by its identities method) and is selected if any of them match the identity parameter. identity may be a string that equals one of a construct’s identities; or a re.Pattern object that matches one of a construct’s identities via re.search.

  • The key of a domain axis construct.

  • None. This is the default, which selects the domain axis construct when there is only one of them. 'key%dimensioncoordinate2' are both acceptable keys.

Parameter example:

identity='long_name=Latitude'

Parameter example:

identity='dimensioncoordinate1'

Parameter example:

identity='domainaxis2'

Parameter example:

identity='key%domainaxis2'

Parameter example:

identity='ncdim%y'

squeeze: bool, optional

If True then allow the removal of a size 1 domain axis construct that is spanned by any data array and squeeze the corresponding dimension from those arrays.

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
DomainAxis

The removed domain axis construct.

Examples

>>> f = cf.example_field(0)
>>> g = f[0]
Field: specific_humidity (ncvar%q)
----------------------------------
Data            : specific_humidity(latitude(1), longitude(8)) 1
Cell methods    : area: mean
Dimension coords: latitude(1) = [-75.0] degrees_north
                : longitude(8) = [22.5, ..., 337.5] degrees_east
                : time(1) = [2019-01-01 00:00:00]
>>> g.del_domain_axis('Y', squeeze=True)
<CF DomainAxis: size(1)>
>>> print(g)
Field: specific_humidity (ncvar%q)
----------------------------------
Data            : specific_humidity(longitude(8)) 1
Cell methods    : area: mean
Dimension coords: longitude(8) = [22.5, ..., 337.5] degrees_east
                : time(1) = [2019-01-01 00:00:00]
>>> g.del_domain_axis('T', squeeze=True)
<CF DomainAxis: size(1)>
>>> print(g)
Field: specific_humidity (ncvar%q)
----------------------------------
Data            : specific_humidity(longitude(8)) 1
Cell methods    : area: mean
Dimension coords: longitude(8) = [22.5, ..., 337.5] degrees_east