forked from NOAA-EMC/global-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexgdas_enkf_earc_tars.py
executable file
·59 lines (42 loc) · 1.93 KB
/
exgdas_enkf_earc_tars.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import os
from pygfs.task.archive import Archive
from wxflow import AttrDict, Logger, cast_strdict_as_dtypedict, chdir, logit
# initialize root logger
logger = Logger(level=os.environ.get("LOGGING_LEVEL", "DEBUG"), colored_log=True)
@logit(logger)
def main():
config = cast_strdict_as_dtypedict(os.environ)
# Instantiate the Archive object
archive = Archive(config)
# Pull out all the configuration keys needed to run the rest of archive steps
keys = ['ATARDIR', 'current_cycle', 'IAUFHRS', 'RUN', 'PDY',
'PSLOT', 'HPSSARCH', 'LOCALARCH', 'ROTDIR', 'PARMgfs',
'ARCDIR', 'SDATE', 'MODE', 'ENSGRP', 'NMEM_EARCGRP',
'NMEM_ENS', 'DO_CALC_INCREMENT_ENKF_GFS', 'DO_JEDIATMENS',
'lobsdiag_forenkf', 'FHMIN_ENKF', 'FHMAX_ENKF_GFS',
'FHOUT_ENKF_GFS', 'FHMAX_ENKF', 'FHOUT_ENKF', 'ENKF_SPREAD',
'restart_interval_enkfgdas', 'restart_interval_enkfgfs',
'DOHYBVAR', 'DOIAU_ENKF', 'IAU_OFFSET', 'DOIAU', 'DO_CA',
'DO_CALC_INCREMENT', 'assim_freq', 'ARCH_CYC', 'DO_JEDISNOWDA',
'ARCH_WARMICFREQ', 'ARCH_FCSTICFREQ',
'IAUFHRS_ENKF', 'NET', 'NMEM_ENS_GFS']
archive_dict = AttrDict()
for key in keys:
archive_dict[key] = archive.task_config.get(key)
if archive_dict[key] is None:
print(f"Warning: key ({key}) not found in task_config!")
# Also import all COMIN* directory and template variables
for key in archive.task_config.keys():
if key.startswith("COM"):
archive_dict[key] = archive.task_config[key]
cwd = os.getcwd()
os.chdir(config.ROTDIR)
# Determine which archives to create
atardir_sets = archive.configure_tars(archive_dict)
# Create the backup tarballs and store in ATARDIR
for atardir_set in atardir_sets:
archive.execute_backup_dataset(atardir_set)
os.chdir(cwd)
if __name__ == '__main__':
main()