1
- import datetime
2
-
3
1
import numpy as np
4
2
from numpy import nan
5
3
import pandas as pd
@@ -96,10 +94,10 @@ def test_arrays_multi():
96
94
apparent_azimuth = np .array ([[180 , 180 ], [180 , 180 ]])
97
95
# singleaxis should fail for num dim > 1
98
96
with pytest .raises (ValueError ):
99
- tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
100
- axis_tilt = 0 , axis_azimuth = 0 ,
101
- max_angle = 90 , backtrack = True ,
102
- gcr = 2.0 / 7.0 )
97
+ tracking .singleaxis (apparent_zenith , apparent_azimuth ,
98
+ axis_tilt = 0 , axis_azimuth = 0 ,
99
+ max_angle = 90 , backtrack = True ,
100
+ gcr = 2.0 / 7.0 )
103
101
# uncomment if we ever get singleaxis to support num dim > 1 arrays
104
102
# assert isinstance(tracker_data, dict)
105
103
# expect = {'tracker_theta': np.full_like(apparent_zenith, 0),
@@ -121,7 +119,7 @@ def test_azimuth_north_south():
121
119
122
120
expect = pd .DataFrame ({'tracker_theta' : - 60 , 'aoi' : 0 ,
123
121
'surface_azimuth' : 90 , 'surface_tilt' : 60 },
124
- index = [0 ], dtype = np .float64 )
122
+ index = [0 ], dtype = np .float64 )
125
123
expect = expect [SINGLEAXIS_COL_ORDER ]
126
124
127
125
assert_frame_equal (expect , tracker_data )
@@ -146,7 +144,7 @@ def test_max_angle():
146
144
147
145
expect = pd .DataFrame ({'aoi' : 15 , 'surface_azimuth' : 90 ,
148
146
'surface_tilt' : 45 , 'tracker_theta' : 45 },
149
- index = [0 ], dtype = np .float64 )
147
+ index = [0 ], dtype = np .float64 )
150
148
expect = expect [SINGLEAXIS_COL_ORDER ]
151
149
152
150
assert_frame_equal (expect , tracker_data )
@@ -163,7 +161,7 @@ def test_backtrack():
163
161
164
162
expect = pd .DataFrame ({'aoi' : 0 , 'surface_azimuth' : 90 ,
165
163
'surface_tilt' : 80 , 'tracker_theta' : 80 },
166
- index = [0 ], dtype = np .float64 )
164
+ index = [0 ], dtype = np .float64 )
167
165
expect = expect [SINGLEAXIS_COL_ORDER ]
168
166
169
167
assert_frame_equal (expect , tracker_data )
@@ -175,7 +173,7 @@ def test_backtrack():
175
173
176
174
expect = pd .DataFrame ({'aoi' : 52.5716 , 'surface_azimuth' : 90 ,
177
175
'surface_tilt' : 27.42833 , 'tracker_theta' : 27.4283 },
178
- index = [0 ], dtype = np .float64 )
176
+ index = [0 ], dtype = np .float64 )
179
177
expect = expect [SINGLEAXIS_COL_ORDER ]
180
178
181
179
assert_frame_equal (expect , tracker_data )
@@ -193,7 +191,7 @@ def test_axis_tilt():
193
191
expect = pd .DataFrame ({'aoi' : 7.286245 , 'surface_azimuth' : 142.65730 ,
194
192
'surface_tilt' : 35.98741 ,
195
193
'tracker_theta' : - 20.88121 },
196
- index = [0 ], dtype = np .float64 )
194
+ index = [0 ], dtype = np .float64 )
197
195
expect = expect [SINGLEAXIS_COL_ORDER ]
198
196
199
197
assert_frame_equal (expect , tracker_data )
@@ -205,7 +203,7 @@ def test_axis_tilt():
205
203
206
204
expect = pd .DataFrame ({'aoi' : 47.6632 , 'surface_azimuth' : 50.96969 ,
207
205
'surface_tilt' : 42.5152 , 'tracker_theta' : 31.6655 },
208
- index = [0 ], dtype = np .float64 )
206
+ index = [0 ], dtype = np .float64 )
209
207
expect = expect [SINGLEAXIS_COL_ORDER ]
210
208
211
209
assert_frame_equal (expect , tracker_data )
@@ -222,7 +220,7 @@ def test_axis_azimuth():
222
220
223
221
expect = pd .DataFrame ({'aoi' : 30 , 'surface_azimuth' : 180 ,
224
222
'surface_tilt' : 0 , 'tracker_theta' : 0 },
225
- index = [0 ], dtype = np .float64 )
223
+ index = [0 ], dtype = np .float64 )
226
224
expect = expect [SINGLEAXIS_COL_ORDER ]
227
225
228
226
assert_frame_equal (expect , tracker_data )
@@ -237,7 +235,7 @@ def test_axis_azimuth():
237
235
238
236
expect = pd .DataFrame ({'aoi' : 0 , 'surface_azimuth' : 180 ,
239
237
'surface_tilt' : 30 , 'tracker_theta' : 30 },
240
- index = [0 ], dtype = np .float64 )
238
+ index = [0 ], dtype = np .float64 )
241
239
expect = expect [SINGLEAXIS_COL_ORDER ]
242
240
243
241
assert_frame_equal (expect , tracker_data )
@@ -277,6 +275,20 @@ def test_horizon_tilted():
277
275
assert_frame_equal (out , expected )
278
276
279
277
278
+ def test_low_sun_angles ():
279
+ # GH 656
280
+ result = tracking .singleaxis (
281
+ apparent_zenith = 80 , apparent_azimuth = 338 , axis_tilt = 30 ,
282
+ axis_azimuth = 180 , max_angle = 60 , backtrack = True , gcr = 0.35 )
283
+ expected = {
284
+ 'tracker_theta' : np .array ([- 50.31051385 ]),
285
+ 'aoi' : np .array ([61.35300178 ]),
286
+ 'surface_azimuth' : np .array ([112.53615425 ]),
287
+ 'surface_tilt' : np .array ([56.42233095 ])}
288
+ for k , v in result .items ():
289
+ assert_allclose (expected [k ], v )
290
+
291
+
280
292
def test_SingleAxisTracker_creation ():
281
293
system = tracking .SingleAxisTracker (max_angle = 45 ,
282
294
gcr = .25 ,
@@ -299,37 +311,35 @@ def test_SingleAxisTracker_tracking():
299
311
300
312
tracker_data = system .singleaxis (apparent_zenith , apparent_azimuth )
301
313
302
- expect = pd .DataFrame ({'aoi' : 7.286245 , 'surface_azimuth' : 142.65730 ,
314
+ expect = pd .DataFrame ({'aoi' : 7.286245 , 'surface_azimuth' : 142.65730 ,
303
315
'surface_tilt' : 35.98741 ,
304
316
'tracker_theta' : - 20.88121 },
305
- index = [0 ], dtype = np .float64 )
317
+ index = [0 ], dtype = np .float64 )
306
318
expect = expect [SINGLEAXIS_COL_ORDER ]
307
319
308
320
assert_frame_equal (expect , tracker_data )
309
321
310
- ### results calculated using PVsyst
322
+ # results calculated using PVsyst
311
323
pvsyst_solar_azimuth = 7.1609
312
324
pvsyst_solar_height = 27.315
313
325
pvsyst_axis_tilt = 20.
314
326
pvsyst_axis_azimuth = 20.
315
- pvsyst_system = tracking .SingleAxisTracker (max_angle = 60. ,
316
- axis_tilt = pvsyst_axis_tilt ,
317
- axis_azimuth = 180 + pvsyst_axis_azimuth ,
318
- backtrack = False )
327
+ pvsyst_system = tracking .SingleAxisTracker (
328
+ max_angle = 60. , axis_tilt = pvsyst_axis_tilt ,
329
+ axis_azimuth = 180 + pvsyst_axis_azimuth , backtrack = False )
319
330
# the definition of azimuth is different from PYsyst
320
331
apparent_azimuth = pd .Series ([180 + pvsyst_solar_azimuth ])
321
332
apparent_zenith = pd .Series ([90 - pvsyst_solar_height ])
322
333
tracker_data = pvsyst_system .singleaxis (apparent_zenith , apparent_azimuth )
323
- expect = pd .DataFrame ({'aoi' : 41.07852 , 'surface_azimuth' : 180 - 18.432 ,
324
- 'surface_tilt' : 24.92122 ,
334
+ expect = pd .DataFrame ({'aoi' : 41.07852 , 'surface_azimuth' : 180 - 18.432 ,
335
+ 'surface_tilt' : 24.92122 ,
325
336
'tracker_theta' : - 15.18391 },
326
- index = [0 ], dtype = np .float64 )
337
+ index = [0 ], dtype = np .float64 )
327
338
expect = expect [SINGLEAXIS_COL_ORDER ]
328
339
329
340
assert_frame_equal (expect , tracker_data )
330
341
331
342
332
-
333
343
def test_LocalizedSingleAxisTracker_creation ():
334
344
localized_system = tracking .LocalizedSingleAxisTracker (latitude = 32 ,
335
345
longitude = - 111 ,
0 commit comments