4
4
import datetime
5
5
6
6
import numpy as np
7
+ from numpy import nan
7
8
import pandas as pd
8
9
9
10
from nose .tools import raises , assert_almost_equals
@@ -162,4 +163,106 @@ def test_index_mismatch():
162
163
tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
163
164
axis_tilt = 0 , axis_azimuth = 90 ,
164
165
max_angle = 90 , backtrack = True ,
165
- gcr = 2.0 / 7.0 )
166
+ gcr = 2.0 / 7.0 )
167
+
168
+
169
+ def test_SingleAxisTracker_creation ():
170
+ system = tracking .SingleAxisTracker (max_angle = 45 ,
171
+ gcr = .25 ,
172
+ module = 'blah' ,
173
+ inverter = 'blarg' )
174
+
175
+ assert system .max_angle == 45
176
+ assert system .gcr == .25
177
+ assert system .module == 'blah'
178
+ assert system .inverter == 'blarg'
179
+
180
+
181
+ def test_SingleAxisTracker_tracking ():
182
+ system = tracking .SingleAxisTracker (max_angle = 90 , axis_tilt = 30 ,
183
+ axis_azimuth = 180 , gcr = 2.0 / 7.0 ,
184
+ backtrack = True )
185
+
186
+ apparent_zenith = pd .Series ([30 ])
187
+ apparent_azimuth = pd .Series ([135 ])
188
+
189
+ tracker_data = system .singleaxis (apparent_zenith , apparent_azimuth )
190
+
191
+ expect = pd .DataFrame ({'aoi' : 7.286245 , 'surface_azimuth' : 37.3427 ,
192
+ 'surface_tilt' : 35.98741 , 'tracker_theta' : - 20.88121 },
193
+ index = [0 ], dtype = np .float64 )
194
+
195
+ assert_frame_equal (expect , tracker_data )
196
+
197
+
198
+ def test_LocalizedSingleAxisTracker_creation ():
199
+ localized_system = tracking .LocalizedSingleAxisTracker (latitude = 32 ,
200
+ longitude = - 111 ,
201
+ module = 'blah' ,
202
+ inverter = 'blarg' )
203
+
204
+ assert localized_system .module == 'blah'
205
+ assert localized_system .inverter == 'blarg'
206
+ assert localized_system .latitude == 32
207
+ assert localized_system .longitude == - 111
208
+
209
+
210
+ def test_SingleAxisTracker_localize ():
211
+ system = tracking .SingleAxisTracker (max_angle = 45 , gcr = .25 ,
212
+ module = 'blah' , inverter = 'blarg' )
213
+
214
+ localized_system = system .localize (latitude = 32 , longitude = - 111 )
215
+
216
+ assert localized_system .module == 'blah'
217
+ assert localized_system .inverter == 'blarg'
218
+ assert localized_system .latitude == 32
219
+ assert localized_system .longitude == - 111
220
+
221
+
222
+ def test_SingleAxisTracker_localize_location ():
223
+ system = tracking .SingleAxisTracker (max_angle = 45 , gcr = .25 ,
224
+ module = 'blah' , inverter = 'blarg' )
225
+ location = Location (latitude = 32 , longitude = - 111 )
226
+ localized_system = system .localize (location = location )
227
+
228
+ assert localized_system .module == 'blah'
229
+ assert localized_system .inverter == 'blarg'
230
+ assert localized_system .latitude == 32
231
+ assert localized_system .longitude == - 111
232
+
233
+
234
+ def test_get_irradiance ():
235
+ system = tracking .SingleAxisTracker (max_angle = 90 , axis_tilt = 30 ,
236
+ axis_azimuth = 180 , gcr = 2.0 / 7.0 ,
237
+ backtrack = True )
238
+ times = pd .DatetimeIndex (start = '20160101 1200-0700' ,
239
+ end = '20160101 1800-0700' , freq = '6H' )
240
+ location = Location (latitude = 32 , longitude = - 111 )
241
+ solar_position = location .get_solarposition (times )
242
+ irrads = pd .DataFrame ({'dni' :[900 ,0 ], 'ghi' :[600 ,0 ], 'dhi' :[100 ,0 ]},
243
+ index = times )
244
+ solar_zenith = solar_position ['apparent_zenith' ]
245
+ solar_azimuth = solar_position ['azimuth' ]
246
+ tracker_data = system .singleaxis (solar_zenith , solar_azimuth )
247
+
248
+ irradiance = system .get_irradiance (irrads ['dni' ],
249
+ irrads ['ghi' ],
250
+ irrads ['dhi' ],
251
+ solar_zenith = solar_zenith ,
252
+ solar_azimuth = solar_azimuth ,
253
+ surface_tilt = tracker_data ['surface_tilt' ],
254
+ surface_azimuth = tracker_data ['surface_azimuth' ])
255
+
256
+ expected = pd .DataFrame (data = np .array (
257
+ [[ 142.71652464 , 87.50125991 , 55.21526473 , 44.68768982 ,
258
+ 10.52757492 ],
259
+ [ nan , nan , nan , nan ,
260
+ nan ]]),
261
+ columns = ['poa_global' , 'poa_direct' ,
262
+ 'poa_diffuse' , 'poa_sky_diffuse' ,
263
+ 'poa_ground_diffuse' ],
264
+ index = times )
265
+
266
+ irradiance = np .round (irradiance , 4 )
267
+ expected = np .round (expected , 4 )
268
+ assert_frame_equal (irradiance , expected )
0 commit comments