Skip to content

Commit

Permalink
make concise
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanLaserGit committed Oct 7, 2024
1 parent 528a4dd commit 87c1df8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_datastream_options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 27 additions & 13 deletions python_tools/src/python_tools/configure_datastream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 87c1df8

Please sign in to comment.