-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvic_assimilate_streamflow.py
More file actions
executable file
·64 lines (51 loc) · 2.55 KB
/
vic_assimilate_streamflow.py
File metadata and controls
executable file
·64 lines (51 loc) · 2.55 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
#!/usr/bin/env python
import argparse
import ConfigParser
import os
import vic.assimilate as va
from utils.parse import parse_date
def parse_commandline():
parser = argparse.ArgumentParser(description='Update VIC state file '
'based on assimilation of observed '
'streamflow')
parser.add_argument('--date', required=True,
metavar='<date>',
help='Forecast date: YYYY-MM-DD')
parser.add_argument('--stations', required=True,
metavar='<stations>',
help='Comma-delimited list of stations to use '
'in the update')
parser.add_argument('--config', required=True,
metavar='<configuration file>',
help='Configuration file')
args = parser.parse_args()
forecastdate = parse_date(args.date, '-')
configparser = ConfigParser.ConfigParser()
configparser.read(os.path.expanduser(args.config))
config = {}
for section in configparser.sections():
for key, value in configparser.items(section):
config[key] = value
config['timeofconcentration'] = int(config['timeofconcentration'])
config['latlondigits'] = int(config['latlondigits'])
stations = dict((station, config['timeofconcentration'])
for station in args.stations.split(','))
return (forecastdate, stations, config)
def main():
(forecastdate, stations, config) = parse_commandline()
stationinfo = va.assimilate_streamflow(forecastdate=forecastdate,
stationdict=stations,
statetemplate=config['statetemplate'],
soilfile=config['soilfile'],
masktemplate=config['masktemplate'],
fluxtemplate=config['fluxtemplate'],
vicflowtemplate=config['vicflowtemplate'],
obsflowtemplate=config['obsflowtemplate'],
polytemplate=config['polytemplate'],
latlondigits=config['latlondigits'])
# for station in sorted(stationinfo.iterkeys()):
# print '{}:'.format(station)
# for k,v in stationinfo[station].iteritems():
# print '\t{} : {}'.format(k, v)
if __name__ == "__main__":
main()