Skip to content

Commit d06c6b8

Browse files
committed
Update input and output names
Change lat/lon to latitude/longitude and changed startyear/endyear to start/end. Also, changed meta to metadata
1 parent 64bc450 commit d06c6b8

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

pvlib/iotools/pvgis.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@
4141
}
4242

4343

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',
4546
usehorizon=True, userhorizon=None, raddatabase=None,
46-
startyear=None, endyear=None, pvcalculation=False,
47+
start=None, end=None, pvcalculation=False,
4748
peakpower=None, pvtechchoice='crystSi',
4849
mountingplace='free', loss=None, trackingtype=0,
4950
optimal_inclination=False, optimalangles=False,
@@ -53,9 +54,9 @@ def get_pvgis_hourly(lat, lon, angle=0, aspect=0, outputformat='json',
5354
5455
Parameters
5556
----------
56-
lat: float
57+
latitude: float
5758
Latitude in degrees north
58-
lon: float
59+
longitude: float
5960
Longitude in degrees east
6061
angle: float, default: 0
6162
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',
7475
will calculate the horizon [4]_
7576
raddatabase: str, default: None
7677
Name of radiation database. Options depend on location, see [3]_.
77-
startyear: int, default: None
78+
start: int, default: None
7879
First year of the radiation time series. Defaults to first year
7980
avaiable.
80-
endyear: int, default: None
81+
end: int, default: None
8182
Last year of the radiation time series. Defaults to last year avaiable.
8283
pvcalculation: bool, default: False
8384
Also return estimate of hourly production.
@@ -118,8 +119,8 @@ def get_pvgis_hourly(lat, lon, angle=0, aspect=0, outputformat='json',
118119
Time-series of hourly data, see Notes for fields
119120
inputs : dict
120121
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
123124
124125
Notes
125126
-----
@@ -168,7 +169,7 @@ def get_pvgis_hourly(lat, lon, angle=0, aspect=0, outputformat='json',
168169
<https://ec.europa.eu/jrc/en/PVGIS/tools/horizon>`_
169170
"""
170171
# 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,
172173
'angle': angle, 'aspect': aspect,
173174
'pvtechchoice': pvtechchoice, 'mountingplace': mountingplace,
174175
'trackingtype': trackingtype, 'components': int(components)}
@@ -182,10 +183,10 @@ def get_pvgis_hourly(lat, lon, angle=0, aspect=0, outputformat='json',
182183
params['userhorizon'] = ','.join(str(x) for x in userhorizon)
183184
if raddatabase is not None:
184185
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
189190
if pvcalculation:
190191
params['pvcalculation'] = 1
191192
if peakpower is not None:
@@ -229,16 +230,16 @@ def get_pvgis_hourly(lat, lon, angle=0, aspect=0, outputformat='json',
229230
return data
230231

231232

232-
def _parse_pvgis_hourly_json(src, map_variables=True):
233+
def _parse_pvgis_hourly_json(src, map_variables):
233234
inputs = src['inputs']
234-
meta = src['meta']
235+
metadata = src['meta']
235236
data = pd.DataFrame(src['outputs']['hourly'])
236237
data.index = pd.to_datetime(data['time'], format='%Y%m%d:%H%M', utc=True)
237238
data = data.drop('time', axis=1)
238239
data = data.astype(dtype={'Int': 'int'}) # The 'Int' column to be integer
239240
if map_variables:
240241
data.rename(columns=VARIABLE_MAP, inplace=True)
241-
return data, inputs, meta
242+
return data, inputs, metadata
242243

243244

244245
def _parse_pvgis_hourly_basic(src):
@@ -264,7 +265,7 @@ def _parse_pvgis_hourly_csv(src, map_variables=True):
264265
while True:
265266
line = src.readline()
266267
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
268269
names = line.replace('\n', '').replace('\r', '').split(',')
269270
break
270271
# Only retrieve metadata from non-empty lines
@@ -291,11 +292,11 @@ def _parse_pvgis_hourly_csv(src, map_variables=True):
291292
# integer. It is necessary to convert to float, before converting to int
292293
data = data.astype(float).astype(dtype={'Int': 'int'})
293294
# Generate metadata dictionary containing description of parameters
294-
meta = {}
295+
metadata = {}
295296
for line in src.readlines():
296297
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
299300

300301

301302
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):
308309
Name, path, or buffer of file downloaded from PVGIS.
309310
pvgis_format : str, default None
310311
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
312313
`pvgis_format` is ``None`` then the file extension will be used to
313314
determine the PVGIS format to parse. For PVGIS files from the API with
314315
``outputformat='basic'``, please set `pvgis_format` to ``'basic'``. If
@@ -321,8 +322,8 @@ def read_pvgis_hourly(filename, map_variables=True, pvgis_format=None):
321322
the weather data
322323
inputs : dict
323324
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
326327
327328
Raises
328329
------
@@ -364,7 +365,7 @@ def read_pvgis_hourly(filename, map_variables=True, pvgis_format=None):
364365
return _parse_pvgis_hourly_json(src)
365366

366367
# 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()
368369
if outputformat in ['csv', 'basic']:
369370
# get the correct parser function for this output format from globals()
370371
pvgis_parser = globals()['_parse_pvgis_hourly_{:s}'.format(outputformat)] # noqa

0 commit comments

Comments
 (0)