Skip to content

Commit d8987e5

Browse files
committed
Merge pull request #70 from wholmgren/variablenames
Update variable names
2 parents 639e019 + ddfacfe commit d8987e5

File tree

11 files changed

+2686
-10092
lines changed

11 files changed

+2686
-10092
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ before_install:
2525

2626
install:
2727
- echo "install"
28-
- conda install --yes python=$TRAVIS_PYTHON_VERSION numpy scipy pandas=$PD_VERSION nose pytz ephem
28+
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then conda install --yes python=$TRAVIS_PYTHON_VERSION numpy scipy pandas=$PD_VERSION nose pytz ephem; fi
29+
- if [[ $TRAVIS_PYTHON_VERSION == '3.3' || $TRAVIS_PYTHON_VERSION == '3.4' ]]; then conda install --yes python=$TRAVIS_PYTHON_VERSION numpy=1.8 scipy=0.14 pandas nose pytz ephem; conda install --yes pandas=$PD_VERSION --no-deps; fi
2930
- test $PD_VERSION != 0.13.1 && conda install --yes "numba>=0.17" || echo "Not installing numba"
3031
- conda install --yes coverage
3132
- pip install coveralls

docs/sphinx/source/whatsnew/v0.2.0.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@
33
v0.2.0 (??, 2015)
44
-----------------------
55

6-
This is a major release from 0.1 and includes a small number of API changes,
6+
This is a major release from 0.1 and includes a large number of API changes,
77
several new features and enhancements along with a number of bug fixes.
88
We recommend that all users upgrade to this version.
99

10+
Due to the large number of API changes, you will probably need to update your
11+
code.
12+
1013

1114
API changes
1215
~~~~~~~~~~~
1316

17+
* Change variable names to conform with new
18+
`Variables and style rules wiki <https://github.com/pvlib/pvlib-python/wiki/Variables-and-style-rules>`_.
19+
This impacts many function declarations and return values.
20+
Your existing code probably will not work! (:issue:`37`, :issue:`54`).
1421
* Move ``dirint`` and ``disc`` algorithms from ``clearsky.py``
1522
to ``irradiance.py`` (:issue:`42`)
1623
* Mark some ``pvsystem.py`` methods as private (:issue:`20`)
24+
* Make output of ``pvsystem.sapm_celltemp`` a DataFrame (:issue:`54`)
1725

1826
Enhancements
1927
~~~~~~~~~~~~
@@ -23,6 +31,7 @@ Enhancements
2331
* Add optional ``projection_ratio`` keyword argument to the ``haydavies``
2432
calculator. Speeds calculations when irradiance changes but
2533
solar position remains the same (:issue:`58`)
34+
* Improved installation instructions in README.
2635

2736
Bug fixes
2837
~~~~~~~~~

docs/tutorials/pvsystem.ipynb

Lines changed: 2048 additions & 9583 deletions
Large diffs are not rendered by default.

pvlib/atmosphere.py

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def pres2alt(pressure):
2222
2323
Parameters
2424
----------
25-
Pressure : scalar or Series
26-
Atomspheric pressure (Pascals)
25+
pressure : scalar or Series
26+
Atmospheric pressure (Pascals)
2727
2828
Returns
2929
-------
@@ -100,7 +100,7 @@ def alt2pres(altitude):
100100

101101

102102

103-
def absoluteairmass(AMrelative, pressure=101325.):
103+
def absoluteairmass(airmass_relative, pressure=101325.):
104104
'''
105105
Determine absolute (pressure corrected) airmass from relative
106106
airmass and pressure
@@ -117,7 +117,7 @@ def absoluteairmass(AMrelative, pressure=101325.):
117117
Parameters
118118
----------
119119
120-
AMrelative : scalar or Series
120+
airmass_relative : scalar or Series
121121
The airmass at sea-level.
122122
123123
pressure : scalar or Series
@@ -136,13 +136,12 @@ def absoluteairmass(AMrelative, pressure=101325.):
136136
137137
'''
138138

139-
AMa = AMrelative * pressure / 101325.
140-
141-
return AMa
139+
airmass_absolute = airmass_relative * pressure / 101325.
142140

141+
return airmass_absolute
143142

144143

