66
77from __future__ import division
88
9+ import logging
10+
911import datetime
1012from collections import OrderedDict
1113from functools import partial
1719from pvlib import solarposition
1820from pvlib import atmosphere
1921
20- # see References section of grounddiffuse function
22+ pvl_logger = logging .getLogger ('pvlib' )
23+
2124SURFACE_ALBEDOS = {'urban' : 0.18 ,
2225 'grass' : 0.20 ,
2326 'fresh grass' : 0.26 ,
3033 'aluminum' : 0.85 ,
3134 'copper' : 0.74 ,
3235 'fresh steel' : 0.35 ,
33- 'dirty steel' : 0.08 ,
34- 'sea' : 0.06 }
36+ 'dirty steel' : 0.08 }
3537
3638
3739def extraradiation (datetime_or_doy , solar_constant = 1366.1 , method = 'spencer' ,
@@ -343,6 +345,8 @@ def total_irrad(surface_tilt, surface_azimuth,
343345 'poa_sky_diffuse', 'poa_ground_diffuse'``.
344346 """
345347
348+ pvl_logger .debug ('planeofarray.total_irrad()' )
349+
346350 solar_zenith = apparent_zenith
347351 solar_azimuth = azimuth
348352
@@ -471,8 +475,8 @@ def grounddiffuse(surface_tilt, ghi, albedo=.25, surface_type=None):
471475
472476 surface_type: None or string, default None
473477 If not None, overrides albedo. String can be one of ``'urban',
474- 'grass', 'fresh grass', 'snow', 'fresh snow', 'asphalt', 'concrete',
475- 'aluminum', 'copper', 'fresh steel', 'dirty steel', 'sea '``.
478+ 'grass', 'fresh grass', 'snow', 'fresh snow', 'asphalt',
479+ 'concrete', 'aluminum', 'copper', 'fresh steel', 'dirty steel'``.
476480
477481 Returns
478482 -------
@@ -489,15 +493,17 @@ def grounddiffuse(surface_tilt, ghi, albedo=.25, surface_type=None):
489493 The calculation is the last term of equations 3, 4, 7, 8, 10, 11, and 12.
490494
491495 [2] albedos from:
492- http://files.pvsyst.com/help/ albedo.htm
496+ http://pvpmc.org/modeling-steps/incident-irradiance/plane-of-array-poa-irradiance/calculating-poa-irradiance/poa-ground-reflected/ albedo/
493497 and
494498 http://en.wikipedia.org/wiki/Albedo
495- and
496- https://doi.org/10.1175/1520-0469(1972)029<0959:AOTSS>2.0.CO;2
497499 '''
498500
501+ pvl_logger .debug ('diffuse_ground.get_diffuse_ground()' )
502+
499503 if surface_type is not None :
500504 albedo = SURFACE_ALBEDOS [surface_type ]
505+ pvl_logger .info ('surface_type=%s mapped to albedo=%s' ,
506+ surface_type , albedo )
501507
502508 diffuse_irrad = ghi * albedo * (1 - np .cos (np .radians (surface_tilt ))) * 0.5
503509
@@ -549,6 +555,8 @@ def isotropic(surface_tilt, dhi):
549555 heat collector. Trans. ASME 64, 91.
550556 '''
551557
558+ pvl_logger .debug ('diffuse_sky.isotropic()' )
559+
552560 sky_diffuse = dhi * (1 + tools .cosd (surface_tilt )) * 0.5
553561
554562 return sky_diffuse
@@ -620,6 +628,8 @@ def klucher(surface_tilt, surface_azimuth, dhi, ghi, solar_zenith,
620628 tilted surfaces. Solar Energy 23 (2), 111-114.
621629 '''
622630
631+ pvl_logger .debug ('diffuse_sky.klucher()' )
632+
623633 # zenith angle with respect to panel normal.
624634 cos_tt = aoi_projection (surface_tilt , surface_azimuth ,
625635 solar_zenith , solar_azimuth )
@@ -709,6 +719,8 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
709719 Ministry of Supply and Services, Canada.
710720 '''
711721
722+ pvl_logger .debug ('diffuse_sky.haydavies()' )
723+
712724 # if necessary, calculate ratio of titled and horizontal beam irradiance
713725 if projection_ratio is None :
714726 cos_tt = aoi_projection (surface_tilt , surface_azimuth ,
@@ -807,6 +819,8 @@ def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra,
807819 hourly tilted surface radiation models. Solar Energy 45(1), 9-17.
808820 '''
809821
822+ pvl_logger .debug ('diffuse_sky.reindl()' )
823+
810824 cos_tt = aoi_projection (surface_tilt , surface_azimuth ,
811825 solar_zenith , solar_azimuth )
812826
@@ -867,6 +881,8 @@ def king(surface_tilt, dhi, ghi, solar_zenith):
867881 The diffuse component of the solar radiation.
868882 '''
869883
884+ pvl_logger .debug ('diffuse_sky.king()' )
885+
870886 sky_diffuse = (dhi * ((1 + tools .cosd (surface_tilt ))) / 2 + ghi *
871887 ((0.012 * solar_zenith - 0.04 )) *
872888 ((1 - tools .cosd (surface_tilt ))) / 2 )
@@ -979,8 +995,7 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
979995 delta = dhi * airmass / dni_extra
980996
981997 # epsilon is the sky's "clearness"
982- with np .errstate (invalid = 'ignore' ):
983- eps = ((dhi + dni ) / dhi + kappa * (z ** 3 )) / (1 + kappa * (z ** 3 ))
998+ eps = ((dhi + dni ) / dhi + kappa * (z ** 3 )) / (1 + kappa * (z ** 3 ))
984999
9851000 # numpy indexing below will not work with a Series
9861001 if isinstance (eps , pd .Series ):
@@ -990,8 +1005,15 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
9901005 # rules. 1 = overcast ... 8 = clear (these names really only make
9911006 # sense for small zenith angles, but...) these values will
9921007 # eventually be used as indicies for coeffecient look ups
993- ebin = np .digitize (eps , (0. , 1.065 , 1.23 , 1.5 , 1.95 , 2.8 , 4.5 , 6.2 ))
994- ebin [np .isnan (eps )] = 0
1008+ ebin = np .zeros_like (eps , dtype = np .int8 )
1009+ ebin [eps < 1.065 ] = 1
1010+ ebin [(eps >= 1.065 ) & (eps < 1.23 )] = 2
1011+ ebin [(eps >= 1.23 ) & (eps < 1.5 )] = 3
1012+ ebin [(eps >= 1.5 ) & (eps < 1.95 )] = 4
1013+ ebin [(eps >= 1.95 ) & (eps < 2.8 )] = 5
1014+ ebin [(eps >= 2.8 ) & (eps < 4.5 )] = 6
1015+ ebin [(eps >= 4.5 ) & (eps < 6.2 )] = 7
1016+ ebin [eps >= 6.2 ] = 8
9951017
9961018 # correct for 0 indexing in coeffecient lookup
9971019 # later, ebin = -1 will yield nan coefficients
@@ -1311,7 +1333,7 @@ def dirindex(ghi, ghi_clearsky, dni_clearsky, zenith, times, pressure=101325.,
13111333 Determine DNI from GHI using the DIRINDEX model, which is a modification of
13121334 the DIRINT model with information from a clear sky model.
13131335
1314- DIRINDEX [1] improves upon the DIRINT model by taking into account
1336+ DIRINDEX [1] improves upon the DIRINT model by taking into account
13151337 turbidity when used with the Ineichen clear sky model results.
13161338
13171339 Parameters
@@ -1374,7 +1396,7 @@ def dirindex(ghi, ghi_clearsky, dni_clearsky, zenith, times, pressure=101325.,
13741396 use_delta_kt_prime = use_delta_kt_prime ,
13751397 temp_dew = temp_dew )
13761398
1377- dni_dirint_clearsky = dirint (ghi_clearsky , zenith , times ,
1399+ dni_dirint_clearsky = dirint (ghi_clearsky , zenith , times ,
13781400 pressure = pressure ,
13791401 use_delta_kt_prime = use_delta_kt_prime ,
13801402 temp_dew = temp_dew )
0 commit comments