@@ -49,13 +49,13 @@ def ineichen(time, location, linke_turbidity=None,
4949 Sets the solar position algorithm.
5050 See solarposition.get_solarposition()
5151
52- zenith_data : None or pandas. Series
52+ zenith_data : None or Series
5353 If None, ephemeris data will be calculated using ``solarposition_method``.
5454
5555 airmass_model : string
5656 See pvlib.airmass.relativeairmass().
5757
58- airmass_data : None or pandas. Series
58+ airmass_data : None or Series
5959 If None, absolute air mass data will be calculated using
6060 ``airmass_model`` and location.alitude.
6161
@@ -65,14 +65,14 @@ def ineichen(time, location, linke_turbidity=None,
6565
6666 Returns
6767 --------
68- DataFrame with the following columns: ``GHI, DNI, DHI ``.
68+ DataFrame with the following columns: ``ghi, dni, dhi ``.
6969
7070 Notes
7171 -----
7272 If you are using this function
7373 in a loop, it may be faster to load LinkeTurbidities.mat outside of
74- the loop and feed it in as a variable , rather than
75- having the function open the file each time it is called.
74+ the loop and feed it in as a keyword argument , rather than
75+ having the function open and process the file each time it is called.
7676
7777 References
7878 ----------
@@ -96,7 +96,7 @@ def ineichen(time, location, linke_turbidity=None,
9696 '''
9797 # Initial implementation of this algorithm by Matthew Reno.
9898 # Ported to python by Rob Andrews
99- # Added functionality by Will Holmgren
99+ # Added functionality by Will Holmgren (@wholmgren)
100100
101101 I0 = irradiance .extraradiation (time .dayofyear )
102102
@@ -161,7 +161,7 @@ def ineichen(time, location, linke_turbidity=None,
161161 # alt2pres) using Kasten and Young's 1989 formula for airmass.
162162
163163 if airmass_data is None :
164- AMabsolute = atmosphere .absoluteairmass (AMrelative = atmosphere .relativeairmass (ApparentZenith , airmass_model ),
164+ AMabsolute = atmosphere .absoluteairmass (airmass_relative = atmosphere .relativeairmass (ApparentZenith , airmass_model ),
165165 pressure = atmosphere .alt2pres (location .altitude ))
166166 else :
167167 AMabsolute = airmass_data
@@ -195,7 +195,9 @@ def ineichen(time, location, linke_turbidity=None,
195195
196196 cos_zenith = tools .cosd (ApparentZenith )
197197
198- clearsky_GHI = cg1 * I0 * cos_zenith * np .exp (- cg2 * AMabsolute * (fh1 + fh2 * (TL - 1 ))) * np .exp (0.01 * AMabsolute ** 1.8 )
198+ clearsky_GHI = ( cg1 * I0 * cos_zenith *
199+ np .exp (- cg2 * AMabsolute * (fh1 + fh2 * (TL - 1 ))) *
200+ np .exp (0.01 * AMabsolute ** 1.8 ) )
199201 clearsky_GHI [clearsky_GHI < 0 ] = 0
200202
201203 # BncI == "normal beam clear sky radiation"
@@ -204,25 +206,24 @@ def ineichen(time, location, linke_turbidity=None,
204206 logger .debug ('b={}' .format (b ))
205207
206208 # "empirical correction" SE 73, 157 & SE 73, 312.
207- BncI_2 = clearsky_GHI * ( 1 - (0.1 - 0.2 * np .exp (- TL ))/ (0.1 + 0.882 / fh1 ) ) / cos_zenith
208- #return BncI, BncI_2
209- clearsky_DNI = np .minimum (BncI , BncI_2 ) # Will H: use np.minimum explicitly
209+ BncI_2 = ( clearsky_GHI *
210+ ( 1 - (0.1 - 0.2 * np .exp (- TL ))/ (0.1 + 0.882 / fh1 ) ) /
211+ cos_zenith )
212+
213+ clearsky_DNI = np .minimum (BncI , BncI_2 )
210214
211215 clearsky_DHI = clearsky_GHI - clearsky_DNI * cos_zenith
212216
213- df_out = pd .DataFrame ({'GHI ' :clearsky_GHI , 'DNI ' :clearsky_DNI ,
214- 'DHI ' :clearsky_DHI })
217+ df_out = pd .DataFrame ({'ghi ' :clearsky_GHI , 'dni ' :clearsky_DNI ,
218+ 'dhi ' :clearsky_DHI })
215219 df_out .fillna (0 , inplace = True )
216- #df_out['BncI'] = BncI
217- #df_out['BncI_2'] = BncI
218220
219221 return df_out
220-
221-
222-
223- def haurwitz (ApparentZenith ):
222+
223+
224+ def haurwitz (apparent_zenith ):
224225 '''
225- Determine clear sky GHI from Haurwitz model
226+ Determine clear sky GHI from Haurwitz model.
226227
227228 Implements the Haurwitz clear sky model for global horizontal
228229 irradiance (GHI) as presented in [1, 2]. A report on clear
@@ -232,7 +233,7 @@ def haurwitz(ApparentZenith):
232233
233234 Parameters
234235 ----------
235- ApparentZenith : DataFrame
236+ apparent_zenith : Series
236237 The apparent (refraction corrected) sun zenith angle
237238 in degrees.
238239
@@ -258,13 +259,13 @@ def haurwitz(ApparentZenith):
258259 Laboratories, SAND2012-2389, 2012.
259260 '''
260261
261- cos_zenith = tools .cosd (ApparentZenith )
262+ cos_zenith = tools .cosd (apparent_zenith )
262263
263264 clearsky_GHI = 1098.0 * cos_zenith * np .exp (- 0.059 / cos_zenith )
264265
265266 clearsky_GHI [clearsky_GHI < 0 ] = 0
266267
267- df_out = pd .DataFrame ({'GHI ' :clearsky_GHI })
268+ df_out = pd .DataFrame ({'ghi ' :clearsky_GHI })
268269
269270 return df_out
270271
@@ -274,5 +275,5 @@ def _linearly_scale(inputmatrix, inputmin, inputmax, outputmin, outputmax):
274275
275276 inputrange = inputmax - inputmin
276277 outputrange = outputmax - outputmin
277- OutputMatrix = (inputmatrix - inputmin ) * outputrange / inputrange + outputmin
278+ OutputMatrix = (inputmatrix - inputmin ) * outputrange / inputrange + outputmin
278279 return OutputMatrix
0 commit comments