Skip to content

Commit 9774a26

Browse files
kandersolarcwhanse
andauthored
Add poa_ prefix to returned names when return_components=True in transposition functions (#2627)
* add `poa_` prefix * update infinite_sheds * whatsnew * lint * Update docs/sphinx/source/whatsnew/v0.13.2.rst Co-authored-by: Cliff Hansen <[email protected]> --------- Co-authored-by: Cliff Hansen <[email protected]>
1 parent 025ff8e commit 9774a26

File tree

4 files changed

+52
-49
lines changed

4 files changed

+52
-49
lines changed

docs/sphinx/source/whatsnew/v0.13.2.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ Breaking Changes
99
* Following the removal of the NSRDB PSM3 API, the :func:`!pvlib.iotools.get_psm3`,
1010
:func:`!pvlib.iotools.read_psm3`, and :func:`!pvlib.iotools.parse_psm3`
1111
functions are removed. (:issue:`2581`, :pull:`2582`)
12-
12+
* Rename output column names to be prefixed with ``"poa_"`` when ``return_components=True``
13+
in :py:func:`~pvlib.irradiance.haydavies`, :py:func:`~pvlib.irradiance.perez`,
14+
and :py:func:`~pvlib.irradiance.perez_driesse`. (:issue:`2529`, :pull:`2627`)
15+
1316

1417
Deprecations
1518
~~~~~~~~~~~~

pvlib/bifacial/infinite_sheds.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,16 @@ def get_irradiance_poa(surface_tilt, surface_azimuth, solar_zenith,
301301
sky_diffuse_comps_horizontal = haydavies(0, 180, dhi, dni, dni_extra,
302302
solar_zenith, solar_azimuth,
303303
return_components=True)
304-
circumsolar_horizontal = sky_diffuse_comps_horizontal['circumsolar']
304+
circumsolar_horizontal = \
305+
sky_diffuse_comps_horizontal['poa_circumsolar']
305306

306307
# Call haydavies a second time where circumsolar_normal is facing
307308
# directly towards sun, and can be added to DNI
308309
sky_diffuse_comps_normal = haydavies(solar_zenith, solar_azimuth, dhi,
309310
dni, dni_extra, solar_zenith,
310311
solar_azimuth,
311312
return_components=True)
312-
circumsolar_normal = sky_diffuse_comps_normal['circumsolar']
313+
circumsolar_normal = sky_diffuse_comps_normal['poa_circumsolar']
313314

314315
dhi = dhi - circumsolar_horizontal
315316
dni = dni + circumsolar_normal

pvlib/irradiance.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -793,10 +793,11 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
793793
794794
diffuse_components : OrderedDict (array input) or DataFrame (Series input)
795795
Keys/columns are:
796-
* sky_diffuse: Total sky diffuse
797-
* isotropic
798-
* circumsolar
799-
* horizon (always zero, not accounted for by the Hay-Davies model)
796+
* poa_sky_diffuse: Total sky diffuse
797+
* poa_isotropic
798+
* poa_circumsolar
799+
* poa_horizon (always zero, not accounted for by the
800+
Hay-Davies model)
800801
801802
Notes
802803
------
@@ -855,13 +856,13 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
855856

856857
if return_components:
857858
diffuse_components = OrderedDict()
858-
diffuse_components['sky_diffuse'] = sky_diffuse
859+
diffuse_components['poa_sky_diffuse'] = sky_diffuse
859860

860861
# Calculate the individual components
861-
diffuse_components['isotropic'] = poa_isotropic
862-
diffuse_components['circumsolar'] = poa_circumsolar
863-
diffuse_components['horizon'] = np.where(
864-
np.isnan(diffuse_components['isotropic']), np.nan, 0.)
862+
diffuse_components['poa_isotropic'] = poa_isotropic
863+
diffuse_components['poa_circumsolar'] = poa_circumsolar
864+
diffuse_components['poa_horizon'] = np.where(
865+
np.isnan(diffuse_components['poa_isotropic']), np.nan, 0.)
865866

866867
if isinstance(sky_diffuse, pd.Series):
867868
diffuse_components = pd.DataFrame(diffuse_components)
@@ -1111,10 +1112,10 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
11111112
11121113
diffuse_components : OrderedDict (array input) or DataFrame (Series input)
11131114
Keys/columns are:
1114-
* sky_diffuse: Total sky diffuse
1115-
* isotropic
1116-
* circumsolar
1117-
* horizon
1115+
* poa_sky_diffuse: Total sky diffuse
1116+
* poa_isotropic
1117+
* poa_circumsolar
1118+
* poa_horizon
11181119
11191120
11201121
References
@@ -1197,12 +1198,12 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
11971198

11981199
if return_components:
11991200
diffuse_components = OrderedDict()
1200-
diffuse_components['sky_diffuse'] = sky_diffuse
1201+
diffuse_components['poa_sky_diffuse'] = sky_diffuse
12011202

12021203
# Calculate the different components
1203-
diffuse_components['isotropic'] = dhi * term1
1204-
diffuse_components['circumsolar'] = dhi * term2
1205-
diffuse_components['horizon'] = dhi * term3
1204+
diffuse_components['poa_isotropic'] = dhi * term1
1205+
diffuse_components['poa_circumsolar'] = dhi * term2
1206+
diffuse_components['poa_horizon'] = dhi * term3
12061207

12071208
# Set values of components to 0 when sky_diffuse is 0
12081209
mask = sky_diffuse == 0
@@ -1353,10 +1354,10 @@ def perez_driesse(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
13531354
13541355
diffuse_components : OrderedDict (array input) or DataFrame (Series input)
13551356
Keys/columns are:
1356-
* sky_diffuse: Total sky diffuse
1357-
* isotropic
1358-
* circumsolar
1359-
* horizon
1357+
* poa_sky_diffuse: Total sky diffuse
1358+
* poa_isotropic
1359+
* poa_circumsolar
1360+
* poa_horizon
13601361
13611362
Notes
13621363
-----
@@ -1417,12 +1418,12 @@ def perez_driesse(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
14171418

14181419
if return_components:
14191420
diffuse_components = OrderedDict()
1420-
diffuse_components['sky_diffuse'] = sky_diffuse
1421+
diffuse_components['poa_sky_diffuse'] = sky_diffuse
14211422

14221423
# Calculate the different components
1423-
diffuse_components['isotropic'] = dhi * term1
1424-
diffuse_components['circumsolar'] = dhi * term2
1425-
diffuse_components['horizon'] = dhi * term3
1424+
diffuse_components['poa_isotropic'] = dhi * term1
1425+
diffuse_components['poa_circumsolar'] = dhi * term2
1426+
diffuse_components['poa_horizon'] = dhi * term3
14261427

14271428
if isinstance(sky_diffuse, pd.Series):
14281429
diffuse_components = pd.DataFrame(diffuse_components)

tests/test_irradiance.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,14 @@ def test_haydavies(irrad_data, ephem_data, dni_et):
210210

211211

212212
def test_haydavies_components(irrad_data, ephem_data, dni_et):
213+
keys = ['poa_sky_diffuse', 'poa_isotropic', 'poa_circumsolar',
214+
'poa_horizon']
213215
expected = pd.DataFrame(np.array(
214216
[[0, 27.1775, 102.9949, 33.1909],
215217
[0, 27.1775, 30.1818, 27.9837],
216218
[0, 0, 72.8130, 5.2071],
217219
[0, 0, 0, 0]]).T,
218-
columns=['sky_diffuse', 'isotropic', 'circumsolar', 'horizon'],
220+
columns=keys,
219221
index=irrad_data.index
220222
)
221223
# pandas
@@ -229,23 +231,16 @@ def test_haydavies_components(irrad_data, ephem_data, dni_et):
229231
40, 180, irrad_data['dhi'].values, irrad_data['dni'].values, dni_et,
230232
ephem_data['apparent_zenith'].values, ephem_data['azimuth'].values,
231233
return_components=True)
232-
assert_allclose(result['sky_diffuse'], expected['sky_diffuse'], atol=1e-4)
233-
assert_allclose(result['isotropic'], expected['isotropic'], atol=1e-4)
234-
assert_allclose(result['circumsolar'], expected['circumsolar'], atol=1e-4)
235-
assert_allclose(result['horizon'], expected['horizon'], atol=1e-4)
234+
for key in keys:
235+
assert_allclose(result[key], expected[key], atol=1e-4)
236236
assert isinstance(result, dict)
237237
# scalar
238238
result = irradiance.haydavies(
239239
40, 180, irrad_data['dhi'].values[-1], irrad_data['dni'].values[-1],
240240
dni_et[-1], ephem_data['apparent_zenith'].values[-1],
241241
ephem_data['azimuth'].values[-1], return_components=True)
242-
assert_allclose(result['sky_diffuse'], expected['sky_diffuse'].iloc[-1],
243-
atol=1e-4)
244-
assert_allclose(result['isotropic'], expected['isotropic'].iloc[-1],
245-
atol=1e-4)
246-
assert_allclose(result['circumsolar'], expected['circumsolar'].iloc[-1],
247-
atol=1e-4)
248-
assert_allclose(result['horizon'], expected['horizon'].iloc[-1], atol=1e-4)
242+
for key in keys:
243+
assert_allclose(result[key], expected[key].iloc[-1], atol=1e-4)
249244
assert isinstance(result, dict)
250245

251246

@@ -312,13 +307,14 @@ def test_perez_components(irrad_data, ephem_data, dni_et, relative_airmass):
312307
[0., 26.84138589, np.nan, 31.72696071],
313308
[0., 0., np.nan, 4.47966439],
314309
[0., 4.62212181, np.nan, 9.25316454]]).T,
315-
columns=['sky_diffuse', 'isotropic', 'circumsolar', 'horizon'],
310+
columns=['poa_sky_diffuse', 'poa_isotropic', 'poa_circumsolar',
311+
'poa_horizon'],
316312
index=irrad_data.index
317313
)
318-
expected_for_sum = expected['sky_diffuse'].copy()
314+
expected_for_sum = expected['poa_sky_diffuse'].copy()
319315
expected_for_sum.iloc[2] = 0
320316
sum_components = out.iloc[:, 1:].sum(axis=1)
321-
sum_components.name = 'sky_diffuse'
317+
sum_components.name = 'poa_sky_diffuse'
322318

