1
1
"""
2
- The ``atmosphere`` module contains methods to calculate
3
- relative and absolute airmass and to determine
4
- pressure from altitude or vice versa.
2
+ The ``atmosphere`` module contains methods to calculate relative and
3
+ absolute airmass and to determine pressure from altitude or vice versa.
5
4
"""
6
5
7
6
from __future__ import division
8
7
9
- import logging
10
- pvl_logger = logging .getLogger ('pvlib' )
11
-
12
8
import numpy as np
13
9
14
10
APPARENT_ZENITH_MODELS = ('simple' , 'kasten1966' , 'kastenyoung1989' ,
@@ -29,7 +25,7 @@ def pres2alt(pressure):
29
25
Returns
30
26
-------
31
27
altitude : scalar or Series
32
- Altitude in meters above sea level
28
+ Altitude in meters above sea level
33
29
34
30
Notes
35
31
------
@@ -51,22 +47,20 @@ def pres2alt(pressure):
51
47
52
48
"A Quick Derivation relating altitude to air pressure" from Portland
53
49
State Aerospace Society, Version 1.03, 12/22/2004.
54
-
55
50
'''
56
51
57
52
alt = 44331.5 - 4946.62 * pressure ** (0.190263 )
58
53
return alt
59
54
60
55
61
-
62
56
def alt2pres (altitude ):
63
57
'''
64
58
Determine site pressure from altitude.
65
59
66
60
Parameters
67
61
----------
68
62
Altitude : scalar or Series
69
- Altitude in meters above sea level
63
+ Altitude in meters above sea level
70
64
71
65
Returns
72
66
-------
@@ -100,29 +94,28 @@ def alt2pres(altitude):
100
94
return press
101
95
102
96
103
-
104
97
def absoluteairmass (airmass_relative , pressure = 101325. ):
105
98
'''
106
- Determine absolute (pressure corrected) airmass from relative
99
+ Determine absolute (pressure corrected) airmass from relative
107
100
airmass and pressure
108
101
109
- Gives the airmass for locations not at sea-level (i.e. not at standard
110
- pressure). The input argument "AMrelative" is the relative airmass. The
111
- input argument "pressure" is the pressure (in Pascals) at the location
112
- of interest and must be greater than 0. The calculation for
113
- absolute airmass is
114
-
102
+ Gives the airmass for locations not at sea-level (i.e. not at
103
+ standard pressure). The input argument "AMrelative" is the relative
104
+ airmass. The input argument "pressure" is the pressure (in Pascals)
105
+ at the location of interest and must be greater than 0. The
106
+ calculation for absolute airmass is
107
+
115
108
.. math::
116
109
absolute airmass = (relative airmass)*pressure/101325
117
110
118
111
Parameters
119
112
----------
120
113
121
- airmass_relative : scalar or Series
122
- The airmass at sea-level.
114
+ airmass_relative : scalar or Series
115
+ The airmass at sea-level.
123
116
124
117
pressure : scalar or Series
125
- The site pressure in Pascal.
118
+ The site pressure in Pascal.
126
119
127
120
Returns
128
121
-------
@@ -131,9 +124,9 @@ def absoluteairmass(airmass_relative, pressure=101325.):
131
124
132
125
References
133
126
----------
134
- [1] C. Gueymard, "Critical analysis and performance assessment of
135
- clear sky solar irradiance models using theoretical and measured data,"
136
- Solar Energy, vol. 51, pp. 121-138, 1993.
127
+ [1] C. Gueymard, "Critical analysis and performance assessment of
128
+ clear sky solar irradiance models using theoretical and measured
129
+ data," Solar Energy, vol. 51, pp. 121-138, 1993.
137
130
138
131
'''
139
132
@@ -146,106 +139,106 @@ def relativeairmass(zenith, model='kastenyoung1989'):
146
139
'''
147
140
Gives the relative (not pressure-corrected) airmass.
148
141
149
- Gives the airmass at sea-level when given a sun zenith angle
150
- (in degrees).
151
- The ``model`` variable allows selection of different airmass models
152
- (described below). If ``model`` is not
153
- included or is not valid, the default model is 'kastenyoung1989'.
142
+ Gives the airmass at sea-level when given a sun zenith angle (in
143
+ degrees). The ``model`` variable allows selection of different
144
+ airmass models (described below). If ``model`` is not included or is
145
+ not valid, the default model is 'kastenyoung1989'.
154
146
155
147
Parameters
156
148
----------
157
149
158
- zenith : float or Series
159
- Zenith angle of the sun in degrees.
160
- Note that some models use the apparent (refraction corrected)
161
- zenith angle, and some models use the true
162
- (not refraction-corrected) zenith angle.
163
- See model descriptions to determine which type of zenith
164
- angle is required.
165
- Apparent zenith angles must be calculated at sea level.
166
-
167
- model : String
150
+ zenith : float or Series
151
+ Zenith angle of the sun in degrees. Note that some models use
152
+ the apparent (refraction corrected) zenith angle, and some
153
+ models use the true (not refraction-corrected) zenith angle. See
154
+ model descriptions to determine which type of zenith angle is
155
+ required. Apparent zenith angles must be calculated at sea level.
156
+
157
+ model : String
168
158
Available models include the following:
169
-
159
+
170
160
* 'simple' - secant(apparent zenith angle) -
171
161
Note that this gives -inf at zenith=90
172
- * 'kasten1966' - See reference [1] - requires apparent sun zenith
173
- * 'youngirvine1967' - See reference [2] - requires true sun zenith
174
- * 'kastenyoung1989' - See reference [3] - requires apparent sun zenith
175
- * 'gueymard1993' - See reference [4] - requires apparent sun zenith
176
- * 'young1994' - See reference [5] - requries true sun zenith
177
- * 'pickering2002' - See reference [6] - requires apparent sun zenith
162
+ * 'kasten1966' - See reference [1] -
163
+ requires apparent sun zenith
164
+ * 'youngirvine1967' - See reference [2] -
165
+ requires true sun zenith
166
+ * 'kastenyoung1989' - See reference [3] -
167
+ requires apparent sun zenith
168
+ * 'gueymard1993' - See reference [4] -
169
+ requires apparent sun zenith
170
+ * 'young1994' - See reference [5] -
171
+ requries true sun zenith
172
+ * 'pickering2002' - See reference [6] -
173
+ requires apparent sun zenith
178
174
179
175
Returns
180
176
-------
181
- airmass_relative : float or Series
182
- Relative airmass at sea level. Will return NaN values for any
177
+ airmass_relative : float or Series
178
+ Relative airmass at sea level. Will return NaN values for any
183
179
zenith angle greater than 90 degrees.
184
180
185
181
References
186
182
----------
187
183
188
184
[1] Fritz Kasten. "A New Table and Approximation Formula for the
189
- Relative Optical Air Mass". Technical Report 136, Hanover, N.H.: U.S.
190
- Army Material Command, CRREL.
185
+ Relative Optical Air Mass". Technical Report 136, Hanover, N.H.:
186
+ U.S. Army Material Command, CRREL.
191
187
192
- [2] A. T. Young and W. M. Irvine, "Multicolor Photoelectric Photometry
193
- of the Brighter Planets," The Astronomical Journal, vol. 72,
194
- pp. 945-950, 1967.
188
+ [2] A. T. Young and W. M. Irvine, "Multicolor Photoelectric
189
+ Photometry of the Brighter Planets," The Astronomical Journal, vol.
190
+ 72, pp. 945-950, 1967.
195
191
196
- [3] Fritz Kasten and Andrew Young. "Revised optical air mass tables and
197
- approximation formula". Applied Optics 28:4735-4738
192
+ [3] Fritz Kasten and Andrew Young. "Revised optical air mass tables
193
+ and approximation formula". Applied Optics 28:4735-4738
198
194
199
- [4] C. Gueymard, "Critical analysis and performance assessment of
200
- clear sky solar irradiance models using theoretical and measured data,"
201
- Solar Energy, vol. 51, pp. 121-138, 1993.
195
+ [4] C. Gueymard, "Critical analysis and performance assessment of
196
+ clear sky solar irradiance models using theoretical and measured
197
+ data," Solar Energy, vol. 51, pp. 121-138, 1993.
202
198
203
- [5] A. T. Young, "AIR-MASS AND REFRACTION," Applied Optics, vol. 33,
199
+ [5] A. T. Young, "AIR-MASS AND REFRACTION," Applied Optics, vol. 33,
204
200
pp. 1108-1110, Feb 1994.
205
201
206
202
[6] Keith A. Pickering. "The Ancient Star Catalog". DIO 12:1, 20,
207
-
208
- [7] Matthew J. Reno, Clifford W. Hansen and Joshua S. Stein,
209
- "Global Horizontal Irradiance Clear Sky Models: Implementation and Analysis"
203
+
204
+ [7] Matthew J. Reno, Clifford W. Hansen and Joshua S. Stein, "Global
205
+ Horizontal Irradiance Clear Sky Models: Implementation and Analysis"
210
206
Sandia Report, (2012).
211
207
'''
212
-
208
+
213
209
z = zenith
214
210
zenith_rad = np .radians (z )
215
-
211
+
216
212
model = model .lower ()
217
-
213
+
218
214
if 'kastenyoung1989' == model :
219
- AM = ( 1.0 / (np .cos (zenith_rad ) +
220
- 0.50572 * (((6.07995 + (90 - z )) ** - 1.6364 ))) )
215
+ am = (1.0 / (np .cos (zenith_rad ) +
216
+ 0.50572 * (((6.07995 + (90 - z )) ** - 1.6364 ))))
221
217
elif 'kasten1966' == model :
222
- AM = 1.0 / (np .cos (zenith_rad ) + 0.15 * ((93.885 - z ) ** - 1.253 ))
218
+ am = 1.0 / (np .cos (zenith_rad ) + 0.15 * ((93.885 - z ) ** - 1.253 ))
223
219
elif 'simple' == model :
224
- AM = 1.0 / np .cos (zenith_rad )
220
+ am = 1.0 / np .cos (zenith_rad )
225
221
elif 'pickering2002' == model :
226
- AM = ( 1.0 / (np .sin (np .radians (90 - z +
227
- 244.0 / (165 + 47.0 * (90 - z ) ** 1.1 )))) )
222
+ am = (1.0 / (np .sin (np .radians (90 - z +
223
+ 244.0 / (165 + 47.0 * (90 - z ) ** 1.1 )))))
228
224
elif 'youngirvine1967' == model :
229
- AM = ( (1.0 / np .cos (zenith_rad )) *
230
- (1 - 0.0012 * ( (1.0 / np .cos (zenith_rad )) ** 2 ) - 1 ) )
225
+ am = ((1.0 / np .cos (zenith_rad )) *
226
+ (1 - 0.0012 * ((1.0 / np .cos (zenith_rad )) ** 2 ) - 1 ))
231
227
elif 'young1994' == model :
232
- AM = ( (1.002432 * ((np .cos (zenith_rad )) ** 2 ) +
233
- 0.148386 * (np .cos (zenith_rad )) + 0.0096467 ) /
234
- (np .cos (zenith_rad ) ** 3 +
235
- 0.149864 * (np .cos (zenith_rad ) ** 2 ) +
236
- 0.0102963 * (np .cos (zenith_rad )) + 0.000303978 ) )
228
+ am = ((1.002432 * ((np .cos (zenith_rad )) ** 2 ) +
229
+ 0.148386 * (np .cos (zenith_rad )) + 0.0096467 ) /
230
+ (np .cos (zenith_rad ) ** 3 +
231
+ 0.149864 * (np .cos (zenith_rad ) ** 2 ) +
232
+ 0.0102963 * (np .cos (zenith_rad )) + 0.000303978 ))
237
233
elif 'gueymard1993' == model :
238
- AM = ( 1.0 / (np .cos (zenith_rad ) +
239
- 0.00176759 * (z )* ((94.37515 - z ) ** - 1.21563 )) )
234
+ am = (1.0 / (np .cos (zenith_rad ) +
235
+ 0.00176759 * (z )* ((94.37515 - z ) ** - 1.21563 )))
240
236
else :
241
- pvl_logger .warning ("%s is not a valid model type for relative airmass. The 'kastenyoung1989' model was used." ,
242
- model )
243
- AM = ( 1.0 / (np .cos (zenith_rad ) +
244
- 0.50572 * (((6.07995 + (90 - z )) ** - 1.6364 ))) )
245
-
237
+ raise ValueError ('%s is not a valid model for relativeairmass' , model )
238
+
246
239
try :
247
- AM [z > 90 ] = np .nan
240
+ am [z > 90 ] = np .nan
248
241
except TypeError :
249
- AM = np .nan if z > 90 else AM
250
-
251
- return AM
242
+ am = np .nan if z > 90 else am
243
+
244
+ return am
0 commit comments