-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
133 lines (123 loc) · 3.9 KB
/
main.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import os
import argparse
import subprocess
import sys
sys.path.append("scripts/libs")
from configdeode import ConfigDeode
def main():
parser = argparse.ArgumentParser(
description=(
"automation of the main.sh for integration into the deode ",
"workflow"
)
)
parser.add_argument(
"--config_file", type=str, help="deode configuration file [.toml]")
parser.add_argument(
"--obs", type=str, default="IMERG_pcp",
help="OBS argument (default: IMERG_pcp)"
)
parser.add_argument(
"--case", type=str, help="Case argument"
)
parser.add_argument(
"--exp", type=str, help="exp argument"
)
parser.add_argument(
"--exp_ref", type=str,
help="reference experiment to be compared with"
)
parser.add_argument(
"--link_obs", action="store_true", help="Launch link_obs.py"
)
parser.add_argument(
"--run_regrid", action="store_true", help="Launch regrid.py"
)
parser.add_argument(
"--run_plot_regrid", action="store_true", help="Launch plot_regrid.py"
)
parser.add_argument(
"--run_verif", action="store_true", help="Launch verification.py"
)
parser.add_argument(
"--run_panels", action="store_true", help="Launch create_panels.py"
)
parser.add_argument(
"--run_comparison", action="store_true",
help="Launch comparison scripts"
)
parser.add_argument(
"--replace_outputs", action="store_true", help=(
"The new outputs will replace those that may exist previously. "
"Only plot_regrid and verification tasks are affected."
)
)
args = parser.parse_args()
if args.config_file:
if os.path.exists(args.config_file):
config_deode = ConfigDeode(
config_toml=args.config_file,
yaml_exp_template="config/templates/config_exp.yaml",
yaml_case_template="config/templates/config_Case.yaml"
)
exp = config_deode.write_config_exp()
if args.case:
case = args.case
else:
case = config_deode.write_config_case()
else:
print(f"ERROR: Configuration file {args.config_file} not found")
sys.exit(1)
else:
if not args.case or not args.exp:
print(
"ERROR: You must set case and exp arguments if no " \
+ "config_file is specified"
)
sys.exit(1)
exp = args.exp
case = args.case
if args.replace_outputs:
replace = "True"
else:
replace = "False"
subprocess.run([
"python3", "scripts/verification/set_environment.py",
args.obs, case, exp
])
if args.link_obs:
subprocess.run([
"python3", "scripts/verification/link_obs.py",
args.obs, case
])
if args.run_regrid:
subprocess.run([
"python3", "scripts/verification/regrid.py",
args.obs, case, exp
])
if args.run_plot_regrid:
subprocess.run([
"python3", "scripts/utils/plot_regrid.py",
args.obs, case, exp, replace
])
if args.run_verif:
subprocess.run([
"python3", "scripts/verification/verification.py",
args.obs, case, exp, replace
])
if args.run_panels:
subprocess.run([
"python3", "scripts/utils/create_panels.py",
args.obs, case, exp
])
if args.run_comparison and args.exp_ref:
subprocess.run([
'python3', 'scripts/verification/compExps_metrics.py',
args.obs, case, f"{args.exp_ref}-VS-{exp}"
])
subprocess.run([
'python3', 'scripts/verification/compExps_maps.py',
args.obs, case, f"{args.exp_ref}-VS-{exp}"
])
if __name__ == '__main__':
main()