323319
assert_frame_equal(out, expected, check_less_precise=2)
324320
assert_series_equal(sum_components, expected_for_sum, check_less_precise=2)
@@ -338,13 +334,14 @@ def test_perez_driesse_components(irrad_data, ephem_data, dni_et,
338334
[0., 25.806, np.nan, 33.181],
339335
[0., 0.000, np.nan, 4.197],
340336
[0., 4.184, np.nan, 10.018]]).T,
341-
columns=['sky_diffuse', 'isotropic', 'circumsolar', 'horizon'],
337+
columns=['poa_sky_diffuse', 'poa_isotropic', 'poa_circumsolar',
338+
'poa_horizon'],
342339
index=irrad_data.index
343340
)
344-
expected_for_sum = expected['sky_diffuse'].copy()
341+
expected_for_sum = expected['poa_sky_diffuse'].copy()
345342
expected_for_sum.iloc[2] = 0
346343
sum_components = out.iloc[:, 1:].sum(axis=1)
347-
sum_components.name = 'sky_diffuse'
344+
sum_components.name = 'poa_sky_diffuse'
348345

349346
assert_frame_equal(out, expected, check_less_precise=2)
350347
assert_series_equal(sum_components, expected_for_sum, check_less_precise=2)
@@ -384,13 +381,14 @@ def test_perez_negative_horizon():
384381
[166.785419, 142.24475, 119.173875, 83.525150, 45.725931],
385382
[113.548755, 16.09757, 9.956174, 3.142467, 0],
386383
[1.076010, -6.13353, -5.262151, -3.831230, -2.208923]]).T,
387-
columns=['sky_diffuse', 'isotropic', 'circumsolar', 'horizon'],
384+
columns=['poa_sky_diffuse', 'poa_isotropic', 'poa_circumsolar',
385+
'poa_horizon'],
388386
index=times
389387
)
390388

391-
expected_for_sum = expected['sky_diffuse'].copy()
389+
expected_for_sum = expected['poa_sky_diffuse'].copy()
392390
sum_components = out.iloc[:, 1:].sum(axis=1)
393-
sum_components.name = 'sky_diffuse'
391+
sum_components.name = 'poa_sky_diffuse'
394392

395393
assert_frame_equal(out, expected, check_less_precise=2)
396394
assert_series_equal(sum_components, expected_for_sum, check_less_precise=2)

0 commit comments

Comments
 (0)