Skip to content

Commit a330127

Browse files
authored
Adapt to changed keys from pvlib perez function (#39)
* adapt to changed keys from pvlib perez function pvlib/pvlib-python#2627 * whatsnew * retain compatibility with older pvlib * fix mistake
1 parent ff6c4d6 commit a330127

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

docs/sphinx/whatsnew/v1.6.1.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
v1.6.1 (??)
44
==========
55

6+
Enhancements
7+
------------
8+
* Compatibility with pvlib >=0.14.0. (:pull:`39`)
69

710
Maintenance
811
-----------
912
* Drop Python 3.8 and 3.9 support (:pull:`30`, :pull:`33`)
1013
* Add Python 3.14 support (:pull:`35`)
1114

12-
1315
Documentation
1416
-------------
1517
* Fixed typo in README. (:issue:`28`, :pull:`29`)

pvfactors/irradiance/utils.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ def perez_diffuse_luminance(timestamps, surface_tilt, surface_azimuth,
9494
am,
9595
return_components=True)
9696

97+
# compatibility with pvlib<0.14.0
98+
components = components.rename(columns={'isotropic': 'poa_isotropic',
99+
'circumsolar': 'poa_circumsolar',
100+
'horizon': 'poa_horizon',
101+
'sky_diffuse': 'poa_sky_diffuse'})
102+
97103
# Calculate Perez view factors:
98104
a = irradiance.aoi_projection(
99105
df_inputs.surface_tilt,
@@ -114,24 +120,19 @@ def perez_diffuse_luminance(timestamps, surface_tilt, surface_azimuth,
114120
# Calculate diffuse luminance
115121
luminance = pd.DataFrame(
116122
np.array([
117-
components['horizon'] / vf_perez['vf_horizon'],
118-
components['circumsolar'] / vf_perez['vf_circumsolar'],
119-
components['isotropic'] / vf_perez['vf_isotropic']
123+
components['poa_horizon'] / vf_perez['vf_horizon'],
124+
components['poa_circumsolar'] / vf_perez['vf_circumsolar'],
125+
components['poa_isotropic'] / vf_perez['vf_isotropic']
120126
]).T,
121127
index=df_inputs.index,
122128
columns=['luminance_horizon', 'luminance_circumsolar',
123129
'luminance_isotropic']
124130
)
125-
luminance.loc[components['sky_diffuse'] == 0, :] = 0.
126-
127-
# Format components column names
128-
components = components.rename(columns={'isotropic': 'poa_isotropic',
129-
'circumsolar': 'poa_circumsolar',
130-
'horizon': 'poa_horizon'})
131+
luminance.loc[components['poa_sky_diffuse'] == 0, :] = 0.
131132

132133
df_inputs = pd.concat([df_inputs, components, vf_perez, luminance],
133134
axis=1, join='outer')
134-
df_inputs = df_inputs.rename(columns={'sky_diffuse': 'poa_total_diffuse'})
135+
df_inputs = df_inputs.rename(columns={'poa_sky_diffuse': 'poa_total_diffuse'})
135136

136137
# Adjust the circumsolar luminance when it hits the back surface
137138
if df_inputs_back_surface.shape[0] > 0:

0 commit comments

Comments
 (0)