-
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
Reporting error in area average of irregular grids in UKESM data #2643
Comments
cheers @rswamina - I'll have a closer look at it tomorrow, it is almost certain the preprocessor fails since there are no |
Hi Ranjini! Yes, V's right. Since these data most likely use a curvilinear grid (what we call "irregular" in ESMValTool jargon), you need cell areas for averaging (in this case the If you already have the cell areas as cube, you can add them to your parent cube with |
Thanks @schlunma and @valeriupredoi for this. I am tagging @jprb-walton here to provide the fx file for the cell areas. Since this is not a standard directory set up in ESMValTool yet, can I just load that file into a cube and use |
Yes |
I looked through the available Terrafirma data, and couldn't find any |
@valeriupredoi and @schlunma - I can confirm that we are to use a previous version's I am still not successfully able to plot the area averaged mean though. I tried the following: area_cells_file = '/badc/cmip6/data/CMIP6/CMIP/MOHC/UKESM1-0-LL/piControl/r1i1p1f2/Ofx/areacello/gn/files/d20190705/areacello_Ofx_UKESM1-0-LL_piControl_r1i1p1f2_gn.nc'
area_cells_cube = iris.load(area_cells_file)
add_supplementary_variables(cube, area_cells_cube)
cube.convert_units('Celsius')
cube = area_statistics(cube,'mean')
cube = annual_statistics(cube, operator="mean")
qplt.plot(cube) What I get is the plot as shown The above is orders of magnitude different from what I should get. I am wondering if this is some area measure instead of area weighted temperature. For reference, here is the plot from one month of one year using the original grid coordinate system (just to get an idea of the range of values). Can you suggest what I should change to get the actual area averages of temperature? Thanks! |
hmm that could be one of these:
|
at least the trend looks correct - so am guessing there's some constant fudge factor that comes in at some point |
How do I fix this? |
I'll have a play with this particular test @rswamina 🍺 |
Hi @valeriupredoi - any updates on this? |
OK this is a problem related to iris lazy vs realized data - a quick fix is for @rswamina to pop a simple realization of the areacello data via eg a print statement import iris
import numpy as np
import matplotlib.pyplot as plt
import iris.quickplot as qplt
from esmvalcore.preprocessor import add_supplementary_variables
from esmvalcore.preprocessor import area_statistics
def do_avg():
filename = '/gws/nopw/j04/terrafirma/TerraFIRMA/MOHC/UKESM1-2/esm-hist/r1i1p1f1/Omon/tos/gn/v20240619/tos_Omon_UKESM1-2-LL_esm-hist_r1i1p1f1_gn_195001-201412.nc'
cube = iris.load_cube(filename)
area_cells_file = '/badc/cmip6/data/CMIP6/CMIP/MOHC/UKESM1-0-LL/piControl/r1i1p1f2/Ofx/areacello/gn/files/d20190705/areacello_Ofx_UKESM1-0-LL_piControl_r1i1p1f2_gn.nc'
area_cells_cube = iris.load(area_cells_file)
print("Area cells data", np.ma.min(area_cells_cube[0].data), np.ma.max(area_cells_cube[0].data))
add_supplementary_variables(cube, area_cells_cube)
cube.convert_units('Celsius')
cube = area_statistics(cube,'mean')
print("Cube mean data after area stats", np.mean(cube.data))
qplt.plot(cube)
plt.show()
do_avg() will give you a nice and sane plot |
could be that the issue (I vaguely remember which one it was) got solved, but Ranjini has iris=3.7 and dask=2024.1 in the JASMIN env (via esmvaltool=2.10 central install), I'll try see if I can replicate the issue with modern iris/Dask now |
I see. I would not have expected to do this but do I understand correctly that the |
any call to |
Ok. But just to clarify, is this something we should learn to do (as in |
No! Realization is bad - because that's heavy memory consumption! This is a bug in Iris and I need to get its roots, if it's not been fixed in the newer versions - that's why I'm trying to get an env on JASMIN with the latest iris (and Dask) |
(this was somwehat of a last resort for me to see where the issue may be coming from) |
OK good news! All is fine with the latest Dask, iris, and esmvalcore:
this is most prob the bug that Manu and I found way back and iris fixed it. I suggest you use a latest install of ESMValTool, Ranjini. I could prob update the central install, but I'd rather do it when v2.12 is out in a month or so. |
OK, so let's do it this way then: I'll install a central version of ESMValTool (with the latest development ESMValCore) on JASMIN and will make it available to you and @jprb-walton (please don't spread the news about it, since it's gonna be usable by others too as a normal |
@valeriupredoi - Will this have implications for those using the new simulations until then? Is it best to use a latest installation of ESMValTool instead of the JASMIN module or is this something that only affects data with irregular grids or perhaps larger files? It will be good to know and let others know as well so they can avoid this problem till the update. |
@valeriupredoi - I am happy to go woth whatever you suggest for how we should use the right version of iris/dask. I don't know if the values are right but will look into that. |
@rswamina there have been a number of (some less serious, some rather serious) bugs in Dask, impacting Iris, and us - via iris, or directly via Dask. As far as I remember this particular one was an issue from iris but I can't remember the exact issue - what's important is that a lot of these issues have now been solved, that's why I want to install the latest ESMValTool with the latest ESMValCore on JASMIN for you and Jeremy to use; don't worry about letting users know about stuff involving the 2.10 installation on JASMIN, that'll get superseded by 2.12 in a short while (somehow I missed installing 2.11 but that'll be this one I'll try do today with latest Tool/Core) |
In testing ESMValTool with some newly CMORized data, I ran into the following error message when I tried to do area averaging. The variable is
tos
. Here is some sample code to test thisI used
module load esmvaltool
on JASMIN and and the error message I got was:The text was updated successfully, but these errors were encountered: