Skip to content
Merged
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
4 changes: 3 additions & 1 deletion docs/sphinx/source/whatsnew/v0.3.3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Bug fixes
* Fix snlinverter and singlediode documentation. They incorrectly said that
inverter/module must be a DataFrame, when in reality they can be any
dict-like object. (:issue:`157`)

* Fix numpy 1.11 deprecation warnings caused by some functions using
non-integer indices.

Documentation
~~~~~~~~~~~~~
Expand Down Expand Up @@ -64,3 +65,4 @@ Contributors
* Will Holmgren
* Mark Mikofski
* Johannes Oos
* Tony Lorenzo
4 changes: 2 additions & 2 deletions pvlib/clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ def lookup_linke_turbidity(time, latitude, longitude, filepath=None,
mat = scipy.io.loadmat(filepath)
linke_turbidity_table = mat['LinkeTurbidity']

latitude_index = np.around(_linearly_scale(latitude, 90, -90, 1, 2160))
longitude_index = np.around(_linearly_scale(longitude, -180, 180, 1, 4320))
latitude_index = np.around(_linearly_scale(latitude, 90, -90, 1, 2160)).astype(np.int64)
longitude_index = np.around(_linearly_scale(longitude, -180, 180, 1, 4320)).astype(np.int64)

g = linke_turbidity_table[latitude_index][longitude_index]

Expand Down
13 changes: 8 additions & 5 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,6 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,

kt_prime = kt / (1.031 * np.exp(-1.4/(0.9+9.4/airmass)) + 0.1)
kt_prime[kt_prime > 0.82] = 0.82 # From SRRL code. consider np.NaN
kt_prime.fillna(0, inplace=True)
pvl_logger.debug('kt_prime:\n%s', kt_prime)

# wholmgren:
Expand All @@ -1519,7 +1518,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
# Later, we'll subtract 1 to conform to Python's 0-indexing.

# Create kt_prime bins
kt_prime_bin = pd.Series(index=times)
kt_prime_bin = pd.Series(0, index=times, dtype=np.int64)
kt_prime_bin[(kt_prime>=0) & (kt_prime<0.24)] = 1
kt_prime_bin[(kt_prime>=0.24) & (kt_prime<0.4)] = 2
kt_prime_bin[(kt_prime>=0.4) & (kt_prime<0.56)] = 3
Expand All @@ -1529,7 +1528,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
pvl_logger.debug('kt_prime_bin:\n%s', kt_prime_bin)

# Create zenith angle bins
zenith_bin = pd.Series(index=times)
zenith_bin = pd.Series(0, index=times, dtype=np.int64)
zenith_bin[(zenith>=0) & (zenith<25)] = 1
zenith_bin[(zenith>=25) & (zenith<40)] = 2
zenith_bin[(zenith>=40) & (zenith<55)] = 3
Expand All @@ -1539,7 +1538,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
pvl_logger.debug('zenith_bin:\n%s', zenith_bin)

# Create the bins for w based on dew point temperature
w_bin = pd.Series(index=times)
w_bin = pd.Series(0, index=times, dtype=np.int64)
w_bin[(w>=0) & (w<1)] = 1
w_bin[(w>=1) & (w<2)] = 2
w_bin[(w>=2) & (w<3)] = 3
Expand All @@ -1548,7 +1547,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
pvl_logger.debug('w_bin:\n%s', w_bin)

# Create delta_kt_prime binning.
delta_kt_prime_bin = pd.Series(index=times)
delta_kt_prime_bin = pd.Series(0, index=times, dtype=np.int64)
delta_kt_prime_bin[(delta_kt_prime>=0) & (delta_kt_prime<0.015)] = 1
delta_kt_prime_bin[(delta_kt_prime>=0.015) & (delta_kt_prime<0.035)] = 2
delta_kt_prime_bin[(delta_kt_prime>=0.035) & (delta_kt_prime<0.07)] = 3
Expand All @@ -1562,6 +1561,10 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
# assignment and Python-style array lookup.
dirint_coeffs = coeffs[kt_prime_bin-1, zenith_bin-1,
delta_kt_prime_bin-1, w_bin-1]
# convert unassigned bins to nan
# use where to avoid boolean indexing deprecation
dirint_coeffs[np.where((kt_prime_bin == 0) | (zenith_bin == 0) |
(w_bin == 0) | (delta_kt_prime_bin == 0))] = np.nan

dni = disc_out['dni'] * dirint_coeffs

Expand Down
13 changes: 13 additions & 0 deletions pvlib/test/test_irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,19 @@ def test_dirint_value():
assert_almost_equal(dirint_data.values,
np.array([928.85, 688.26]), 1)


def test_dirint_nans():
times = pd.DatetimeIndex(start='2014-06-24T12-0700', periods=5, freq='6H')
ghi = pd.Series([np.nan, 1038.62, 1038.62, 1038.62, 1038.62], index=times)
zenith = pd.Series([10.567, np.nan, 10.567, 10.567, 10.567,], index=times)
pressure = pd.Series([93193., 93193., np.nan, 93193., 93193.], index=times)
temp_dew = pd.Series([10, 10, 10, np.nan, 10], index=times)
dirint_data = irradiance.dirint(ghi, zenith, times, pressure=pressure,
temp_dew=temp_dew)
assert_almost_equal(dirint_data.values,
np.array([np.nan, np.nan, np.nan, np.nan, 934.2]), 1)


def test_dirint_tdew():
times = pd.DatetimeIndex(['2014-06-24T12-0700','2014-06-24T18-0700'])
ghi = pd.Series([1038.62, 254.53], index=times)
Expand Down