@@ -43,31 +43,31 @@ def get_meteonorm(latitude, longitude, start, end, api_key, endpoint,
43
43
44
44
Parameters
45
45
----------
46
- latitude: float
46
+ latitude : float
47
47
In decimal degrees, north is positive (ISO 19115).
48
48
longitude: float
49
49
In decimal degrees, east is positive (ISO 19115).
50
- start: datetime like
50
+ start : datetime like
51
51
First timestamp of the requested period. If a timezone is not
52
52
specified, UTC is assumed. Relative datetime strings are supported.
53
- end: datetime like
53
+ end : datetime like
54
54
Last timestamp of the requested period. If a timezone is not
55
55
specified, UTC is assumed. Relative datetime strings are supported.
56
- api_key: str
56
+ api_key : str
57
57
Meteonorm API key.
58
58
endpoint : str
59
59
API endpoint, see [3]_. Must be one of:
60
60
61
- * ``'/ observation/training'`` - historical data with a 7-day delay
62
- * ``'/ observation/realtime'`` - near-real time (past 7-days)
63
- * ``'/ forecast/basic'`` - forcast with hourly resolution
64
- * ``'/ forecast/precision'`` - forecast with 15-min resolution
61
+ * ``'observation/training'`` - historical data with a 7-day delay
62
+ * ``'observation/realtime'`` - near-real time (past 7-days)
63
+ * ``'forecast/basic'`` - forecast with hourly resolution
64
+ * ``'forecast/precision'`` - forecast with 15-min resolution
65
65
66
- parameters: list or 'all', default 'all'
66
+ parameters : list or 'all', default : 'all'
67
67
List of parameters to request or `'all'` to get all parameters.
68
- surface_tilt: float, default : 0
68
+ surface_tilt : float, default : 0
69
69
Tilt angle from horizontal plane.
70
- surface_azimuth: float, default : 180
70
+ surface_azimuth : float, default : 180
71
71
Orientation (azimuth angle) of the (fixed) plane. Clockwise from north
72
72
(north=0, east=90, south=180, west=270).
73
73
time_step : {'1min', '15min', '1h'}, default : '15min'
@@ -76,14 +76,13 @@ def get_meteonorm(latitude, longitude, start, end, api_key, endpoint,
76
76
horizon : str or list, default : 'auto'
77
77
Specification of the horizon line. Can be either a 'flat', 'auto', or
78
78
a list of 360 horizon elevation angles.
79
- interval_index: bool, default : False
80
- Whether the index of the returned data object is of the type
81
- pd.DatetimeIndex or pd.IntervalIndex. This is an experimental feature
82
- which may be removed without warning.
83
- map_variables: bool, default : True
79
+ interval_index : bool, default : False
80
+ Index is pd.DatetimeIndex when False, and pd.IntervalIndex when True.
81
+ This is an experimental feature which may be removed without warning.
82
+ map_variables : bool, default : True
84
83
When true, renames columns of the Dataframe to pvlib variable names
85
84
where applicable. See variable :const:`VARIABLE_MAP`.
86
- url: str, optional
85
+ url : str, optional
87
86
Base URL of the Meteonorm API. The ``endpoint`` parameter is
88
87
appended to the url. The default is
89
88
:const:`pvlib.iotools.meteonorm.URL`.
@@ -137,16 +136,17 @@ def get_meteonorm(latitude, longitude, start, end, api_key, endpoint,
137
136
parameters = [parameter_dict .get (p , p ) for p in parameters ]
138
137
params ['parameters' ] = ',' .join (parameters )
139
138
140
- if horizon not in [ 'auto' , 'flat' ] :
141
- params ['horizon' ] = ',' .join (horizon )
139
+ if not isinstance ( horizon , str ) :
140
+ params ['horizon' ] = ',' .join (map ( str , horizon ) )
142
141
143
142
if 'forecast' not in endpoint .lower ():
144
143
params ['frequency' ] = TIME_STEP_MAP .get (time_step , time_step )
145
144
146
145
headers = {"Authorization" : f"Bearer { api_key } " }
147
146
148
147
response = requests .get (
149
- urljoin (url , endpoint ), headers = headers , params = params )
148
+ urljoin (url , endpoint .lstrip ('/' )), headers = headers , params = params )
149
+
150
150
if not response .ok :
151
151
# response.raise_for_status() does not give a useful error message
152
152
raise requests .HTTPError (response .json ())
@@ -175,53 +175,52 @@ def get_meteonorm_tmy(latitude, longitude, api_key,
175
175
176
176
Parameters
177
177
----------
178
- latitude: float
178
+ latitude : float
179
179
In decimal degrees, north is positive (ISO 19115).
180
- longitude: float
180
+ longitude : float
181
181
In decimal degrees, east is positive (ISO 19115).
182
- api_key: str
182
+ api_key : str
183
183
Meteonorm API key.
184
- parameters: list or 'all', default 'all'
184
+ parameters : list or 'all', default : 'all'
185
185
List of parameters to request or `'all'` to get all parameters.
186
- surface_tilt: float, default : 0
186
+ surface_tilt : float, default : 0
187
187
Tilt angle from horizontal plane.
188
188
surface_azimuth : float, default : 180
189
189
Orientation (azimuth angle) of the (fixed) plane. Clockwise from north
190
190
(north=0, east=90, south=180, west=270).
191
- time_step: {'1min', '1h'}, default : '1h'
191
+ time_step : {'1min', '1h'}, default : '1h'
192
192
Frequency of the time series.
193
- horizon: str, optional
194
- Specification of the hoirzon line. Can be either 'flat' or 'auto', or
193
+ horizon : str, optional
194
+ Specification of the horizon line. Can be either 'flat' or 'auto', or
195
195
specified as a list of 360 horizon elevation angles.
196
196
'auto'.
197
- terrain: str, default : 'open'
197
+ terrain : str, default : 'open'
198
198
Local terrain situation. Must be one of: ['open', 'depression',
199
199
'cold_air_lake', 'sea_lake', 'city', 'slope_south',
200
200
'slope_west_east'].
201
- albedo: float, default : 0.2
201
+ albedo : float, default : 0.2
202
202
Ground albedo. Albedo changes due to snow fall are modelled.
203
- turbidity: list or 'auto', optional
203
+ turbidity : list or 'auto', optional
204
204
List of 12 monthly mean atmospheric Linke turbidity values. The default
205
205
is 'auto'.
206
- random_seed: int, optional
206
+ random_seed : int, optional
207
207
Random seed to be used for stochastic processes. Two identical requests
208
208
with the same random seed will yield identical results.
209
209
clear_sky_radiation_model : str, default : 'esra'
210
210
Which clearsky model to use. Must be either `'esra'` or `'solis'`.
211
211
data_version : str, default : 'latest'
212
212
Version of Meteonorm climatological data to be used.
213
- future_scenario: str, optional
213
+ future_scenario : str, optional
214
214
Future climate scenario.
215
215
future_year : int, optional
216
216
Central year for a 20-year reference period in the future.
217
- interval_index: bool, default : False
218
- Whether the index of the returned data object is of the type
219
- pd.DatetimeIndex or pd.IntervalIndex. This is an experimental feature
220
- which may be removed without warning.
221
- map_variables: bool, default : True
217
+ interval_index : bool, default : False
218
+ Index is pd.DatetimeIndex when False, and pd.IntervalIndex when True.
219
+ This is an experimental feature which may be removed without warning.
220
+ map_variables : bool, default : True
222
221
When true, renames columns of the Dataframe to pvlib variable names
223
222
where applicable. See variable :const:`VARIABLE_MAP`.
224
- url: str, optional.
223
+ url : str, optional.
225
224
Base URL of the Meteonorm API. `'climate/tmy'` is
226
225
appended to the URL. The default is:
227
226
:const:`pvlib.iotools.meteonorm.URL`.
@@ -264,6 +263,9 @@ def get_meteonorm_tmy(latitude, longitude, api_key,
264
263
'turbidity' : turbidity ,
265
264
'clear_sky_radiation_model' : clear_sky_radiation_model ,
266
265
'data_version' : data_version ,
266
+ 'random_seed' : random_seed ,
267
+ 'future_scenario' : future_scenario ,
268
+ 'future_year' : future_year ,
267
269
}
268
270
269
271
# convert list to string with values separated by commas
@@ -273,25 +275,16 @@ def get_meteonorm_tmy(latitude, longitude, api_key,
273
275
parameters = [parameter_dict .get (p , p ) for p in parameters ]
274
276
params ['parameters' ] = ',' .join (parameters )
275
277
276
- if horizon not in ['auto' , 'flat' ]:
277
- params ['horizon' ] = ',' .join (horizon )
278
-
279
- if turbidity != 'auto' :
280
- params ['turbidity' ] = ',' .join (turbidity )
281
-
282
- if random_seed is not None :
283
- params ['random_seed' ] = random_seed
284
-
285
- if future_scenario is not None :
286
- params ['future_scenario' ] = future_scenario
278
+ if isinstance (horizon , str ):
279
+ params ['horizon' ] = ',' .join (map (str , horizon ))
287
280
288
- if future_year is not None :
289
- params ['future_year ' ] = future_year
281
+ if isinstance ( turbidity , str ) :
282
+ params ['turbidity ' ] = ',' . join ( map ( str , turbidity ))
290
283
291
284
headers = {"Authorization" : f"Bearer { api_key } " }
292
285
293
286
response = requests .get (
294
- urljoin (url , TMY_ENDPOINT ), headers = headers , params = params )
287
+ urljoin (url , TMY_ENDPOINT . lstrip ( '/' ) ), headers = headers , params = params )
295
288
296
289
if not response .ok :
297
290
# response.raise_for_status() does not give a useful error message
0 commit comments