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

Inefficient mask construction in Cross-contour_transport.ipynb #179

Closed
navidcy opened this issue Nov 21, 2022 · 3 comments
Closed

Inefficient mask construction in Cross-contour_transport.ipynb #179

navidcy opened this issue Nov 21, 2022 · 3 comments
Labels
💻 hackathon 2.0 like the 1.0 but better

Comments

@navidcy
Copy link
Collaborator

navidcy commented Nov 21, 2022

The Documented example Cross-contour_transport.ipynb creates masks in a very inefficient way (using nested for loops). A more efficient way would be to utilize xarray's functionality

by @angus-g

You could probably use boolean masks (just compare the entire array with mask_value), and DataArray.shift() or DataArray.roll() from each of the directions to generate the masks without using loops.

@adele-morrison
Copy link
Collaborator

True that this is very inefficient. But in this code, the mask is only computed once and then the very expensive part is calculating the cross-contour transport (often using daily output). Unless changing the mask code is really easy for someone to do, I don't think it's worth the effort for the time it would save us.

@adele-morrison
Copy link
Collaborator

I'm closing this issue. The code mentioned in this issue only takes 25s and only has to be done once and then the mask is usually saved to file. There is another cell in this script (calculating the distance along contour) which takes 10 minutes. I think it's more worthwhile that we spend our efforts fixing that distance code instead of this mask code.

@claireyung
Copy link
Collaborator

I agree it's less of a priority! Only thing I could think that it might be useful for is if you want to calculate transport over a moving SSH contour e.g. at daily resolution or something for a more Lagrangian approach, but that's probably too big a task for cosima recipes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 hackathon 2.0 like the 1.0 but better
Development

No branches or pull requests

4 participants