-
Notifications
You must be signed in to change notification settings - Fork 37
/
setup_default_args.py
161 lines (137 loc) · 4.04 KB
/
setup_default_args.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
from __future__ import print_function
import json
import os
# Populate default arguments
ArgDefaults = {}
ArgDefaults["--parameters"] = {"aliases": ["-p"]}
ArgDefaults["--modpath"] = {
"aliases": ["--mp"],
"type": "str",
"dest": "modpath",
"help": "Explicit path to model data",
}
ArgDefaults["--modnames"] = {
"aliases": ["--mns"],
"type": "ast.literal_eval",
"dest": "modnames",
"default": "None",
"help": "A list of names that can be used to loop through modpath",
}
ArgDefaults["--mip"] = {
"aliases": ["--MIP"],
"type": "ast.literal_eval",
"dest": "mip",
"default": "None",
"help": "A WCRP MIP project such as CMIP3 and CMIP5",
}
ArgDefaults["--exp"] = {
"aliases": ["--EXP"],
"type": "ast.literal_eval",
"dest": "exp",
"default": "None",
"help": "An experiment such as AMIP, historical or pi-contorl",
}
ArgDefaults["--start_day"] = {
"aliases": ["--sd"],
"type": "ast.literal_eval",
"dest": "startday",
"default": "None",
"help": "The start day of, for example, data to extract from a time series",
}
ArgDefaults["--start_month"] = {
"aliases": ["--sm"],
"type": "ast.literal_eval",
"dest": "startmonth",
"default": "None",
"help": "The start month of, for example, data to extract from a time series",
}
ArgDefaults["--start_year"] = {
"aliases": ["--sy"],
"type": "ast.literal_eval",
"dest": "startyear",
"default": "None",
"help": "The start year of, for example, data to extract from a time series",
}
ArgDefaults["--end_day"] = {
"aliases": ["--ed"],
"type": "ast.literal_eval",
"dest": "endday",
"default": "None",
"help": "The end day of, for example, data to extract from a time series",
}
ArgDefaults["--end_month"] = {
"aliases": ["--em"],
"type": "ast.literal_eval",
"dest": "endmonth",
"default": "None",
"help": "The end month of, for example, data to extract from a time series",
}
ArgDefaults["--end_year"] = {
"aliases": ["--ey"],
"type": "ast.literal_eval",
"dest": "endyear",
"default": "None",
"help": "The end year of, for example, data to extract from a time series",
}
ArgDefaults["--seasons"] = {
"aliases": ["--seas"],
"type": "ast.literal_eval",
"dest": "sea",
"default": "None",
"help": 'A list of seasons, e.g., ["DJF","JJA"]',
}
ArgDefaults["--results_dir"] = {
"aliases": ["--rd"],
"type": "str",
"default": "None",
"help": "The name of the folder where all runs will be stored.",
}
ArgDefaults["--case_id"] = {
"aliases": ["--cid"],
"dest": "modnames",
"default": "None",
"help": "The name of the subdirectory (below results_dir where results from a paritcular code execution is stored ",
}
ArgDefaults["--reference_data_path"] = {
"aliases": ["--rdp"],
"type": "str",
"help": "The path/filename of reference (obs) data.",
}
ArgDefaults["--test_data_path"] = {
"aliases": ["--tp"],
"help": "The path/filename to model output.",
}
ArgDefaults["--diags"] = {
"aliases": ["-d"],
"help": "Path to other user-defined parameter file.",
"help": "Path to other user-defined parameter file.",
"type": "str",
"nargs": "+",
"required": False,
"dest": "other_parameters",
}
ArgDefaults["--num_workers"] = {
"aliases": ["-n"],
"help": "Number of workers, used when running with multiprocessing or in distributed mode.",
"type": "int",
"required": False,
}
ArgDefaults['--scheduler_addr"'] = {
"aliases": ["--N/A"],
"help": "Address of scheduler in the form of IP_ADDRESS:PORT. Used when running in distributed mode.",
"type": "str",
"required": False,
}
ArgDefaults["--variables"] = {
"aliases": ["--vars"],
"help": "A list of variables to be processed",
}
# Write arguments json
if os.path.exists("DefArgsCIA.json"):
print("File existing, purging: DefArgsCIA.json")
os.remove("DefArgsCIA.json")
fH = open("DefArgsCIA.json", "w")
json.dump(
ArgDefaults, fH, ensure_ascii=True, sort_keys=True, indent=4, separators=(",", ":")
)
fH.close()