Skip to content

fixed missing frequency for cmip6 cmor checks#985

Closed
valeriupredoi wants to merge 17 commits into
version2_developmentfrom
version2_development_CMIP6FreqIssue981
Closed

fixed missing frequency for cmip6 cmor checks#985
valeriupredoi wants to merge 17 commits into
version2_developmentfrom
version2_development_CMIP6FreqIssue981

Conversation

@valeriupredoi

Copy link
Copy Markdown
Contributor

should solve #981

@mattiarighi

Copy link
Copy Markdown
Contributor

The problem with obs4mips persists (tried with dataset CERES-EBAF and variable lwcre).

@valeriupredoi

valeriupredoi commented Mar 20, 2019 via email

Copy link
Copy Markdown
Contributor Author

@mattiarighi

Copy link
Copy Markdown
Contributor

With hus (non-derived) and AIRS it works!

@valeriupredoi

valeriupredoi commented Mar 20, 2019 via email

Copy link
Copy Markdown
Contributor Author

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

ok @mattiarighi now it should work for any derived variable (with base CMIP5, 6 or any other) - I tested with a synthetic derived variable since I don't have CMIP6 data and it works. Note that you need to add frequency: xxx in the custom CMOR table

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

guys, pls have a test or two and let me know if all works so I can fix the test that's failing (keeping that at the very end); also, it would be very useful, now that @jvegasbsc has gone on daddy leave, to ask @sloosvel to double check these changes when she got time (we should probably merge if all works fine, but keep that in mind) - I really am not a CMORChecks expert at all 😈

@mattiarighi

Copy link
Copy Markdown
Contributor

Now I get a different error for CERES-EBAF with lwcre

2019-03-20 15:25:57,526 UTC [45300] ERROR   Failed to run fix_metadata([<iris 'Cube' of TOA Longwave Cloud Radiative Effect / (W m-2) (time: 36; latitude: 180; longitude: 360)>], {'project': 'obs4mips', 'dataset': 'CERES-EBAF', 'short_name': 'lwcre', 'cmor_table': 'obs4mips', 'mip': 'Amon', 'frequency': ''})
2019-03-20 15:25:57,878 UTC [32979] ERROR   Program terminated abnormally, see stack trace below for more information
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/pf/b/b309057/SOFTWARE/miniconda3/envs/esmvaltool/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/_task.py", line 660, in _run_task
    output_files = task.run()
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/_task.py", line 226, in run
    self.output_files = self._run(input_files)
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/preprocessor/__init__.py", line 392, in _run
    product.apply(step, self.debug)
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/preprocessor/__init__.py", line 259, in apply
    self.cubes = preprocess(self.cubes, step, **self.settings[step])
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/preprocessor/__init__.py", line 201, in preprocess
    result.append(_run_preproc_function(function, items, settings))
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/preprocessor/__init__.py", line 187, in _run_preproc_function
    return function(items, **kwargs)
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/cmor/fix.py", line 116, in fix_metadata
    checker(cube).check_metadata()
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/cmor/check.py", line 100, in check_metadata
    self._check_time_coord()
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/cmor/check.py", line 443, in _check_time_coord
    elif self.frequency.endswith('hr'):
AttributeError: 'NoneType' object has no attribute 'endswith'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/_main.py", line 228, in run
    conf = main(args)
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/_main.py", line 156, in main
    process_recipe(recipe_file=recipe, config_user=cfg)
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/_main.py", line 206, in process_recipe
    recipe.run()
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/_recipe.py", line 1066, in run
    self.tasks, max_parallel_tasks=self._cfg['max_parallel_tasks'])
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/_task.py", line 585, in run_tasks
    _run_tasks_parallel(tasks, max_parallel_tasks)
  File "/mnt/lustre01/pf/b/b309057/ESMValTool/public/esmvaltool/_task.py", line 630, in _run_tasks_parallel
    task.output_files, updated_products = result.get()
  File "/pf/b/b309057/SOFTWARE/miniconda3/envs/esmvaltool/lib/python3.6/multiprocessing/pool.py", line 670, in get
    raise self._value
AttributeError: 'NoneType' object has no attribute 'endswith'

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

you need to add frequency: xxx in CMOR_lwcre.dat, I think it's mon

