Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
# This example shows how the :py:class:`~pvlib.modelchain.ModelChain` can
# be adjusted to use a different set of Perez coefficients.

import pandas as pd
from pvlib.pvsystem import PVSystem
from pvlib.modelchain import ModelChain
from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS
Expand Down
22 changes: 11 additions & 11 deletions pvlib/singlediode.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,12 @@
# Ensure that we are working with read-only views of numpy arrays
# Turns Series into arrays so that we don't have to worry about
# multidimensional broadcasting failing
I, IL, I0, Rs, Gsh, a = \
Iop, IL, I0, Rs, Gsh, a = \
np.broadcast_arrays(current, photocurrent, saturation_current,
resistance_series, conductance_shunt, nNsVth)

# Intitalize output V (I might not be float64)
V = np.full_like(I, np.nan, dtype=np.float64)
# Intitalize output Vop (Iop might not be float64)
Vop = np.full_like(Iop, np.nan, dtype=np.float64)

# Determine indices where 0 < Gsh requires implicit model solution
idx_p = 0. < Gsh
Expand All @@ -783,14 +783,14 @@

# Explicit solutions where Gsh=0
if np.any(idx_z):
V[idx_z] = a[idx_z] * np.log1p((IL[idx_z] - I[idx_z]) / I0[idx_z]) - \
I[idx_z] * Rs[idx_z]
Vop[idx_z] = a[idx_z] * np.log1p((IL[idx_z] - Iop[idx_z]) / I0[idx_z]) - \

Check failure on line 786 in pvlib/singlediode.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E501 line too long (82 > 79 characters)
Iop[idx_z] * Rs[idx_z]

Check failure on line 787 in pvlib/singlediode.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E126 continuation line over-indented for hanging indent

# Only compute using LambertW if there are cases with Gsh>0
if np.any(idx_p):

# use only the relevant subset for what follows
I = I[idx_p]
Iop = Iop[idx_p]
IL = IL[idx_p]
I0 = I0[idx_p]
Rs = Rs[idx_p]
Expand All @@ -800,7 +800,7 @@
# LambertW argument, cannot be float128, may overflow to np.inf
# overflow is explicitly handled below, so ignore warnings here
with np.errstate(over='ignore'):
argW = I0 / (Gsh * a) * np.exp((-I + IL + I0) / (Gsh * a))
argW = I0 / (Gsh * a) * np.exp((-Iop + IL + I0) / (Gsh * a))

lambertwterm = np.zeros_like(argW)

Expand All @@ -814,19 +814,19 @@
# Calculate using log(argW) in case argW is really big
logargW = (np.log(I0[idx_inf]) - np.log(Gsh[idx_inf]) -
np.log(a[idx_inf]) +
(-I[idx_inf] + IL[idx_inf] + I0[idx_inf]) /
(-Iop[idx_inf] + IL[idx_inf] + I0[idx_inf]) /
(Gsh[idx_inf] * a[idx_inf]))
lambertwterm[idx_inf] = _log_lambertw(logargW)

# Eqn. 3 in Jain and Kapoor, 2004
# V = -I*(Rs + Rsh) + IL*Rsh - a*lambertwterm + I0*Rsh
# Recast in terms of Gsh=1/Rsh for better numerical stability.
V[idx_p] = (IL + I0 - I) / Gsh - I * Rs - a * lambertwterm
Vop[idx_p] = (IL + I0 - Iop) / Gsh - Iop * Rs - a * lambertwterm

if output_is_scalar:
return V.item()
return Vop.item()
else:
return V
return Vop


def _lambertw_i_from_v(voltage, photocurrent, saturation_current,
Expand Down
4 changes: 2 additions & 2 deletions pvlib/spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@

l_rad = (l0 + l1 * jme + l2 * jme**2 + l3 * jme**3 + l4 * jme**4 +
l5 * jme**5)/10**8
l = np.rad2deg(l_rad)
return l % 360
l_deg = np.rad2deg(l_rad)
return l_deg % 360

@jcompile('float64(float64)', nopython=True)

Check failure on line 478 in pvlib/spa.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E302 expected 2 blank lines, found 1
def heliocentric_latitude(jme):
b0 = sum_mult_cos_add_mult(B0, jme)
b1 = sum_mult_cos_add_mult(B1, jme)
Expand Down
2 changes: 0 additions & 2 deletions pvlib/spectrum/mismatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import pandas as pd
from scipy.integrate import trapezoid

from warnings import warn


def calc_spectral_mismatch_field(sr, e_sun, e_ref=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion pvlib/tracking.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import pandas as pd

from pvlib.tools import cosd, sind, tand, acosd, asind
from pvlib.tools import cosd, sind, tand, acosd
from pvlib import irradiance
from pvlib import shading
from pvlib._deprecation import renamed_kwarg_warning
Expand Down
3 changes: 1 addition & 2 deletions tests/iotools/test_midc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pandas as pd
import pytest
import pytz

from pvlib.iotools import midc
from tests.conftest import TESTS_DATA_DIR, RERUNS, RERUNS_DELAY
Expand Down Expand Up @@ -34,7 +33,7 @@ def test_midc__format_index():
start = start.tz_localize("MST")
end = pd.Timestamp("20181014 23:59")
end = end.tz_localize("MST")
assert type(data.index) == pd.DatetimeIndex
assert isinstance(data.index, pd.DatetimeIndex)
assert data.index[0] == start
assert data.index[-1] == end

Expand Down
2 changes: 1 addition & 1 deletion tests/test_clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,11 @@
clearsky._clearsky_get_threshold(0.5)


def test_detect_clearsky_calls_threshold(mocker, detect_clearsky_threshold_data):

Check failure on line 575 in tests/test_clearsky.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E501 line too long (81 > 79 characters)
threshold_spy = mocker.spy(clearsky, '_clearsky_get_threshold')
expected, cs = detect_clearsky_threshold_data
threshold_actual = clearsky.detect_clearsky(expected['GHI'], cs['ghi'],
_ = clearsky.detect_clearsky(expected['GHI'], cs['ghi'],
infer_limits=True)

Check failure on line 579 in tests/test_clearsky.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E128 continuation line under-indented for visual indent
assert threshold_spy.call_count == 1


Expand Down
14 changes: 7 additions & 7 deletions tests/test_pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,18 +1298,18 @@ def test_v_from_i(fixture_v_from_i, method, atol):
Rsh = fixture_v_from_i['Rsh']
Rs = fixture_v_from_i['Rs']
nNsVth = fixture_v_from_i['nNsVth']
I = fixture_v_from_i['I']
Iop = fixture_v_from_i['I']
I0 = fixture_v_from_i['I0']
IL = fixture_v_from_i['IL']
V_expected = fixture_v_from_i['V_expected']

V = pvsystem.v_from_i(I, IL, I0, Rs, Rsh, nNsVth, method=method)
Vop = pvsystem.v_from_i(Iop, IL, I0, Rs, Rsh, nNsVth, method=method)

assert isinstance(V, type(V_expected))
if isinstance(V, np.ndarray):
assert isinstance(V.dtype, type(V_expected.dtype))
assert V.shape == V_expected.shape
assert_allclose(V, V_expected, atol=atol)
assert isinstance(Vop, type(V_expected))
if isinstance(Vop, np.ndarray):
assert isinstance(Vop.dtype, type(V_expected.dtype))
assert Vop.shape == V_expected.shape
assert_allclose(Vop, V_expected, atol=atol)


def test_i_from_v_from_i(fixture_v_from_i):
Expand Down
Loading