-
Notifications
You must be signed in to change notification settings - Fork 145
Python cmorizers for CDR1 and CDR2 ESACCI H2O (TCWV=prw) data. #2152
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6a8eb60
Python morizers for CDR2 and CDR1 ESACCI H2O (TCWV=prw) data.
23f4ffb
Merge branch 'main' into CMUG_ESACCI_H2O_cmorizer
645d7ff
Fix time bounds and rename from ...TCWV to ...WATERVAPOUR.
058f0a3
Using core function (esmvalcore.cmor.check _get_time_bounds) for time…
01c1ae7
Prospector fix.
594bd14
Update esmvaltool/cmorizers/obs/cmor_config/ESACCI-WATERVAPOUR.yml
axel-lauer 9f35f3b
Update esmvaltool/cmorizers/obs/cmorize_obs_esacci_watervapour.py
axel-lauer 3210bab
updated recipe_check_obs.yml + input.rst
axel-lauer 1d1431f
Merge remote-tracking branch 'origin/main' into CMUG_ESACCI_H2O_cmorizer
0c998c0
Merge remote-tracking branch 'origin/CMUG_ESACCI_H2O_cmorizer' into C…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
esmvaltool/cmorizers/obs/cmor_config/ESACCI-WATERVAPOUR.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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_<var>_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 |
84 changes: 84 additions & 0 deletions
84
esmvaltool/cmorizers/obs/cmorize_obs_esacci_watervapour.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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']) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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} | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okease remove commented out code if not needed anymore