ESMValGroup / ESMValCore

ESMValCore: A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts.
https://www.esmvaltool.org
Apache License 2.0
42 stars 38 forks source link

ERA5-Land daily cmoriser #2150

Open rbeucher opened 1 year ago

rbeucher commented 1 year ago

Hi All,

I have been trying to use the recipe_daily_era5.yml with ERA5-Land hourly data. For now, only the pr variable is supported via the native6 project era5_land.py

So I tried to run the following recipe using hourly data for pr

# ESMValTool
# recipe_daily_era5-land.yml
---
documentation:
  description: Create daily ERA5-Land data

  title: Daily ERA5 data CMORization and creation

  authors:
    - andela_bouwe

  maintainer:
    - unmaintained

  references:
    - acknow_project

datasets:
  - {dataset: ERA5-Land, project: native6, type: reanaly, version: v1, tier: 3, start_year: 1990, end_year: 1991}

preprocessors:
  add_one_day: &add_one_day
    extract_time:
      start_year: 1990
      start_month: 1
      start_day: 1
      end_year: 1991
      end_month: 1
      end_day: 1

  daily_mean:
    <<: *add_one_day
    daily_statistics:
      operator: mean
  daily_min:
    <<: *add_one_day
    daily_statistics:
      operator: min
  daily_max:
    <<: *add_one_day
    daily_statistics:
      operator: max

diagnostics:
  daily:
    description: Create daily ERA5 data
    scripts:
      rename:
        script: cmorizers/era5.py
    variables:
      pr:
        mip: E1hr
        era5_name: total_precipitation
        era5_freq: hourly
        preprocessor: daily_mean

Here is what I get:

with function argument(s)
check_level = <CheckLevels.DEFAULT: 3>,
cmor_table = 'native6',
mip = 'E1hr',
frequency = '1hr',
short_name = 'pr'
2023-07-27 05:14:46,152 UTC [535439] ERROR   Failed to run preprocessor function 'cmor_check_metadata' on the data
[<iris 'Cube' of precipitation_flux / (kg m-2 s-1) (time: 17520; latitude: 1801; longitude: 3600)>]
loaded from original input file(s)
[LocalFile('/g/data/kj13/datasets/esmvaltool/raw-data/Tier3/ERA5-Land/v1/1hr/pr/tp_era5-land_oper_sfc_19900101-19900131.nc'),
 LocalFile('/g/data/kj13/datasets/esmvaltool/raw-data/Tier3/ERA5-Land/v1/1hr/pr/tp_era5-land_oper_sfc_19900201-19900228.nc'),
 LocalFile('/g/data/kj13/datasets/esmvaltool/raw-data/Tier3/ERA5-Land/v1/1hr/pr/tp_era5-land_oper_sfc_19900301-19900331.nc'),
 LocalFile('/g/data/kj13/datasets/esmvaltool/raw-data/Tier3/ERA5-Land/v1/1hr/pr/tp_era5-land_oper_sfc_19900401-19900430.nc')]
