ESMValGroup / ESMValTool

ESMValTool: A community diagnostic and performance metrics tool for routine evaluation of Earth system models in CMIP
https://www.esmvaltool.org
Apache License 2.0
223 stars 128 forks source link

PORTING AutoAssess_radiation_rms_ to v2 #514

Closed valeriupredoi closed 6 years ago

valeriupredoi commented 6 years ago

Starting this with the first commit on branch https://github.com/ESMValGroup/ESMValTool/tree/version2_autoassess_v1_port (Amon_all yaml namelist and v1 diagnostic so I can start changing it)

valeriupredoi commented 6 years ago

@mattiarighi I am happily reporting that the autoassess_rms_radiation_Amon_all recipe https://github.com/ESMValGroup/ESMValTool/blob/version2_autoassess_v1_port/esmvaltool/recipes/recipe_autoassess_radiation_rms_Amon_all.yml is fully functional (together with variable derivations that I am asking you to check: https://github.com/ESMValGroup/ESMValTool/blob/version2_autoassess_v1_port/esmvaltool/preprocessor/_derive.py - I replicated ad literam the derivation from V1, but a check and deletion of TODO's there should still be done). I just need to clean up a few things in the diagnostic codes (codacy stuff) and make sure the other two recipes are working fine too; the big work was to actually refactor the diagnostics which were a total Python mess. The results are very close -- have a look at the comparison doc: https://github.com/ESMValGroup/ESMValTool/blob/version2_autoassess_v1_port/esmvaltool/diag_scripts/autoassess/autoassess_source/comparison.txt The caveat is that I could not test with the OBS files that are needed -- I don't have those files and no idea where to get them but by replacing the actual OBS with another model (eg MPI-ESM-MR) it works no problemo

mattiarighi commented 6 years ago

I will check whether I have these OBS and send them to you... :mailbox_with_mail:

valeriupredoi commented 6 years ago

awesomepossum, cheers @mattiarighi :eggplant:

valeriupredoi commented 6 years ago

just letting you know @mattiarighi I will be away tomorrow and on Friday (celebrations in Cardiff for my graduating friends) so I'll restart the work on this on Monday :beer: Have a look at https://github.com/ESMValGroup/ESMValTool/issues/519 in the meantime and see if you can replicate the issue yourself (by moving the derived vars at the bottom of the list) and if you got some time, check my derivations in _derive and the CMOR custom files, there are only four variables no biggie :grin:

valeriupredoi commented 6 years ago

as of 31 July 2018 the porting is 98% done and the PR is almost to be merged. One this is missing: the derivation of the 6 cloud formation variables that are used for the cfMon recipe. This will be done immediately after the PR gets merged into version2_development and a new branch will be started with its own PR to follow. Here is the comment from @mattiarighi that has kindly provided insight into the derivation of these variables:

I had a look at the 6 cl*isccp derivation functions in v1 (NCL).

They all do the same thing:

reading clisccp, which is a five-dim variable: time, tau, plev, lat, lon
sum over given plev and tau (=cloud optical depth) ranges, according to the ISCCP cloud classification
each of the derived variable includes different ranges

Please find below a quick explanation of the original NCL derivation code (for cllmtisccp, but it applies to the other 5 ones as well):

dimNames = getvardims(tmp1)

This reads the names of the dimensions (returns an array time, tau, plev, lat, lon)

taus = ind(tmp1&$dimNames(1)$.gt.3.6 .and. tmp1&$dimNames(1)$.le.23)

This returns the indexes in the tau coordinate that satisfy the condition 3.6<tau<23

plevs = ind(tmp1&$dimNames(2)$.gt.68000.)

This does the same for the pressure coordinate satisfying the condition plev>68000 (hPa)

if ((dimsizes(taus).gt.1).and.(dimsizes(plevs).gt.1)) then
    avgdims = (/1, 2/)
else if (dimsizes(taus).gt.1) then
    avgdims = (/1/)
else
    avgdims = (/2/)
end if
end if

NCL is not very flexible with arrays allocation, this block tries to find out the dimension numbers after the subsetting with the above indexes has been applied. In python this can be ignored I guess.

cllmtisccp = dim_sum_n_Wrap(tmp1(:,taus,plevs,:,:), avgdims)

This is just summing over all tau s and all pressure levels plevs selected above.

This is basically equivalent to averaging a variable over a specific lat-lon region, but instead of lat and lon you have plev and tau and you sum instead of averaging.

valeriupredoi commented 6 years ago

posting the v1->v2 comparison results:

1. RMS Radiation
=================

RMS computation (Amon_all, MPI-ESM-LR, rlut, zonal_mean)
------------------------------------------------------------
Region               V1              V2         Rel. Err.
------------------------------------------------------------
north                218.697         218.411     0.0013
global               238.607         238.239     0.0015
south                215.790         215.637     0.0007
------------------------------------------------------------
valeriupredoi commented 6 years ago

version2_autoassess_v1_port has now been merged into version2_development: https://github.com/ESMValGroup/ESMValTool/commit/cba2859657b07aecd3d83c3c7f1965f84680d294

valeriupredoi commented 6 years ago

deletion of branch; need to implement (and test) the cl-vars derivation onto a new branch

valeriupredoi commented 6 years ago

this has been done and tested, cfMon fully working (ISCCP/clisccp needs fixes in _fixes/obs4mips)

mattiarighi commented 6 years ago

If no further work on this recipe/diag is required you can close this (#552 will remind us of the problem with ISCCP) and add the :heavy_check_mark: in #503.

valeriupredoi commented 6 years ago

would love to do that, I am actually going to right now :grin: how do you add the :heavy_check_mark: there?

mattiarighi commented 6 years ago

You should be allowed to click on it, or is it only for the author of the issue?