@@ -40,11 +40,12 @@ class Location(object):
40
40
Positive is east of the prime meridian.
41
41
Use decimal degrees notation.
42
42
43
- tz : string or pytz.timezone.
43
+ tz : str, int, float, or pytz.timezone.
44
44
See
45
45
http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
46
46
for a list of valid time zones.
47
47
pytz.timezone objects will be converted to strings.
48
+ ints and floats must be in hours from UTC.
48
49
49
50
alitude : float.
50
51
Altitude from sea level in meters.
@@ -73,6 +74,9 @@ def __init__(self, latitude, longitude, tz='UTC', altitude=0,
73
74
elif isinstance (tz , datetime .tzinfo ):
74
75
self .tz = tz .zone
75
76
self .pytz = tz
77
+ elif isinstance (tz , (int , float )):
78
+ self .tz = tz
79
+ self .pytz = pytz .FixedOffset (tz * 60 )
76
80
else :
77
81
raise TypeError ('Invalid tz specification' )
78
82
@@ -114,21 +118,21 @@ def from_tmy(cls, tmy_metadata, tmy_data=None, **kwargs):
114
118
# might need code to handle the difference between tmy2 and tmy3
115
119
116
120
# determine if we're dealing with TMY2 or TMY3 data
117
- tmy2 = tmy_metadata .get ('StationName ' , False )
121
+ tmy2 = tmy_metadata .get ('City ' , False )
118
122
119
123
latitude = tmy_metadata ['latitude' ]
120
124
longitude = tmy_metadata ['longitude' ]
121
125
122
126
if tmy2 :
123
- altitude = tmy_metadata ['SiteElevation' ]
124
- name = tmy_metadata ['StationName' ]
125
- tz = tmy_metadata ['SiteTimeZone' ]
126
- else :
127
- altitude = tmy_metadata ['alititude' ]
127
+ name = tmy_metadata ['City' ]
128
+ else :
128
129
name = tmy_metadata ['Name' ]
129
- tz = tmy_metadata ['TZ' ]
130
-
131
- new_object = cls (latitude , longitude , tz , altitude , name , ** kwargs )
130
+
131
+ tz = tmy_metadata ['TZ' ]
132
+ altitude = tmy_metadata ['altitude' ]
133
+
134
+ new_object = cls (latitude , longitude , tz = tz , altitude = altitude ,
135
+ name = name , ** kwargs )
132
136
133
137
# not sure if this should be assigned regardless of input.
134
138
if tmy_data is not None :
@@ -137,26 +141,36 @@ def from_tmy(cls, tmy_metadata, tmy_data=None, **kwargs):
137
141
return new_object
138
142
139
143
140
- def get_solarposition (self , times , ** kwargs ):
144
+ def get_solarposition (self , times , pressure = None , temperature = 12 ,
145
+ ** kwargs ):
141
146
"""
142
- Uses the :func:`solarposition.get_solarposition` function
147
+ Uses the :py: func:`solarposition.get_solarposition` function
143
148
to calculate the solar zenith, azimuth, etc. at this location.
144
149
145
150
Parameters
146
151
----------
147
152
times : DatetimeIndex
148
-
149
- kwargs passed to :func:`solarposition.get_solarposition`
153
+ pressure : None, float, or array-like
154
+ If None, pressure will be calculated using
155
+ :py:func:`atmosphere.alt2pres` and ``self.altitude``.
156
+ temperature : None, float, or array-like
157
+
158
+ kwargs passed to :py:func:`solarposition.get_solarposition`
150
159
151
160
Returns
152
161
-------
153
- solarposition : DataFrame
162
+ solar_position : DataFrame
154
163
Columns depend on the ``method`` kwarg, but always include
155
- ``zenith`` and ``azimuth``.
164
+ ``zenith`` and ``azimuth``.
156
165
"""
166
+ if pressure is None :
167
+ pressure = atmosphere .alt2pres (self .altitude )
168
+
157
169
return solarposition .get_solarposition (times , latitude = self .latitude ,
158
170
longitude = self .longitude ,
159
171
altitude = self .altitude ,
172
+ pressure = pressure ,
173
+ temperature = temperature ,
160
174
** kwargs )
161
175
162
176
@@ -221,14 +235,9 @@ def get_airmass(self, times=None, solar_position=None,
221
235
if solar_position is None :
222
236
solar_position = self .get_solarposition (times )
223
237
224
- apparents = ['simple' , 'kasten1966' , 'kastenyoung1989' ,
225
- 'gueymard1993' , 'pickering2002' ]
226
-
227
- trues = ['youngirvine1967' , 'young1994' ]
228
-
229
- if model in apparents :
238
+ if model in atmosphere .APPARENT_ZENITH_MODELS :
230
239
zenith = solar_position ['apparent_zenith' ]
231
- elif model in trues :
240
+ elif model in atmosphere . TRUE_ZENITH_MODELS :
232
241
zenith = solar_position ['zenith' ]
233
242
else :
234
243
raise ValueError ('{} is not a valid airmass model' .format (model ))
0 commit comments