From 87c1df8e1573b07b38399378bd80575f34a45789 Mon Sep 17 00:00:00 2001 From: Jordan Laser Date: Mon, 7 Oct 2024 11:48:17 -0600 Subject: [PATCH] make concise --- .github/workflows/test_datastream_options.yml | 2 +- .../src/python_tools/configure_datastream.py | 40 +++++++++++++------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test_datastream_options.yml b/.github/workflows/test_datastream_options.yml index 0b75fd83..39550930 100644 --- a/.github/workflows/test_datastream_options.yml +++ b/.github/workflows/test_datastream_options.yml @@ -133,6 +133,6 @@ jobs: if: always() run: | sudo rm -rf $(pwd)/data/datastream_test - ./scripts/stream.sh -s DAILY_ANALYSIS_ASSIM_EXTEND -d $(pwd)/data/datastream_test -g $(pwd)/palisade.gpkg -R $(pwd)/configs/ngen/realization_sloth_nom_cfe_pet.json + ./scripts/stream.sh -s DAILY_ANALYSIS_ASSIM_EXTEND -e $(date -d '-2 day' '+%Y%d%m0000') -d $(pwd)/data/datastream_test -g $(pwd)/palisade.gpkg -R $(pwd)/configs/ngen/realization_sloth_nom_cfe_pet.json \ No newline at end of file diff --git a/python_tools/src/python_tools/configure_datastream.py b/python_tools/src/python_tools/configure_datastream.py index 46a95fe3..56086a0e 100644 --- a/python_tools/src/python_tools/configure_datastream.py +++ b/python_tools/src/python_tools/configure_datastream.py @@ -7,6 +7,27 @@ PATTERN_VPU = r'\$VPU' +NWMURL_RUN_INPUT_MAPPING = { + "SHORT_RANGE": 1, + "MEDIUM_RANGE": 2, + "MEDIUM_RANGE_NO_DA": 3, + "LONG_RANGE": 4, + "ANALYSIS_ASSIM": 5, + "ANALYSIS_ASSIM_EXTEND": 6, + "ANALYSIS_ASSIM_EXTEND_NO_DA": 7, + "ANALYSIS_ASSIM_LONG": 8, + "ANALYSIS_ASSIM_LONG_NO_DA": 9, + "ANALYSIS_ASSIM_NO_DA": 10, + "SHORT_RANGE_NO_DA": 11 +} + +NWMURL_NUM_HRS_MAPPING = { + "SHORT_RANGE": 18, + "MEDIUM_RANGE": 240, + "ANALYSIS_ASSIM": 3, + "ANALYSIS_ASSIM_EXTEND": 28, +} + def bytes2human(n): # http://code.activestate.com/recipes/578019 # >>> bytes2human(10000) @@ -146,19 +167,12 @@ def create_confs(args): start_date = datetime.strptime(conf['globals']['end_date'],'%Y%m%d%H%M') retro_or_op="operational" run_type='daily' - - if "SHORT_RANGE" in conf['globals']['start_date']: - num_hrs = 18 - runinput = 1 - run_type='short_range' - if "MEDIUM_RANGE" in conf['globals']['start_date']: - num_hrs = 240 - runinput = 2 - run_type='medium_range' - if "ANALYSIS_ASSIM_EXTEND" in conf['globals']['start_date']: - num_hrs = 28 - runinput = 6 - run_type='analysis_assim_extend' + parts = conf['globals']['start_date'].split('_') + if len(parts) > 1: + RUN_NAME='_'.join(parts[1:]) + runinput = NWMURL_RUN_INPUT_MAPPING[RUN_NAME] + run_type='_'.join([x.lower() for x in parts[1:]]) + num_hrs = NWMURL_NUM_HRS_MAPPING[RUN_NAME] start_datetime0 = start_date.replace(hour=1, minute=0, second=0, microsecond=0) end_datetime = start_datetime0 + timedelta(hours=num_hrs-1)