@@ -1495,7 +1495,6 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
1495
1495
1496
1496
kt_prime = kt / (1.031 * np .exp (- 1.4 / (0.9 + 9.4 / airmass )) + 0.1 )
1497
1497
kt_prime [kt_prime > 0.82 ] = 0.82 # From SRRL code. consider np.NaN
1498
- kt_prime .fillna (0 , inplace = True )
1499
1498
pvl_logger .debug ('kt_prime:\n %s' , kt_prime )
1500
1499
1501
1500
# wholmgren:
@@ -1519,7 +1518,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
1519
1518
# Later, we'll subtract 1 to conform to Python's 0-indexing.
1520
1519
1521
1520
# Create kt_prime bins
1522
- kt_prime_bin = pd .Series (index = times )
1521
+ kt_prime_bin = pd .Series (0 , index = times , dtype = np . int64 )
1523
1522
kt_prime_bin [(kt_prime >= 0 ) & (kt_prime < 0.24 )] = 1
1524
1523
kt_prime_bin [(kt_prime >= 0.24 ) & (kt_prime < 0.4 )] = 2
1525
1524
kt_prime_bin [(kt_prime >= 0.4 ) & (kt_prime < 0.56 )] = 3
@@ -1529,7 +1528,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
1529
1528
pvl_logger .debug ('kt_prime_bin:\n %s' , kt_prime_bin )
1530
1529
1531
1530
# Create zenith angle bins
1532
- zenith_bin = pd .Series (index = times )
1531
+ zenith_bin = pd .Series (0 , index = times , dtype = np . int64 )
1533
1532
zenith_bin [(zenith >= 0 ) & (zenith < 25 )] = 1
1534
1533
zenith_bin [(zenith >= 25 ) & (zenith < 40 )] = 2
1535
1534
zenith_bin [(zenith >= 40 ) & (zenith < 55 )] = 3
@@ -1539,7 +1538,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
1539
1538
pvl_logger .debug ('zenith_bin:\n %s' , zenith_bin )
1540
1539
1541
1540
# Create the bins for w based on dew point temperature
1542
- w_bin = pd .Series (index = times )
1541
+ w_bin = pd .Series (0 , index = times , dtype = np . int64 )
1543
1542
w_bin [(w >= 0 ) & (w < 1 )] = 1
1544
1543
w_bin [(w >= 1 ) & (w < 2 )] = 2
1545
1544
w_bin [(w >= 2 ) & (w < 3 )] = 3
@@ -1548,7 +1547,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
1548
1547
pvl_logger .debug ('w_bin:\n %s' , w_bin )
1549
1548
1550
1549
# Create delta_kt_prime binning.
1551
- delta_kt_prime_bin = pd .Series (index = times )
1550
+ delta_kt_prime_bin = pd .Series (0 , index = times , dtype = np . int64 )
1552
1551
delta_kt_prime_bin [(delta_kt_prime >= 0 ) & (delta_kt_prime < 0.015 )] = 1
1553
1552
delta_kt_prime_bin [(delta_kt_prime >= 0.015 ) & (delta_kt_prime < 0.035 )] = 2
1554
1553
delta_kt_prime_bin [(delta_kt_prime >= 0.035 ) & (delta_kt_prime < 0.07 )] = 3
@@ -1562,6 +1561,10 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
1562
1561
# assignment and Python-style array lookup.
1563
1562
dirint_coeffs = coeffs [kt_prime_bin - 1 , zenith_bin - 1 ,
1564
1563
delta_kt_prime_bin - 1 , w_bin - 1 ]
1564
+ # convert unassigned bins to nan
1565
+ # use where to avoid boolean indexing deprecation
1566
+ dirint_coeffs [np .where ((kt_prime_bin == 0 ) | (zenith_bin == 0 ) |
1567
+ (w_bin == 0 ) | (delta_kt_prime_bin == 0 ))] = np .nan
1565
1568
1566
1569
dni = disc_out ['dni' ] * dirint_coeffs
1567
1570
0 commit comments