Skip to content

Commit 839feb9

Browse files
committed
change disc from nan to 0. make dirint pressure optional
1 parent c484e2c commit 839feb9

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pvlib/clearsky.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def disc(GHI, zenith, times, pressure=101325):
335335

336336
logger.debug('clearsky.disc')
337337

338-
temp = pd.DataFrame(index=times, columns=['A','B','C'])
338+
temp = pd.DataFrame(index=times, columns=['A','B','C'], dtype=float)
339339

340340
doy = times.dayofyear
341341

@@ -355,16 +355,13 @@ def disc(GHI, zenith, times, pressure=101325):
355355
Kt = GHI / I0h
356356
Kt[Kt < 0] = 0
357357
Kt[Kt > 2] = np.NaN
358-
358+
359359
temp.A[Kt > 0.6] = -5.743 + 21.77*(Kt[Kt > 0.6]) - 27.49*(Kt[Kt > 0.6] ** 2) + 11.56*(Kt[Kt > 0.6] ** 3)
360360
temp.B[Kt > 0.6] = 41.4 - 118.5*(Kt[Kt > 0.6]) + 66.05*(Kt[Kt > 0.6] ** 2) + 31.9*(Kt[Kt > 0.6] ** 3)
361361
temp.C[Kt > 0.6] = -47.01 + 184.2*(Kt[Kt > 0.6]) - 222.0 * Kt[Kt > 0.6] ** 2 + 73.81*(Kt[Kt > 0.6] ** 3)
362362
temp.A[Kt <= 0.6] = 0.512 - 1.56*(Kt[Kt <= 0.6]) + 2.286*(Kt[Kt <= 0.6] ** 2) - 2.222*(Kt[Kt <= 0.6] ** 3)
363363
temp.B[Kt <= 0.6] = 0.37 + 0.962*(Kt[Kt <= 0.6])
364364
temp.C[Kt <= 0.6] = -0.28 + 0.932*(Kt[Kt <= 0.6]) - 2.048*(Kt[Kt <= 0.6] ** 2)
365-
366-
#return to numeric after masking operations
367-
temp = temp.astype(float)
368365

369366
delKn = temp.A + temp.B * np.exp(temp.C*AM)
370367

@@ -374,8 +371,7 @@ def disc(GHI, zenith, times, pressure=101325):
374371
DNI = Kn * I0
375372

376373
DNI[zenith > 87] = np.NaN
377-
DNI[GHI < 1] = np.NaN
378-
DNI[DNI < 0] = np.NaN
374+
DNI[(GHI < 0) | (DNI < 0)] = 0
379375

380376
DFOut = pd.DataFrame({'DNI_gen_DISC':DNI})
381377
DFOut['Kt_gen_DISC'] = Kt
@@ -384,7 +380,7 @@ def disc(GHI, zenith, times, pressure=101325):
384380
return DFOut
385381

386382

387-
def dirint(ghi, zenith, times, pressure, use_delta_kt_prime=True,
383+
def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
388384
temp_dew=None):
389385
"""
390386
Determine DNI from GHI using the DIRINT modification
@@ -409,7 +405,7 @@ def dirint(ghi, zenith, times, pressure, use_delta_kt_prime=True,
409405
410406
times : DatetimeIndex
411407
412-
pressure : pd.Series
408+
pressure : float or pd.Series
413409
The site pressure in Pascal.
414410
Pressure may be measured or an average pressure may be
415411
calculated from site altitude.
@@ -537,6 +533,8 @@ def dirint(ghi, zenith, times, pressure, use_delta_kt_prime=True,
537533
delta_kt_prime_bin-1, w_bin-1]
538534

539535
dni = disc_out['DNI_gen_DISC'] * dirint_coeffs
536+
537+
dni.name = 'DNI_DIRINT'
540538

541539
return dni
542540

0 commit comments

Comments
 (0)