Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aggregated_by/collapsed inconsistency for integer points #4455

Open
rcomer opened this issue Dec 8, 2021 · 3 comments
Open

aggregated_by/collapsed inconsistency for integer points #4455

rcomer opened this issue Dec 8, 2021 · 3 comments

Comments

@rcomer
Copy link
Member

rcomer commented Dec 8, 2021

🐛 Bug Report

Following on from #4315, #1528. When handling integer coordinates, collapsed and aggregated_by produce inconsistent points.

How To Reproduce

Minimal example:

import iris
import iris.cube
import iris.coords

import numpy as np

N = 6
cube = iris.cube.Cube(range(N), long_name="foo")
dim_coord = iris.coords.DimCoord(range(N), long_name="bar")
aux_coord = iris.coords.AuxCoord(np.arange(N) // 2, long_name="baz")

cube.add_dim_coord(dim_coord, 0)
cube.add_aux_coord(aux_coord, 0)

print(cube.aggregated_by("baz", iris.analysis.MEAN).coord("bar"))

# Emulate aggregated_by procedure with extract and collapsed.
for baz_val in np.unique(aux_coord.points):
    constraint = iris.Constraint(baz=baz_val)
    sub_cube = cube.extract(constraint)
    mean = sub_cube.collapsed("bar", iris.analysis.MEAN) 
    print(mean.coord("bar"))

"bar" coord after aggregated_by:

DimCoord(array([0.5, 2.5, 4.5]), bounds=array([[0, 1],
       [2, 3],
       [4, 5]]), standard_name=None, units=Unit('unknown'), long_name='bar')

"bar" coords after extract and collapse:

DimCoord(array([0]), bounds=array([[0, 1]]), standard_name=None, units=Unit('unknown'), long_name='bar')
DimCoord(array([2]), bounds=array([[2, 3]]), standard_name=None, units=Unit('unknown'), long_name='bar')
DimCoord(array([4]), bounds=array([[4, 5]]), standard_name=None, units=Unit('unknown'), long_name='bar')

Expected behaviour

The output points should either be 0, 2, 4 in both cases, or 0.5, 2.5, 4.5 in both cases. Note that @pp-mo at #1528 expected integer output points.

Environment

  • Iris Version: 3.2.dev0
@github-actions
Copy link
Contributor

In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity.

If this issue is still important to you, then please comment on this issue and the stale label will be removed.

Otherwise this issue will be automatically closed in 28 days time.

@github-actions github-actions bot added the Stale A stale issue/pull-request label Oct 29, 2023
@rcomer
Copy link
Member Author

rcomer commented Oct 29, 2023

We cannot do anything about this until next major release. Perhaps we should have the stalebot ignore issues with that label?

@github-actions github-actions bot removed the Stale A stale issue/pull-request label Oct 30, 2023
@rcomer
Copy link
Member Author

rcomer commented Oct 31, 2023

We cannot do anything about this until next major release. Perhaps we should have the stalebot ignore issues with that label?

#5559

@scitools-ci scitools-ci bot removed this from 🚴 Peloton Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants