-
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
Fix units after derivation #754
Conversation
It would be good to test if the currently implemented derivation scripts actually work, instead of just adding some warnings and leaving the problems for our users. Maybe you could update the recipe |
Good idea! I totally forgot that this recipe existed. I will update it and test all variables for CMIP5 and CMIP6 models. |
I updated the recipe in ESMValGroup/ESMValTool#1790 with the new derived variables and added CMIP6 models. I had to fix several issues in the derivation scripts (but only one is related to this PR):
Please note that I only tested if the test recipe ran successful. I did not check if the resulting data is scientifically correct. |
Great!
A
The variable is defined in the CMIP5 Omon table. A
|
I found NorCPM1 (that was the only one with
Sorry, I meant CMIP6. CMIP5 is already included in the recipe. |
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.
Looks good, I left a small suggestion for writing the tests in a nicer way. Only if you have time.
@axel-lauer Do you think it would be possible to find someone to do a scientific review of this pull request? That would require running the recipe in ESMValGroup/ESMValTool#1790 and having a look at the results. It would be great if this could still be included in v2.1, but the deadline is already this Monday, so maybe it will have to wait for the next release. |
Change the derivation of |
@axel-lauer Would you be able to do a final test of the changes you proposed, so we can still include this in v2.1? We're doing the feature freeze today, but since this is a bugfix, we could still include it if it gets approved soon. |
I'll test the changes and report back soon... |
There were two corrections introduced: och and vegfrac. The changes to ohc look good, the values for CMIP6 models are now in the expected range. vegfrac still looks weird (e.g. vegfrac=100% in Antarctica). This is not related to this PR or the corrections introduced but I think it would be good to get this fixed now. vegfrac is currently calculated as 100.0 - baresoilfrac (in %) The CMOR tables (CMIP5) say: From this, I would presume vegfrac should actually be calculated as follows: vegfrac = 100.0 - baresoilfrac - residualfrac @ledm , I think you introduced vegfrac. Can you confirm that this would be correct? Please let us know what you think s soon as possible. |
Fixed While testing this I encountered an issue with the CMOR checker.
I added a fix for this: try:
cube_coord = self._cube.coord(var_name=coordinate.out_name)
- if cube_coord.standard_name != coordinate.standard_name:
+ if (cube_coord.standard_name is None and
+ coordinate.standard_name == ''):
+ pass
+ elif cube_coord.standard_name != coordinate.standard_name:
self.report_critical(
self._attr_msg,
coordinate.out_name, This isn't really nice but does the job. The optimal solution here would be when |
I think the best solution would be to change the way we read the cmor tables so we read this in as @axel-lauer Would you be able to test the latest changes? |
I tested the latest changes and it works. As @schlunma already noticed, however, there are spurious values along the coast lines. I presume these are caused by us assuming a land fraction of 100% for all land grid cells, i.e.: vegfrac = 100% - baresoil - residualfrac I think to get rid of those spurious coastal values, we would have to use the "real" land fraction and calculate vegfrac as: vegfrac = landfrac - baresoil - residualfrac Here is the "corrected" example from @schlunma. This now looks fine to me. As "landfrac" I used the atmospheric fx file "sftlf". I guess to generalize this, a check would be needed if baresoil / residualfrac and sftlf are on the same grid. |
Thanks @schlunma! I tested this and it works. I would leave it like this for now. Let's get this merged then! |
* Added check for units at the end of derivation function * Fixed tests for variable derivation interface * Adapted several derivation scripts * Adapted sm derivation script for CMIP6 * Fixed derivation of vegfrac and ohc * Fixed CMOR checker when coordinate standard_name is empty
good stuff, guys! we have just cherry-picked this PR in the 2.1 release 🍺 |
Adds checks if the units after executing a derivation script are compatible to the CMOR table and converts the units if necessary. Since not all derivation scripts have unit tests, I do not know if all of these still work. However, the changes in this PR only raise an exception if the units are not convertible (e.g.
m
andkg
) and in this case the tool should definitely not silently set the units to the excepted ones like it does right now.Tasks
yamllint
to check that your YAML files do not contain mistakesIf you need help with any of the tasks above, please do not hesitate to ask by commenting in the issue or pull request.
Closes #750