def pvl_clearsky_haurwitz(ApparentZenith): ''' Determine clear sky GHI from Haurwitz model Implements the Haurwitz clear sky model for global horizontal irradiance (GHI) as presented in [1, 2]. A report on clear sky models found the Haurwitz model to have the best performance of models which require only zenith angle [3]. Parameters ---------- ApparentZenith : DataFrame The apparent (refraction corrected) sun zenith angle in degrees. Returns ------- ClearSkyGHI : DataFrame the modeled global horizonal irradiance in W/m^2 provided by the Haurwitz clear-sky model. Initial implementation of this algorithm by Matthew Reno. References ---------- [1] B. Haurwitz, "Insolation in Relation to Cloudiness and Cloud Density," Journal of Meteorology, vol. 2, pp. 154-166, 1945. [2] B. Haurwitz, "Insolation in Relation to Cloud Type," Journal of Meteorology, vol. 3, pp. 123-124, 1946. [3] M. Reno, C. Hansen, and J. Stein, "Global Horizontal Irradiance Clear Sky Models: Implementation and Analysis", Sandia National Laboratories, SAND2012-2389, 2012. See Also --------- pvl_maketimestruct pvl_makelocationstruct pvl_ephemeris pvl_spa pvl_ineichen ''' Vars = locals() Expect = {'ApparentZenith': ('x<=180', 'x>=0')} var = pvl_tools.Parse(Vars, Expect) ClearSkyGHI = 1098.0 * pvl_tools.cosd(ApparentZenith) * (np.exp( -0.059 / pvl_tools.cosd(ApparentZenith))) ClearSkyGHI[ClearSkyGHI < 0] = 0 return ClearSkyGHI
def pvl_clearsky_haurwitz(ApparentZenith): ''' Determine clear sky GHI from Haurwitz model Implements the Haurwitz clear sky model for global horizontal irradiance (GHI) as presented in [1, 2]. A report on clear sky models found the Haurwitz model to have the best performance of models which require only zenith angle [3]. Parameters ---------- ApparentZenith : DataFrame The apparent (refraction corrected) sun zenith angle in degrees. Returns ------- ClearSkyGHI : DataFrame the modeled global horizonal irradiance in W/m^2 provided by the Haurwitz clear-sky model. Initial implementation of this algorithm by Matthew Reno. References ---------- [1] B. Haurwitz, "Insolation in Relation to Cloudiness and Cloud Density," Journal of Meteorology, vol. 2, pp. 154-166, 1945. [2] B. Haurwitz, "Insolation in Relation to Cloud Type," Journal of Meteorology, vol. 3, pp. 123-124, 1946. [3] M. Reno, C. Hansen, and J. Stein, "Global Horizontal Irradiance Clear Sky Models: Implementation and Analysis", Sandia National Laboratories, SAND2012-2389, 2012. See Also --------- pvl_maketimestruct pvl_makelocationstruct pvl_ephemeris pvl_spa pvl_ineichen ''' Vars=locals() Expect={'ApparentZenith':('x<=180','x>=0')} var=pvl_tools.Parse(Vars,Expect) ClearSkyGHI=1098.0 * pvl_tools.cosd(ApparentZenith)*(np.exp(- 0.059 / pvl_tools.cosd(ApparentZenith))) ClearSkyGHI[ClearSkyGHI < 0]=0 return ClearSkyGHI
def pvl_kingdiffuse(SurfTilt, DHI, GHI, SunZen): ''' Determine diffuse irradiance from the sky on a tilted surface using the King model King's model determines the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface using the surface tilt angle, diffuse horizontal irradiance, global horizontal irradiance, and sun zenith angle. Note that this model is not well documented and has not been published in any fashion (as of January 2012). Parameters ---------- SurfTilt : float or DataFrame Surface tilt angles in decimal degrees. SurfTilt must be >=0 and <=180. The tilt angle is defined as degrees from horizontal (e.g. surface facing up = 0, surface facing horizon = 90) DHI : float or DataFrame diffuse horizontal irradiance in W/m^2. DHI must be >=0. GHI : float or DataFrame global horizontal irradiance in W/m^2. DHI must be >=0. SunZen : float or DataFrame apparent (refraction-corrected) zenith angles in decimal degrees. SunZen must be >=0 and <=180. Returns -------- SkyDiffuse : float or DataFrame the diffuse component of the solar radiation on an arbitrarily tilted surface as given by a model developed by David L. King at Sandia National Laboratories. See Also -------- pvl_ephemeris pvl_extraradiation pvl_isotropicsky pvl_haydavies1980 pvl_perez pvl_klucher1979 pvl_reindl1990 ''' Vars = locals() Expect = { 'SurfTilt': ('num', 'x>=0'), 'SunZen': ('x>=-180'), 'DHI': ('x>=0'), 'GHI': ('x>=0') } var = pvl_tools.Parse(Vars, Expect) SkyDiffuse = DHI * ((1 + pvl_tools.cosd(SurfTilt))) / 2 + GHI * ( (0.012 * SunZen - 0.04)) * ((1 - pvl_tools.cosd(SurfTilt))) / 2 return SkyDiffuse
def pvl_isotropicsky(SurfTilt, DHI): ''' Determine diffuse irradiance from the sky on a tilted surface using isotropic sky model Hottel and Woertz's model treats the sky as a uniform source of diffuse irradiance. Thus the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface can be found from the diffuse horizontal irradiance and the tilt angle of the surface. Parameters ---------- SurfTilt : float or DataFrame Surface tilt angles in decimal degrees. SurfTilt must be >=0 and <=180. The tilt angle is defined as degrees from horizontal (e.g. surface facing up = 0, surface facing horizon = 90) DHI : float or DataFrame Diffuse horizontal irradiance in W/m^2. DHI must be >=0. Returns ------- SkyDiffuse : float of DataFrame The diffuse component of the solar radiation on an arbitrarily tilted surface defined by the isotropic sky model as given in Loutzenhiser et. al (2007) equation 3. SkyDiffuse is the diffuse component ONLY and does not include the ground reflected irradiance or the irradiance due to the beam. SkyDiffuse is a column vector vector with a number of elements equal to the input vector(s). References ---------- [1] Loutzenhiser P.G. et. al. "Empirical validation of models to compute solar irradiance on inclined surfaces for building energy simulation" 2007, Solar Energy vol. 81. pp. 254-267 [2] Hottel, H.C., Woertz, B.B., 1942. Evaluation of flat-plate solar heat collector. Trans. ASME 64, 91. See also -------- pvl_reindl1990 pvl_haydavies1980 pvl_perez pvl_klucher1979 pvl_kingdiffuse ''' Vars = locals() Expect = {'SurfTilt': 'x <= 180 & x >= 0 ', 'DHI': 'x>=0'} var = pvl_tools.Parse(Vars, Expect) SkyDiffuse = DHI * (1 + pvl_tools.cosd(SurfTilt)) * 0.5 return SkyDiffuse
def pvl_isotropicsky(SurfTilt,DHI): ''' Determine diffuse irradiance from the sky on a tilted surface using isotropic sky model Hottel and Woertz's model treats the sky as a uniform source of diffuse irradiance. Thus the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface can be found from the diffuse horizontal irradiance and the tilt angle of the surface. Parameters ---------- SurfTilt : float or DataFrame Surface tilt angles in decimal degrees. SurfTilt must be >=0 and <=180. The tilt angle is defined as degrees from horizontal (e.g. surface facing up = 0, surface facing horizon = 90) DHI : float or DataFrame Diffuse horizontal irradiance in W/m^2. DHI must be >=0. Returns ------- SkyDiffuse : float of DataFrame The diffuse component of the solar radiation on an arbitrarily tilted surface defined by the isotropic sky model as given in Loutzenhiser et. al (2007) equation 3. SkyDiffuse is the diffuse component ONLY and does not include the ground reflected irradiance or the irradiance due to the beam. SkyDiffuse is a column vector vector with a number of elements equal to the input vector(s). References ---------- [1] Loutzenhiser P.G. et. al. "Empirical validation of models to compute solar irradiance on inclined surfaces for building energy simulation" 2007, Solar Energy vol. 81. pp. 254-267 [2] Hottel, H.C., Woertz, B.B., 1942. Evaluation of flat-plate solar heat collector. Trans. ASME 64, 91. See also -------- pvl_reindl1990 pvl_haydavies1980 pvl_perez pvl_klucher1979 pvl_kingdiffuse ''' Vars=locals() Expect={'SurfTilt':'x <= 180 & x >= 0 ', 'DHI':'x>=0' } var=pvl_tools.Parse(Vars,Expect) SkyDiffuse=DHI * (1 + pvl_tools.cosd(SurfTilt)) * 0.5 return SkyDiffuse
def pvl_clearsky_ineichen(Time, Location, LinkeTurbidity=-999): ''' Determine clear sky GHI, DNI, and DHI from Ineichen/Perez model Implements the Ineichen and Perez clear sky model for global horizontal irradiance (GHI), direct normal irradiance (DNI), and calculates the clear-sky diffuse horizontal (DHI) component as the difference between GHI and DNI*cos(zenith) as presented in [1, 2]. A report on clear sky models found the Ineichen/Perez model to have excellent performance with a minimal input data set [3]. Default values for Linke turbidity provided by SoDa [4, 5]. Parameters ---------- Time : Dataframe.index A timezone aware pandas dataframe index. Location : dict latitude vector or scalar latitude in decimal degrees (positive is northern hemisphere) longitude vector or scalar longitude in decimal degrees (positive is east of prime meridian) altitude an optional component of the Location struct, not used in the ephemeris code directly, but it may be used to calculate standard site pressure (see pvl_alt2pres function) TZ Time Zone offset from UTC Other Parameters ---------------- LinkeTurbidityInput : Optional, float or DataFrame An optional input to provide your own Linke turbidity. If this input is omitted, the default Linke turbidity maps will be used. LinkeTurbidityInput may be a float or dataframe of Linke turbidities. If dataframe is provided, the same turbidity will be used for all time/location sets. If a dataframe is provided, it must be of the same size as any time/location dataframes and each element of the dataframe corresponds to any time and location elements. Returns ------- ClearSkyGHI : Dataframe the modeled global horizonal irradiance in W/m^2 provided by the Ineichen clear-sky model. ClearSkyDNI : Dataframe the modeled direct normal irradiance in W/m^2 provided by the Ineichen clear-sky model. ClearSkyDHI : Dataframe the calculated diffuse horizonal irradiance in W/m^2 provided by the Ineichen clear-sky model. Notes ----- This implementation of the Ineichen model requires a number of other PV_LIB functions including pvl_ephemeris, pvl_date2doy, pvl_extraradiation, pvl_absoluteairmass, pvl_relativeairmass, and pvl_alt2pres. It also requires the file "LinkeTurbidities.mat" to be in the working directory. If you are using pvl_ineichen in a loop, it may be faster to load LinkeTurbidities.mat outside of the loop and feed it into pvl_ineichen as a variable, rather than having pvl_ineichen open the file each time it is called (or utilize column vectors of time/location instead of a loop). Initial implementation of this algorithm by Matthew Reno. References ---------- [1] P. Ineichen and R. Perez, "A New airmass independent formulation for the Linke turbidity coefficient", Solar Energy, vol 73, pp. 151-157, 2002. [2] R. Perez et. al., "A New Operational Model for Satellite-Derived Irradiances: Description and Validation", Solar Energy, vol 73, pp. 307-317, 2002. [3] M. Reno, C. Hansen, and J. Stein, "Global Horizontal Irradiance Clear Sky Models: Implementation and Analysis", Sandia National Laboratories, SAND2012-2389, 2012. [4] http://www.soda-is.com/eng/services/climat_free_eng.php#c5 (obtained July 17, 2012). [5] J. Remund, et. al., "Worldwide Linke Turbidity Information", Proc. ISES Solar World Congress, June 2003. Goteborg, Sweden. See Also -------- pvl_maketimestruct pvl_makelocationstruct pvl_ephemeris pvl_haurwitz ''' Vars = locals() Expect = {'Time': (''), 'Location': (''), 'LinkeTurbidity': ('optional')} var = pvl_tools.Parse(Vars, Expect) I0 = pvl_extraradiation.pvl_extraradiation(var.Time.dayofyear) __, __, ApparentSunElevation, __, __ = pvl_ephemeris.pvl_ephemeris( var.Time, var.Location, pvl_alt2pres.pvl_alt2pres(var.Location['altitude'])) # nargout=4 ApparentZenith = 90 - ApparentSunElevation ApparentZenith[ApparentZenith >= 90] = 90 if LinkeTurbidity == -999: # The .mat file 'LinkeTurbidities.mat' contains a single 2160 x 4320 x 12 # matrix of type uint8 called 'LinkeTurbidity'. The rows represent global # latitudes from 90 to -90 degrees; the columns represent global longitudes # from -180 to 180; and the depth (third dimension) represents months of # the year from January (1) to December (12). To determine the Linke # turbidity for a position on the Earth's surface for a given month do the # following: LT = LinkeTurbidity(LatitudeIndex, LongitudeIndex, month). Note that the numbers within the matrix are 20 * Linke # Turbidity, so divide the number from the file by 20 to get the # turbidity. mat = scipy.io.loadmat('LinkeTurbidities.mat') LinkeTurbidity = mat['LinkeTurbidity'] LatitudeIndex = np.round_( LinearlyScale(Location['latitude'], 90, -90, 1, 2160)) LongitudeIndex = np.round_( LinearlyScale(Location['longitude'], -180, 180, 1, 4320)) g = LinkeTurbidity[LatitudeIndex][LongitudeIndex] ApplyMonth = lambda x: g[x[0] - 1] LT = pd.DataFrame(Time.month) LT.index = Time LT = LT.apply(ApplyMonth, axis=1) TL = LT / float(20) else: TL = var.LinkeTurbidity # Get the absolute airmass assuming standard local pressure (per # pvl_alt2pres) using Kasten and Young's 1989 formula for airmass. AMabsolute = pvl_absoluteairmass.pvl_absoluteairmass( AMrelative=pvl_relativeairmass.pvl_relativeairmass( ApparentZenith, model='kastenyoung1989'), Pressure=pvl_alt2pres.pvl_alt2pres(var.Location['altitude'])) fh1 = np.exp(var.Location['altitude'] * ((-1 / 8000))) fh2 = np.exp(var.Location['altitude'] * ((-1 / 1250))) cg1 = (5.09e-05 * (var.Location['altitude']) + 0.868) cg2 = 3.92e-05 * (var.Location['altitude']) + 0.0387 # Dan's note on the TL correction: By my reading of the publication on # pages 151-157, Ineichen and Perez introduce (among other things) three # things. 1) Beam model in eqn. 8, 2) new turbidity factor in eqn 9 and # appendix A, and 3) Global horizontal model in eqn. 11. They do NOT appear # to use the new turbidity factor (item 2 above) in either the beam or GHI # models. The phrasing of appendix A seems as if there are two separate # corrections, the first correction is used to correct the beam/GHI models, # and the second correction is used to correct the revised turibidity # factor. In my estimation, there is no need to correct the turbidity # factor used in the beam/GHI models. # Create the corrected TL for TL < 2 # TLcorr = TL; # TLcorr(TL < 2) = TLcorr(TL < 2) - 0.25 .* (2-TLcorr(TL < 2)) .^ (0.5); # This equation is found in Solar Energy 73, pg 311. It is slightly # different than the equation given in Solar Energy 73, pg 156. We used the # equation from pg 311 because of the existence of known typos in the pg 156 # publication (notably the fh2-(TL-1) should be fh2 * (TL-1)). ClearSkyGHI = cg1 * (I0) * (pvl_tools.cosd(ApparentZenith)) * (np.exp( -cg2 * (AMabsolute) * ((fh1 + fh2 * ((TL - 1)))))) * (np.exp(0.01 * ((AMabsolute)**(1.8)))) ClearSkyGHI[ClearSkyGHI < 0] = 0 b = 0.664 + 0.163 / fh1 BncI = b * (I0) * (np.exp(-0.09 * (AMabsolute) * ((TL - 1)))) ClearSkyDNI = np.min( BncI, ClearSkyGHI * ((1 - (0.1 - 0.2 * (np.exp(-TL))) / (0.1 + 0.882 / fh1))) / pvl_tools.cosd(ApparentZenith)) #ClearSkyDNI=ClearSkyGHI*((1 - (0.1 - 0.2*(np.exp(- TL))) / (0.1 + 0.882 / fh1))) / pvl_tools.cosd(ApparentZenith) ClearSkyDHI = ClearSkyGHI - ClearSkyDNI * (pvl_tools.cosd(ApparentZenith)) return ClearSkyGHI, ClearSkyDNI, ClearSkyDHI, BncI
def pvl_kingdiffuse(SurfTilt,DHI,GHI,SunZen): ''' Determine diffuse irradiance from the sky on a tilted surface using the King model King's model determines the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface using the surface tilt angle, diffuse horizontal irradiance, global horizontal irradiance, and sun zenith angle. Note that this model is not well documented and has not been published in any fashion (as of January 2012). Parameters ---------- SurfTilt : float or DataFrame Surface tilt angles in decimal degrees. SurfTilt must be >=0 and <=180. The tilt angle is defined as degrees from horizontal (e.g. surface facing up = 0, surface facing horizon = 90) DHI : float or DataFrame diffuse horizontal irradiance in W/m^2. DHI must be >=0. GHI : float or DataFrame global horizontal irradiance in W/m^2. DHI must be >=0. SunZen : float or DataFrame apparent (refraction-corrected) zenith angles in decimal degrees. SunZen must be >=0 and <=180. Returns -------- SkyDiffuse : float or DataFrame the diffuse component of the solar radiation on an arbitrarily tilted surface as given by a model developed by David L. King at Sandia National Laboratories. See Also -------- pvl_ephemeris pvl_extraradiation pvl_isotropicsky pvl_haydavies1980 pvl_perez pvl_klucher1979 pvl_reindl1990 ''' Vars=locals() Expect={'SurfTilt':('num','x>=0'), 'SunZen':('x>=-180'), 'DHI':('x>=0'), 'GHI':('x>=0') } var=pvl_tools.Parse(Vars,Expect) SkyDiffuse=DHI*((1 + pvl_tools.cosd(SurfTilt))) / 2 + GHI*((0.012 * SunZen - 0.04))*((1 - pvl_tools.cosd(SurfTilt))) / 2 return SkyDiffuse
def pvl_klucher1979(SurfTilt, SurfAz, DHI, GHI, SunZen, SunAz): ''' Determine diffuse irradiance from the sky on a tilted surface using Klucher's 1979 model Klucher's 1979 model determines the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface using the surface tilt angle, surface azimuth angle, diffuse horizontal irradiance, direct normal irradiance, global horizontal irradiance, extraterrestrial irradiance, sun zenith angle, and sun azimuth angle. Parameters ---------- SurfTilt : float or DataFrame Surface tilt angles in decimal degrees. SurfTilt must be >=0 and <=180. The tilt angle is defined as degrees from horizontal (e.g. surface facing up = 0, surface facing horizon = 90) SurfAz : float or DataFrame Surface azimuth angles in decimal degrees. SurfAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, South=180 East = 90, West = 270). DHI : float or DataFrame diffuse horizontal irradiance in W/m^2. DHI must be >=0. GHI : float or DataFrame Global irradiance in W/m^2. DNI must be >=0. SunZen : float or DataFrame apparent (refraction-corrected) zenith angles in decimal degrees. SunZen must be >=0 and <=180. SunAz : float or DataFrame Sun azimuth angles in decimal degrees. SunAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, East = 90, West = 270). Returns ------- SkyDiffuse : float or DataFrame the diffuse component of the solar radiation on an arbitrarily tilted surface defined by the Klucher model as given in Loutzenhiser et. al (2007) equation 4. SkyDiffuse is the diffuse component ONLY and does not include the ground reflected irradiance or the irradiance due to the beam. SkyDiffuse is a column vector vector with a number of elements equal to the input vector(s). References ---------- [1] Loutzenhiser P.G. et. al. "Empirical validation of models to compute solar irradiance on inclined surfaces for building energy simulation" 2007, Solar Energy vol. 81. pp. 254-267 [2] Klucher, T.M., 1979. Evaluation of models to predict insolation on tilted surfaces. Solar Energy 23 (2), 111-114. See also -------- pvl_ephemeris pvl_extraradiation pvl_isotropicsky pvl_haydavies1980 pvl_perez pvl_reindl1990 pvl_kingdiffuse ''' Vars = locals() Expect = { 'SurfTilt': ('num', 'x>=0'), 'SurfAz': ('x>=-180'), 'DHI': ('x>=0'), 'GHI': ('x>=0'), 'SunZen': ('x>=0'), 'SunAz': ('x>=-180') } var = pvl_tools.Parse(Vars, Expect) GHI[GHI < DHI] = DHI GHI[GHI < 1e-06] = 1e-06 COSTT = pvl_tools.cosd(SurfTilt) * pvl_tools.cosd(SunZen) + pvl_tools.sind( SurfTilt) * pvl_tools.sind(SunZen) * pvl_tools.cosd(SunAz - SurfAz) F = 1 - ((DHI / GHI)**2) SkyDiffuse = DHI * ((0.5 * ((1 + pvl_tools.cosd(SurfTilt))))) * ((1 + F * ( ((pvl_tools.sind(SurfTilt / 2))**3)))) * ((1 + F * (((COSTT)**2)) * (( (pvl_tools.sind(SunZen))**3)))) return SkyDiffuse
def pvl_haydavies1980(SurfTilt,SurfAz,DHI,DNI,HExtra,SunZen,SunAz): ''' Determine diffuse irradiance from the sky on a tilted surface using Hay & Davies' 1980 model Hay and Davies' 1980 model determines the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface using the surface tilt angle, surface azimuth angle, diffuse horizontal irradiance, direct normal irradiance, extraterrestrial irradiance, sun zenith angle, and sun azimuth angle. Parameters ---------- SurfTilt : float or DataFrame Surface tilt angles in decimal degrees. SurfTilt must be >=0 and <=180. The tilt angle is defined as degrees from horizontal (e.g. surface facing up = 0, surface facing horizon = 90) SurfAz : float or DataFrame Surface azimuth angles in decimal degrees. SurfAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, South=180 East = 90, West = 270). DHI : float or DataFrame diffuse horizontal irradiance in W/m^2. DHI must be >=0. DNI : float or DataFrame direct normal irradiance in W/m^2. DNI must be >=0. HExtra : float or DataFrame extraterrestrial normal irradiance in W/m^2. HExtra must be >=0. SunZen : float or DataFrame apparent (refraction-corrected) zenith angles in decimal degrees. SunZen must be >=0 and <=180. SunAz : float or DataFrame Sun azimuth angles in decimal degrees. SunAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, East = 90, West = 270). Returns -------- SkyDiffuse : float or DataFrame the diffuse component of the solar radiation on an arbitrarily tilted surface defined by the Perez model as given in reference [3]. SkyDiffuse is the diffuse component ONLY and does not include the ground reflected irradiance or the irradiance due to the beam. References ----------- [1] Loutzenhiser P.G. et. al. "Empirical validation of models to compute solar irradiance on inclined surfaces for building energy simulation" 2007, Solar Energy vol. 81. pp. 254-267 [2] Hay, J.E., Davies, J.A., 1980. Calculations of the solar radiation incident on an inclined surface. In: Hay, J.E., Won, T.K. (Eds.), Proc. of First Canadian Solar Radiation Data Workshop, 59. Ministry of Supply and Services, Canada. See Also -------- pvl_ephemeris pvl_extraradiation pvl_isotropicsky pvl_reindl1990 pvl_perez pvl_klucher1979 pvl_kingdiffuse pvl_spa ''' Vars=locals() Expect={'SurfTilt':('num','x>=0'), 'SurfAz':('x>=-180'), 'DHI':('x>=0'), 'DNI':('x>=0'), 'HExtra':('x>=0'), 'SunZen':('x>=0'), 'SunAz':('x>=-180'), } var=pvl_tools.Parse(Vars,Expect) COSTT=pvl_tools.cosd(SurfTilt)*pvl_tools.cosd(SunZen) + pvl_tools.sind(SurfTilt)*pvl_tools.sind(SunZen)*pvl_tools.cosd(SunAz - SurfAz) RB=np.max(COSTT,0) / np.max(pvl_tools.cosd(SunZen),0.01745) AI=DNI / HExtra SkyDiffuse=DHI*((AI*(RB) + (1 - AI)*(0.5)*((1 + pvl_tools.cosd(SurfTilt))))) return SkyDiffuse
def pvl_klucher1979(SurfTilt,SurfAz,DHI,GHI,SunZen,SunAz): ''' Determine diffuse irradiance from the sky on a tilted surface using Klucher's 1979 model Klucher's 1979 model determines the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface using the surface tilt angle, surface azimuth angle, diffuse horizontal irradiance, direct normal irradiance, global horizontal irradiance, extraterrestrial irradiance, sun zenith angle, and sun azimuth angle. Parameters ---------- SurfTilt : float or DataFrame Surface tilt angles in decimal degrees. SurfTilt must be >=0 and <=180. The tilt angle is defined as degrees from horizontal (e.g. surface facing up = 0, surface facing horizon = 90) SurfAz : float or DataFrame Surface azimuth angles in decimal degrees. SurfAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, South=180 East = 90, West = 270). DHI : float or DataFrame diffuse horizontal irradiance in W/m^2. DHI must be >=0. GHI : float or DataFrame Global irradiance in W/m^2. DNI must be >=0. SunZen : float or DataFrame apparent (refraction-corrected) zenith angles in decimal degrees. SunZen must be >=0 and <=180. SunAz : float or DataFrame Sun azimuth angles in decimal degrees. SunAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, East = 90, West = 270). Returns ------- SkyDiffuse : float or DataFrame the diffuse component of the solar radiation on an arbitrarily tilted surface defined by the Klucher model as given in Loutzenhiser et. al (2007) equation 4. SkyDiffuse is the diffuse component ONLY and does not include the ground reflected irradiance or the irradiance due to the beam. SkyDiffuse is a column vector vector with a number of elements equal to the input vector(s). References ---------- [1] Loutzenhiser P.G. et. al. "Empirical validation of models to compute solar irradiance on inclined surfaces for building energy simulation" 2007, Solar Energy vol. 81. pp. 254-267 [2] Klucher, T.M., 1979. Evaluation of models to predict insolation on tilted surfaces. Solar Energy 23 (2), 111-114. See also -------- pvl_ephemeris pvl_extraradiation pvl_isotropicsky pvl_haydavies1980 pvl_perez pvl_reindl1990 pvl_kingdiffuse ''' Vars=locals() Expect={'SurfTilt':('num','x>=0'), 'SurfAz':('x>=-180'), 'DHI':('x>=0'), 'GHI':('x>=0'), 'SunZen':('x>=0'), 'SunAz':('x>=-180') } var=pvl_tools.Parse(Vars,Expect) GHI[GHI < DHI]=DHI GHI[GHI < 1e-06]=1e-06 COSTT=pvl_tools.cosd(SurfTilt)*pvl_tools.cosd(SunZen) + pvl_tools.sind(SurfTilt)*pvl_tools.sind(SunZen)*pvl_tools.cosd(SunAz - SurfAz) F=1 - ((DHI / GHI) ** 2) SkyDiffuse=DHI*((0.5*((1 + pvl_tools.cosd(SurfTilt)))))*((1 + F*(((pvl_tools.sind(SurfTilt / 2)) ** 3))))*((1 + F*(((COSTT) ** 2))*(((pvl_tools.sind(SunZen)) ** 3)))) return SkyDiffuse
def pvl_clearsky_ineichen(Time,Location,LinkeTurbidity=-999): ''' Determine clear sky GHI, DNI, and DHI from Ineichen/Perez model Implements the Ineichen and Perez clear sky model for global horizontal irradiance (GHI), direct normal irradiance (DNI), and calculates the clear-sky diffuse horizontal (DHI) component as the difference between GHI and DNI*cos(zenith) as presented in [1, 2]. A report on clear sky models found the Ineichen/Perez model to have excellent performance with a minimal input data set [3]. Default values for Linke turbidity provided by SoDa [4, 5]. Parameters ---------- Time : Dataframe.index A timezone aware pandas dataframe index. Location : dict latitude vector or scalar latitude in decimal degrees (positive is northern hemisphere) longitude vector or scalar longitude in decimal degrees (positive is east of prime meridian) altitude an optional component of the Location struct, not used in the ephemeris code directly, but it may be used to calculate standard site pressure (see pvl_alt2pres function) TZ Time Zone offset from UTC Other Parameters ---------------- LinkeTurbidityInput : Optional, float or DataFrame An optional input to provide your own Linke turbidity. If this input is omitted, the default Linke turbidity maps will be used. LinkeTurbidityInput may be a float or dataframe of Linke turbidities. If dataframe is provided, the same turbidity will be used for all time/location sets. If a dataframe is provided, it must be of the same size as any time/location dataframes and each element of the dataframe corresponds to any time and location elements. Returns ------- ClearSkyGHI : Dataframe the modeled global horizonal irradiance in W/m^2 provided by the Ineichen clear-sky model. ClearSkyDNI : Dataframe the modeled direct normal irradiance in W/m^2 provided by the Ineichen clear-sky model. ClearSkyDHI : Dataframe the calculated diffuse horizonal irradiance in W/m^2 provided by the Ineichen clear-sky model. Notes ----- This implementation of the Ineichen model requires a number of other PV_LIB functions including pvl_ephemeris, pvl_date2doy, pvl_extraradiation, pvl_absoluteairmass, pvl_relativeairmass, and pvl_alt2pres. It also requires the file "LinkeTurbidities.mat" to be in the working directory. If you are using pvl_ineichen in a loop, it may be faster to load LinkeTurbidities.mat outside of the loop and feed it into pvl_ineichen as a variable, rather than having pvl_ineichen open the file each time it is called (or utilize column vectors of time/location instead of a loop). Initial implementation of this algorithm by Matthew Reno. References ---------- [1] P. Ineichen and R. Perez, "A New airmass independent formulation for the Linke turbidity coefficient", Solar Energy, vol 73, pp. 151-157, 2002. [2] R. Perez et. al., "A New Operational Model for Satellite-Derived Irradiances: Description and Validation", Solar Energy, vol 73, pp. 307-317, 2002. [3] M. Reno, C. Hansen, and J. Stein, "Global Horizontal Irradiance Clear Sky Models: Implementation and Analysis", Sandia National Laboratories, SAND2012-2389, 2012. [4] http://www.soda-is.com/eng/services/climat_free_eng.php#c5 (obtained July 17, 2012). [5] J. Remund, et. al., "Worldwide Linke Turbidity Information", Proc. ISES Solar World Congress, June 2003. Goteborg, Sweden. See Also -------- pvl_maketimestruct pvl_makelocationstruct pvl_ephemeris pvl_haurwitz ''' Vars=locals() Expect={'Time':(''), 'Location':(''), 'LinkeTurbidity':('optional')} var=pvl_tools.Parse(Vars,Expect) I0=pvl_extraradiation.pvl_extraradiation(var.Time.dayofyear) __,__,ApparentSunElevation,__,__=pvl_ephemeris.pvl_ephemeris(var.Time,var.Location,pvl_alt2pres.pvl_alt2pres(var.Location['altitude'])) # nargout=4 ApparentZenith=90 - ApparentSunElevation ApparentZenith[ApparentZenith>=90]=90 if LinkeTurbidity==-999: # The .mat file 'LinkeTurbidities.mat' contains a single 2160 x 4320 x 12 # matrix of type uint8 called 'LinkeTurbidity'. The rows represent global # latitudes from 90 to -90 degrees; the columns represent global longitudes # from -180 to 180; and the depth (third dimension) represents months of # the year from January (1) to December (12). To determine the Linke # turbidity for a position on the Earth's surface for a given month do the # following: LT = LinkeTurbidity(LatitudeIndex, LongitudeIndex, month). Note that the numbers within the matrix are 20 * Linke # Turbidity, so divide the number from the file by 20 to get the # turbidity. mat = scipy.io.loadmat('LinkeTurbidities.mat') LinkeTurbidity=mat['LinkeTurbidity'] LatitudeIndex=np.round_(LinearlyScale(Location['latitude'],90,- 90,1,2160)) LongitudeIndex=np.round_(LinearlyScale(Location['longitude'],- 180,180,1,4320)) g=LinkeTurbidity[LatitudeIndex][LongitudeIndex] ApplyMonth=lambda x:g[x[0]-1] LT=pd.DataFrame(Time.month) LT.index=Time LT=LT.apply(ApplyMonth,axis=1) TL=LT / float(20) else: TL=var.LinkeTurbidity # Get the absolute airmass assuming standard local pressure (per # pvl_alt2pres) using Kasten and Young's 1989 formula for airmass. AMabsolute=pvl_absoluteairmass.pvl_absoluteairmass(AMrelative=pvl_relativeairmass.pvl_relativeairmass(ApparentZenith,model='kastenyoung1989'),Pressure=pvl_alt2pres.pvl_alt2pres(var.Location['altitude'])) fh1=np.exp(var.Location['altitude']*((- 1 / 8000))) fh2=np.exp(var.Location['altitude']*((- 1 / 1250))) cg1=(5.09e-05*(var.Location['altitude']) + 0.868) cg2=3.92e-05*(var.Location['altitude']) + 0.0387 # Dan's note on the TL correction: By my reading of the publication on # pages 151-157, Ineichen and Perez introduce (among other things) three # things. 1) Beam model in eqn. 8, 2) new turbidity factor in eqn 9 and # appendix A, and 3) Global horizontal model in eqn. 11. They do NOT appear # to use the new turbidity factor (item 2 above) in either the beam or GHI # models. The phrasing of appendix A seems as if there are two separate # corrections, the first correction is used to correct the beam/GHI models, # and the second correction is used to correct the revised turibidity # factor. In my estimation, there is no need to correct the turbidity # factor used in the beam/GHI models. # Create the corrected TL for TL < 2 # TLcorr = TL; # TLcorr(TL < 2) = TLcorr(TL < 2) - 0.25 .* (2-TLcorr(TL < 2)) .^ (0.5); # This equation is found in Solar Energy 73, pg 311. It is slightly # different than the equation given in Solar Energy 73, pg 156. We used the # equation from pg 311 because of the existence of known typos in the pg 156 # publication (notably the fh2-(TL-1) should be fh2 * (TL-1)). ClearSkyGHI=cg1*(I0)*(pvl_tools.cosd(ApparentZenith))*(np.exp(- cg2*(AMabsolute)*((fh1 + fh2*((TL - 1))))))*(np.exp(0.01*((AMabsolute) ** (1.8)))) ClearSkyGHI[ClearSkyGHI < 0]=0 b=0.664 + 0.163 / fh1 BncI=b*(I0)*(np.exp(- 0.09*(AMabsolute)*((TL - 1)))) ClearSkyDNI=np.min(BncI,ClearSkyGHI*((1 - (0.1 - 0.2*(np.exp(- TL))) / (0.1 + 0.882 / fh1))) / pvl_tools.cosd(ApparentZenith)) #ClearSkyDNI=ClearSkyGHI*((1 - (0.1 - 0.2*(np.exp(- TL))) / (0.1 + 0.882 / fh1))) / pvl_tools.cosd(ApparentZenith) ClearSkyDHI=ClearSkyGHI - ClearSkyDNI*(pvl_tools.cosd(ApparentZenith)) return ClearSkyGHI,ClearSkyDNI,ClearSkyDHI,BncI
def pvl_perez(SurfTilt, SurfAz, DHI, DNI, HExtra, SunZen, SunAz, AM,modelt='allsitescomposite1990'): ''' Determine diffuse irradiance from the sky on a tilted surface using one of the Perez models Perez models determine the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface using the surface tilt angle, surface azimuth angle, diffuse horizontal irradiance, direct normal irradiance, extraterrestrial irradiance, sun zenith angle, sun azimuth angle, and relative (not pressure-corrected) airmass. Optionally a selector may be used to use any of Perez's model coefficient sets. Parameters ---------- SurfTilt : float or DataFrame Surface tilt angles in decimal degrees. SurfTilt must be >=0 and <=180. The tilt angle is defined as degrees from horizontal (e.g. surface facing up = 0, surface facing horizon = 90) SurfAz : float or DataFrame Surface azimuth angles in decimal degrees. SurfAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, South=180 East = 90, West = 270). DHI : float or DataFrame diffuse horizontal irradiance in W/m^2. DHI must be >=0. DNI : float or DataFrame direct normal irradiance in W/m^2. DNI must be >=0. HExtra : float or DataFrame extraterrestrial normal irradiance in W/m^2. HExtra must be >=0. SunZen : float or DataFrame apparent (refraction-corrected) zenith angles in decimal degrees. SunZen must be >=0 and <=180. SunAz : float or DataFrame Sun azimuth angles in decimal degrees. SunAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, East = 90, West = 270). AM : float or DataFrame relative (not pressure-corrected) airmass values. If AM is a DataFrame it must be of the same size as all other DataFrame inputs. AM must be >=0 (careful using the 1/sec(z) model of AM generation) Other Parameters ---------------- model : string (optional, default='allsitescomposite1990') a character string which selects the desired set of Perez coefficients. If model is not provided as an input, the default, '1990' will be used. All possible model selections are: * '1990' * 'allsitescomposite1990' (same as '1990') * 'allsitescomposite1988' * 'sandiacomposite1988' * 'usacomposite1988' * 'france1988' * 'phoenix1988' * 'elmonte1988' * 'osage1988' * 'albuquerque1988' * 'capecanaveral1988' * 'albany1988' Returns -------- SkyDiffuse : float or DataFrame the diffuse component of the solar radiation on an arbitrarily tilted surface defined by the Perez model as given in reference [3]. SkyDiffuse is the diffuse component ONLY and does not include the ground reflected irradiance or the irradiance due to the beam. References ---------- [1] Loutzenhiser P.G. et. al. "Empirical validation of models to compute solar irradiance on inclined surfaces for building energy simulation" 2007, Solar Energy vol. 81. pp. 254-267 [2] Perez, R., Seals, R., Ineichen, P., Stewart, R., Menicucci, D., 1987. A new simplified version of the Perez diffuse irradiance model for tilted surfaces. Solar Energy 39(3), 221-232. [3] Perez, R., Ineichen, P., Seals, R., Michalsky, J., Stewart, R., 1990. Modeling daylight availability and irradiance components from direct and global irradiance. Solar Energy 44 (5), 271-289. [4] Perez, R. et. al 1988. "The Development and Verification of the Perez Diffuse Radiation Model". SAND88-7030 See also -------- pvl_ephemeris pvl_extraradiation pvl_isotropicsky pvl_haydavies1980 pvl_reindl1990 pvl_klucher1979 pvl_kingdiffuse pvl_relativeairmass ''' Vars=locals() Expect={'SurfTilt':('num','x>=0'), 'SurfAz':('x>=-180'), 'DHI':('x>=0'), 'DNI':('x>=0'), 'HExtra':('x>=0'), 'SunZen':('x>=0'), 'SunAz':('x>=-180'), 'AM':('x>=0'), 'modelt': ('default','default=allsitescomposite1990')} var=pvl_tools.Parse(Vars,Expect) kappa = 1.041 #for SunZen in radians z = var.SunZen*np.pi/180# # convert to radians Dhfilter = var.DHI > 0 e = ((var.DHI[Dhfilter] + var.DNI[Dhfilter])/var.DHI[Dhfilter]+kappa*z[Dhfilter]**3)/(1+kappa*z[Dhfilter]**3).reindex_like(var.SunZen) ebin = pd.Series(np.zeros(var.DHI.shape[0]),index=e.index) # Select which bin e falls into ebin[(e<1.065)]= 1 ebin[(e>=1.065) & (e<1.23)]= 2 ebin[(e>=1.23) & (e<1.5)]= 3 ebin[(e>=1.5) & (e<1.95)]= 4 ebin[(e>=1.95) & (e<2.8)]= 5 ebin[(e>=2.8) & (e<4.5)]= 6 ebin[(e>=4.5) & (e<6.2)]= 7 ebin[e>=6.2] = 8 ebinfilter=ebin>0 ebin=ebin-1 #correct for 0 indexing ebin[ebinfilter==False]=np.NaN ebin=ebin.dropna().astype(int) # This is added because in cases where the sun is below the horizon # (var.SunZen > 90) but there is still diffuse horizontal light (var.DHI>0), it is # possible that the airmass (var.AM) could be NaN, which messes up later # calculations. Instead, if the sun is down, and there is still var.DHI, we set # the airmass to the airmass value on the horizon (approximately 37-38). #var.AM(var.SunZen >=90 & var.DHI >0) = 37; var.HExtra[var.HExtra==0]=.00000001 #very hacky, fix this delt = var.DHI*var.AM/var.HExtra # # The various possible sets of Perez coefficients are contained # in a subfunction to clean up the code. F1c,F2c = GetPerezCoefficients(var.modelt) F1= F1c[ebin,0] + F1c[ebin,1]*delt[ebinfilter] + F1c[ebin,2]*z[ebinfilter] F1[F1<0]=0; F1=F1.astype(float) F2= F2c[ebin,0] + F2c[ebin,1]*delt[ebinfilter] + F2c[ebin,2]*z[ebinfilter] F2[F2<0]=0 F2=F2.astype(float) A = pvl_tools.cosd(var.SurfTilt)*pvl_tools.cosd(var.SunZen) + pvl_tools.sind(var.SurfTilt)*pvl_tools.sind(var.SunZen)*pvl_tools.cosd(var.SunAz-var.SurfAz); #removed +180 from azimuth modifier: Rob Andrews October 19th 2012 A[A < 0] = 0 B = pvl_tools.cosd(var.SunZen); B[B < pvl_tools.cosd(85)] = pvl_tools.cosd(85) #Calculate Diffuse POA from sky dome #SkyDiffuse = pd.Series(np.zeros(var.DHI.shape[0]),index=data.index) SkyDiffuse = var.DHI[ebinfilter]*( 0.5* (1-F1[ebinfilter])*(1+pvl_tools.cosd(var.SurfTilt))+F1[ebinfilter] * A[ebinfilter]/ B[ebinfilter] + F2[ebinfilter]* pvl_tools.sind(var.SurfTilt)) SkyDiffuse[SkyDiffuse <= 0]= 0 return pd.DataFrame({'In_Plane_SkyDiffuse':SkyDiffuse})
def pvl_reindl1990(SurfTilt, SurfAz, DHI, DNI, GHI, HExtra, SunZen, SunAz): ''' Determine diffuse irradiance from the sky on a tilted surface using Reindl's 1990 model Reindl's 1990 model determines the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface using the surface tilt angle, surface azimuth angle, diffuse horizontal irradiance, direct normal irradiance, global horizontal irradiance, extraterrestrial irradiance, sun zenith angle, and sun azimuth angle. Parameters ---------- SurfTilt : DataFrame Surface tilt angles in decimal degrees. SurfTilt must be >=0 and <=180. The tilt angle is defined as degrees from horizontal (e.g. surface facing up = 0, surface facing horizon = 90) SurfAz : DataFrame Surface azimuth angles in decimal degrees. SurfAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, South=180 East = 90, West = 270). DHI : DataFrame diffuse horizontal irradiance in W/m^2. DHI must be >=0. DNI : DataFrame direct normal irradiance in W/m^2. DNI must be >=0. GHI: DataFrame Global irradiance in W/m^2. GHI must be >=0. HExtra : DataFrame extraterrestrial normal irradiance in W/m^2. HExtra must be >=0. SunZen : DataFrame apparent (refraction-corrected) zenith angles in decimal degrees. SunZen must be >=0 and <=180. SunAz : DataFrame Sun azimuth angles in decimal degrees. SunAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, East = 90, West = 270). Returns ------- SkyDiffuse : DataFrame the diffuse component of the solar radiation on an arbitrarily tilted surface defined by the Reindl model as given in Loutzenhiser et. al (2007) equation 8. SkyDiffuse is the diffuse component ONLY and does not include the ground reflected irradiance or the irradiance due to the beam. SkyDiffuse is a column vector vector with a number of elements equal to the input vector(s). Notes ----- The POAskydiffuse calculation is generated from the Loutzenhiser et al. (2007) paper, equation 8. Note that I have removed the beam and ground reflectance portion of the equation and this generates ONLY the diffuse radiation from the sky and circumsolar, so the form of the equation varies slightly from equation 8. References ---------- [1] Loutzenhiser P.G. et. al. "Empirical validation of models to compute solar irradiance on inclined surfaces for building energy simulation" 2007, Solar Energy vol. 81. pp. 254-267 [2] Reindl, D.T., Beckmann, W.A., Duffie, J.A., 1990a. Diffuse fraction correlations. Solar Energy 45(1), 1-7. [3] Reindl, D.T., Beckmann, W.A., Duffie, J.A., 1990b. Evaluation of hourly tilted surface radiation models. Solar Energy 45(1), 9-17. See Also --------- pvl_ephemeris pvl_extraradiation pvl_isotropicsky pvl_haydavies1980 pvl_perez pvl_klucher1979 pvl_kingdiffuse ''' Vars = locals() Expect = { 'SurfTilt': ('num', 'x>=0'), 'SurfAz': ('num', 'x>=-180'), 'DHI': ('num', 'x>=0'), 'DNI': ('num', 'x>=0'), 'GHI': ('num', 'x>=0'), 'HExtra': ('num', 'x>=0'), 'SunZen': ('num', 'x>=0'), 'SunAz': ('num', 'x>=-180'), } var = pvl_tools.Parse(Vars, Expect) small = 1e-06 COSTT = pvl_tools.cosd(SurfTilt) * pvl_tools.cosd(SunZen) + pvl_tools.sind( SurfTilt) * pvl_tools.sind(SunZen) * pvl_tools.cosd(SunAz - SurfAz) RB = np.max(COSTT, 0) / np.max(pvl_tools.cosd(SunZen), 0.01745) AI = DNI / HExtra GHI[GHI < small] = small HB = DNI * (pvl_tools.cosd(SunZen)) HB[HB < 0] = 0 GHI[GHI < 0] = 0 F = np.sqrt(HB / GHI) SCUBE = (pvl_tools.sind(SurfTilt * (0.5)))**3 SkyDiffuse = DHI * ((AI * (RB) + (1 - AI) * (0.5) * ((1 + pvl_tools.cosd(SurfTilt))) * ((1 + F * (SCUBE))))) return SkyDiffuse
def pvl_perez(SurfTilt, SurfAz, DHI, DNI, HExtra, SunZen, SunAz, AM, modelt='allsitescomposite1990'): ''' Determine diffuse irradiance from the sky on a tilted surface using one of the Perez models Perez models determine the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface using the surface tilt angle, surface azimuth angle, diffuse horizontal irradiance, direct normal irradiance, extraterrestrial irradiance, sun zenith angle, sun azimuth angle, and relative (not pressure-corrected) airmass. Optionally a selector may be used to use any of Perez's model coefficient sets. Parameters ---------- SurfTilt : float or DataFrame Surface tilt angles in decimal degrees. SurfTilt must be >=0 and <=180. The tilt angle is defined as degrees from horizontal (e.g. surface facing up = 0, surface facing horizon = 90) SurfAz : float or DataFrame Surface azimuth angles in decimal degrees. SurfAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, South=180 East = 90, West = 270). DHI : float or DataFrame diffuse horizontal irradiance in W/m^2. DHI must be >=0. DNI : float or DataFrame direct normal irradiance in W/m^2. DNI must be >=0. HExtra : float or DataFrame extraterrestrial normal irradiance in W/m^2. HExtra must be >=0. SunZen : float or DataFrame apparent (refraction-corrected) zenith angles in decimal degrees. SunZen must be >=0 and <=180. SunAz : float or DataFrame Sun azimuth angles in decimal degrees. SunAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, East = 90, West = 270). AM : float or DataFrame relative (not pressure-corrected) airmass values. If AM is a DataFrame it must be of the same size as all other DataFrame inputs. AM must be >=0 (careful using the 1/sec(z) model of AM generation) Other Parameters ---------------- model : string (optional, default='allsitescomposite1990') a character string which selects the desired set of Perez coefficients. If model is not provided as an input, the default, '1990' will be used. All possible model selections are: * '1990' * 'allsitescomposite1990' (same as '1990') * 'allsitescomposite1988' * 'sandiacomposite1988' * 'usacomposite1988' * 'france1988' * 'phoenix1988' * 'elmonte1988' * 'osage1988' * 'albuquerque1988' * 'capecanaveral1988' * 'albany1988' Returns -------- SkyDiffuse : float or DataFrame the diffuse component of the solar radiation on an arbitrarily tilted surface defined by the Perez model as given in reference [3]. SkyDiffuse is the diffuse component ONLY and does not include the ground reflected irradiance or the irradiance due to the beam. References ---------- [1] Loutzenhiser P.G. et. al. "Empirical validation of models to compute solar irradiance on inclined surfaces for building energy simulation" 2007, Solar Energy vol. 81. pp. 254-267 [2] Perez, R., Seals, R., Ineichen, P., Stewart, R., Menicucci, D., 1987. A new simplified version of the Perez diffuse irradiance model for tilted surfaces. Solar Energy 39(3), 221-232. [3] Perez, R., Ineichen, P., Seals, R., Michalsky, J., Stewart, R., 1990. Modeling daylight availability and irradiance components from direct and global irradiance. Solar Energy 44 (5), 271-289. [4] Perez, R. et. al 1988. "The Development and Verification of the Perez Diffuse Radiation Model". SAND88-7030 See also -------- pvl_ephemeris pvl_extraradiation pvl_isotropicsky pvl_haydavies1980 pvl_reindl1990 pvl_klucher1979 pvl_kingdiffuse pvl_relativeairmass ''' Vars = locals() Expect = { 'SurfTilt': ('num', 'x>=0'), 'SurfAz': ('x>=-180'), 'DHI': ('x>=0'), 'DNI': ('x>=0'), 'HExtra': ('x>=0'), 'SunZen': ('x>=0'), 'SunAz': ('x>=-180'), 'AM': ('x>=0'), 'modelt': ('default', 'default=allsitescomposite1990') } var = pvl_tools.Parse(Vars, Expect) kappa = 1.041 #for SunZen in radians z = var.SunZen * np.pi / 180 # # convert to radians Dhfilter = var.DHI > 0 e = ((var.DHI[Dhfilter] + var.DNI[Dhfilter]) / var.DHI[Dhfilter] + kappa * z[Dhfilter]**3) / (1 + kappa * z[Dhfilter]**3).reindex_like( var.SunZen) ebin = pd.Series(np.zeros(var.DHI.shape[0]), index=e.index) # Select which bin e falls into ebin[(e < 1.065)] = 1 ebin[(e >= 1.065) & (e < 1.23)] = 2 ebin[(e >= 1.23) & (e < 1.5)] = 3 ebin[(e >= 1.5) & (e < 1.95)] = 4 ebin[(e >= 1.95) & (e < 2.8)] = 5 ebin[(e >= 2.8) & (e < 4.5)] = 6 ebin[(e >= 4.5) & (e < 6.2)] = 7 ebin[e >= 6.2] = 8 ebinfilter = ebin > 0 ebin = ebin - 1 #correct for 0 indexing ebin[ebinfilter == False] = np.NaN ebin = ebin.dropna().astype(int) # This is added because in cases where the sun is below the horizon # (var.SunZen > 90) but there is still diffuse horizontal light (var.DHI>0), it is # possible that the airmass (var.AM) could be NaN, which messes up later # calculations. Instead, if the sun is down, and there is still var.DHI, we set # the airmass to the airmass value on the horizon (approximately 37-38). #var.AM(var.SunZen >=90 & var.DHI >0) = 37; var.HExtra[var.HExtra == 0] = .00000001 #very hacky, fix this delt = var.DHI * var.AM / var.HExtra # # The various possible sets of Perez coefficients are contained # in a subfunction to clean up the code. F1c, F2c = GetPerezCoefficients(var.modelt) F1 = F1c[ebin, 0] + F1c[ebin, 1] * delt[ebinfilter] + F1c[ebin, 2] * z[ebinfilter] F1[F1 < 0] = 0 F1 = F1.astype(float) F2 = F2c[ebin, 0] + F2c[ebin, 1] * delt[ebinfilter] + F2c[ebin, 2] * z[ebinfilter] F2[F2 < 0] = 0 F2 = F2.astype(float) A = pvl_tools.cosd(var.SurfTilt) * pvl_tools.cosd( var.SunZen) + pvl_tools.sind(var.SurfTilt) * pvl_tools.sind( var.SunZen) * pvl_tools.cosd(var.SunAz - var.SurfAz) #removed +180 from azimuth modifier: Rob Andrews October 19th 2012 A[A < 0] = 0 B = pvl_tools.cosd(var.SunZen) B[B < pvl_tools.cosd(85)] = pvl_tools.cosd(85) #Calculate Diffuse POA from sky dome #SkyDiffuse = pd.Series(np.zeros(var.DHI.shape[0]),index=data.index) SkyDiffuse = var.DHI[ebinfilter] * ( 0.5 * (1 - F1[ebinfilter]) * (1 + pvl_tools.cosd(var.SurfTilt)) + F1[ebinfilter] * A[ebinfilter] / B[ebinfilter] + F2[ebinfilter] * pvl_tools.sind(var.SurfTilt)) SkyDiffuse[SkyDiffuse <= 0] = 0 return pd.DataFrame({'In_Plane_SkyDiffuse': SkyDiffuse})
def pvl_physicaliam(K, L, n, theta): ''' Determine the incidence angle modifier using refractive index, glazing thickness, and extinction coefficient pvl_physicaliam calculates the incidence angle modifier as described in De Soto et al. "Improvement and validation of a model for photovoltaic array performance", section 3. The calculation is based upon a physical model of absorbtion and transmission through a cover. Required information includes, incident angle, cover extinction coefficient, cover thickness Note: The authors of this function believe that eqn. 14 in [1] is incorrect. This function uses the following equation in its place: theta_r = arcsin(1/n * sin(theta)) Parameters ---------- K : float The glazing extinction coefficient in units of 1/meters. Reference [1] indicates that a value of 4 is reasonable for "water white" glass. K must be a numeric scalar or vector with all values >=0. If K is a vector, it must be the same size as all other input vectors. L : float The glazing thickness in units of meters. Reference [1] indicates that 0.002 meters (2 mm) is reasonable for most glass-covered PV panels. L must be a numeric scalar or vector with all values >=0. If L is a vector, it must be the same size as all other input vectors. n : float The effective index of refraction (unitless). Reference [1] indicates that a value of 1.526 is acceptable for glass. n must be a numeric scalar or vector with all values >=0. If n is a vector, it must be the same size as all other input vectors. theta :float The angle of incidence between the module normal vector and the sun-beam vector in degrees. Theta must be a numeric scalar or vector. For any values of theta where abs(theta)>90, IAM is set to 0. For any values of theta where -90 < theta < 0, theta is set to abs(theta) and evaluated. A warning will be generated if any(theta<0 or theta>90). Returns ------- IAM : float The incident angle modifier as specified in eqns. 14-16 of [1]. IAM is a column vector with the same number of elements as the largest input vector. References ---------- [1] W. De Soto et al., "Improvement and validation of a model for photovoltaic array performance", Solar Energy, vol 80, pp. 78-88, 2006. [2] Duffie, John A. & Beckman, William A.. (2006). Solar Engineering of Thermal Processes, third edition. [Books24x7 version] Available from http://common.books24x7.com/toc.aspx?bookid=17160. See Also -------- pvl_getaoi pvl_ephemeris pvl_spa pvl_ashraeiam ''' Vars = locals() Expect = {'K': 'x >= 0', 'L': 'x >= 0', 'n': 'x >= 0', 'theta': 'num'} var = pvl_tools.Parse(Vars, Expect) if any((var.theta < 0) | (var.theta >= 90)): print( 'Input incident angles <0 or >=90 detected For input angles with absolute value greater than 90, the ' + 'modifier is set to 0. For input angles between -90 and 0, the ' + 'angle is changed to its absolute value and evaluated.') var.theta[(var.theta < 0) | (var.theta >= 90)] = abs((var.theta < 0) | (var.theta >= 90)) thetar_deg = pvl_tools.asind(1.0 / n * (pvl_tools.sind(theta))) tau = np.exp(-1.0 * (K * (L) / pvl_tools.cosd(thetar_deg))) * ((1 - 0.5 * ( (((pvl_tools.sind(thetar_deg - theta))**2) / ((pvl_tools.sind(thetar_deg + theta))**2) + ((pvl_tools.tand(thetar_deg - theta))**2) / ((pvl_tools.tand(thetar_deg + theta))**2))))) zeroang = 1e-06 thetar_deg0 = pvl_tools.asind(1.0 / n * (pvl_tools.sind(zeroang))) tau0 = np.exp(-1.0 * (K * (L) / pvl_tools.cosd(thetar_deg0))) * ( (1 - 0.5 * ((((pvl_tools.sind(thetar_deg0 - zeroang))**2) / ((pvl_tools.sind(thetar_deg0 + zeroang))**2) + ((pvl_tools.tand(thetar_deg0 - zeroang))**2) / ((pvl_tools.tand(thetar_deg0 + zeroang))**2))))) IAM = tau / tau0 IAM[theta == 0] = 1 IAM[abs(theta) > 90 | (IAM < 0)] = 0 return IAM
def pvl_haydavies1980(SurfTilt, SurfAz, DHI, DNI, HExtra, SunZen, SunAz): ''' Determine diffuse irradiance from the sky on a tilted surface using Hay & Davies' 1980 model Hay and Davies' 1980 model determines the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface using the surface tilt angle, surface azimuth angle, diffuse horizontal irradiance, direct normal irradiance, extraterrestrial irradiance, sun zenith angle, and sun azimuth angle. Parameters ---------- SurfTilt : float or DataFrame Surface tilt angles in decimal degrees. SurfTilt must be >=0 and <=180. The tilt angle is defined as degrees from horizontal (e.g. surface facing up = 0, surface facing horizon = 90) SurfAz : float or DataFrame Surface azimuth angles in decimal degrees. SurfAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, South=180 East = 90, West = 270). DHI : float or DataFrame diffuse horizontal irradiance in W/m^2. DHI must be >=0. DNI : float or DataFrame direct normal irradiance in W/m^2. DNI must be >=0. HExtra : float or DataFrame extraterrestrial normal irradiance in W/m^2. HExtra must be >=0. SunZen : float or DataFrame apparent (refraction-corrected) zenith angles in decimal degrees. SunZen must be >=0 and <=180. SunAz : float or DataFrame Sun azimuth angles in decimal degrees. SunAz must be >=0 and <=360. The Azimuth convention is defined as degrees east of north (e.g. North = 0, East = 90, West = 270). Returns -------- SkyDiffuse : float or DataFrame the diffuse component of the solar radiation on an arbitrarily tilted surface defined by the Perez model as given in reference [3]. SkyDiffuse is the diffuse component ONLY and does not include the ground reflected irradiance or the irradiance due to the beam. References ----------- [1] Loutzenhiser P.G. et. al. "Empirical validation of models to compute solar irradiance on inclined surfaces for building energy simulation" 2007, Solar Energy vol. 81. pp. 254-267 [2] Hay, J.E., Davies, J.A., 1980. Calculations of the solar radiation incident on an inclined surface. In: Hay, J.E., Won, T.K. (Eds.), Proc. of First Canadian Solar Radiation Data Workshop, 59. Ministry of Supply and Services, Canada. See Also -------- pvl_ephemeris pvl_extraradiation pvl_isotropicsky pvl_reindl1990 pvl_perez pvl_klucher1979 pvl_kingdiffuse pvl_spa ''' Vars = locals() Expect = { 'SurfTilt': ('num', 'x>=0'), 'SurfAz': ('x>=-180'), 'DHI': ('x>=0'), 'DNI': ('x>=0'), 'HExtra': ('x>=0'), 'SunZen': ('x>=0'), 'SunAz': ('x>=-180'), } var = pvl_tools.Parse(Vars, Expect) COSTT = pvl_tools.cosd(SurfTilt) * pvl_tools.cosd(SunZen) + pvl_tools.sind( SurfTilt) * pvl_tools.sind(SunZen) * pvl_tools.cosd(SunAz - SurfAz) RB = np.max(COSTT, 0) / np.max(pvl_tools.cosd(SunZen), 0.01745) AI = DNI / HExtra SkyDiffuse = DHI * ((AI * (RB) + (1 - AI) * (0.5) * ((1 + pvl_tools.cosd(SurfTilt))))) return SkyDiffuse
def pvl_physicaliam(K,L,n,theta): ''' Determine the incidence angle modifier using refractive index, glazing thickness, and extinction coefficient pvl_physicaliam calculates the incidence angle modifier as described in De Soto et al. "Improvement and validation of a model for photovoltaic array performance", section 3. The calculation is based upon a physical model of absorbtion and transmission through a cover. Required information includes, incident angle, cover extinction coefficient, cover thickness Note: The authors of this function believe that eqn. 14 in [1] is incorrect. This function uses the following equation in its place: theta_r = arcsin(1/n * sin(theta)) Parameters ---------- K : float The glazing extinction coefficient in units of 1/meters. Reference [1] indicates that a value of 4 is reasonable for "water white" glass. K must be a numeric scalar or vector with all values >=0. If K is a vector, it must be the same size as all other input vectors. L : float The glazing thickness in units of meters. Reference [1] indicates that 0.002 meters (2 mm) is reasonable for most glass-covered PV panels. L must be a numeric scalar or vector with all values >=0. If L is a vector, it must be the same size as all other input vectors. n : float The effective index of refraction (unitless). Reference [1] indicates that a value of 1.526 is acceptable for glass. n must be a numeric scalar or vector with all values >=0. If n is a vector, it must be the same size as all other input vectors. theta :float The angle of incidence between the module normal vector and the sun-beam vector in degrees. Theta must be a numeric scalar or vector. For any values of theta where abs(theta)>90, IAM is set to 0. For any values of theta where -90 < theta < 0, theta is set to abs(theta) and evaluated. A warning will be generated if any(theta<0 or theta>90). Returns ------- IAM : float The incident angle modifier as specified in eqns. 14-16 of [1]. IAM is a column vector with the same number of elements as the largest input vector. References ---------- [1] W. De Soto et al., "Improvement and validation of a model for photovoltaic array performance", Solar Energy, vol 80, pp. 78-88, 2006. [2] Duffie, John A. & Beckman, William A.. (2006). Solar Engineering of Thermal Processes, third edition. [Books24x7 version] Available from http://common.books24x7.com/toc.aspx?bookid=17160. See Also -------- pvl_getaoi pvl_ephemeris pvl_spa pvl_ashraeiam ''' Vars=locals() Expect={'K':'x >= 0', 'L':'x >= 0', 'n':'x >= 0', 'theta':'num'} var=pvl_tools.Parse(Vars,Expect) if any((var.theta < 0) | (var.theta >= 90)): print('Input incident angles <0 or >=90 detected For input angles with absolute value greater than 90, the ' + 'modifier is set to 0. For input angles between -90 and 0, the ' + 'angle is changed to its absolute value and evaluated.') var.theta[(var.theta < 0) | (var.theta >= 90)]=abs((var.theta < 0) | (var.theta >= 90)) thetar_deg=pvl_tools.asind(1.0 / n*(pvl_tools.sind(theta))) tau=np.exp(- 1.0 * (K*(L) / pvl_tools.cosd(thetar_deg)))*((1 - 0.5*((((pvl_tools.sind(thetar_deg - theta)) ** 2) / ((pvl_tools.sind(thetar_deg + theta)) ** 2) + ((pvl_tools.tand(thetar_deg - theta)) ** 2) / ((pvl_tools.tand(thetar_deg + theta)) ** 2))))) zeroang=1e-06 thetar_deg0=pvl_tools.asind(1.0 / n*(pvl_tools.sind(zeroang))) tau0=np.exp(- 1.0 * (K*(L) / pvl_tools.cosd(thetar_deg0)))*((1 - 0.5*((((pvl_tools.sind(thetar_deg0 - zeroang)) ** 2) / ((pvl_tools.sind(thetar_deg0 + zeroang)) ** 2) + ((pvl_tools.tand(thetar_deg0 - zeroang)) ** 2) / ((pvl_tools.tand(thetar_deg0 + zeroang)) ** 2))))) IAM=tau / tau0 IAM[theta == 0]=1 IAM[abs(theta) > 90 | (IAM < 0)]=0 return IAM