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

Smarter area weighted sum #1613

Closed
znicholls opened this issue Jun 6, 2022 · 6 comments · Fixed by #2139
Closed

Smarter area weighted sum #1613

znicholls opened this issue Jun 6, 2022 · 6 comments · Fixed by #2139
Labels
enhancement New feature or request

Comments

@znicholls
Copy link

Follows comment made here (other issues could also be spun out of that comment).

Is your feature request related to a problem? Please describe.

Currently, when doing an area-weighted sum, the units are not changed. They should be multiplied with area ** 2.

Would you be able to help out?

Yes, but this would not be a backwards compatible change so I would need guidance.

@znicholls
Copy link
Author

Would also provide a solution to #708 if solved I think

@znicholls
Copy link
Author

Was some discussion in #418 already

@bouweandela
Copy link
Member

Maybe it would be good to raise this issue with the iris developers too. We're using iris to compute area statistics and iris is supposed to handle metadata correctly for you (this is one of the big advantages of using iris over xarray), but apparently it doesn't.

@zklaus
Copy link

zklaus commented Jun 7, 2022

With regards to Iris, the thing is that the function takes the weights as an array, not as a cube or similar (coordinate, cell measure, ancillary variable), so they don't come with units and indeed Iris has no way of knowing that these particular weights happen to be areas. Of course, that could (and perhaps should?) be changed. Why not accept all those things I mentioned above and integrate proper unit handling?

@bouweandela
Copy link
Member

bouweandela commented Jun 7, 2022

Or maybe it could even be just a string: if the cube has a 'cell area' cell measure attached and I ask for

cube.collapsed(['latitude', 'longitude'], iris.analysis.SUM, weights='cell area')

shouldn't that just work? Instead of having to do:

cube.collapsed(['latitude', 'longitude'], iris.analysis.SUM, weights=cube.cell_measures('cell area').core_data())

@schlunma
Copy link
Contributor

I opened an issue in iris about this, already have a working solution 👍

SciTools/iris#5082

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants