-
Notifications
You must be signed in to change notification settings - Fork 39
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 preprocessor to extract surface values from 3D atmospheric variables #2641
base: main
Are you sure you want to change the base?
Conversation
@bouweandela if you could point me to where in the documentation I should add relevant information ? Thanks 🙂 |
In this file, please: https://github.com/ESMValGroup/ESMValCore/blob/main/doc/recipe/preprocessor.rst You can find this, and much more useful information on contributing, under the links in the checklist above and in our contribution guidelines: https://docs.esmvaltool.org/projects/ESMValCore/en/latest/contributing.html |
var_cube.coord_dims(air_pressure_coord), | ||
) | ||
target_levels = np.expand_dims(ps_cube.data, axis=z_axis) | ||
sfc_data = stratify.interpolate( |
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.
Have you looked into using the esmvalcore.preprocessor.extract_levels
function?
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.
I tried to make it work but couldn't manage to. To replace the interpolation step I tried with
sfc_data = extract_levels(
cube=cube,
levels=ps_cube.data,
scheme="linear",
coordinate="air_pressure",
rtol=1e-7,
atol=None
)
but I always get the following error TypeError: extract_levels() missing 1 required positional argument: 'data'
which I don't really understand where it comes from. In case you have any insights on that.
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.
This seems to be caused by the preserve_float_dtype
decorator around extract_levels
. Using
sfc_data = extract_levels(
cube,
levels=ps_cube.data,
scheme="linear",
coordinate="air_pressure",
rtol=1e-7,
atol=None
)
avoids this problem. @schlunma Since you introduced the wrapper, would you have time to take a look at improving it to avoid this puzzling error?
Here is an interesting example of doing something similar for ocean data: https://cosima-recipes.readthedocs.io/en/latest/Recipes/Extract_Variables_at_Ocean_Bottom.html I guess the ocean equivalent of |
Description
This pull request introduces a new preprocessor function to extract the surface values from 3D atmospheric variables and corresponding surface pressure
ps
. The preprocessor function is largely based on the implementation done for the derivation of surface CO2co2s
at https://github.com/ESMValGroup/ESMValCore/blob/main/esmvalcore/preprocessor/_derive/co2s.py. It thus avoids having to create either at standalone_derive
preprocessor or a new entry in the relevant CMOR tables. The attributes of the 3D atmospheric variables are transferred to the newly created cube and the variable name is changed tof'{var_name}s'
.Closes #2611
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: