@@ -57,6 +57,12 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
57
57
58
58
PVGIS data is freely available at [1]_.
59
59
60
+ .. versionchanged:: 0.13.0
61
+ The function now returns two items ``(data,meta)``. Previous
62
+ versions of this function returned three elements
63
+ ``(data,inputs,meta)``. The ``inputs`` dictionary is now included in
64
+ ``meta``, which has changed structure to accommodate it.
65
+
60
66
Parameters
61
67
----------
62
68
latitude: float
@@ -130,8 +136,6 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
130
136
-------
131
137
data : pandas.DataFrame
132
138
Time-series of hourly data, see Notes for fields
133
- inputs : dict
134
- Dictionary of the request input parameters
135
139
metadata : dict
136
140
Dictionary containing metadata
137
141
@@ -189,7 +193,7 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
189
193
Examples
190
194
--------
191
195
>>> # Retrieve two years of irradiance data from PVGIS:
192
- >>> data, meta, inputs = pvlib.iotools.get_pvgis_hourly( # doctest: +SKIP
196
+ >>> data, meta = pvlib.iotools.get_pvgis_hourly( # doctest: +SKIP
193
197
>>> latitude=45, longitude=8, start=2015, end=2016) # doctest: +SKIP
194
198
195
199
References
@@ -241,28 +245,33 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
241
245
242
246
243
247
def _parse_pvgis_hourly_json (src , map_variables ):
244
- inputs = src ['inputs' ]
245
- metadata = src ['meta' ]
248
+ metadata = src ['meta' ].copy ()
249
+ # Override the "inputs" in metadata
250
+ metadata ['inputs' ] = src ['inputs' ]
251
+ # Re-add the inputs in metadata one-layer down
252
+ metadata ['inputs' ]['descriptions' ] = src ['meta' ]['inputs' ]
246
253
data = pd .DataFrame (src ['outputs' ]['hourly' ])
247
254
data .index = pd .to_datetime (data ['time' ], format = '%Y%m%d:%H%M' , utc = True )
248
255
data = data .drop ('time' , axis = 1 )
249
256
data = data .astype (dtype = {'Int' : 'int' }) # The 'Int' column to be integer
250
257
if map_variables :
251
258
data = data .rename (columns = VARIABLE_MAP )
252
- return data , inputs , metadata
259
+ return data , metadata
253
260
254
261
255
262
def _parse_pvgis_hourly_csv (src , map_variables ):
256
263
# The first 4 rows are latitude, longitude, elevation, radiation database
257
- inputs = {}
264
+ metadata = {'inputs' : {}}
265
+ # 'location' metadata
258
266
# 'Latitude (decimal degrees): 45.000\r\n'
259
- inputs ['latitude' ] = float (src .readline ().split (':' )[1 ])
267
+ metadata [ ' inputs' ] ['latitude' ] = float (src .readline ().split (':' )[1 ])
260
268
# 'Longitude (decimal degrees): 8.000\r\n'
261
- inputs ['longitude' ] = float (src .readline ().split (':' )[1 ])
269
+ metadata [ ' inputs' ] ['longitude' ] = float (src .readline ().split (':' )[1 ])
262
270
# Elevation (m): 1389.0\r\n
263
- inputs ['elevation' ] = float (src .readline ().split (':' )[1 ])
271
+ metadata [ ' inputs' ] ['elevation' ] = float (src .readline ().split (':' )[1 ])
264
272
# 'Radiation database: \tPVGIS-SARAH\r\n'
265
- inputs ['radiation_database' ] = src .readline ().split (':' )[1 ].strip ()
273
+ metadata ['inputs' ]['radiation_database' ] = \
274
+ src .readline ().split (':' )[1 ].strip ()
266
275
# Parse through the remaining metadata section (the number of lines for
267
276
# this section depends on the requested parameters)
268
277
while True :
@@ -273,7 +282,7 @@ def _parse_pvgis_hourly_csv(src, map_variables):
273
282
break
274
283
# Only retrieve metadata from non-empty lines
275
284
elif line .strip () != '' :
276
- inputs [line .split (':' )[0 ]] = line .split (':' )[1 ].strip ()
285
+ metadata [ ' inputs' ] [line .split (':' )[0 ]] = line .split (':' )[1 ].strip ()
277
286
elif line == '' : # If end of file is reached
278
287
raise ValueError ('No data section was detected. File has probably '
279
288
'been modified since being downloaded from PVGIS' )
@@ -295,16 +304,23 @@ def _parse_pvgis_hourly_csv(src, map_variables):
295
304
# integer. It is necessary to convert to float, before converting to int
296
305
data = data .astype (float ).astype (dtype = {'Int' : 'int' })
297
306
# Generate metadata dictionary containing description of parameters
298
- metadata = {}
307
+ metadata [ 'descriptions' ] = {}
299
308
for line in src .readlines ():
300
309
if ':' in line :
301
- metadata [line .split (':' )[0 ]] = line .split (':' )[1 ].strip ()
302
- return data , inputs , metadata
310
+ metadata ['descriptions' ][line .split (':' )[0 ]] = \
311
+ line .split (':' )[1 ].strip ()
312
+ return data , metadata
303
313
304
314
305
315
def read_pvgis_hourly (filename , pvgis_format = None , map_variables = True ):
306
316
"""Read a PVGIS hourly file.
307
317
318
+ .. versionchanged:: 0.13.0
319
+ The function now returns two items ``(data,meta)``. Previous
320
+ versions of this function returned three elements
321
+ ``(data,inputs,meta)``. The ``inputs`` dictionary is now included in
322
+ ``meta``, which has changed structure to accommodate it.
323
+
308
324
Parameters
309
325
----------
310
326
filename : str, pathlib.Path, or file-like buffer
@@ -323,8 +339,6 @@ def read_pvgis_hourly(filename, pvgis_format=None, map_variables=True):
323
339
-------
324
340
data : pandas.DataFrame
325
341
the time series data
326
- inputs : dict
327
- the inputs
328
342
metadata : dict
329
343
metadata
330
344
0 commit comments