145-
def relativeairmass(z, model='kastenyoung1989'):
144+
def relativeairmass(zenith, model='kastenyoung1989'):
146145
'''
147146
Gives the relative (not pressure-corrected) airmass
148147
@@ -155,17 +154,20 @@ def relativeairmass(z, model='kastenyoung1989'):
155154
Parameters
156155
----------
157156
158-
z : float or DataFrame
157+
zenith : float or Series
159158
Zenith angle of the sun in degrees.
160159
Note that some models use the apparent (refraction corrected)
161-
zenith angle, and some models use the true (not refraction-corrected)
162-
zenith angle. See model descriptions to determine which type of zenith
163-
angle is required. Apparent zenith angles must be calculated at sea level.
160+
zenith angle, and some models use the true
161+
(not refraction-corrected) zenith angle.
162+
See model descriptions to determine which type of zenith
163+
angle is required.
164+
Apparent zenith angles must be calculated at sea level.
164165
165166
model : String
166167
Available models include the following:
167168
168-
* 'simple' - secant(apparent zenith angle) - Note that this gives -inf at zenith=90
169+
* 'simple' - secant(apparent zenith angle) -
170+
Note that this gives -inf at zenith=90
169171
* 'kasten1966' - See reference [1] - requires apparent sun zenith
170172
* 'youngirvine1967' - See reference [2] - requires true sun zenith
171173
* 'kastenyoung1989' - See reference [3] - requires apparent sun zenith
@@ -175,7 +177,7 @@ def relativeairmass(z, model='kastenyoung1989'):
175177
176178
Returns
177179
-------
178-
AM : float or DataFrame
180+
airmass_relative : float or Series
179181
Relative airmass at sea level. Will return NaN values for any
180182
zenith angle greater than 90 degrees.
181183
@@ -207,27 +209,38 @@ def relativeairmass(z, model='kastenyoung1989'):
207209
Sandia Report, (2012).
208210
'''
209211

212+
z = zenith
210213
zenith_rad = np.radians(z)
211214

212215
model = model.lower()
213216

214217
if 'kastenyoung1989' == model:
215-
AM = 1.0 / (np.cos(zenith_rad) + 0.50572*(((6.07995 + (90 - z)) ** - 1.6364)))
218+
AM = ( 1.0 / (np.cos(zenith_rad) +
219+
0.50572*(((6.07995 + (90 - z)) ** - 1.6364))) )
216220
elif 'kasten1966' == model:
217221
AM = 1.0 / (np.cos(zenith_rad) + 0.15*((93.885 - z) ** - 1.253))
218222
elif 'simple' == model:
219223
AM = 1.0 / np.cos(zenith_rad)
220224
elif 'pickering2002' == model:
221-
AM = 1.0 / (np.sin(np.radians(90 - z + 244.0 / (165 + 47.0 * (90 - z) ** 1.1))))
225+
AM = ( 1.0 / (np.sin(np.radians(90 - z +
226+
244.0 / (165 + 47.0 * (90 - z) ** 1.1)))) )
222227
elif 'youngirvine1967' == model:
223-
AM = (1.0 / np.cos(zenith_rad)) * (1 - 0.0012*( (1.0 / np.cos(zenith_rad)) ** 2) - 1)
228+
AM = ( (1.0 / np.cos(zenith_rad)) *
229+
(1 - 0.0012*( (1.0 / np.cos(zenith_rad)) ** 2) - 1) )
224230
elif 'young1994' == model:
225-
AM = (1.002432*((np.cos(zenith_rad)) ** 2) + 0.148386*(np.cos(zenith_rad)) + 0.0096467) / (np.cos(zenith_rad) ** 3 + 0.149864*(np.cos(zenith_rad) ** 2) + 0.0102963*(np.cos(zenith_rad)) + 0.000303978)
231+
AM = ( (1.002432*((np.cos(zenith_rad)) ** 2) +
232+
0.148386*(np.cos(zenith_rad)) + 0.0096467) /
233+
(np.cos(zenith_rad) ** 3 +
234+
0.149864*(np.cos(zenith_rad) ** 2) +
235+
0.0102963*(np.cos(zenith_rad)) + 0.000303978) )
226236
elif 'gueymard1993' == model:
227-
AM = 1.0 / (np.cos(zenith_rad) + 0.00176759*(z)*((94.37515 - z) ** - 1.21563))
237+
AM = ( 1.0 / (np.cos(zenith_rad) +
238+
0.00176759*(z)*((94.37515 - z) ** - 1.21563)) )
228239
else:
229-
pvl_logger.warning("{} is not a valid model type for relative airmass. The 'kastenyoung1989' model was used.".format(model))
230-
AM = 1.0 / (np.cos(zenith_rad) + 0.50572*(((6.07995 + (90 - z)) ** - 1.6364)))
240+
pvl_logger.warning("{} is not a valid model type for relative airmass. The 'kastenyoung1989' model was used."
241+
.format(model))
242+
AM = ( 1.0 / (np.cos(zenith_rad) +
243+
0.50572*(((6.07995 + (90 - z)) ** - 1.6364))) )
231244

232245
try:
233246
AM[z > 90] = np.nan

pvlib/clearsky.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)