Skip to content

Commit f1c5475

Browse files
author
Alan D. Snow
committed
added forcing option for forecasts. However only supports constant flow
1 parent d76dcaa commit f1c5475

17 files changed

+304
-18
lines changed

spt_compute/imports/ecmwf_rapid_multiprocess_worker.py

+5
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def remove_file(file_name):
144144
ZS_dtR=15*60, #internal routing time step
145145
ZS_TauM=duration_1hr, #total simulation time
146146
ZS_dtM=interval_1hr, #RAPID internal loop time interval
147+
ZS_dtF=interval_1hr, # forcing time interval
147148
Vlat_file=inflow_file_name_1hr,
148149
Qout_file=outflow_file_name,
149150
Qinit_file=qinit_file,
@@ -166,6 +167,7 @@ def remove_file(file_name):
166167
ZS_dtR=15*60, #internal routing time step
167168
ZS_TauM=duration_3hr, #total simulation time
168169
ZS_dtM=interval_3hr, #RAPID internal loop time interval
170+
ZS_dtF=interval_3hr, # forcing time interval
169171
Vlat_file=inflow_file_name_3hr,
170172
Qout_file=qout_3hr)
171173
rapid_manager.run()
@@ -185,6 +187,7 @@ def remove_file(file_name):
185187
ZS_dtR=15*60, #internal routing time step
186188
ZS_TauM=duration_6hr, #total simulation time
187189
ZS_dtM=interval_6hr, #RAPID internal loop time interval
190+
ZS_dtF=interval_6hr, # forcing time interval
188191
Vlat_file=inflow_file_name_6hr,
189192
Qout_file=qout_6hr)
190193
rapid_manager.run()
@@ -243,6 +246,7 @@ def remove_file(file_name):
243246
ZS_dtR=15*60, #internal routing time step
244247
ZS_TauM=duration_3hr, #total simulation time
245248
ZS_dtM=interval_3hr, #RAPID internal loop time interval
249+
ZS_dtF=interval_3hr, # forcing time interval
246250
Vlat_file=inflow_file_name_3hr,
247251
Qout_file=outflow_file_name,
248252
Qinit_file=qinit_file,
@@ -264,6 +268,7 @@ def remove_file(file_name):
264268
ZS_dtR=15*60, #internal routing time step
265269
ZS_TauM=duration_6hr, #total simulation time
266270
ZS_dtM=interval_6hr, #RAPID internal loop time interval
271+
ZS_dtF=interval_6hr, # forcing time interval
267272
Vlat_file=inflow_file_name_6hr,
268273
Qout_file=qout_6hr)
269274
rapid_manager.run()

tests/conftest.py

+20-17
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
1717
RAPID_EXE_PATH = os.path.join(SCRIPT_DIR, "..", "..", "rapid", "src", "rapid")
1818

19+
1920
def compare_warnings(return_file, compare_return_file):
2021
"""compares warning json files"""
2122
with open(return_file) as returnfp, \
@@ -24,6 +25,7 @@ def compare_warnings(return_file, compare_return_file):
2425
creturndata = json.load(creturnfp)
2526
assert returndata == creturndata
2627

28+
2729
class TestDirectories(object):
2830
input = os.path.join(SCRIPT_DIR, 'input')
2931
compare = os.path.join(SCRIPT_DIR, 'compare')
@@ -50,41 +52,42 @@ def clean(self):
5052

5153