@mattiarighi

Copy link
Copy Markdown
Contributor

Ok, but how? As an additional variable attribute or at the top of the table?

@mattiarighi

Copy link
Copy Markdown
Contributor

The frequency is also not unique for the custom variables, since sometimes the same table is used for mon and day.

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

it's a variable attribute just like units etc; in that case we're kinda screwed since we need to create separate files for different frequencies; the code needs that frequency from the CMOR table in light of the new CMIP6 CMOR table structure

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

I also found this discrepancy between CMIP5 and 6 standard names:

Amon:
prw:
CMIP5: "atmosphere_water_vapor_content"
CMIP6: "atmosphere_mass_content_of_water_vapor"

do we have a strategy for these cases yet?

@mattiarighi

Copy link
Copy Markdown
Contributor

it's a variable attribute just like units etc; in that case we're kinda screwed since we need to create separate files for different frequencies; the code needs that frequency from the CMOR table in light of the new CMIP6 CMOR table structure

It's still not clear to me how this affects obs4mips and the custom variables, since both follow their own tables, the latter based on CMIP5. Changes in CMIP6 tables should not have any effect here.

@mattiarighi

Copy link
Copy Markdown
Contributor

do we have a strategy for these cases yet?

Not yet, as far as I know @jvegasbsc only implemented a fix for the short_name (see #950).

@valeriupredoi

valeriupredoi commented Mar 20, 2019

Copy link
Copy Markdown
Contributor Author

cmor_type for obs4mips is CMIP6 as per config-developer

@mattiarighi

Copy link
Copy Markdown
Contributor

Should we try to update the obs4mips tables as well?

@mattiarighi

Copy link
Copy Markdown
Contributor

As a quick solution, can we revert the CMIP6 tables to the previous version until this is solved?

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

OK so here's the status:

  • with this PR we have all working with the current CMIP6 tables provided that the derived variables custom CMOR tables contain a valid frequency field; the standard variables should work fine as of now;
  • if we use cmor_type: CMIP5 in the various data types in config-developer.yml we revert to CMIP5 CMOR tables and we don't need to add frequency fields in the derived variables' CMOR files; or we revert to previous version of CMIP6 CMOR tables; I'd go with the first option since it involves less file tracking

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

there are small differences if we want to use CMIP5 CMOR tables for CMIP6 data eg:

    _CMIP_5to6_varname = {
        'sic': 'siconc',
        'sit': 'sithick',
        'tro3': 'o3',
    }

but these shouldn't bite us too badly

@mattiarighi

Copy link
Copy Markdown
Contributor

provided that the derived variables custom CMOR tables contain a valid frequency field

But they don't, and adding it would mean redesigning the way the custom tables are defined (i.e., group them by mip) and regenerate our obs data pool again (including also adjusting most of the cmorizers).
This is something we would need to do anyway at some point, but not now.

if we use cmor_type: CMIP5 in the various data types in config-developer.yml we revert to CMIP5 CMOR tables

Isn't this also controlling the table format (plain text in CMIP5 vs json in CMIP6)?

we revert to previous version of CMIP6 CMOR tables

It still looks the quickest way out to me, at least until we have a clean solution for the issues you mentioned (which may be some work).

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

using cmor_type: CMIP5 for anything CMIP6 including CMIP6 data works fine no problemo, what you mean by "Isn't this also controlling the table format (plain text in CMIP5 vs json in CMIP6)?" - it just loads different CMOR tables and applies the same checks and cmorization, no worries about tables' format

@mattiarighi

Copy link
Copy Markdown
Contributor

CMIP5 for anything CMIP6 including CMIP6 data works fine no problemo

That would probably not work for those variables with a different short_name (see #950).
@LisaBock or @axel-lauer any suggestion?

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

also if you temporarily just add frequency: something in the derived vars custom tables, that doesn't break any CMIP5 functionality and the bonus is that addition will make work with CMIP6 even before we start re-arranging them custom tables and rerun the obs's (OK we just add mon). Alas, the code changes in this PR are actually the ones we will need to be able to work with the latest CMIP6 tables (well, unless @jvegasbsc gets bored of his new wee baby and makes changes 😁 )

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

CMIP5 for anything CMIP6 including CMIP6 data works fine no problemo

That would probably not work for those variables with a different short_name (see #950).
@LisaBock or @axel-lauer any suggestion?

yesh indeed, but those are not on any ESGF node yet anyway so people can keep their CMIP5 names 😁

@mattiarighi

Copy link
Copy Markdown
Contributor

yesh indeed, but those are not on any ESGF node yet anyway so people can keep their CMIP5 names

The CMIP6 data are flowing right now and people are start working with them.
Therefore I'm hesitant introducing changes now and would go back to the previous version (which has been quite extensively tested in our group).

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

I have been trying to say that myself since March 🤣 - I was thinking about adding the frequency info in the custom var based on all the component variables in an automatic way (and not by hand in the custom table) but I had left it for you to review and decide - it shouldn't be too hard since all the component vars should have consistent frequencies no?

@mattiarighi

Copy link
Copy Markdown
Contributor

Some use fx variable together with monthly, e.g. nbp_grid.

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

good point! The fx var should be sidelined then - #1065 and #1037 are taking care of that the fx variable is treated correctly as a bloody fx variable anyway

@jvegreg

jvegreg commented May 23, 2019

Copy link
Copy Markdown
Contributor

I am counting the frequency and assigning the max value

@axel-lauer

Copy link
Copy Markdown
Contributor

Just tested recipe_ecs_scatter_cmip6.yml successfully.

Comment thread esmvaltool/cmor/table.py
from collections import Counter
var_freqs = (var.frequency for var in table.values())
table_freq, _ = Counter(var_freqs).most_common(1)[0]
table.frequency = table_freq

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boss! I like it - I tested with a whole bunch of tables and the closest one I got was this one:

Counter(freqs).most_common(2)
[(' "yr"', 10), (' "yrPt"', 9)]

for Eyr

@jvegreg

jvegreg commented May 24, 2019

Copy link
Copy Markdown
Contributor

Mattia, can you test again? Now custom vars will be assigned the table frequency, so I expect this will fix your issue

@mattiarighi

Copy link
Copy Markdown
Contributor

Thanks, I will test asap.

@mattiarighi

Copy link
Copy Markdown
Contributor

I can't test anything until #1097 is solved. 😭

@mattiarighi

Copy link
Copy Markdown
Contributor

Tested successfully!

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

@mattiarighi @jvegasbsc shall we merge then? awesome work guys 🍺

@bouweandela

Copy link
Copy Markdown
Member

Please re-open this pull request in the ESMValTool Core repository. You can do so by pushing this branch to that repository, using the following instructions.

First add the repository with

git remote add esmvalcore git@github.com:esmvalgroup/esmvalcore

or

git remote add esmvalcore https://github.com/esmvalgroup/esmvalcore

if you're not using ssh to connect to GitHub.

Next upload the branch with

git push esmvalcore your_branch

and open a pull request here

@mattiarighi

mattiarighi commented Jun 11, 2019

Copy link
Copy Markdown
Contributor

Also note the new issues number #38 and #45.

@sloosvel sloosvel closed this Jun 20, 2019
@sloosvel

Copy link
Copy Markdown
Contributor

sorry I did not mean to close that :/

@sloosvel sloosvel reopened this Jul 12, 2019
@mattiarighi

Copy link
Copy Markdown
Contributor

@valeriupredoi is this still relevant?

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

still is, somewhat relevant albeit the code is starting to become obsolete, see the discussion here ESMValGroup/ESMValCore#158

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

ie the code = CMOR tables which are even more modern in ESMValGroup/ESMValCore#158

@mattiarighi

Copy link
Copy Markdown
Contributor

But shouldn't it be moved to Core?

@valeriupredoi

Copy link
Copy Markdown
Contributor Author

yes, I believe @jvegasbsc is cherrypicking the changes in that Core PR, no?

@jvegreg

jvegreg commented Jul 15, 2019

Copy link
Copy Markdown
Contributor

I will close this when the pull requests is created for the core

@jvegreg

jvegreg commented Jul 15, 2019

Copy link
Copy Markdown
Contributor

Ported to /ESMValGroup/ESMValCore#158

@jvegreg jvegreg closed this Jul 15, 2019
@jvegreg jvegreg deleted the version2_development_CMIP6FreqIssue981 branch July 15, 2019 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants