Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/sphinx/source/whatsnew/v0.9.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Bug fixes
* When using ``utc_time_range`` with :py:func:`pvlib.iotools.read_ecmwf_macc`,
the time index subset is now selected with ``nearest`` instead of ``before``
and ``after`` for consistency with ``cftime>=1.6.0``. (:issue:`1609`, :pull:`1656`)
* :py:func:`~pvlib.ivtools.sdm.pvsyst_temperature_coeff` no longer raises
a scipy deprecation warning (and is slightly more accurate) (:issue:`1644`, :pull:`1674`)


Testing
Expand Down
9 changes: 7 additions & 2 deletions pvlib/ivtools/sdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from scipy import constants
from scipy import optimize
from scipy.special import lambertw
from scipy.misc import derivative

from pvlib.pvsystem import calcparams_pvsyst, singlediode, v_from_i
from pvlib.singlediode import bishop88_mpp
Expand Down Expand Up @@ -1344,5 +1343,11 @@ def maxp(temp_cell, irrad_ref, alpha_sc, gamma_ref, mu_gamma, I_L_ref,
I_o_ref, R_sh_ref, R_sh_0, R_s, cells_in_series, R_sh_exp, EgRef,
temp_ref)
pmp = maxp(temp_ref, *args)
gamma_pdc = derivative(maxp, temp_ref, args=args)

# first order centered difference at temp_ref
dx = 1e-3
x0 = temp_ref
dy = maxp(x0+dx, *args) - maxp(x0-dx, *args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since bishop88 is vectorized it shouldn't cost any more to compute 4 values than 2. Why not x = [x0-2dx, x0-dx, x0+dx, x0+2dx], pmp = maxp(x, ...) and use the fourth order formula?

gamma_pdc = np.array([1, -8, 8, -1]) * pmp / (12 * dx)

https://www.dam.brown.edu/people/alcyew/handouts/numdiff.pdf

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't hit the button to submit this comment. No action required here, archiving the comment in case the issue arises.

gamma_pdc = dy / (2*dx)

return gamma_pdc / pmp