From 3b171d7169be46e3606c6abb7c21f6eed3c7d960 Mon Sep 17 00:00:00 2001 From: Cory Martin Date: Wed, 15 Nov 2023 11:22:54 -0600 Subject: [PATCH] working version I think --- parm/ioda/bufr2ioda/bufr2ioda_atms.yaml | 2 +- ush/ioda/bufr2ioda/gen_bufr2ioda_yaml.py | 7 +++++++ ush/ioda/bufr2ioda/run_bufr2ioda.py | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/parm/ioda/bufr2ioda/bufr2ioda_atms.yaml b/parm/ioda/bufr2ioda/bufr2ioda_atms.yaml index a7180614d..37b40260f 100644 --- a/parm/ioda/bufr2ioda/bufr2ioda_atms.yaml +++ b/parm/ioda/bufr2ioda/bufr2ioda_atms.yaml @@ -83,7 +83,7 @@ observations: ioda: backend: netcdf - obsdataout: "{{ COM_OBS }}/{{ RUN }}.t{{ cyc }}z.atms.{{splits/satId}}.tm00.nc" + obsdataout: "{{ COM_OBS }}/{{ RUN }}.t{{ cyc }}z.atms.$(splitvar).tm00.nc" dimensions: - name: Channel diff --git a/ush/ioda/bufr2ioda/gen_bufr2ioda_yaml.py b/ush/ioda/bufr2ioda/gen_bufr2ioda_yaml.py index 5526bbd4e..8a650e67e 100755 --- a/ush/ioda/bufr2ioda/gen_bufr2ioda_yaml.py +++ b/ush/ioda/bufr2ioda/gen_bufr2ioda_yaml.py @@ -6,12 +6,19 @@ import argparse import os from wxflow import Logger, parse_j2yaml, cast_strdict_as_dtypedict, save_as_yaml +from wxflow import Template, TemplateConstants + +# initialize root logger +logger = Logger('gen_bufr2ioda_yaml.py', level='INFO', colored_log=True) def gen_bufr_yaml(config, template, output): # read in templated YAML and do substitution logger.info(f"Using {template} as input") bufr_config = parse_j2yaml(template, config) + # need to do some special manipulation for the splits + substitutions = {'splitvar': '{{splits/satId}}'} + bufr_config = Template.substitute_structure(bufr_config, TemplateConstants.DOLLAR_PARENTHESES, substitutions.get) save_as_yaml(bufr_config, output) logger.info(f"Wrote to {output}") diff --git a/ush/ioda/bufr2ioda/run_bufr2ioda.py b/ush/ioda/bufr2ioda/run_bufr2ioda.py index 96ae80a2d..c2de34cf8 100755 --- a/ush/ioda/bufr2ioda/run_bufr2ioda.py +++ b/ush/ioda/bufr2ioda/run_bufr2ioda.py @@ -29,7 +29,9 @@ def bufr2ioda(current_cycle, RUN, DMPDIR, config_template_dir, COM_OBS): 'RUN': RUN, 'current_cycle': current_cycle, 'DMPDIR': DMPDIR, - 'COM_OBS': COM_OBS + 'COM_OBS': COM_OBS, + 'PDY': current_cycle.strftime('%Y%m%d'), + 'cyc': current_cycle.strftime('%H'), } # Specify observation types to be processed by a script @@ -59,7 +61,7 @@ def bufr2ioda(current_cycle, RUN, DMPDIR, config_template_dir, COM_OBS): # Specify observation types to be processed by the bufr2ioda executable BUFR_yaml_files = glob.glob(os.path.join(config_template_dir, '*.yaml')) - BUFR_py_files = [os.path.basename(f) for f in BUFR_yaml_files] + BUFR_yaml_files = [os.path.basename(f) for f in BUFR_yaml_files] BUFR_yaml = [f.replace('bufr2ioda_', '').replace('.yaml', '') for f in BUFR_yaml_files] for obtype in BUFR_yaml: