@@ -43,31 +43,31 @@ def get_meteonorm(latitude, longitude, start, end, api_key, endpoint,
4343
4444 Parameters
4545 ----------
46- latitude: float
46+ latitude : float
4747 In decimal degrees, north is positive (ISO 19115).
4848 longitude: float
4949 In decimal degrees, east is positive (ISO 19115).
50- start: datetime like
50+ start : datetime like
5151 First timestamp of the requested period. If a timezone is not
5252 specified, UTC is assumed. Relative datetime strings are supported.
53- end: datetime like
53+ end : datetime like
5454 Last timestamp of the requested period. If a timezone is not
5555 specified, UTC is assumed. Relative datetime strings are supported.
56- api_key: str
56+ api_key : str
5757 Meteonorm API key.
5858 endpoint : str
5959 API endpoint, see [3]_. Must be one of:
6060
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
6565
66- parameters: list or 'all', default 'all'
66+ parameters : list or 'all', default : 'all'
6767 List of parameters to request or `'all'` to get all parameters.
68- surface_tilt: float, default : 0
68+ surface_tilt : float, default : 0
6969 Tilt angle from horizontal plane.
70- surface_azimuth: float, default : 180
70+ surface_azimuth : float, default : 180
7171 Orientation (azimuth angle) of the (fixed) plane. Clockwise from north
7272 (north=0, east=90, south=180, west=270).
7373 time_step : {'1min', '15min', '1h'}, default : '15min'
@@ -76,14 +76,13 @@ def get_meteonorm(latitude, longitude, start, end, api_key, endpoint,
7676 horizon : str or list, default : 'auto'
7777 Specification of the horizon line. Can be either a 'flat', 'auto', or
7878 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
8483 When true, renames columns of the Dataframe to pvlib variable names
8584 where applicable. See variable :const:`VARIABLE_MAP`.
86- url: str, optional
85+ url : str, optional
8786 Base URL of the Meteonorm API. The ``endpoint`` parameter is
8887 appended to the url. The default is
8988 :const:`pvlib.iotools.meteonorm.URL`.
@@ -137,16 +136,17 @@ def get_meteonorm(latitude, longitude, start, end, api_key, endpoint,
137136 parameters = [parameter_dict .get (p , p ) for p in parameters ]
138137 params ['parameters' ] = ',' .join (parameters )
139138
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 ) )
142141
143142 if 'forecast' not in endpoint .lower ():
144143 params ['frequency' ] = TIME_STEP_MAP .get (time_step , time_step )
145144
146145 headers = {"Authorization" : f"Bearer { api_key } " }
147146
148147 response = requests .get (
149- urljoin (url , endpoint ), headers = headers , params = params )
148+ urljoin (url , endpoint .lstrip ('/' )), headers = headers , params = params )
149+
150150 if not response .ok :
151151 # response.raise_for_status() does not give a useful error message
152152 raise requests .HTTPError (response .json ())
@@ -175,53 +175,52 @@ def get_meteonorm_tmy(latitude, longitude, api_key,
175175
176176 Parameters
177177 ----------
178- latitude: float
178+ latitude : float
179179 In decimal degrees, north is positive (ISO 19115).
180- longitude: float
180+ longitude : float
181181 In decimal degrees, east is positive (ISO 19115).
182- api_key: str
182+ api_key : str
183183 Meteonorm API key.
184- parameters: list or 'all', default 'all'
184+ parameters : list or 'all', default : 'all'
185185 List of parameters to request or `'all'` to get all parameters.
186- surface_tilt: float, default : 0
186+ surface_tilt : float, default : 0
187187 Tilt angle from horizontal plane.
188188 surface_azimuth : float, default : 180
189189 Orientation (azimuth angle) of the (fixed) plane. Clockwise from north
190190 (north=0, east=90, south=180, west=270).
191- time_step: {'1min', '1h'}, default : '1h'
191+ time_step : {'1min', '1h'}, default : '1h'
192192 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
195195 specified as a list of 360 horizon elevation angles.
196196 'auto'.
197- terrain: str, default : 'open'
197+ terrain : str, default : 'open'
198198 Local terrain situation. Must be one of: ['open', 'depression',
199199 'cold_air_lake', 'sea_lake', 'city', 'slope_south',
200200 'slope_west_east'].
201- albedo: float, default : 0.2
201+ albedo : float, default : 0.2
202202 Ground albedo. Albedo changes due to snow fall are modelled.
203- turbidity: list or 'auto', optional
203+ turbidity : list or 'auto', optional
204204 List of 12 monthly mean atmospheric Linke turbidity values. The default
205205 is 'auto'.
206- random_seed: int, optional
206+ random_seed : int, optional
207207 Random seed to be used for stochastic processes. Two identical requests
208208 with the same random seed will yield identical results.
209209 clear_sky_radiation_model : str, default : 'esra'
210210 Which clearsky model to use. Must be either `'esra'` or `'solis'`.
211211 data_version : str, default : 'latest'
212212 Version of Meteonorm climatological data to be used.
213- future_scenario: str, optional
213+ future_scenario : str, optional
214214 Future climate scenario.
215215 future_year : int, optional
216216 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
222221 When true, renames columns of the Dataframe to pvlib variable names
223222 where applicable. See variable :const:`VARIABLE_MAP`.
224- url: str, optional.
223+ url : str, optional.
225224 Base URL of the Meteonorm API. `'climate/tmy'` is
226225 appended to the URL. The default is:
227226 :const:`pvlib.iotools.meteonorm.URL`.
@@ -264,6 +263,9 @@ def get_meteonorm_tmy(latitude, longitude, api_key,
264263 'turbidity' : turbidity ,
265264 'clear_sky_radiation_model' : clear_sky_radiation_model ,
266265 'data_version' : data_version ,
266+ 'random_seed' : random_seed ,
267+ 'future_scenario' : future_scenario ,
268+ 'future_year' : future_year ,
267269 }
268270
269271 # convert list to string with values separated by commas
@@ -273,25 +275,16 @@ def get_meteonorm_tmy(latitude, longitude, api_key,
273275 parameters = [parameter_dict .get (p , p ) for p in parameters ]
274276 params ['parameters' ] = ',' .join (parameters )
275277
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 ))
287280
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 ))
290283
291284 headers = {"Authorization" : f"Bearer { api_key } " }
292285
293286 response = requests .get (
294- urljoin (url , TMY_ENDPOINT ), headers = headers , params = params )
287+ urljoin (url , TMY_ENDPOINT . lstrip ( '/' ) ), headers = headers , params = params )
295288
296289 if not response .ok :
297290 # response.raise_for_status() does not give a useful error message
0 commit comments