diff --git a/doc/sphinx/source/input.rst b/doc/sphinx/source/input.rst index d1aa66fcd6..a6cbfa0e58 100644 --- a/doc/sphinx/source/input.rst +++ b/doc/sphinx/source/input.rst @@ -222,6 +222,8 @@ A list of the datasets for which a cmorizers is available is provided in the fol +------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+ | ESACCI-SST | ts, tsStderr (Amon) | 2 | NCL | +------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+ +| ESACCI-WATERVAPOUR | prw (Amon) | 3 | Python | ++------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+ | ESRL | co2s (Amon) | 2 | NCL | +------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+ | FLUXCOM | gpp (Lmon) | 3 | Python | diff --git a/esmvaltool/cmorizers/obs/cmor_config/ESACCI-WATERVAPOUR.yml b/esmvaltool/cmorizers/obs/cmor_config/ESACCI-WATERVAPOUR.yml new file mode 100644 index 0000000000..400fb7e8da --- /dev/null +++ b/esmvaltool/cmorizers/obs/cmor_config/ESACCI-WATERVAPOUR.yml @@ -0,0 +1,34 @@ +--- +# Common global attributes for Cmorizer output + + +# Input +# CDR-2 +filename: 'ESACCI-WATERVAPOUR-L3S-TCWV-*-05deg-{year}{month}-fv3.1.nc' +# CDR-1 +# filename: 'dataset3_1/CDR-1/monthlies/ESACCI-WATERVAPOUR-L3?-TCWV-*-05deg-{year}{month}-fv3.1.nc' +attributes: + dataset_id: ESACCI-WATERVAPOUR + # CDR-2 + version: 'CDR2-L3S-05deg_fv3.1' + # CDR-1 + # version: 'CDR1-L3-05deg_fv3.1' + tier: 3 + modeling_realm: sat + project_id: OBS + source: "ftp.brockmann-consult.de, access currently restricted" + reference: ["esacci-watervapour"] + comment: "Preliminary data." + +# Variables to cmorize (here use only filename prefix) +variables: + prw: + mip: Amon + raw: tcwv + # Output automatially added: Amon__200910-200910.nc + # CDR-2 + file: OBS_ESACCI-WATERVAPOUR-CDR2-L3S-TCWV-05deg + # CDR-1 + # file: OBS_ESACCI-WATERVAPOUR-CDR1-L3-TCWV-05deg + start_year: 2003 + end_year: 2017 diff --git a/esmvaltool/cmorizers/obs/cmorize_obs_esacci_watervapour.py b/esmvaltool/cmorizers/obs/cmorize_obs_esacci_watervapour.py new file mode 100644 index 0000000000..a3852f6885 --- /dev/null +++ b/esmvaltool/cmorizers/obs/cmorize_obs_esacci_watervapour.py @@ -0,0 +1,84 @@ +"""ESMValTool CMORizer for ESACCI-WATERVAPOUR data. + +Tier + Tier 3: currently still restricted because preliminary. + +Source + Marc Schröder, ftp.brockmann-consult.de + +Last access + 20210329 + +Download and processing instructions + FTP server: ftp.brockmann-consult.de, access currently restricted + data/tcwv/dataset3_1/CDR-*/... + All files need to be in one directory, not in yearly subdirectories. + +Modification history + 20210607-weigel_katja: Fix for monthly time bounds. + 20210408-weigel_katja: written. + +""" + +import logging +import os + +import iris + +from esmvalcore.preprocessor import concatenate +from esmvalcore.cmor.check import _get_time_bounds +from esmvaltool.cmorizers.obs.utilities import (convert_timeunits, fix_coords, + fix_var_metadata, + save_variable, set_global_atts) + +logger = logging.getLogger(__name__) + + +def extract_variable(var_info, raw_info, attrs, year): + """Extract to all vars.""" + cubes = iris.load(raw_info['file']) + rawvar = raw_info['name'] + + for cube in cubes: + if cube.var_name == rawvar: + fix_var_metadata(cube, var_info) + convert_timeunits(cube, year) + fix_coords(cube, overwrite_time_bounds=False) + set_global_atts(cube, attrs) + # Remove disfunctional ancillary data without sandard name + for ancillary_variable_, dim in cube._ancillary_variables_and_dims: + cube.remove_ancillary_variable(ancillary_variable_) + return cube + + +def cmorization(in_dir, out_dir, cfg, _): + """Cmorize data.""" + # cmor_table = cfg['cmor_table'] + glob_attrs = cfg['attributes'] + + # run the cmorization + for var, vals in cfg['variables'].items(): + var_info = cfg['cmor_table'].get_variable(vals['mip'], var) + glob_attrs['mip'] = vals['mip'] + raw_info = {'name': vals['raw'], 'file': vals['file']} + inpfile = os.path.join(in_dir, cfg['filename']) + logger.info("CMORizing var %s from file type %s", var, inpfile) + # years = range(vals['start_year'], vals['end_year'] + 1) + months = ["0" + str(mo) for mo in range(1, 10)] + ["10", "11", "12"] + for year in range(vals['start_year'], vals['end_year'] + 1): + monthly_cubes = [] + for month in months: + raw_info['file'] = inpfile.format(year=year, month=month) + logger.info("CMORizing var %s from file type %s", var, + raw_info['file']) + monthly_cubes.append(extract_variable(var_info, raw_info, + glob_attrs, year)) + yearly_cube = concatenate(monthly_cubes) + # Fix monthly time bounds + time = yearly_cube.coord('time') + time.bounds = _get_time_bounds(time, 'mon') + save_variable(yearly_cube, + var, + out_dir, + glob_attrs, + unlimited_dimensions=['time']) diff --git a/esmvaltool/recipes/examples/recipe_check_obs.yml b/esmvaltool/recipes/examples/recipe_check_obs.yml index adedde1fa1..45e08dc2f4 100644 --- a/esmvaltool/recipes/examples/recipe_check_obs.yml +++ b/esmvaltool/recipes/examples/recipe_check_obs.yml @@ -1117,6 +1117,17 @@ diagnostics: scripts: null + ESACCI-WATERVAPOUR: + description: ESACCI-WV check + variables: + prw: + additional_datasets: + - {dataset: ESACCI-WATERVAPOUR, project: OBS, mip: Amon, tier: 3, + type: sat, version: CDR2-L3S-05deg_fv3.1, + start_year: 2003, end_year: 2017} + scripts: null + + GRACE: description: GRACE check variables: diff --git a/esmvaltool/references/esacci-watervapour.bibtex b/esmvaltool/references/esacci-watervapour.bibtex new file mode 100644 index 0000000000..bdccb12a5e --- /dev/null +++ b/esmvaltool/references/esacci-watervapour.bibtex @@ -0,0 +1,10 @@ +@misc{esacci-watervapour, + doi = {CCIWV.REP.015}, + url = {https://climate.esa.int/documents/357/Water_Vapour_cci_D4.2_CRDP_v2.1.pdf}, + year = 2020, + month = {october}, + publisher = {ESA / ECSAT}, + issue = {2.1}, + author = {Michaela Hegglin, Olaf Danne, Marc Schröder, Hao Ye}, + title = {Climate Research Data Package (CRDP) Water Vapour Climate Change Initiative (WV{\_}cci)- CCI+ Phase 1} +}