|
9 | 9 | import glob
|
10 | 10 | import shutil
|
11 | 11 | import global_det_atmos_util as gda_util
|
| 12 | +import sys |
12 | 13 |
|
13 | 14 | print("BEGIN: "+os.path.basename(__file__))
|
14 | 15 |
|
|
25 | 26 | RUN = os.environ['RUN']
|
26 | 27 | COMPONENT = os.environ['COMPONENT']
|
27 | 28 | STEP = os.environ['STEP']
|
| 29 | +MODEL_list = os.environ['MODEL_list'].split(' ') |
28 | 30 | gfs_ver = os.environ['gfs_ver']
|
29 | 31 | cmc_ver = os.environ['cmc_ver']
|
30 | 32 | cfs_ver = os.environ['cfs_ver']
|
|
207 | 209 | +'t{init?fmt=%2H}z.'
|
208 | 210 | +'f{lead?fmt=%3H}')
|
209 | 211 |
|
210 |
| -for model in list(global_det_model_dict.keys()): |
211 |
| - print("---- Prepping data for "+model+" for init "+INITDATE) |
212 |
| - model_dict = global_det_model_dict[model] |
| 212 | +for MODEL in MODEL_list: |
| 213 | + if MODEL not in list(global_det_model_dict.keys()): |
| 214 | + print("ERROR: "+MODEL+" not recongized") |
| 215 | + sys.exit(1) |
| 216 | + print("---- Prepping data for "+MODEL+" for init "+INITDATE) |
| 217 | + model_dict = global_det_model_dict[MODEL] |
213 | 218 | for cycle in model_dict['cycles']:
|
214 | 219 | CDATE = INITDATE+cycle
|
215 | 220 | CDATE_dt = datetime.datetime.strptime(CDATE, '%Y%m%d%H')
|
|
223 | 228 | )
|
224 | 229 | arch_fcst_file = gda_util.format_filler(
|
225 | 230 | arch_fcst_file_format, VDATE_dt, CDATE_dt,
|
226 |
| - str(fcst_hr), {'model': model} |
| 231 | + str(fcst_hr), {'model': MODEL} |
227 | 232 | )
|
228 | 233 | if not os.path.exists(arch_fcst_file):
|
229 | 234 | print("----> Trying to create "+arch_fcst_file)
|
230 | 235 | arch_fcst_file_dir = arch_fcst_file.rpartition('/')[0]
|
231 | 236 | if not os.path.exists(arch_fcst_file_dir):
|
232 | 237 | os.makedirs(arch_fcst_file_dir)
|
233 |
| - if model in ['ecmwf']: |
| 238 | + if MODEL in ['ecmwf']: |
234 | 239 | gda_util.run_shell_command(['chmod', '750',
|
235 | 240 | arch_fcst_file_dir])
|
236 | 241 | gda_util.run_shell_command(['chgrp', 'rstprod',
|
237 | 242 | arch_fcst_file_dir])
|
238 |
| - if model == 'gfs': |
| 243 | + if MODEL == 'gfs': |
239 | 244 | gda_util.prep_prod_gfs_file(prod_fcst_file,
|
240 | 245 | arch_fcst_file,
|
241 | 246 | str(fcst_hr),
|
242 | 247 | 'full')
|
243 |
| - elif model == 'jma': |
| 248 | + elif MODEL == 'jma': |
244 | 249 | gda_util.prep_prod_jma_file(prod_fcst_file,
|
245 | 250 | arch_fcst_file,
|
246 | 251 | str(fcst_hr),
|
247 | 252 | 'full')
|
248 |
| - elif model == 'ecmwf': |
| 253 | + elif MODEL == 'ecmwf': |
249 | 254 | gda_util.prep_prod_ecmwf_file(prod_fcst_file,
|
250 | 255 | arch_fcst_file,
|
251 | 256 | str(fcst_hr),
|
252 | 257 | 'full')
|
253 |
| - elif model == 'ukmet': |
| 258 | + elif MODEL == 'ukmet': |
254 | 259 | gda_util.prep_prod_ukmet_file(prod_fcst_file,
|
255 | 260 | arch_fcst_file,
|
256 | 261 | str(fcst_hr),
|
|
264 | 269 | )
|
265 | 270 | arch_precip_file = gda_util.format_filler(
|
266 | 271 | arch_precip_file_format, VDATE_dt,
|
267 |
| - CDATE_dt, str(fcst_hr), {'model': model} |
| 272 | + CDATE_dt, str(fcst_hr), {'model': MODEL} |
268 | 273 | )
|
269 | 274 | if not os.path.exists(arch_precip_file) and fcst_hr != 0:
|
270 | 275 | print("----> Trying to create "+arch_precip_file)
|
|
273 | 278 | )
|
274 | 279 | if not os.path.exists(arch_precip_file_dir):
|
275 | 280 | os.makedirs(arch_precip_file_dir)
|
276 |
| - if model in ['ecmwf']: |
| 281 | + if MODEL in ['ecmwf']: |
277 | 282 | gda_util.run_shell_command(
|
278 | 283 | ['chmod', '750', arch_precip_file_dir]
|
279 | 284 | )
|
280 | 285 | gda_util.run_shell_command(
|
281 | 286 | ['chgrp', 'rstprod',
|
282 | 287 | arch_precip_file_dir]
|
283 | 288 | )
|
284 |
| - if model == 'gfs': |
| 289 | + if MODEL == 'gfs': |
285 | 290 | gda_util.prep_prod_gfs_file(prod_precip_file,
|
286 | 291 | arch_precip_file,
|
287 | 292 | str(fcst_hr),
|
288 | 293 | 'precip')
|
289 |
| - elif model == 'jma': |
| 294 | + elif MODEL == 'jma': |
290 | 295 | gda_util.prep_prod_jma_file(prod_precip_file,
|
291 | 296 | arch_precip_file,
|
292 | 297 | str(fcst_hr),
|
293 | 298 | 'precip')
|
294 |
| - elif model == 'ecmwf': |
| 299 | + elif MODEL == 'ecmwf': |
295 | 300 | gda_util.prep_prod_ecmwf_file(prod_precip_file,
|
296 | 301 | arch_precip_file,
|
297 | 302 | str(fcst_hr),
|
298 | 303 | 'precip')
|
299 |
| - elif model == 'ukmet': |
| 304 | + elif MODEL == 'ukmet': |
300 | 305 | gda_util.prep_prod_ukmet_file(prod_precip_file,
|
301 | 306 | arch_precip_file,
|
302 | 307 | str(fcst_hr),
|
303 | 308 | 'precip')
|
304 |
| - elif model == 'dwd': |
| 309 | + elif MODEL == 'dwd': |
305 | 310 | gda_util.prep_prod_dwd_file(prod_precip_file,
|
306 | 311 | arch_precip_file,
|
307 | 312 | str(fcst_hr),
|
308 | 313 | 'precip')
|
309 |
| - elif model == 'metfra': |
| 314 | + elif MODEL == 'metfra': |
310 | 315 | gda_util.prep_prod_metfra_file(prod_precip_file,
|
311 | 316 | arch_precip_file,
|
312 | 317 | str(fcst_hr),
|
|
322 | 327 | )
|
323 | 328 | arch_anl_file = gda_util.format_filler(
|
324 | 329 | arch_anl_file_format, CDATE_dt, CDATE_dt,
|
325 |
| - 'anl', {'model': model} |
| 330 | + 'anl', {'model': MODEL} |
326 | 331 | )
|
327 | 332 | if not os.path.exists(arch_anl_file):
|
328 | 333 | arch_anl_file_dir = arch_anl_file.rpartition('/')[0]
|
329 | 334 | if not os.path.exists(arch_anl_file_dir):
|
330 | 335 | os.makedirs(arch_anl_file_dir)
|
331 |
| - if model in ['ecmwf']: |
| 336 | + if MODEL in ['ecmwf']: |
332 | 337 | gda_util.run_shell_command(['chmod', '750',
|
333 | 338 | arch_anl_file_dir])
|
334 | 339 | gda_util.run_shell_command(['chgrp', 'rstprod',
|
335 | 340 | arch_anl_file_dir])
|
336 | 341 | print("----> Trying to create "+arch_anl_file)
|
337 |
| - if model == 'gfs': |
| 342 | + if MODEL == 'gfs': |
338 | 343 | gda_util.prep_prod_gfs_file(prod_anl_file,
|
339 | 344 | arch_anl_file,
|
340 | 345 | 'anl',
|
341 | 346 | 'full')
|
342 |
| - elif model == 'jma': |
| 347 | + elif MODEL == 'jma': |
343 | 348 | gda_util.prep_prod_jma_file(prod_anl_file,
|
344 | 349 | arch_anl_file,
|
345 | 350 | 'anl',
|
346 | 351 | 'full')
|
347 |
| - elif model == 'ecmwf': |
| 352 | + elif MODEL == 'ecmwf': |
348 | 353 | gda_util.prep_prod_ecmwf_file(prod_anl_file,
|
349 | 354 | arch_anl_file,
|
350 | 355 | 'anl',
|
351 | 356 | 'full')
|
352 |
| - elif model == 'ukmet': |
| 357 | + elif MODEL == 'ukmet': |
353 | 358 | gda_util.prep_prod_ukmet_file(prod_anl_file,
|
354 | 359 | arch_anl_file,
|
355 | 360 | 'anl',
|
|
0 commit comments