Skip to content

Commit 245ace1

Browse files
cwhansewholmgren
authored andcommitted
Improves sapm deprecation warning checker (#854)
* improve warning condition * fix indent * overthinking this * handle different types * stickler * fix test logic * hush, stickler
1 parent 6dbac00 commit 245ace1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pvlib/pvsystem.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,11 +1678,14 @@ def sapm(effective_irradiance, temp_cell, module):
16781678
irrad_ref = 1000
16791679
# TODO: remove this warning in v0.8 after deprecation period for change in
16801680
# effective irradiance units, made in v0.7
1681-
if np.all(effective_irradiance < 2.0):
1682-
import warnings
1683-
warnings.warn('effective_irradiance inputs appear to be in suns.'
1684-
' Units changed in v0.7 from suns to W/m2',
1685-
RuntimeWarning)
1681+
with np.errstate(invalid='ignore'): # turn off warning for NaN
1682+
ee = np.asarray(effective_irradiance)
1683+
ee_gt0 = ee[ee > 0.0]
1684+
if ee_gt0.size > 0 and np.all(ee_gt0 < 2.0):
1685+
import warnings
1686+
msg = 'effective_irradiance inputs appear to be in suns. Units ' \
1687+
'changed in v0.7 from suns to W/m2'
1688+
warnings.warn(msg, RuntimeWarning)
16861689

16871690
q = 1.60218e-19 # Elementary charge in units of coulombs
16881691
kb = 1.38066e-23 # Boltzmann's constant in units of J/K

0 commit comments

Comments
 (0)