Skip to content

Disentangling the order in which constraints and callback are applied #3944

@SimonPeatman

Description

@SimonPeatman

📰 Custom Issue

I tried to run the following line of code and was surprised to find myself running into problems:

u_cubes = iris.load(filenames, domain & 'eastward_wind', callback=cb)

Here, domain is an iris.Constraint object and cb is a valid callback function. The callback function relies on the correct domain already having been extracted from the Cube, but this didn't happen! Therefore, I assume the callback function is applied first, then the constraint afterwards. However, only the 'eastward_wind' data were loaded from the file (other variables were also present) so in fact it seems to apply the string constraint first, then the callback function, then the Constraint object. I can work around this by putting cube = cube.extract(domain) at the top of the callback function, but Iris' behaviour seems counter-intuitive here.

  1. I couldn't see anything in the documentation about this, but I think this behaviour needs to be documented clearly.
  2. Is there any particular reason for the constraints and callback being applied in this order?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions