8000 Add method to fit Huld model by cwhanse · Pull Request #1979 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Add method to fit Huld model #1979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
respond to comments
  • Loading branch information
cwhanse committed Apr 18, 2024
commit 464749e5d928149886854109f0bf838fa25c852b
71 changes: 0 additions & 71 deletions docs/sphinx/source/whatsnew/v0.10.4.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/sphinx/source/whatsnew/v0.10.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Deprecations

Enhancements
~~~~~~~~~~~~

* Added a method to fit the Huld PV model (:pull:`1979`)

Bug fixes
~~~~~~~~~
Expand Down
6 changes: 3 additions & 3 deletions pvlib/pvarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ def fit_huld(effective_irradiance, temp_module, pdc, method='ols'):
gprime = effective_irradiance / 1000
tprime = temp_module - 25
# accomodate gprime<=0
logGprime = np.log(gprime, out=np.nan*gprime,
where=np.array(gprime > 0))
with np.errstate(divide='ignore'):
logGprime = np.log(gprime, out=np.zeros_like(gprime),
where=np.array(gprime > 0))
Y = np.divide(pdc, gprime, out=np.zeros_like(gprime),
Y = np.divide(pdc, gprime, out=np.nan*gprime,
where=np.array(gprime > 0))

X = np.stack((logGprime, logGprime**2, tprime, tprime*logGprime,
Expand Down
9 changes: 2 additions & 7 deletions pvlib/tests/test_pvarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,13 @@ def test_fit_huld(method):
pdc = pvarray.huld(ee, tc, pdc0, cell_type='csi')
pdc[11] = np.nan
m_pdc0, k = pvarray.fit_huld(ee, tc, pdc, method='ols')
# known solution for OLS obtained with statsmodels v0.14.0
expected = np.array([2.07118648e+02, -8.35033390e+01, -3.83844606e+01,
2.75629738e+00, 1.87571414e+00, -2.86429730e-01,
-6.00418853e-02])
expected = np.array([pdc0, ] + [v for v in k0], dtype=float)
modeled = np.hstack((m_pdc0, k))
assert_allclose(expected, modeled, rtol=1e-5)
assert_allclose(expected, modeled, rtol=1e-8)


@requires_statsmodels
def test_fit_huld_method_error():
# test is to recover the parameters in _infer_huld_k for each cell type
# IEC61853 conditions to make data for fitting
ee, tc = pvarray._build_iec61853()
pdc0 = 250
pdc = pvarray.huld(ee, tc, pdc0, cell_type='csi')
Expand Down
0