41
41
}
42
42
43
43
44
- def get_pvgis_hourly (lat , lon , angle = 0 , aspect = 0 , outputformat = 'json' ,
44
+ def get_pvgis_hourly (latitude , longitude , angle = 0 , aspect = 0 ,
45
+ outputformat = 'json' ,
45
46
usehorizon = True , userhorizon = None , raddatabase = None ,
46
- startyear = None , endyear = None , pvcalculation = False ,
47
+ start = None , end = None , pvcalculation = False ,
47
48
peakpower = None , pvtechchoice = 'crystSi' ,
48
49
mountingplace = 'free' , loss = None , trackingtype = 0 ,
49
50
optimal_inclination = False , optimalangles = False ,
@@ -53,9 +54,9 @@ def get_pvgis_hourly(lat, lon, angle=0, aspect=0, outputformat='json',
53
54
54
55
Parameters
55
56
----------
56
- lat : float
57
+ latitude : float
57
58
Latitude in degrees north
58
- lon : float
59
+ longitude : float
59
60
Longitude in degrees east
60
61
angle: float, default: 0
61
62
Tilt angle from horizontal plane. Not relevant for 2-axis tracking.
@@ -74,10 +75,10 @@ def get_pvgis_hourly(lat, lon, angle=0, aspect=0, outputformat='json',
74
75
will calculate the horizon [4]_
75
76
raddatabase: str, default: None
76
77
Name of radiation database. Options depend on location, see [3]_.
77
- startyear : int, default: None
78
+ start : int, default: None
78
79
First year of the radiation time series. Defaults to first year
79
80
avaiable.
80
- endyear : int, default: None
81
+ end : int, default: None
81
82
Last year of the radiation time series. Defaults to last year avaiable.
82
83
pvcalculation: bool, default: False
83
84
Also return estimate of hourly production.
@@ -118,8 +119,8 @@ def get_pvgis_hourly(lat, lon, angle=0, aspect=0, outputformat='json',
118
119
Time-series of hourly data, see Notes for fields
119
120
inputs : dict
120
121
Dictionary of the request input parameters, ``None`` for basic
121
- meta : list or dict
122
- meta data , ``None`` for basic
122
+ metadata : list or dict
123
+ metadata , ``None`` for basic
123
124
124
125
Notes
125
126
-----
@@ -168,7 +169,7 @@ def get_pvgis_hourly(lat, lon, angle=0, aspect=0, outputformat='json',
168
169
<https://ec.europa.eu/jrc/en/PVGIS/tools/horizon>`_
169
170
"""
170
171
# use requests to format the query string by passing params dictionary
171
- params = {'lat' : lat , 'lon' : lon , 'outputformat' : outputformat ,
172
+ params = {'lat' : latitude , 'lon' : longitude , 'outputformat' : outputformat ,
172
173
'angle' : angle , 'aspect' : aspect ,
173
174
'pvtechchoice' : pvtechchoice , 'mountingplace' : mountingplace ,
174
175
'trackingtype' : trackingtype , 'components' : int (components )}
@@ -182,10 +183,10 @@ def get_pvgis_hourly(lat, lon, angle=0, aspect=0, outputformat='json',
182
183
params ['userhorizon' ] = ',' .join (str (x ) for x in userhorizon )
183
184
if raddatabase is not None :
184
185
params ['raddatabase' ] = raddatabase
185
- if startyear is not None :
186
- params ['startyear' ] = startyear
187
- if endyear is not None :
188
- params ['endyear' ] = endyear
186
+ if start is not None :
187
+ params ['startyear' ] = start
188
+ if end is not None :
189
+ params ['endyear' ] = end
189
190
if pvcalculation :
190
191
params ['pvcalculation' ] = 1
191
192
if peakpower is not None :
@@ -229,16 +230,16 @@ def get_pvgis_hourly(lat, lon, angle=0, aspect=0, outputformat='json',
229
230
return data
230
231
231
232
232
- def _parse_pvgis_hourly_json (src , map_variables = True ):
233
+ def _parse_pvgis_hourly_json (src , map_variables ):
233
234
inputs = src ['inputs' ]
234
- meta = src ['meta' ]
235
+ metadata = src ['meta' ]
235
236
data = pd .DataFrame (src ['outputs' ]['hourly' ])
236
237
data .index = pd .to_datetime (data ['time' ], format = '%Y%m%d:%H%M' , utc = True )
237
238
data = data .drop ('time' , axis = 1 )
238
239
data = data .astype (dtype = {'Int' : 'int' }) # The 'Int' column to be integer
239
240
if map_variables :
240
241
data .rename (columns = VARIABLE_MAP , inplace = True )
241
- return data , inputs , meta
242
+ return data , inputs , metadata
242
243
243
244
244
245
def _parse_pvgis_hourly_basic (src ):
@@ -264,7 +265,7 @@ def _parse_pvgis_hourly_csv(src, map_variables=True):
264
265
while True :
265
266
line = src .readline ()
266
267
if line .startswith ('time,' ): # The data header starts with 'time,'
267
- # The last line of the meta-data section contains the column names
268
+ # The last line of the metadata section contains the column names
268
269
names = line .replace ('\n ' , '' ).replace ('\r ' , '' ).split (',' )
269
270
break
270
271
# Only retrieve metadata from non-empty lines
@@ -291,11 +292,11 @@ def _parse_pvgis_hourly_csv(src, map_variables=True):
291
292
# integer. It is necessary to convert to float, before converting to int
292
293
data = data .astype (float ).astype (dtype = {'Int' : 'int' })
293
294
# Generate metadata dictionary containing description of parameters
294
- meta = {}
295
+ metadata = {}
295
296
for line in src .readlines ():
296
297
if ':' in line :
297
- meta [line .split (':' )[0 ]] = line .split (':' )[1 ].strip ()
298
- return data , inputs , meta
298
+ metadata [line .split (':' )[0 ]] = line .split (':' )[1 ].strip ()
299
+ return data , inputs , metadata
299
300
300
301
301
302
def read_pvgis_hourly (filename , map_variables = True , pvgis_format = None ):
@@ -308,7 +309,7 @@ def read_pvgis_hourly(filename, map_variables=True, pvgis_format=None):
308
309
Name, path, or buffer of file downloaded from PVGIS.
309
310
pvgis_format : str, default None
310
311
Format of PVGIS file or buffer. Equivalent to the ``outputformat``
311
- parameter in the PVGIS TMY API. If `filename` is a file and
312
+ parameter in the PVGIS API. If `filename` is a file and
312
313
`pvgis_format` is ``None`` then the file extension will be used to
313
314
determine the PVGIS format to parse. For PVGIS files from the API with
314
315
``outputformat='basic'``, please set `pvgis_format` to ``'basic'``. If
@@ -321,8 +322,8 @@ def read_pvgis_hourly(filename, map_variables=True, pvgis_format=None):
321
322
the weather data
322
323
inputs : dict
323
324
the inputs, ``None`` for basic
324
- meta : list or dict
325
- meta data , ``None`` for basic
325
+ metadata : list or dict
326
+ metadata , ``None`` for basic
326
327
327
328
Raises
328
329
------
@@ -364,7 +365,7 @@ def read_pvgis_hourly(filename, map_variables=True, pvgis_format=None):
364
365
return _parse_pvgis_hourly_json (src )
365
366
366
367
# CSV or basic: use the correct parser from this module
367
- # eg: _parse_pvgis_tmy_csv () or _parse_pvgist_tmy_basic ()
368
+ # eg: _parse_pvgis_hourly_csv () or _parse_pvgis_hourly_basic ()
368
369
if outputformat in ['csv' , 'basic' ]:
369
370
# get the correct parser function for this output format from globals()
370
371
pvgis_parser = globals ()['_parse_pvgis_hourly_{:s}' .format (outputformat )] # noqa
0 commit comments