-
Notifications
You must be signed in to change notification settings - Fork 23
/
write_cfg.py
executable file
·52 lines (42 loc) · 1.46 KB
/
write_cfg.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
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#from ecmwfapi import ECMWFDataServer
#import cdsapi
#from ecmwfapi import ECMWFDataServer
#from calendar import monthrange
#from calendar import month_name
from optparse import OptionParser
import sys
import datetime
import string
import numpy as np
import era5utils
"""
MAIN PROGRAM: writes an cfg file for conversion utility
PRGRMMR: Alice Crawford ORG: CICS-MD DATE:2017-10-16
PYTHON 3.x
"""
##Parse command line arguments and set defaults#####
parser = OptionParser()
parser.add_option("-t", type="str" , dest="levtype", default='ml',
help="ml for model levels, pl for pressure levels")
#If no retrieval options are set then retrieve 2d data and 2d data in one file.
(options, args) = parser.parse_args()
levtype = options.levtype
param2da = ['T02M', 'V10M', 'U10M', 'PRSS','PBLH', 'CAPE','SHGT']
tm=1
print('Level type', levtype)
if levtype=='pl':
levs = era5utils.pressure_levels()
param3d = ['TEMP' , 'UWND', 'VWND' , 'WWND' , 'RELH' , 'HGTS' ]
rstr = 'reanalysis-era5-pressure-levels'
estr='pl'
elif levtype=='ml':
levs = era5utils.model_levels_default()
param3d = ['TEMP' , 'UWND', 'VWND' , 'WWND' , 'SPHU', 'HGTS','LNSP']
rstr = 'reanalysis-era5-complete'
estr='ml'
elif levtype=='enda':
param3d = ['TEMP' , 'UWND', 'VWND' , 'WWND' , 'RELH' , 'HGTS' ]
rstr = 'reanalysis-era5-complete'
estr='enda'
era5utils.write_cfg(param3d, param2da, levs, tm=tm, levtype=levtype)