-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add example of apply_ufunc
#421
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
This looks great! I've added a comment to suggest a bit more motivation at the top of the notebook :) |
Thankyou for doing this Jemma! I think this could go in Tutorials rather than Examples ? (I will also point out xarray has a polyfit which does the same as the notebook :) ) If we move to the intake catalog, then the chunking warnings will go away :) And it would be good to fix up the figure to be tripole aware ... although I guess its not actually essential. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jemmajeffree thanks!
I pushed few edits... space after commas etc
the PR looks good to me! I run the notebook and it's all good!
I just don't understand what np.arange(sst.time.shape[0])/12
does...
Seems something hardcoded to me... something related with months (or the conspicuous coincidental 12)... but I have no idea.
If we can reduce the hardcoding it'd be great. Otherwise a comment next to it explaining what's happening will be useful for somebody reading this example down the road. But I am happy to merge this even as is rather than keep ruminating over details!
Also @ashjbarnes suggestion is nice. If you can incorporate this before merging it'd be nice! |
@jemmajeffree I think I'll include a sentence along what @ashjbarnes suggested and merge. Unless you plan to edit/work on this? |
(We can always open a new PR in the future and revisit-enhance the recipe!) |
I've updated the example here /g/data/x77/jj8842/cosima-recipes/Examples/Apply_scipy_function_to_every_gridpoint.ipynb, but I can't work out how to push it back to the PR and merge with existing changes here. I can try follow instructions, or I'm very happy to have someone else work out how to merge them again. I've: Also noting the comments by @anton-seaice, I know you could do this specific task faster with xr.polyfit, but some things you can't and linregress is an approachable example Feel free to rewrite any of my explanations, or add anything you think they're lacking |
We can zoom and I show you? |
oh I see... probably you can't push because I pushed few edits and you need to merge them! damn... I made it hard.... |
I'll sort it out! |
Thanks @navidcy for sorting that out! |
I've written up an example of how to calculate the trend and significance at each gridpoint using xr.apply_ufunc to pass things through to scipy.stats.linregress, so it's vectorised and much faster than using a for loop
Is this something that's of use to the COSIMA community?