Skip to content

Commit 722f6fd

Browse files
committed
Add tests
1 parent dcd202c commit 722f6fd

2 files changed

Lines changed: 76 additions & 1 deletion

File tree

pvlib/irradiance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ def poa_components(aoi, dni, poa_sky_diffuse, poa_ground_diffuse):
528528
* ``poa_sky_diffuse`` : In-plane diffuse irradiance from sky. [Wm⁻²]
529529
* ``poa_ground_diffuse`` : In-plane diffuse irradiance from ground.
530530
[Wm⁻²]
531-
531+
532532
If ``poa_sky_diffuse`` is a Dict or DataFrame, ``irrads`` will
533533
contain additional keys for each of the diffuse components returned by
534534
the selected diffuse irradiance model.

tests/test_irradiance.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,28 @@ def test_get_total_irradiance(irrad_data, ephem_data, dni_et,
536536
'poa_ground_diffuse']
537537

538538

539+
def test_get_total_irradiance_diffuse_components(irrad_data, ephem_data,
540+
dni_et, relative_airmass):
541+
models = ['perez', 'perez-driesse']
542+
543+
for model in models:
544+
total = irradiance.get_total_irradiance(
545+
32, 180,
546+
ephem_data['apparent_zenith'], ephem_data['azimuth'],
547+
dni=irrad_data['dni'], ghi=irrad_data['ghi'],
548+
dhi=irrad_data['dhi'],
549+
dni_extra=dni_et, airmass=relative_airmass,
550+
model=model,
551+
surface_type='urban',
552+
diffuse_components=True)
553+
554+
assert total.columns.tolist() == ['poa_global', 'poa_direct',
555+
'poa_diffuse', 'poa_sky_diffuse',
556+
'poa_ground_diffuse',
557+
'poa_isotropic', 'poa_circumsolar',
558+
'poa_horizon']
559+
560+
539561
@pytest.mark.parametrize('model', ['isotropic', 'klucher',
540562
'haydavies', 'reindl', 'king',
541563
'perez', 'perez-driesse'])
@@ -625,6 +647,59 @@ def test_poa_components(irrad_data, ephem_data, dni_et, relative_airmass):
625647
assert_frame_equal(out, expected)
626648

627649

650+
def test_poa_components_diffuse_components_perez(irrad_data, ephem_data,
651+
dni_et, relative_airmass):
652+
aoi = irradiance.aoi(40, 180, ephem_data['apparent_zenith'],
653+
ephem_data['azimuth'])
654+
gr_sand = irradiance.get_ground_diffuse(40, irrad_data['ghi'],
655+
surface_type='sand')
656+
diff_perez = irradiance.perez(
657+
40, 180, irrad_data['dhi'], irrad_data['dni'], dni_et,
658+
ephem_data['apparent_zenith'], ephem_data['azimuth'], relative_airmass,
659+
return_components=True)
660+
out = irradiance.poa_components(
661+
aoi, irrad_data['dni'], diff_perez, gr_sand)
662+
expected = pd.DataFrame(np.array(
663+
[[0., -0., 0., 0.,
664+
0., 0., 0., 0.],
665+
[35.19456561, 0., 35.19456561, 31.4635077,
666+
3.73105791, 26.841386, 0.000000, 4.622122],
667+
[956.18253696, 798.31939281, 157.86314414, 109.08433162,
668+
48.77881252, 41.621826, 61.619987, 5.842518],
669+
[90.99624896, 33.50143401, 57.49481495, 45.45978964,
670+
12.03502531, 31.726961, 4.479664, 9.253165]]),
671+
columns=['poa_global', 'poa_direct', 'poa_diffuse', 'poa_sky_diffuse',
672+
'poa_ground_diffuse', 'poa_isotropic', 'poa_circumsolar',
673+
'poa_horizon'],
674+
index=irrad_data.index)
675+
assert_frame_equal(out, expected)
676+
677+
678+
def test_poa_components_diffuse_components_isotropic(irrad_data, ephem_data,
679+
dni_et, relative_airmass):
680+
aoi = irradiance.aoi(40, 180, ephem_data['apparent_zenith'],
681+
ephem_data['azimuth'])
682+
gr_sand = irradiance.get_ground_diffuse(40, irrad_data['ghi'],
683+
surface_type='sand')
684+
diff_isotropic = irradiance.isotropic(
685+
40, irrad_data['dhi'], return_components=True)
686+
out = irradiance.poa_components(
687+
aoi, irrad_data['dni'], diff_isotropic, gr_sand)
688+
expected = pd.DataFrame(np.array(
689+
[[0., -0., 0., 0.,
690+
0., 0.],
691+
[39.459460, 0.000000, 39.459460, 35.728402,
692+
3.731058, 35.728402],
693+
[951.699533, 798.319393, 153.380140, 104.601328,
694+
48.778813, 104.601328],
695+
[100.313650, 33.501434, 66.812216, 54.777191,
696+
12.035025, 54.777191]]),
697+
columns=['poa_global', 'poa_direct', 'poa_diffuse', 'poa_sky_diffuse',
698+
'poa_ground_diffuse', 'poa_isotropic'],
699+
index=irrad_data.index)
700+
assert_frame_equal(out, expected)
701+
702+
628703
@pytest.mark.parametrize('pressure,expected', [
629704
(93193, [[830.46567, 0.79742, 0.93505],
630705
[676.18340, 0.63782, 3.02102]]),

0 commit comments

Comments
 (0)