-
Notifications
You must be signed in to change notification settings - Fork 18
/
run_c2w.py
59 lines (41 loc) · 1.47 KB
/
run_c2w.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
'''
Date: Feb 25, 2021
This is the main script to drive the CMIP6-WRF data extraction.
Revision:
Jul 3, 2022 --- Revised for NCL version
Feb 25, 2021 --- MVP v0.01 completed
Zhenning LI
'''
import lib
import logging, logging.config
from utils import utils
import argparse
import os
def main_run():
# logging manager
logging.config.fileConfig('./conf/logging_config.ini')
parser = argparse.ArgumentParser(
description='Process some user inputs.')
parser.add_argument(
'-m', '--model_name', type=str,
default='MPI-ESM1-2-HR', help='Model name for config file path')
args = parser.parse_args()
config_file_path = f'./conf/config.{args.model_name}.ini'
if not os.path.exists(config_file_path):
utils.throw_error(
f'Error: Invalid input model_name "{args.model_name}"')
exit()
utils.write_log(f'Read Config for {args.model_name}...')
cfg_hdl=lib.cfgparser.read_cfg(config_file_path)
utils.write_log('Construct CMIPHandler...')
cmip_hdl=lib.cmip_handler.CMIPHandler(cfg_hdl)
for time_frm in cmip_hdl.out_time_series:
utils.write_log('Processing time: '+str(time_frm))
cmip_hdl.parse_data(time_frm)
utils.write_log('Writing time: '+str(time_frm))
cmip_hdl.write_wrfinterm(time_frm, 'main')
if cmip_hdl.model_name=='BCMM':
cmip_hdl.write_wrfinterm(time_frm, 'sst')
if __name__=='__main__':
main_run()