Skip to content

Commit

Permalink
Merge branch 'async' of github.com:C2SM/processing-chain into async
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaehn committed Jan 5, 2024
2 parents 7c4ab07 + 3221bb7 commit 837334d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions jobs/prepare_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def async_error(cfg, part="This part"):

# ... (previous code remains unchanged)


def main(cfg):
"""
**ICON and COSMO Data Preparation**
Expand Down Expand Up @@ -145,7 +146,7 @@ def main(cfg):
datafile_list_rest = []
datafile_list_chem = []
for time in tools.iter_hours(cfg.startdate_sim, cfg.enddate_sim,
cfg.meteo['inc']):
cfg.meteo['inc']):
meteo_file = cfg.icon_input_icbc / (
cfg.meteo['prefix'] + time.strftime(cfg.meteo['nameformat']))
if cfg.workflow_name == 'icon-art' or cfg.workflow_name == 'icon-art-oem':
Expand Down Expand Up @@ -228,7 +229,8 @@ def main(cfg):
if not src_file.exists() and cfg.meteo.get('dir_alt') \
is not None:
meteo_dir = cfg.meteo['dir_alt']
subdir = meteo_dir / cfg.startdate_sim.strftime('%y%m%d%H')
subdir = meteo_dir / cfg.startdate_sim.strftime(
'%y%m%d%H')
src_file = subdir / ('eas' + time.strftime('%Y%m%d%H'))
dest_path = cfg.int2lm_input / 'meteo' / (
cfg.meteo['prefix'] + '00000000')
Expand All @@ -241,18 +243,20 @@ def main(cfg):
days_total = str(td_total.days).zfill(2)
hours_total = str(td_total.seconds // 3600).zfill(2)

src_file = subdir / (
cfg.meteo['prefix'] + days + hours + '0000')
src_file = subdir / (cfg.meteo['prefix'] + days + hours +
'0000')
dest_path = cfg.int2lm_input / 'meteo' / (
cfg.meteo['prefix'] + days_total + hours_total + '0000')
cfg.meteo['prefix'] + days_total + hours_total +
'0000')

# Next time, change directory
checkdir = meteo_dir / time.strftime('%y%m%d%H')
if checkdir.is_dir():
num_steps += 1
subdir = checkdir
elif cfg.meteo.get('dir_alt') is not None:
checkdir = cfg.meteo['dir_alt'] / time.strftime('%y%m%d%H')
checkdir = cfg.meteo['dir_alt'] / time.strftime(
'%y%m%d%H')
if checkdir.is_dir():
num_steps += 1
subdir = checkdir
Expand Down Expand Up @@ -333,8 +337,9 @@ def main(cfg):
cfg.enddate_sim, inc):
logging.info(time)

filename = inv["outdir"] / (
p["suffix"] + "_" + time.strftime("%Y%m%d%H") + ".nc")
filename = inv["outdir"] / (p["suffix"] + "_" +
time.strftime("%Y%m%d%H") +
".nc")
if not filename.exists():
logging.info(filename)
try:
Expand Down

0 comments on commit 837334d

Please sign in to comment.