Skip to content

Commit

Permalink
Correct date in output filenames of ERA5 CMORizer recipe (#1773)
Browse files Browse the repository at this point in the history
* Add correct date in filenames

* Extend check recipe accordingly

Co-authored-by: Mattia Righi <mattia.righi@dlr.de>
  • Loading branch information
bouweandela and mattiarighi committed Aug 3, 2020
1 parent 8a529b9 commit b0071a7
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 28 deletions.
23 changes: 17 additions & 6 deletions esmvaltool/diag_scripts/cmorizers/era5.py
@@ -1,14 +1,15 @@
"""native6 diagnostic."""
"""Rename preprocessor output files so they are named according to OBS6."""

import logging
import shutil
from pathlib import Path

import iris
from esmvalcore.cmor.table import CMOR_TABLES

from esmvaltool.diag_scripts.shared import (get_diagnostic_filename,
run_diagnostic)

from esmvalcore.cmor.table import CMOR_TABLES

logger = logging.getLogger(Path(__file__).name)


Expand All @@ -26,9 +27,19 @@ def main(cfg):
basename = basename.replace('E1hr', mip)
basename = basename.replace('E1hr', 'day')

if 'fx' not in basename:
end_year = basename[-4:]
basename = basename.replace(end_year, f'{int(end_year) - 1}')
cube = iris.load_cube(file)
try:
time = cube.coord('time')
except iris.exceptions.CoordinateNotFoundError:
pass
else:
if info['diagnostic'] == "monthly":
start = time.cell(0).point.strftime("%Y%m")
end = time.cell(-1).point.strftime("%Y%m")
else:
start = time.cell(0).point.strftime("%Y%m%d")
end = time.cell(-1).point.strftime("%Y%m%d")
basename = f"{basename.rstrip('0123456789-')}{start}-{end}"

outfile = get_diagnostic_filename(basename, cfg)
logger.info('Moving %s to %s', file, outfile)
Expand Down
192 changes: 170 additions & 22 deletions esmvaltool/recipes/examples/recipe_check_obs.yml
Expand Up @@ -895,50 +895,198 @@ diagnostics:
ERA5:
description: ERA5 check
variables:
clt:
clt_E1hr:
short_name: clt
mip: E1hr
evspsbl:
evspsbl_E1hr:
short_name: evspsbl
mip: E1hr
evspsblpot:
evspsblpot_E1hr:
short_name: evspsblpot
mip: E1hr
mrro:
mrro_E1hr:
short_name: mrro
mip: E1hr
pr:
pr_E1hr:
short_name: pr
mip: E1hr
prsn:
prsn_E1hr:
short_name: prsn
mip: E1hr
ps:
ps_E1hr:
short_name: ps
mip: E1hr
psl:
psl_E1hr:
short_name: psl
mip: E1hr
ptype:
ptype_E1hr:
short_name: ptype
mip: E1hr
rls:
rls_E1hr:
short_name: rls
mip: E1hr
rlds:
rlds_E1hr:
short_name: rlds
mip: E1hr
rsds:
rsds_E1hr:
short_name: rsds
mip: E1hr
rsdt:
rsdt_E1hr:
short_name: rsdt
mip: E1hr
rss:
rss_E1hr:
short_name: rss
mip: E1hr
uas:
uas_E1hr:
short_name: uas
mip: E1hr
vas:
vas_E1hr:
short_name: vas
mip: E1hr
tas:
tas_E1hr:
short_name: tas
mip: E1hr
tasmax:
tasmax_E1hr:
short_name: tasmax
mip: E1hr
tasmin:
tasmin_E1hr:
short_name: tasmin
mip: E1hr
tdps:
tdps_E1hr:
short_name: tdps
mip: E1hr
ts:
ts_E1hr:
short_name: ts
mip: E1hr
tsn:
tsn_E1hr:
short_name: tsn
mip: E1hr
evspsbl_Eday:
short_name: evspsbl
mip: Eday
evspsblpot_Eday:
short_name: evspsblpot
mip: Eday
tdps_Eday:
short_name: tdps
mip: Eday
ts_Eday:
short_name: ts
mip: Eday
tsn_Eday:
short_name: tsn
mip: Eday
clt_day:
short_name: clt
mip: day
mrro_day:
short_name: mrro
mip: day
pr_day:
short_name: pr
mip: day
prsn_day:
short_name: prsn
mip: day
psl_day:
short_name: psl
mip: day
rlds_day:
short_name: rlds
mip: day
rls_day:
short_name: rls
mip: day
rsds_day:
short_name: rsds
mip: day
rss_day:
short_name: rss
mip: day
tas_day:
short_name: tas
mip: day
tasmax_day:
short_name: tasmax
mip: day
tasmin_day:
short_name: tasmin
mip: day
uas_day:
short_name: uas
mip: day
vas_day:
short_name: vas
mip: day
ps_CFday:
short_name: ps
mip: CFday
rsdt_CFday:
short_name: rsdt
mip: CFday
clt_Amon:
short_name: clt
mip: Amon
evspsbl_Amon:
short_name: evspsbl
mip: Amon
evspsblpot_Amon:
short_name: evspsblpot
mip: Amon
mrro_Amon:
short_name: mrro
mip: Amon
pr_Amon:
short_name: pr
mip: Amon
prsn_Amon:
short_name: prsn
mip: Amon
ps_Amon:
short_name: ps
mip: Amon
psl_Amon:
short_name: psl
mip: Amon
ptype_Amon:
short_name: ptype
mip: Amon
rlds_Amon:
short_name: rlds
mip: Amon
rls_Amon:
short_name: rls
mip: Amon
rsds_Amon:
short_name: rsds
mip: Amon
rsdt_Amon:
short_name: rsdt
mip: Amon
rss_Amon:
short_name: rss
mip: Amon
ta_Amon:
short_name: ta
mip: Amon
tas_Amon:
short_name: tas
mip: Amon
tdps_Amon:
short_name: tdps
mip: Amon
ts_Amon:
short_name: ts
mip: Amon
tsn_Amon:
short_name: tsn
mip: Amon
va_Amon:
short_name: va
mip: Amon
zg_Amon:
short_name: zg
mip: Amon
orog:
mip: fx
additional_datasets:
Expand Down

0 comments on commit b0071a7

Please sign in to comment.