@@ -57,6 +57,12 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
5757
5858 PVGIS data is freely available at [1]_.
5959
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+
6066 Parameters
6167 ----------
6268 latitude: float
@@ -130,8 +136,6 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
130136 -------
131137 data : pandas.DataFrame
132138 Time-series of hourly data, see Notes for fields
133- inputs : dict
134- Dictionary of the request input parameters
135139 metadata : dict
136140 Dictionary containing metadata
137141
@@ -189,7 +193,7 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
189193 Examples
190194 --------
191195 >>> # 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
193197 >>> latitude=45, longitude=8, start=2015, end=2016) # doctest: +SKIP
194198
195199 References
@@ -241,28 +245,33 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
241245
242246
243247def _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' ]
246253 data = pd .DataFrame (src ['outputs' ]['hourly' ])
247254 data .index = pd .to_datetime (data ['time' ], format = '%Y%m%d:%H%M' , utc = True )
248255 data = data .drop ('time' , axis = 1 )
249256 data = data .astype (dtype = {'Int' : 'int' }) # The 'Int' column to be integer
250257 if map_variables :
251258 data = data .rename (columns = VARIABLE_MAP )
252- return data , inputs , metadata
259+ return data , metadata
253260
254261
255262def _parse_pvgis_hourly_csv (src , map_variables ):
256263 # The first 4 rows are latitude, longitude, elevation, radiation database
257- inputs = {}
264+ metadata = {'inputs' : {}}
265+ # 'location' metadata
258266 # 'Latitude (decimal degrees): 45.000\r\n'
259- inputs ['latitude' ] = float (src .readline ().split (':' )[1 ])
267+ metadata [ ' inputs' ] ['latitude' ] = float (src .readline ().split (':' )[1 ])
260268 # 'Longitude (decimal degrees): 8.000\r\n'
261- inputs ['longitude' ] = float (src .readline ().split (':' )[1 ])
269+ metadata [ ' inputs' ] ['longitude' ] = float (src .readline ().split (':' )[1 ])
262270 # Elevation (m): 1389.0\r\n
263- inputs ['elevation' ] = float (src .readline ().split (':' )[1 ])
271+ metadata [ ' inputs' ] ['elevation' ] = float (src .readline ().split (':' )[1 ])
264272 # '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 ()
266275 # Parse through the remaining metadata section (the number of lines for
267276 # this section depends on the requested parameters)
268277 while True :
@@ -273,7 +282,7 @@ def _parse_pvgis_hourly_csv(src, map_variables):
273282 break
274283 # Only retrieve metadata from non-empty lines
275284 elif line .strip () != '' :
276- inputs [line .split (':' )[0 ]] = line .split (':' )[1 ].strip ()
285+ metadata [ ' inputs' ] [line .split (':' )[0 ]] = line .split (':' )[1 ].strip ()
277286 elif line == '' : # If end of file is reached
278287 raise ValueError ('No data section was detected. File has probably '
279288 'been modified since being downloaded from PVGIS' )
@@ -295,16 +304,23 @@ def _parse_pvgis_hourly_csv(src, map_variables):
295304 # integer. It is necessary to convert to float, before converting to int
296305 data = data .astype (float ).astype (dtype = {'Int' : 'int' })
297306 # Generate metadata dictionary containing description of parameters
298- metadata = {}
307+ metadata [ 'descriptions' ] = {}
299308 for line in src .readlines ():
300309 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
303313
304314
305315def read_pvgis_hourly (filename , pvgis_format = None , map_variables = True ):
306316 """Read a PVGIS hourly file.
307317
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+
308324 Parameters
309325 ----------
310326 filename : str, pathlib.Path, or file-like buffer
@@ -323,8 +339,6 @@ def read_pvgis_hourly(filename, pvgis_format=None, map_variables=True):
323339 -------
324340 data : pandas.DataFrame
325341 the time series data
326- inputs : dict
327- the inputs
328342 metadata : dict
329343 metadata
330344
0 commit comments