(and 20 further file(s) not shown here; refer to the debug log for a full list)
with function argument(s)
check_level = <CheckLevels.DEFAULT: 3>,
cmor_table = 'native6',
mip = 'E1hr',
frequency = '1hr',
short_name = 'pr'
2023-07-27 05:14:46,863 UTC [535351] INFO    Maximum memory used (estimate): 1.7 GB
2023-07-27 05:14:46,864 UTC [535351] INFO    Sampled every second. It may be inaccurate if short but high spikes in memory consumption occur.
2023-07-27 05:14:46,865 UTC [535351] ERROR   Program terminated abnormally, see stack trace below for more information:
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/_task.py", line 816, in _run_task
    output_files = task.run()
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/_task.py", line 264, in run
    self.output_files = self._run(input_files)
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/preprocessor/__init__.py", line 670, in _run
    product.apply(step, self.debug)
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/preprocessor/__init__.py", line 470, in apply
    self.cubes = preprocess(self.cubes, step,
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/preprocessor/__init__.py", line 481, in cubes
    self._cubes = [
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/preprocessor/__init__.py", line 482, in <listcomp>
    ds._load_with_callback(callback) for ds in self.datasets
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/dataset.py", line 689, in _load_with_callback
    cube = self._load(callback)
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/dataset.py", line 774, in _load
    result = preprocess(
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/preprocessor/__init__.py", line 379, in preprocess
    result.append(_run_preproc_function(function, item, settings,
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/preprocessor/__init__.py", line 328, in _run_preproc_function
    return function(items, **kwargs)
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/cmor/check.py", line 1138, in cmor_check_metadata
    checker(cube).check_metadata()
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/cmor/check.py", line 195, in check_metadata
    self.report_errors()
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/cmor/check.py", line 251, in report_errors
    raise CMORCheckError(msg)
esmvalcore.cmor.check.CMORCheckError: There were errors in variable pr:
 lon: has values < valid_min = 0.0
in cube:
precipitation_flux / (kg m-2 s-1)   (time: 17520; latitude: 1801; longitude: 3600)
    Dimension coordinates:
        time                             x                -                -
        latitude                         -                x                -
        longitude                        -                -                x
    Attributes:
        Conventions                 'CF-1.6'
        comment                     'Contains modified Copernicus Climate Change Service Information 2023'
        license                     'Licence to use Copernicus Products: https://apps.ecmwf.int/datasets/li ...'
        summary                     'ERA5 is the fifth generation ECMWF atmospheric reanalysis of the global ...'
        title                       'ERA5 land total_precipitation 19900101-19900131 ERA5 land total_precipitation ...'
loaded from file 
"""

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

Traceback (most recent call last):
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/_main.py", line 524, in run
    fire.Fire(ESMValTool())
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/fire/core.py", line 475, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/fire/core.py", line 691, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/_main.py", line 411, in run
    self._run(recipe, session)
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/_main.py", line 453, in _run
    process_recipe(recipe_file=recipe, session=session)
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/_main.py", line 125, in process_recipe
    recipe.run()
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/_recipe/recipe.py", line 1294, in run
    self.tasks.run(max_parallel_tasks=self.session['max_parallel_tasks'])
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/_task.py", line 738, in run
    self._run_parallel(address, max_parallel_tasks)
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/_task.py", line 782, in _run_parallel
    _copy_results(task, running[task])
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/site-packages/esmvalcore/_task.py", line 805, in _copy_results
    task.output_files, task.products = future.get()
  File "/g/data/xp65/public/apps/med_conda/envs/access-med-0.3/lib/python3.10/multiprocessing/pool.py", line 774, in get
    raise self._value
esmvalcore.cmor.check.CMORCheckError: There were errors in variable pr:
 lon: has values < valid_min = 0.0
in cube:
precipitation_flux / (kg m-2 s-1)   (time: 17520; latitude: 1801; longitude: 3600)
    Dimension coordinates:
        time                             x                -                -
        latitude                         -                x                -
        longitude                        -                -                x
    Attributes:
        Conventions                 'CF-1.6'
        comment                     'Contains modified Copernicus Climate Change Service Information 2023'
        license                     'Licence to use Copernicus Products: https://apps.ecmwf.int/datasets/li ...'
        summary                     'ERA5 is the fifth generation ECMWF atmospheric reanalysis of the global ...'
        title                       'ERA5 land total_precipitation 19900101-19900131 ERA5 land total_precipitation ...'
loaded from file 
2023-07-27 05:14:46,870 UTC [535351] INFO    
If you have a question or need help, please start a new discussion on https://github.com/ESMValGroup/ESMValTool/discussions
If you suspect this is a bug, please open an issue on https://github.com/ESMValGroup/ESMValTool/issues
To make it easier to find out what the problem is, please consider attaching the files run/recipe_*.yml and run/main_log_debug.txt from the output directory.

Longitude has negative values of course (-180 to 180) but that is the same for ERA5.

Is this related to the grid size that is different in ERA5-Land (9km)?

@katjaweigel I am pinging you here as I have found you worked on the monthly CMORiser #879

Thanks for your help

rbeucher commented 1 year ago

The rationale behind having a daily cmoriser for ERA5-Land hourly data is that quite a few recipes use daily averages from ERA5. Some HPC systems have chosen to store variables from ERA5-Land instead because they are better resolved. pr is one of them. It would be good to be able to run the recipes with either of them.

rbeucher commented 1 year ago

The CMOR checks for valid values for the longitude. I don't understand why it is not picking the same checks as ERA5 hourly data.

katjaweigel commented 1 year ago

Hi @rbeucher I never encountered this for monthly data (unfortunately I'm on holidays next two weeks and don't really have time to look at it before). It should be easy to include further variables for era5_land if the fix exists in ESMValCore/esmvalcore/cmor/_fixes/native6/era5.py you can just include them as pr in ESMValCore/esmvalcore/cmor/_fixes/native6/era5_land.py. But they need to be tested if further adjustments are necessary, therefore they are not in main.

katjaweigel commented 1 year ago

@rbeucher Which tests are used for ERA5 is determined in ESMValCore/tests/integration/cmor/_fixes/native6/test_era5.py Maybe an analogue ESMValCore/tests/integration/cmor/_fixes/native6/test_era5_land.py is needed to switch this test off? Unfortunately I have not much experience with the tests.

valeriupredoi commented 1 year ago

that's probably on a -180 -> 180 lon grid