5254
class SetupForecast(object):
53-
def __init__(self, tclean, watershed_folder, forecast_folder):
54-
tclean.clean()
55+
def __init__(self, a_tclean, watershed_folder, forecast_folder, historical=True):
56+
a_tclean.clean()
5557
# make log folder
56-
self.log_folder = os.path.join(tclean.output, "logs")
58+
self.log_folder = os.path.join(a_tclean.output, "logs")
5759
os.makedirs(self.log_folder)
5860
# copy RAPID model files
59-
self.rapid_io_folder = os.path.join(tclean.output, "rapid-io")
61+
self.rapid_io_folder = os.path.join(a_tclean.output, "rapid-io")
6062
rapid_input_folder = os.path.join(self.rapid_io_folder, "input")
6163
os.makedirs(rapid_input_folder)
6264
self.watershed_input_folder = os.path.join(rapid_input_folder, watershed_folder)
63-
copytree(os.path.join(tclean.input, "rapid_input", watershed_folder),
65+
copytree(os.path.join(a_tclean.input, "rapid_input", watershed_folder),
6466
self.watershed_input_folder)
65-
# copy historical simulation_files
66-
self.historical_input_folder = os.path.join(tclean.output, "historical_input")
67-
os.makedirs(self.historical_input_folder)
68-
copytree(os.path.join(tclean.input, "historical_input", watershed_folder),
69-
os.path.join(self.historical_input_folder, watershed_folder))
67+
if historical:
68+
# copy historical simulation_files
69+
self.historical_input_folder = os.path.join(a_tclean.output, "historical_input")
70+
os.makedirs(self.historical_input_folder)
71+
copytree(os.path.join(a_tclean.input, "historical_input", watershed_folder),
72+
os.path.join(self.historical_input_folder, watershed_folder))
7073
# copy forecast grid files
71-
self.lsm_folder = os.path.join(tclean.output, forecast_folder)
72-
copytree(os.path.join(tclean.input, "forecast_grids", forecast_folder),
74+
self.lsm_folder = os.path.join(a_tclean.output, forecast_folder)
75+
copytree(os.path.join(a_tclean.input, "forecast_grids", forecast_folder),
7376
self.lsm_folder)
7477
# add path to comparison files
75-
self.watershed_compare_folder = os.path.join(tclean.compare,
78+
self.watershed_compare_folder = os.path.join(a_tclean.compare,
7679
'rapid_output',
7780
watershed_folder)
7881

7982

8083
class SetupECMWFForecast(SetupForecast):
81-
def __init__(self, tclean, watershed_folder, forecast_folder):
82-
super(SetupECMWFForecast, self).__init__(tclean, watershed_folder, forecast_folder)
84+
def __init__(self, a_tclean, watershed_folder, forecast_folder, historical=True):
85+
super(SetupECMWFForecast, self).__init__(a_tclean, watershed_folder, forecast_folder, historical)
8386
# make subprocess log folder
84-
self.subprocess_log_folder = os.path.join(tclean.output, "subprocess_logs")
87+
self.subprocess_log_folder = os.path.join(a_tclean.output, "subprocess_logs")
8588
os.makedirs(self.subprocess_log_folder)
8689
# make multiprocess execute folder
87-
self.multiprocess_execute_folder = os.path.join(tclean.output, "mp_execute")
90+
self.multiprocess_execute_folder = os.path.join(a_tclean.output, "mp_execute")
8891
os.makedirs(self.multiprocess_execute_folder)
8992
# extract the forecasts
9093
forecast_targz = os.path.join(self.lsm_folder, "Runoff.20170708.00.C.america.exp1.Fgrid.netcdf.tar.gz")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
COMID,Lat,Lon,Elev_m
2+
21841,18.72881291300007,-70.23344103099998,0.0
3+
21852,18.697594237000033,-70.24768063999994,0.0
4+
21889,18.60342360900006,-70.20573020099994,0.0
5+
21890,18.66302281000003,-70.18478411299998,0.0
6+
21893,18.59684929900004,-70.17987023499995,0.0
7+
21898,18.58736170700007,-70.21416914599996,0.0
8+
22074,18.510065534000034,-70.08183596899994,0.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
21893
2+
21890
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
21841
2+
21852
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
7343.34527374
2+
7094.99799851
3+
1551.10387491
4+
23463.6692458
5+
6712.40049501
6+
7879.29868686
7+
55139.0729639
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
1000, 400
2+
2000, 400
3+
2000, 700
4+
1000, 400
5+
1000, 400
6+
2000, 300
7+
1000, 400
8+
2000, 400
9+
2000, 700
10+
1000, 400
11+
1000, 400
12+
2000, 300
13+
1000, 400
14+
2000, 400
15+
2000, 700
16+
1000, 400
17+
1000, 400
18+
2000, 300
19+
1000, 400
20+
2000, 400
21+
2000, 700
22+
1000, 400
23+
1000, 400
24+
2000, 300
25+
1000, 400
26+
2000, 400
27+
2000, 700
28+
1000, 400
29+
1000, 400
30+
2000, 300
31+
1000, 400
32+
2000, 400
33+
2000, 700
34+
1000, 400
35+
1000, 400
36+
2000, 300
37+
1000, 400
38+
2000, 400
39+
2000, 700
40+
1000, 400
41+
1000, 400
42+
2000, 300
43+
1000, 400
44+
2000, 400
45+
2000, 700
46+
1000, 400
47+
1000, 400
48+
2000, 300
49+
1000, 400
50+
2000, 400
51+
2000, 700
52+
1000, 400
53+
1000, 400
54+
2000, 300
55+
1000, 400
56+
2000, 400
57+
2000, 700
58+
1000, 400
59+
1000, 400
60+
2000, 300
61+
1000, 400
62+
2000, 400
63+
2000, 700
64+
1000, 400
65+
1000, 400
66+
2000, 300
67+
1000, 400
68+
2000, 400
69+
2000, 700
70+
1000, 400
71+
1000, 400
72+
2000, 300
73+
1000, 400
74+
2000, 400
75+
2000, 700
76+
1000, 400
77+
1000, 400
78+
2000, 300
79+
1000, 400
80+
2000, 400
81+
2000, 700
82+
1000, 400
83+
1000, 400
84+
2000, 300
85+
1000, 400
86+
2000, 400
87+
2000, 700
88+
1000, 400
89+
1000, 400
90+
2000, 300
91+
1000, 400
92+
2000, 400
93+
2000, 700
94+
1000, 400
95+
1000, 400
96+
2000, 300
97+
1000, 400
98+
2000, 400
99+
2000, 700
100+
1000, 400
101+
1000, 400
102+
2000, 300
103+
1000, 400
104+
2000, 400
105+
2000, 700
106+
1000, 400
107+
1000, 400
108+
2000, 300
109+
1000, 400
110+
2000, 400
111+
2000, 700
112+
1000, 400
113+
1000, 400
114+
2000, 300
115+
1000, 400
116+
2000, 400
117+
2000, 700
118+
1000, 400
119+
1000, 400
120+
2000, 300
121+
1000, 400
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
21841,21890,0,0,0
2+
21852,21890,0,0,0
3+
21889,21893,0,0,0
4+
21890,22074,2,21841,21852
5+
21893,22074,2,21889,21898
6+
21898,21893,0,0,0
7+
22074,0,2,21890,21893
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
21893
2+
21890
3+
21898
4+
21889
5+
21852
6+
21841
7+
22074
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
DrainLnID,area_sqm,lon_index,lat_index,npoints,weight,Lon,Lat
2+
21841,18231588.465928447,681,188,5,0.23475001809016308,-70.241790770999955,18.804920197000058
3+
21841,45423.76348278272,681,190,5,0.00058487659038784182,-70.241790770999955,18.664323807000073
4+
21841,44351843.61380054,681,189,5,0.57107454515711331,-70.241790770999955,18.734621048000065
5+
21841,10113595.650855558,680,189,5,0.13022270475399478,-70.312103270999955,18.734621048000065
6+
21841,4921391.151201547,680,188,5,0.063367855408341014,-70.312103270999955,18.804920197000058
7+
21852,14929271.379126888,681,190,4,0.26154594569696904,-70.241790770999955,18.664323807000073
8+
21852,1831125.266391957,681,189,4,0.0320794884978578,-70.241790770999955,18.734621048000065
9+
21852,23484283.80135522,680,190,4,0.41142123147611231,-70.312103270999955,18.664323807000073
10+
21852,16836194.346819587,680,189,4,0.29495333432906085,-70.312103270999955,18.734621048000065
11+
21889,16812969.009330254,681,190,5,0.37397017394848259,-70.241790770999955,18.664323807000073
12+
21889,815399.7380854919,682,191,5,0.018136902632732901,-70.171478270999955,18.594024658000023
13+
21889,23992659.680193305,681,191,5,0.53366773644258658,-70.241790770999955,18.594024658000023
14+
21889,2265531.8230847646,680,191,5,0.050392130592440923,-70.312103270999955,18.594024658000023
15+
21889,1071487.6915101917,680,190,5,0.023833056383756844,-70.312103270999955,18.664323807000073
16+
21890,25933709.865720827,681,190,6,0.22971515996213845,-70.241790770999955,18.664323807000073
17+
21890,13240973.951338822,682,191,6,0.11728566661057474,-70.171478270999955,18.594024658000023
18+
21890,835595.5208883828,681,191,6,0.0074015233353959646,-70.241790770999955,18.594024658000023
19+
21890,11179137.972941315,681,189,6,0.099022372078259244,-70.241790770999955,18.734621048000065
20+
21890,37556624.66148296,682,190,6,0.33266841059073271,-70.171478270999955,18.664323807000073
21+
21890,24149031.51775003,682,189,6,0.21390686742289891,-70.171478270999955,18.734621048000065
22+
21893,12809632.324096272,682,191,2,0.98633338346286714,-70.171478270999955,18.594024658000023
23+
21893,177490.0210114161,681,191,2,0.013666616537132836,-70.241790770999955,18.594024658000023
24+
21898,8911230.249323474,681,192,5,0.18206562020813422,-70.241790770999955,18.523725510000077
25+
21898,1825819.4174872474,682,191,5,0.037303372860117347,-70.171478270999955,18.594024658000023
26+
21898,30816574.581964828,681,191,5,0.62961438622704213,-70.241790770999955,18.594024658000023
27+
21898,1003421.441208436,680,192,5,0.020500934429073157,-70.312103270999955,18.523725510000077
28+
21898,6388110.672520433,680,191,5,0.13051568627563306,-70.312103270999955,18.594024658000023
29+
22074,150048.21283344744,681,192,13,0.00072215422878761236,-70.241790770999955,18.523725510000077
30+
22074,50526845.86177828,683,192,13,0.24317634123963008,-70.101165770999955,18.523725510000077
31+
22074,1290017.1025552233,685,192,13,0.0062086131399156216,-69.960540770999955,18.523725510000077
32+
22074,12686551.402143274,683,193,13,0.061058019757679806,-70.101165770999955,18.453426361000027
33+
22074,12821978.613746239,685,193,13,0.061709805818341207,-69.960540770999955,18.453426361000027
34+
22074,141111.11277692625,684,194,13,0.00067914162319211192,-70.030853270999955,18.383127213000023
35+
22074,40996166.0944053,684,193,13,0.19730694654801453,-70.030853270999955,18.453426361000027
36+
22074,26984957.951262243,684,192,13,0.1298735994929224,-70.030853270999955,18.523725510000077
37+
22074,4219392.528019115,683,191,13,0.020307153943953115,-70.101165770999955,18.594024658000023
38+
22074,30230910.77998046,682,192,13,0.14549576864401975,-70.171478270999955,18.523725510000077
39+
22074,25833728.71082761,682,191,13,0.12433294660153056,-70.171478270999955,18.594024658000023
40+
22074,1895600.189967049,681,191,13,0.0091231722619368582,-70.241790770999955,18.594024658000023
41+
22074,1316.6308301151973,682,190,13,6.3367000763629745e-06,-70.171478270999955,18.664323807000073
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
DrainLnID,area_sqm,lon_index,lat_index,npoints,weight,Lon,Lat
2+
21841,22426497.60039799,341,95,2,0.28876368768841287,-70.171478270999955,18.766105652000022
3+
21841,55237345.03828254,340,95,2,0.71123631231158713,-70.312103270999955,18.766105652000022
4+
21852,41247.868797639676,341,96,4,0.00072262152500295919,-70.171478270999955,18.62553596500004
5+
21852,34677199.27611546,340,96,4,0.60750994788782853,-70.312103270999955,18.62553596500004
6+
21852,787594.9572838908,341,95,4,0.013797878186368096,-70.171478270999955,18.766105652000022
7+
21852,21574832.699409228,340,95,4,0.37796955240080038,-70.312103270999955,18.766105652000022
8+
21889,18173002.2465068,341,96,2,0.40422133663948678,-70.171478270999955,18.62553596500004
9+
21889,26785045.731833268,340,96,2,0.59577866336051322,-70.312103270999955,18.62553596500004
10+
21890,71121791.20051993,341,96,3,0.62998135331271266,-70.171478270999955,18.62553596500004
11+
21890,3383344.196082747,340,96,3,0.029968926814027415,-70.312103270999955,18.62553596500004
12+
21890,38389938.1266548,341,95,3,0.34004971987326005,-70.171478270999955,18.766105652000022
13+
21893,12987122.307429988,341,96,1,1.0,-70.171478270999955,18.62553596500004
14+
21898,17339474.450199958,341,96,4,0.35426333760893319,-70.171478270999955,18.62553596500004
15+
21898,1465573.2209805513,341,97,4,0.029943171707194235,-70.171478270999955,18.484966278000059
16+
21898,5946824.839778148,340,97,4,0.12149976182762685,-70.312103270999955,18.484966278000059
17+
21898,24193283.844285715,340,96,4,0.49429372885624578,-70.312103270999955,18.62553596500004
18+
22074,35912178.92360923,341,96,3,0.17283865886474045,-70.171478270999955,18.62553596500004
19+
22074,116145151.01229768,342,97,3,0.55898507793998198,-70.030853270999955,18.484966278000059
20+
22074,55721295.28307999,341,97,3,0.26817626319527771,-70.171478270999955,18.484966278000059
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
0.3
2+
0.3
3+
0.3
4+
0.3
5+
0.3
6+
0.3
7+
0.3

0 commit comments

Comments
 (0)