-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathramsin_adv_model_validator.py
More file actions
326 lines (266 loc) · 9.68 KB
/
Copy pathramsin_adv_model_validator.py
File metadata and controls
326 lines (266 loc) · 9.68 KB
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
from __future__ import annotations
import ramsin_adv_model
from pydantic import BaseSettings, validator
from ramsin_model_config import RamsinConfig
class ModelGrids2(ramsin_adv_model.ModelGrids2):
@validator("ihtran")
def ihtran_valid_values(cls, v):
choices = [0, 1]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("ideltat")
def ideltat_valid_values(cls, v):
choices = [0, 1, 2]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
class CcattInfo2(ramsin_adv_model.CcattInfo2):
@validator("split_method")
def split_method_valid_values(cls, v):
choices = ['SYMMETRIC', 'SEQUENTIAL', 'PARALLEL']
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("chemistry_aq", "recycle_tracers", "plumerise", "volcanoes")
def ccattinfo2_on_off_valid_values(cls, v):
choices = [0, 1]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("def_proc_src")
def def_proc_src_valid_values(cls, v):
choices = ['STOP', 'LAST_SOURCES']
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
class TebSpmInfo(ramsin_adv_model.TebSpmInfo):
@validator("teb_spm")
def teb_spm_valid_values(cls, v):
choices = [0, 1]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
class ModelFileInfo2(ramsin_adv_model.ModelFileInfo2):
@validator("nud_type")
def nud_type_valid_values(cls, v):
choices = [0, 1, 2, 3, 4]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("iclobber", "ihistdel", "ipastin", "kwrite", "initfld", "iupdndvi",
"iupdsst", "mkcoltab")
def modelfileinfo2_on_off_valid_values(cls, v):
choices = [0, 1]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("applyiau")
def applyiau_valid_values(cls, v):
choices = [0, 1, 2]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
class ModelOptions2(ramsin_adv_model.ModelOptions2):
@validator("dyncore_flag")
def dyncore_flag_valid_values(cls, v):
choices = [0, 1, 2, 3]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("advmnt")
def advmnt_valid_values(cls, v):
choices = [0, 1, 2]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("iexev")
def iexev_valid_values(cls, v):
choices = [1, 2]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("jbnd")
def jbnd_valid_values(cls, v):
choices = [1, 2, 3, 4]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("lsflg")
def lsflg_valid_values(cls, v):
choices = [0, 1, 2, 3]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("npatch")
def npatch_valid_values(cls, v):
minimum = 2
if v < minimum:
raise ValueError(f"Value must be greater or equal to {minimum}")
return v
@validator("nvegpat")
def nvegpat_valid_values(cls, v, values):
minimum = 1
if v < minimum or (values.get("npatch") is not None and v >= values["npatch"]):
raise ValueError(
f"Value must be greater or equal to {minimum} and lesser than NPATCH")
return v
@validator("nvgcon")
def nvgcon_valid_values(cls, v):
choices = list(range(1, 19)) # 1 - 18
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("nslcon")
def nslcon_valid_values(cls, v):
choices = list(range(1, 13)) # 1 - 12
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("ihorgrad")
def ihorgrad_valid_values(cls, v):
choices = [1, 2]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("irime")
def irime_valid_values(cls, v):
choices = [0, 1]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("iplaws")
def iplaws_valid_values(cls, v):
choices = [0, 1]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("icorflg", "imassflx", "lonrad", "g3d_spread")
def modeloptions2_on_off_valid_values(cls, v):
choices = [0, 1]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("idiffk")
def idiffk_valid_values(cls, v):
choices = list(range(1, 9)) # 1 - 8
for element in v:
if element not in choices:
raise ValueError(f"Each value must be one of {choices}")
return v
@validator("soil_moist")
def soil_moist_valid_values(cls, v):
choices = ['n', 'i', 'h', 'a']
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
class ModelSound(ramsin_adv_model.ModelSound):
@validator("ipsflg")
def ipsflg_valid_values(cls, v):
choices = [0, 1]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("itsflg")
def itsflg_valid_values(cls, v):
choices = [0, 1, 2]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("irtsflg")
def irtsflg_valid_values(cls, v):
choices = [0, 1, 2, 3, 4]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("iusflg")
def iusflg_valid_values(cls, v):
choices = [0, 1]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
class ModelPrint(ramsin_adv_model.ModelPrint):
@validator("nplt")
def nplt_valid_values(cls, v):
if v < 0 or v > 50:
raise ValueError(f"Value must be between 0 and 50")
return v
@validator("ixsctn")
def ixsctn_valid_values(cls, v):
choices = [1, 2, 3]
for element in v:
if element not in choices:
raise ValueError(f"Each value must be one of {choices}")
return v
@validator("iplfld")
def iplfld_valid_values(cls, v):
choices = ['UP', 'VP', 'WP', 'PP', 'THP', 'RT', 'RC', 'PCPT', 'TKE', 'HSCL',
'RR', 'RP', 'RA', 'TV', 'CP', 'RV', 'RTP',
'VSCL', 'THETA', 'RL', 'TG', 'SLM', 'THVP', 'RI', 'RCOND', 'CONPR',
'CONP', 'CONH', 'CONM', 'THIL', 'TEMP', 'TVP', 'THV', 'RELHUM',
'SPEED', 'FTHRD', 'MICRO', 'Z0', 'ZI', 'ZMAT', 'USTARL', 'USTARW',
'TSTARL', 'TSTARW', 'RSTARL', 'RSTARW', 'UW', 'VW', 'WFZ', 'TFZ',
'QFZ', 'RLONG', 'RSHORT']
for element in v:
if element not in choices:
raise ValueError(f"Each value must be one of {choices}")
return v
class IsanControl2(ramsin_adv_model.IsanControl2):
@validator("guess1st")
def guess1st_valid_values(cls, v):
choices = ['PRESS', 'RAMS']
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("i1st_flg")
def i1st_flg_valid_values(cls, v):
choices = [1, 2, 3]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("iupa_flg")
def iupa_flg_valid_values(cls, v):
choices = [1, 2, 3]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("isfc_flg")
def isfc_flg_valid_values(cls, v):
choices = [1, 2, 3]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
@validator("ioflgisz", "ioflgvar")
def ioflgisz_ioflgvar_valid_values(cls, v):
choices = [0, 1]
if v not in choices:
raise ValueError(f"Value must be one of {choices}")
return v
class IsanIsentropic2(ramsin_adv_model.IsanIsentropic2):
@validator("nisn")
def nisn_gte_1(cls, v):
if v < 1:
raise ValueError("Value must be greater or equal to 1")
return v
@validator("levth")
def levth_length_eq_nisn(cls, v, values):
if values.get("nisn") is not None and len(v) != values["nisn"]:
raise ValueError("Length must be equal to nisn")
return v
class Digitalfilter(ramsin_adv_model.Digitalfilter):
pass
class Meteogram(ramsin_adv_model.Meteogram):
pass
class RamsinAdvanced(BaseSettings):
class Config(RamsinConfig): pass
model_grids2: ModelGrids2
ccatt_info2: CcattInfo2
teb_spm_info: TebSpmInfo
model_file_info2: ModelFileInfo2
model_options2: ModelOptions2
model_sound: ModelSound
model_print: ModelPrint
isan_control2: IsanControl2
isan_isentropic2: IsanIsentropic2
digitalfilter: Digitalfilter
meteogram: Meteogram