1010import pandas as pd
1111import pdb
1212
13+
1314def pvl_clearsky_ineichen (Time ,Location ,LinkeTurbidity = - 999 ):
1415 '''
1516 Determine clear sky GHI, DNI, and DHI from Ineichen/Perez model
1617
17-
1818 Implements the Ineichen and Perez clear sky model for global horizontal
1919 irradiance (GHI), direct normal irradiance (DNI), and calculates
2020 the clear-sky diffuse horizontal (DHI) component as the difference
@@ -24,43 +24,51 @@ def pvl_clearsky_ineichen(Time,Location,LinkeTurbidity=-999):
2424 provided by SoDa [4, 5].
2525
2626 Parameters
27- -----------
27+ ----------
28+
2829 Time : Dataframe.index
29- A timezone aware pandas dataframe index.
3030
31+ A timezone aware pandas dataframe index.
3132
3233 Location : struct
3334
34- *Location.latitude* - vector or scalar latitude in decimal degrees (positive is
35- northern hemisphere)
36- *Location.longitude* - vector or scalar longitude in decimal degrees (positive is
37- east of prime meridian)
38- *Location.altitude* - an optional component of the Location struct, not
39- used in the ephemeris code directly, but it may be used to calculate
40- standard site pressure (see pvl_alt2pres function)
41- *location.TZ* - Time Zone offset from UTC
35+ Location.latitude
36+ vector or scalar latitude in decimal degrees (positive is
37+ northern hemisphere)
38+
39+ Location.longitude
40+ vector or scalar longitude in decimal degrees (positive is
41+ east of prime meridian)
42+
43+ Location.altitude
44+ an optional component of the Location struct, not
45+ used in the ephemeris code directly, but it may be used to calculate
46+ standard site pressure (see pvl_alt2pres function)
4247
43- Other Parameters
48+ location.TZ
49+ Time Zone offset from UTC
50+
51+ Other Parameters
4452 ----------------
4553
4654 LinkeTurbidityInput : Optional, float or DataFrame
4755
48- An optional input to provide your own Linke
49- turbidity. If this input is omitted, the default Linke turbidity
50- maps will be used. LinkeTurbidityInput may be a float or
51- dataframe of Linke turbidities. If dataframe is provided, the same
52- turbidity will be used for all time/location sets. If a dataframe is
53- provided, it must be of the same size as any time/location dataframes
54- and each element of the dataframe corresponds to any time and location
55- elements.
56+ An optional input to provide your own Linke
57+ turbidity. If this input is omitted, the default Linke turbidity
58+ maps will be used. LinkeTurbidityInput may be a float or
59+ dataframe of Linke turbidities. If dataframe is provided, the same
60+ turbidity will be used for all time/location sets. If a dataframe is
61+ provided, it must be of the same size as any time/location dataframes
62+ and each element of the dataframe corresponds to any time and location
63+ elements.
5664
5765 Returns
58- --------
66+ -------
5967
6068 ClearSkyGHI : Dataframe
6169
62- the modeled global horizonal irradiance in W/m^2 provided
63- by the Ineichen clear-sky model.
70+ the modeled global horizonal irradiance in W/m^2 provided
71+ by the Ineichen clear-sky model.
6472
6573 ClearSkyDNI : Dataframe
6674
@@ -69,50 +77,50 @@ def pvl_clearsky_ineichen(Time,Location,LinkeTurbidity=-999):
6977
7078 ClearSkyDHI : Dataframe
7179
72- the calculated diffuse horizonal irradiance in W/m^2
80+ the calculated diffuse horizonal irradiance in W/m^2
7381 provided by the Ineichen clear-sky model.
7482
7583 Notes
7684 -----
7785
78- This implementation of the Ineichen model requires a number of other
79- PV_LIB functions including pvl_ephemeris, pvl_date2doy,
80- pvl_extraradiation, pvl_absoluteairmass, pvl_relativeairmass, and
81- pvl_alt2pres. It also requires the file "LinkeTurbidities.mat" to be
82- in the working directory. If you are using pvl_ineichen
83- in a loop, it may be faster to load LinkeTurbidities.mat outside of
84- the loop and feed it into pvl_ineichen as a variable, rather than
85- having pvl_ineichen open the file each time it is called (or utilize
86- column vectors of time/location instead of a loop).
86+ This implementation of the Ineichen model requires a number of other
87+ PV_LIB functions including pvl_ephemeris, pvl_date2doy,
88+ pvl_extraradiation, pvl_absoluteairmass, pvl_relativeairmass, and
89+ pvl_alt2pres. It also requires the file "LinkeTurbidities.mat" to be
90+ in the working directory. If you are using pvl_ineichen
91+ in a loop, it may be faster to load LinkeTurbidities.mat outside of
92+ the loop and feed it into pvl_ineichen as a variable, rather than
93+ having pvl_ineichen open the file each time it is called (or utilize
94+ column vectors of time/location instead of a loop).
8795
88- Initial implementation of this algorithm by Matthew Reno.
96+ Initial implementation of this algorithm by Matthew Reno.
8997
9098 References
9199 ----------
92100
93- [1] P. Ineichen and R. Perez, "A New airmass independent formulation for
94- the Linke turbidity coefficient", Solar Energy, vol 73, pp. 151-157, 2002.
101+ [1] P. Ineichen and R. Perez, "A New airmass independent formulation for
102+ the Linke turbidity coefficient", Solar Energy, vol 73, pp. 151-157, 2002.
95103
96- [2] R. Perez et. al., "A New Operational Model for Satellite-Derived
97- Irradiances: Description and Validation", Solar Energy, vol 73, pp.
98- 307-317, 2002.
104+ [2] R. Perez et. al., "A New Operational Model for Satellite-Derived
105+ Irradiances: Description and Validation", Solar Energy, vol 73, pp.
106+ 307-317, 2002.
99107
100- [3] M. Reno, C. Hansen, and J. Stein, "Global Horizontal Irradiance Clear
101- Sky Models: Implementation and Analysis", Sandia National
102- Laboratories, SAND2012-2389, 2012.
108+ [3] M. Reno, C. Hansen, and J. Stein, "Global Horizontal Irradiance Clear
109+ Sky Models: Implementation and Analysis", Sandia National
110+ Laboratories, SAND2012-2389, 2012.
103111
104- [4] http://www.soda-is.com/eng/services/climat_free_eng.php#c5 (obtained
105- July 17, 2012).
112+ [4] http://www.soda-is.com/eng/services/climat_free_eng.php#c5 (obtained
113+ July 17, 2012).
106114
107- [5] J. Remund, et. al., "Worldwide Linke Turbidity Information", Proc.
108- ISES Solar World Congress, June 2003. Goteborg, Sweden.
115+ [5] J. Remund, et. al., "Worldwide Linke Turbidity Information", Proc.
116+ ISES Solar World Congress, June 2003. Goteborg, Sweden.
109117
110118
111119 See Also
112120 --------
113121
114- pvl_maketimestruct
115- pvl_makelocationstruct
122+ pvl_maketimestruct
123+ pvl_makelocationstruct
116124 pvl_ephemeris
117125 pvl_haurwitz
118126
@@ -123,15 +131,15 @@ def pvl_clearsky_ineichen(Time,Location,LinkeTurbidity=-999):
123131 'Location' :('' ),
124132 'LinkeTurbidity' :('optional' )}
125133 var = pvl_tools .Parse (Vars ,Expect )
126-
134+
127135 I0 = pvl_extraradiation .pvl_extraradiation (var .Time .dayofyear )
128-
136+
129137 __ ,__ ,ApparentSunElevation ,__ ,__ = pvl_ephemeris .pvl_ephemeris (var .Time ,var .Location ,pvl_alt2pres .pvl_alt2pres (var .Location .altitude )) # nargout=4
130-
138+
131139 ApparentZenith = 90 - ApparentSunElevation
132140 ApparentZenith [ApparentZenith >= 90 ]= 90
133-
134-
141+
142+
135143
136144 if LinkeTurbidity == - 999 :
137145
@@ -155,7 +163,7 @@ def pvl_clearsky_ineichen(Time,Location,LinkeTurbidity=-999):
155163 LT = LT .apply (ApplyMonth ,axis = 1 )
156164 TL = LT / float (20 )
157165 else :
158-
166+
159167 TL = var .LinkeTurbidity
160168
161169 # Get the absolute airmass assuming standard local pressure (per
@@ -195,13 +203,14 @@ def pvl_clearsky_ineichen(Time,Location,LinkeTurbidity=-999):
195203 BncI = b * (I0 )* (np .exp (- 0.09 * (AMabsolute )* ((TL - 1 ))))
196204
197205 ClearSkyDNI = np .min (BncI ,ClearSkyGHI * ((1 - (0.1 - 0.2 * (np .exp (- TL ))) / (0.1 + 0.882 / fh1 ))) / pvl_tools .cosd (ApparentZenith ))
198-
206+
199207 #ClearSkyDNI=ClearSkyGHI*((1 - (0.1 - 0.2*(np.exp(- TL))) / (0.1 + 0.882 / fh1))) / pvl_tools.cosd(ApparentZenith)
200-
208+
201209 ClearSkyDHI = ClearSkyGHI - ClearSkyDNI * (pvl_tools .cosd (ApparentZenith ))
202210
203211 return ClearSkyGHI ,ClearSkyDNI ,ClearSkyDHI ,BncI
204212
213+
205214def LinearlyScale (inputmatrix ,inputmin ,inputmax ,outputmin ,outputmax ):
206215 inputrange = inputmax - inputmin
207216 outputrange = outputmax - outputmin
0 commit comments