@@ -55,7 +55,7 @@ def test_froude_number_g_type_error(self):
55
55
h = 5
56
56
g = "invalid_type" # String instead of int/float
57
57
with self .assertRaises (TypeError ):
58
- river .resource .Froude_number (v , h , g )
58
+ river .resource .froude_number (v , h , g )
59
59
60
60
def test_exceedance_probability (self ):
61
61
# Create arbitrary discharge between 0 and 8(N=9)
@@ -121,7 +121,7 @@ def test_discharge_to_velocity(self):
121
121
p , r2 = river .resource .polynomial_fit (np .arange (9 ), 10 * np .arange (9 ), 1 )
122
122
# Because the polynomial line fits perfect we should expect the V to equal 10*Q
123
123
V = river .resource .discharge_to_velocity (Q , p )
124
- self .assertAlmostEqual (np .sum (10 * Q - V ["V " ]), 0.00 , places = 2 )
124
+ self .assertAlmostEqual (np .sum (10 * Q - V ["velocity " ]), 0.00 , places = 2 )
125
125
126
126
def test_discharge_to_velocity_xarray (self ):
127
127
# Create arbitrary discharge between 0 and 8(N=9)
@@ -132,7 +132,7 @@ def test_discharge_to_velocity_xarray(self):
132
132
p , r2 = river .resource .polynomial_fit (np .arange (9 ), 10 * np .arange (9 ), 1 )
133
133
# Because the polynomial line fits perfect we should expect the V to equal 10*Q
134
134
V = river .resource .discharge_to_velocity (Q , p , to_pandas = False )
135
- self .assertAlmostEqual (np .sum (10 * Q - V ["V " ]).values , 0.00 , places = 2 )
135
+ self .assertAlmostEqual (np .sum (10 * Q - V ["velocity " ]).values , 0.00 , places = 2 )
136
136
137
137
def test_discharge_to_velocity_D_type_error (self ):
138
138
D = "invalid_type" # String instead of pd.Series or pd.DataFrame
@@ -154,16 +154,18 @@ def test_velocity_to_power(self):
154
154
# Calculate a first order polynomial on an VP_Curve x=y line 10 times greater than the V values
155
155
p2 , r22 = river .resource .polynomial_fit (np .arange (9 ), 10 * np .arange (9 ), 1 )
156
156
# Set cut in/out to exclude 1 bin on either end of V range
157
- cut_in = V ["V " ][1 ]
158
- cut_out = V ["V " ].iloc [- 2 ]
157
+ cut_in = V ["velocity " ][1 ]
158
+ cut_out = V ["velocity " ].iloc [- 2 ]
159
159
# Power should be 10x greater and exclude the ends of V
160
- P = river .resource .velocity_to_power (V ["V " ], p2 , cut_in , cut_out )
160
+ P = river .resource .velocity_to_power (V ["velocity " ], p2 , cut_in , cut_out )
161
161
# Cut in power zero
162
- self .assertAlmostEqual (P ["P " ][0 ], 0.00 , places = 2 )
162
+ self .assertAlmostEqual (P ["power " ][0 ], 0.00 , places = 2 )
163
163
# Cut out power zero
164
- self .assertAlmostEqual (P ["P " ].iloc [- 1 ], 0.00 , places = 2 )
164
+ self .assertAlmostEqual (P ["power " ].iloc [- 1 ], 0.00 , places = 2 )
165
165
# Middle 10x greater than velocity
166
- self .assertAlmostEqual ((P ["P" ][1 :- 1 ] - 10 * V ["V" ][1 :- 1 ]).sum (), 0.00 , places = 2 )
166
+ self .assertAlmostEqual (
167
+ (P ["power" ][1 :- 1 ] - 10 * V ["velocity" ][1 :- 1 ]).sum (), 0.00 , places = 2
168
+ )
167
169
168
170
def test_velocity_to_power_xarray (self ):
169
171
# Calculate a first order polynomial on an DV_Curve x=y line 10 times greater than the Q values
@@ -175,19 +177,19 @@ def test_velocity_to_power_xarray(self):
175
177
# Calculate a first order polynomial on an VP_Curve x=y line 10 times greater than the V values
176
178
p2 , r22 = river .resource .polynomial_fit (np .arange (9 ), 10 * np .arange (9 ), 1 )
177
179
# Set cut in/out to exclude 1 bin on either end of V range
178
- cut_in = V ["V " ].values [1 ]
179
- cut_out = V ["V " ].values [- 2 ]
180
+ cut_in = V ["velocity " ].values [1 ]
181
+ cut_out = V ["velocity " ].values [- 2 ]
180
182
# Power should be 10x greater and exclude the ends of V
181
183
P = river .resource .velocity_to_power (
182
- V ["V " ], p2 , cut_in , cut_out , to_pandas = False
184
+ V ["velocity " ], p2 , cut_in , cut_out , to_pandas = False
183
185
)
184
186
# Cut in power zero
185
- self .assertAlmostEqual (P ["P " ][0 ], 0.00 , places = 2 )
187
+ self .assertAlmostEqual (P ["power " ][0 ], 0.00 , places = 2 )
186
188
# Cut out power zero
187
- self .assertAlmostEqual (P ["P " ][- 1 ], 0.00 , places = 2 )
189
+ self .assertAlmostEqual (P ["power " ][- 1 ], 0.00 , places = 2 )
188
190
# Middle 10x greater than velocity
189
191
self .assertAlmostEqual (
190
- (P ["P " ][1 :- 1 ] - 10 * V ["V " ][1 :- 1 ]).sum ().values , 0.00 , places = 2
192
+ (P ["power " ][1 :- 1 ] - 10 * V ["velocity " ][1 :- 1 ]).sum ().values , 0.00 , places = 2
191
193
)
192
194
193
195
def test_velocity_to_power_V_type_error (self ):
@@ -278,7 +280,9 @@ def test_plot_flow_duration_curve(self):
278
280
279
281
f = river .resource .exceedance_probability (self .data .Q )
280
282
plt .figure ()
281
- river .graphics .plot_flow_duration_curve (self .data ["Q" ], f ["F" ])
283
+ river .graphics .plot_flow_duration_curve (
284
+ self .data ["Q" ], f ["exceedance_probability" ]
285
+ )
282
286
plt .savefig (filename , format = "png" )
283
287
plt .close ()
284
288
@@ -291,7 +295,9 @@ def test_plot_power_duration_curve(self):
291
295
292
296
f = river .resource .exceedance_probability (self .data .Q )
293
297
plt .figure ()
294
- river .graphics .plot_flow_duration_curve (self .results ["P_control" ], f ["F" ])
298
+ river .graphics .plot_flow_duration_curve (
299
+ self .results ["P_control" ], f ["exceedance_probability" ]
300
+ )
295
301
plt .savefig (filename , format = "png" )
296
302
plt .close ()
297
303
@@ -304,7 +310,9 @@ def test_plot_velocity_duration_curve(self):
304
310
305
311
f = river .resource .exceedance_probability (self .data .Q )
306
312
plt .figure ()
307
- river .graphics .plot_velocity_duration_curve (self .results ["V_control" ], f ["F" ])
313
+ river .graphics .plot_velocity_duration_curve (
314
+ self .results ["V_control" ], f ["exceedance_probability" ]
315
+ )
308
316
plt .savefig (filename , format = "png" )
309
317
plt .close ()
310
318
0 commit comments