Skip to content

Commit df389aa

Browse files
committed
implement PVSystem tests
1 parent 49c670d commit df389aa

File tree

1 file changed

+56
-14
lines changed

1 file changed

+56
-14
lines changed

pvlib/test/test_pvsystem.py

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,31 +220,73 @@ def test_PVSystem_creation():
220220

221221

222222
def test_PVSystem_get_aoi():
223-
raise Exception('test me')
223+
system = pvsystem.PVSystem(surface_tilt=32, surface_azimuth=135)
224+
aoi = system.get_aoi(30, 225)
225+
assert np.round(aoi, 4) == 42.7408
224226

225227

226228
def test_PVSystem_get_irradiance():
227-
raise Exception('test me')
229+
system = pvsystem.PVSystem(surface_tilt=32, surface_azimuth=135)
230+
times = pd.DatetimeIndex(start='20160101 1200-0700',
231+
end='20160101 1800-0700', freq='6H')
232+
location = Location(latitude=32, longitude=-111)
233+
solar_position = location.get_solarposition(times)
234+
irrads = pd.DataFrame({'dni':[900,0], 'ghi':[600,0], 'dhi':[100,0]},
235+
index=times)
236+
237+
irradiance = system.get_irradiance(solar_position['apparent_zenith'],
238+
solar_position['azimuth'],
239+
irrads['dni'],
240+
irrads['ghi'],
241+
irrads['dhi'])
242+
243+
expected = pd.DataFrame(data=np.array(
244+
[[ 883.65494055, 745.86141676, 137.79352379, 126.397131 ,
245+
11.39639279],
246+
[ 0. , -0. , 0. , 0. , 0. ]]),
247+
columns=['poa_global', 'poa_direct',
248+
'poa_diffuse', 'poa_sky_diffuse',
249+
'poa_ground_diffuse'],
250+
index=times)
251+
252+
irradiance = np.round(irradiance, 4)
253+
expected = np.round(expected, 4)
254+
assert_frame_equal(irradiance, expected)
228255

229256

230257
def test_PVSystem_localize_with_location():
231-
raise Exception('test me')
258+
system = pvsystem.PVSystem(module='blah', inverter='blarg')
259+
location = Location(latitude=32, longitude=-111)
260+
localized_system = system.localize(location=location)
261+
262+
assert localized_system.module == 'blah'
263+
assert localized_system.inverter == 'blarg'
264+
assert localized_system.latitude == 32
265+
assert localized_system.longitude == -111
232266

233267

234268
def test_PVSystem_localize_with_latlon():
235-
raise Exception('test me')
269+
system = pvsystem.PVSystem(module='blah', inverter='blarg')
270+
localized_system = system.localize(latitude=32, longitude=-111)
271+
272+
assert localized_system.module == 'blah'
273+
assert localized_system.inverter == 'blarg'
274+
assert localized_system.latitude == 32
275+
assert localized_system.longitude == -111
236276

237277

238-
# in principle, we should be retesting each of the models tested above
239-
# when they are attached to PVSystem
278+
# we could retest each of the models tested above
279+
# when they are attached to LocalizedPVSystem, but
280+
# that's probably not necessary at this point.
240281

241282

242283
def test_LocalizedPVSystem_creation():
243-
localized_pv_system = pvsystem.LocalizedPVSystem(latitude=30,
244-
longitude=-110,
245-
module='blah',
246-
inverter='blarg')
247-
248-
249-
def test_LocalizedPVSystem_do_stuff():
250-
raise Exception('test me')
284+
localized_system = pvsystem.LocalizedPVSystem(latitude=32,
285+
longitude=-111,
286+
module='blah',
287+
inverter='blarg')
288+
289+
assert localized_system.module == 'blah'
290+
assert localized_system.inverter == 'blarg'
291+
assert localized_system.latitude == 32
292+
assert localized_system.longitude == -111

0 commit comments

Comments
 (0)