Skip to content

Allow relaxed_units in cf.aggregate to cope with invalid (in addition to missing) units #602

@davidhassell

Description

@davidhassell

Currently, the relaxed_units keyword to cf.aggregate copes with missing units (i.e. cf.units()), but not invalid but otherwise equal units:

>>> # 3.14.0 behaviour
>>> f = cf.example_field(0)
>>> bad_units = cf.Units("bad-units")
>>  f.override_units(bad_units, inplace=True)
>>> g = f[:2]
>>> h = f[2:]
>>> i = cf.aggregate([g, h], relaxed_units=True)
[<CF Field: specific_humidity(latitude(2), longitude(8)) bad-units>,
 <CF Field: specific_humidity(latitude(3), longitude(8)) bad-units>]

It would be good to extend the functionality to include this case:

>>> # Desired new behaviour
>>> i = cf.aggregate([g, h], relaxed_units=True)
[<CF Field: specific_humidity(latitude(5), longitude(8)) bad-units>]

Metadata

Metadata

Assignees

No one assigned

    Labels

    aggregationRerlating to metadata-based field and domain aggregationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions