Skip to content

Commit 414f8ca

Browse files
committed
Merge branch 'modelchain_test' of https://github.com/RDaxini/pvlib-python into modelchain_test
2 parents 78b71e7 + aef91b7 commit 414f8ca

10 files changed

Lines changed: 47 additions & 33 deletions

File tree

docs/examples/agrivoltaics/plot_agrivoltaics_ground_irradiance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
tracking_orientations = pvlib.tracking.singleaxis(
6161
apparent_zenith=solpos['apparent_zenith'],
62-
apparent_azimuth=solpos['azimuth'],
62+
solar_azimuth=solpos['azimuth'],
6363
axis_azimuth=axis_azimuth,
6464
max_angle=max_angle,
6565
backtrack=True,

docs/examples/shading/plot_martinez_shade_loss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090

9191
tracking_result = pvlib.tracking.singleaxis(
9292
apparent_zenith=solar_apparent_zenith,
93-
apparent_azimuth=solar_azimuth,
93+
solar_azimuth=solar_azimuth,
9494
axis_tilt=axis_tilt,
9595
axis_azimuth=axis_azimuth,
9696
max_angle=(-90 + cross_axis_tilt, 90 + cross_axis_tilt), # (min, max)

docs/examples/solar-tracking/plot_single_axis_tracking.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
truetracking_angles = tracking.singleaxis(
3535
apparent_zenith=solpos['apparent_zenith'],
36-
apparent_azimuth=solpos['azimuth'],
36+
solar_azimuth=solpos['azimuth'],
3737
axis_tilt=0,
3838
axis_azimuth=180,
3939
max_angle=90,
@@ -61,7 +61,7 @@
6161
for gcr in [0.2, 0.4, 0.6]:
6262
backtracking_angles = tracking.singleaxis(
6363
apparent_zenith=solpos['apparent_zenith'],
64-
apparent_azimuth=solpos['azimuth'],
64+
solar_azimuth=solpos['azimuth'],
6565
axis_tilt=0,
6666
axis_azimuth=180,
6767
max_angle=90,

docs/examples/solar-tracking/plot_single_axis_tracking_on_sloped_terrain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
for cross_axis_tilt in [0, 5, 10]:
101101
tracker_data = tracking.singleaxis(
102102
apparent_zenith=solpos['apparent_zenith'],
103-
apparent_azimuth=solpos['azimuth'],
103+
solar_azimuth=solpos['azimuth'],
104104
axis_tilt=0, # flat because the axis is perpendicular to the slope
105105
axis_azimuth=180, # N-S axis, azimuth facing south
106106
max_angle=90,
@@ -156,7 +156,7 @@
156156

157157
tracker_data = tracking.singleaxis(
158158
apparent_zenith=solpos['apparent_zenith'],
159-
apparent_azimuth=solpos['azimuth'],
159+
solar_azimuth=solpos['azimuth'],
160160
axis_tilt=axis_tilt, # no longer flat because the terrain imparts a tilt
161161
axis_azimuth=axis_azimuth,
162162
max_angle=90,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Deprecations
1212
~~~~~~~~~~~~
1313
* Deprecate :py:func:`~pvlib.modelchain.get_orientation`. Removal scheduled for
1414
``v0.14.0``. (:pull:`2691`)
15-
15+
* Rename parameter name ``aparent_azimuth`` to ``solar_azimuth`` in :py:func:`~pvlib.tracking.singleaxis`.
16+
(:issue:`2479`, :pull:`2480`)
1617

1718
Bug fixes
1819
~~~~~~~~~

pvlib/bifacial/pvfactors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
The ``bifacial.pvfactors`` module contains functions for modeling back surface
3-
plane-of-array irradiance using an external implementaton of the pvfactors
3+
plane-of-array irradiance using an external implementation of the pvfactors
44
model (either ``solarfactors`` or the original ``pvfactors``).
55
"""
66

pvlib/ivtools/sdm/_fit_desoto_pvsyst_sandia.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def _update_io(voc, iph, io, rs, rsh, nnsvth):
267267
.. [1] PVLib MATLAB https://github.com/sandialabs/MATLAB_PV_LIB
268268
.. [2] C. Hansen, Parameter Estimation for Single Diode Models of
269269
Photovoltaic Modules, Sandia National Laboratories Report SAND2015-2065
270-
.. [3] C. Hansen, Estimation of Parameteres for Single Diode Models using
270+
.. [3] C. Hansen, Estimation of Parameters for Single Diode Models using
271271
Measured IV Curves, Proc. of the 39th IEEE PVSC, June 2013.
272272
"""
273273

pvlib/singlediode.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -696,27 +696,34 @@ def _lambertw_v_from_i(current, photocurrent, saturation_current,
696696

697697
# Only compute using LambertW if there are cases with Gsh>0
698698
if np.any(idx_p):
699+
700+
# use only the relevant subset for what follows
701+
I = I[idx_p]
702+
IL = IL[idx_p]
703+
I0 = I0[idx_p]
704+
Rs = Rs[idx_p]
705+
Gsh = Gsh[idx_p]
706+
a = a[idx_p]
707+
699708
# LambertW argument, cannot be float128, may overflow to np.inf
700709
# overflow is explicitly handled below, so ignore warnings here
701710
with np.errstate(over='ignore'):
702-
argW = (I0[idx_p] / (Gsh[idx_p] * a[idx_p]) *
703-
np.exp((-I[idx_p] + IL[idx_p] + I0[idx_p]) /
704-
(Gsh[idx_p] * a[idx_p])))
711+
argW = I0 / (Gsh * a) * np.exp((-I + IL + I0) / (Gsh * a))
705712

706713
# lambertw typically returns complex value with zero imaginary part
707714
# may overflow to np.inf
708715
lambertwterm = lambertw(argW).real
709716

710717
# Record indices where lambertw input overflowed output
711-
idx_inf = np.logical_not(np.isfinite(lambertwterm))
718+
idx_inf = np.isinf(lambertwterm)
712719

713720
# Only re-compute LambertW if it overflowed
714721
if np.any(idx_inf):
715722
# Calculate using log(argW) in case argW is really big
716-
logargW = (np.log(I0[idx_p]) - np.log(Gsh[idx_p]) -
717-
np.log(a[idx_p]) +
718-
(-I[idx_p] + IL[idx_p] + I0[idx_p]) /
719-
(Gsh[idx_p] * a[idx_p]))[idx_inf]
723+
logargW = (np.log(I0[idx_inf]) - np.log(Gsh[idx_inf]) -
724+
np.log(a[idx_inf]) +
725+
(-I[idx_inf] + IL[idx_inf] + I0[idx_inf]) /
726+
(Gsh[idx_inf] * a[idx_inf]))
720727

721728
# Three iterations of Newton-Raphson method to solve
722729
# w+log(w)=logargW. The initial guess is w=logargW. Where direct
@@ -730,8 +737,7 @@ def _lambertw_v_from_i(current, photocurrent, saturation_current,
730737
# Eqn. 3 in Jain and Kapoor, 2004
731738
# V = -I*(Rs + Rsh) + IL*Rsh - a*lambertwterm + I0*Rsh
732739
# Recast in terms of Gsh=1/Rsh for better numerical stability.
733-
V[idx_p] = (IL[idx_p] + I0[idx_p] - I[idx_p]) / Gsh[idx_p] - \
734-
I[idx_p] * Rs[idx_p] - a[idx_p] * lambertwterm
740+
V[idx_p] = (IL + I0 - I) / Gsh - I * Rs - a * lambertwterm
735741

736742
if output_is_scalar:
737743
return V.item()

pvlib/tracking.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
from pvlib.tools import cosd, sind, tand, acosd, asind
55
from pvlib import irradiance
66
from pvlib import shading
7+
from pvlib._deprecation import renamed_kwarg_warning
78

89

9-
def singleaxis(apparent_zenith, apparent_azimuth,
10+
@renamed_kwarg_warning(
11+
since='0.13.1',
12+
old_param_name='apparent_azimuth',
13+
new_param_name='solar_azimuth')
14+
def singleaxis(apparent_zenith, solar_azimuth,
1015
axis_tilt=0, axis_azimuth=0, max_angle=90,
1116
backtrack=True, gcr=2.0/7.0, cross_axis_tilt=0):
1217
"""
@@ -33,7 +38,7 @@ def singleaxis(apparent_zenith, apparent_azimuth,
3338
apparent_zenith : float, 1d array, or Series
3439
Solar apparent zenith angles in decimal degrees.
3540
36-
apparent_azimuth : float, 1d array, or Series
41+
solar_azimuth : float, 1d array, or Series
3742
Solar apparent azimuth angles in decimal degrees.
3843
3944
axis_tilt : float, default 0
@@ -123,10 +128,10 @@ def singleaxis(apparent_zenith, apparent_azimuth,
123128
index = None
124129

125130
# convert scalars to arrays
126-
apparent_azimuth = np.atleast_1d(apparent_azimuth)
131+
solar_azimuth = np.atleast_1d(solar_azimuth)
127132
apparent_zenith = np.atleast_1d(apparent_zenith)
128133

129-
if apparent_azimuth.ndim > 1 or apparent_zenith.ndim > 1:
134+
if solar_azimuth.ndim > 1 or apparent_zenith.ndim > 1:
130135
raise ValueError('Input dimensions must not exceed 1')
131136

132137
# The ideal tracking angle, omega_ideal, is the rotation to place the sun
@@ -142,7 +147,7 @@ def singleaxis(apparent_zenith, apparent_azimuth,
142147
axis_tilt=axis_tilt,
143148
axis_azimuth=axis_azimuth,
144149
solar_zenith=apparent_zenith,
145-
solar_azimuth=apparent_azimuth,
150+
solar_azimuth=solar_azimuth,
146151
)
147152

148153
# filter for sun above panel horizon
@@ -191,7 +196,7 @@ def singleaxis(apparent_zenith, apparent_azimuth,
191196
surface_tilt = surface['surface_tilt']
192197
surface_azimuth = surface['surface_azimuth']
193198
aoi = irradiance.aoi(surface_tilt, surface_azimuth,
194-
apparent_zenith, apparent_azimuth)
199+
apparent_zenith, solar_azimuth)
195200

196201
# Bundle DataFrame for return values and filter for sun below horizon.
197202
out = {'tracker_theta': tracker_theta, 'aoi': aoi,

tests/ivtools/sdm/test__fit_desoto_pvsyst_sandia.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def test__update_io(voc, iph, io, rs, rsh, nnsvth, expected):
5656
(2., 2., 2., 2., 2., 0.),
5757
(-1., -1., -1., -1., -1., -1.)])
5858
def test__update_io_nan(voc, iph, io, rs, rsh, nnsvth):
59-
outio = _update_io(voc, iph, io, rs, rsh, nnsvth)
59+
with np.errstate(invalid='ignore', divide='ignore'):
60+
outio = _update_io(voc, iph, io, rs, rsh, nnsvth)
6061
assert np.isnan(outio)
6162

6263

@@ -89,13 +90,14 @@ def test__calc_theta_phi_exact_one_nan():
8990

9091

9192
def test__calc_theta_phi_exact_vector():
92-
theta, phi = _calc_theta_phi_exact(imp=np.array([1., -1.]),
93-
iph=np.array([-1., 1.]),
94-
vmp=np.array([1., -1.]),
95-
io=np.array([-1., 1.]),
96-
nnsvth=np.array([1., -1.]),
97-
rs=np.array([-1., 1.]),
98-
rsh=np.array([1., -1.]))
93+
with np.errstate(invalid='ignore'):
94+
theta, phi = _calc_theta_phi_exact(imp=np.array([1., -1.]),
95+
iph=np.array([-1., 1.]),
96+
vmp=np.array([1., -1.]),
97+
io=np.array([-1., 1.]),
98+
nnsvth=np.array([1., -1.]),
99+
rs=np.array([-1., 1.]),
100+
rsh=np.array([1., -1.]))
99101
assert np.isnan(theta[0])
100102
assert np.isnan(theta[1])
101103
assert np.isnan(phi[0])

0 commit comments

Comments
 (0)