-
Notifications
You must be signed in to change notification settings - Fork 44
More lazy extract_levels preprocessor function
#2120
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
Conversation
|
cheers muchly for starting this @bouweandela 🍺 I am testing with @ledm 's used case: import iris
from esmvalcore.preprocessor._regrid import extract_levels
fn = "/badc/cmip6/data/CMIP6/CMIP/MOHC/UKESM1-0-LL/historical/r2i1p1f2/Omon/po4/gn/v20190708/po4_Omon_UKESM1-0-LL_historical_r2i1p1f2_gn_200001-201412.nc"
cube= iris.load_cube(fn)
c2 = extract_levels(cube, scheme='nearest', levels = [0.1 ,])which with |
|
@bouweandela your code changes are are proving to be absolutele memory-savers, bud! I tested again with @ledm 's minimal case above, and now the run goes fine, needing order 300M of memory, as compared to a needed allocation of 12G as per file 🍺 🍺 🍺 @ledm you may want to grab this one to save you tons of memory (if you are not using altitude-pressure conversions which are still realized in memory 👍 |
|
Yes, this should work for normal use cases and possibly also with the altitude - pressure conversion. However, it does not work for derived coordinates like hybrid sigma because these end up with really large chunks (the example I saw had 14 GB chunks). I suspect that is an iris issue though, but need more time to investigate. |
|
OK how about we merge this as is (needs a couple tests, I can do that) with the caveat emptor to be solved that derived coords need lazy-ing? |
|
This is great - thanks! It seems to fix the minimal test case. I'll check the full run next! |
Nope, failed again with the same error. Starting to think this is something else? |
Opened an issue about this in Iris: SciTools/iris#5457 |
It would be great if you have time to finish this pull request |
|
OK I'll have a look this week then, bud 🍺 |
|
Uploading coverage to Codecov is failing for some reason, even if their status page reports all systems are online. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2120 +/- ##
==========================================
+ Coverage 94.08% 94.11% +0.02%
==========================================
Files 240 240
Lines 13308 13363 +55
==========================================
+ Hits 12521 12576 +55
Misses 787 787 ☔ View full report in Codecov by Sentry. |
|
@schlunma @valeriupredoi @ledm I think I have now fixed all the issues with making the |
schlunma
left a comment
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.
Thanks @bouweandela, code looks good!
Will test this with real data now.
|
Just tested this with a real recipe (see below) that covers all cases (regular pressure level coordinate, hybrid height coordinate, conversion altitude -> air pressure). Everything works well! 🚀 Without this PR, the recipe hangs indefinitely; with this PR, the recipe finishes in ~2 min when a reasonably high amount of memory is used: cluster:
type: distributed.LocalCluster
n_workers: 3
threads_per_worker: 4
memory_limit: 10 GiBRecipe# ESMValTool
---
documentation:
title: Test
description: test
authors:
- schlund_manuel
datasets:
- {project: CMIP6, dataset: MPI-ESM1-2-HR, exp: historical, ensemble: r1i1p1f1, grid: gn}
- {project: CMIP6, dataset: MPI-ESM1-2-LR, exp: historical, ensemble: r1i1p1f1, grid: gn}
- {project: CMIP6, dataset: HadGEM3-GC31-LL, exp: historical, ensemble: r1i1p1f3, grid: gn}
- {project: native6, dataset: ERA5, type: reanaly, version: v1, tier: 3}
preprocessors:
test:
extract_levels:
levels: 12345 # use weird level to ensure interpolation
scheme: linear
coordinate: air_pressure
diagnostics:
test:
variables:
cl:
timerange: '2003/2007'
mip: Amon
preprocessor: test
scripts:
null |
schlunma
left a comment
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.
Thanks for implementing my comments. I am fine with merging this now, but we could also wait until the iris features are available. Please just make sure to remove any duplicated code when the corresponding iris counterpart is available.
…zy-extract-levels
|
Merging now because the iris 3.8 release candidate is out and it does not include the features needed here. They will hopefully be available the 3.9 release planned for early summer. |
extract_levels preprocessor functionextract_levels preprocessor function
extract_levels preprocessor functionextract_levels preprocessor function
Description
Closes #2114 and closes #2121
Before you get started
Checklist
It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.
To help with the number pull requests: