26
26
URL = 'https://re.jrc.ec.europa.eu/api/'
27
27
28
28
# Dictionary mapping PVGIS names to pvlib names
29
- PVGIS_VARIABLE_MAP = {
29
+ VARIABLE_MAP = {
30
30
'G(h)' : 'ghi' ,
31
31
'Gb(n)' : 'dni' ,
32
32
'Gd(h)' : 'dhi' ,
@@ -112,10 +112,11 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
112
112
documentation [2]_ for more info.
113
113
url: str, default: :const:`pvlib.iotools.pvgis.URL`
114
114
Base url of PVGIS API. ``seriescalc`` is appended to get hourly data
115
- endpoint.
115
+ endpoint. Note, a specific PVGIS version can be specified, e.g.,
116
+ https://re.jrc.ec.europa.eu/api/v5_2/
116
117
map_variables: bool, default: True
117
118
When true, renames columns of the Dataframe to pvlib variable names
118
- where applicable. See variable PVGIS_VARIABLE_MAP .
119
+ where applicable. See variable :const:`VARIABLE_MAP` .
119
120
timeout: int, default: 30
120
121
Time in seconds to wait for server response before timeout
121
122
@@ -138,10 +139,10 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
138
139
Hint
139
140
----
140
141
PVGIS provides access to a number of different solar radiation datasets,
141
- including satellite-based (SARAH, CMSAF , and NSRDB PSM3) and re-analysis
142
- products (ERA5 and COSMO ). Each data source has a different geographical
143
- coverage and time stamp convention, e.g., SARAH and CMSAF provide
144
- instantaneous values, whereas values from ERA5 are averages for the hour.
142
+ including satellite-based (SARAH, SARAH2 , and NSRDB PSM3) and re-analysis
143
+ products (ERA5). Each data source has a different geographical coverage and
144
+ time stamp convention, e.g., SARAH and SARAH2 provide instantaneous values,
145
+ whereas values from ERA5 are averages for the hour.
145
146
146
147
Notes
147
148
-----
@@ -172,6 +173,12 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
172
173
--------
173
174
pvlib.iotools.read_pvgis_hourly, pvlib.iotools.get_pvgis_tmy
174
175
176
+ Examples
177
+ --------
178
+ >>> # Retrieve two years of irradiance data from PVGIS:
179
+ >>> data, meta, inputs = pvlib.iotools.get_pvgis_hourly( # doctest: +SKIP
180
+ >>> latitude=45, longitude=8, start=2015, end=2016) # doctest: +SKIP
181
+
175
182
References
176
183
----------
177
184
.. [1] `PVGIS <https://ec.europa.eu/jrc/en/pvgis>`_
@@ -228,7 +235,7 @@ def _parse_pvgis_hourly_json(src, map_variables):
228
235
data = data .drop ('time' , axis = 1 )
229
236
data = data .astype (dtype = {'Int' : 'int' }) # The 'Int' column to be integer
230
237
if map_variables :
231
- data = data .rename (columns = PVGIS_VARIABLE_MAP )
238
+ data = data .rename (columns = VARIABLE_MAP )
232
239
return data , inputs , metadata
233
240
234
241
@@ -270,7 +277,7 @@ def _parse_pvgis_hourly_csv(src, map_variables):
270
277
data .index = pd .to_datetime (data ['time' ], format = '%Y%m%d:%H%M' , utc = True )
271
278
data = data .drop ('time' , axis = 1 )
272
279
if map_variables :
273
- data = data .rename (columns = PVGIS_VARIABLE_MAP )
280
+ data = data .rename (columns = VARIABLE_MAP )
274
281
# All columns should have the dtype=float, except 'Int' which should be
275
282
# integer. It is necessary to convert to float, before converting to int
276
283
data = data .astype (float ).astype (dtype = {'Int' : 'int' })
@@ -297,7 +304,7 @@ def read_pvgis_hourly(filename, pvgis_format=None, map_variables=True):
297
304
``pvgis_format`` is required and must be in ``['csv', 'json']``.
298
305
map_variables: bool, default True
299
306
When true, renames columns of the DataFrame to pvlib variable names
300
- where applicable. See variable PVGIS_VARIABLE_MAP .
307
+ where applicable. See variable :const:`VARIABLE_MAP` .
301
308
302
309
Returns
303
310
-------
@@ -369,8 +376,9 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
369
376
userhorizon = None , startyear = None , endyear = None , url = URL ,
370
377
map_variables = None , timeout = 30 ):
371
378
"""
372
- Get TMY data from PVGIS. For more information see the PVGIS [1]_ TMY tool
373
- documentation [2]_.
379
+ Get TMY data from PVGIS.
380
+
381
+ For more information see the PVGIS [1]_ TMY tool documentation [2]_.
374
382
375
383
Parameters
376
384
----------
@@ -396,7 +404,7 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
396
404
base url of PVGIS API, append ``tmy`` to get TMY endpoint
397
405
map_variables: bool
398
406
When true, renames columns of the Dataframe to pvlib variable names
399
- where applicable. See variable PVGIS_VARIABLE_MAP .
407
+ where applicable. See variable const:`VARIABLE_MAP` .
400
408
timeout : int, default 30
401
409
time in seconds to wait for server response before timeout
402
410
@@ -428,13 +436,12 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
428
436
the error message in the response will be raised as an exception,
429
437
otherwise raise whatever ``HTTP/1.1`` error occurred
430
438
431
- See also
439
+ See Also
432
440
--------
433
441
read_pvgis_tmy
434
442
435
443
References
436
444
----------
437
-
438
445
.. [1] `PVGIS <https://ec.europa.eu/jrc/en/pvgis>`_
439
446
.. [2] `PVGIS TMY tool <https://ec.europa.eu/jrc/en/PVGIS/tools/tmy>`_
440
447
.. [3] `PVGIS horizon profile tool
@@ -492,7 +499,7 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
492
499
)
493
500
map_variables = False
494
501
if map_variables :
495
- data = data .rename (columns = PVGIS_VARIABLE_MAP )
502
+ data = data .rename (columns = VARIABLE_MAP )
496
503
497
504
return data , months_selected , inputs , meta
498
505
@@ -566,7 +573,7 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
566
573
be in ``['csv', 'epw', 'json', 'basic']``.
567
574
map_variables: bool
568
575
When true, renames columns of the Dataframe to pvlib variable names
569
- where applicable. See variable PVGIS_VARIABLE_MAP .
576
+ where applicable. See variable :const:`VARIABLE_MAP` .
570
577
571
578
572
579
Returns
@@ -584,12 +591,12 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
584
591
------
585
592
ValueError
586
593
if ``pvgis_format`` is ``None`` and the file extension is neither
587
- ``.csv``, ``.json``, nor ``.epw``, or if ``pvgis_format`` is provided as
588
- input but isn't in ``['csv', 'epw', 'json', 'basic']``
594
+ ``.csv``, ``.json``, nor ``.epw``, or if ``pvgis_format`` is provided
595
+ as input but isn't in ``['csv', 'epw', 'json', 'basic']``
589
596
TypeError
590
597
if ``pvgis_format`` is ``None`` and ``filename`` is a buffer
591
598
592
- See also
599
+ See Also
593
600
--------
594
601
get_pvgis_tmy
595
602
"""
@@ -655,7 +662,6 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
655
662
)
656
663
map_variables = False
657
664
if map_variables :
658
- data = data .rename (columns = PVGIS_VARIABLE_MAP )
665
+ data = data .rename (columns = VARIABLE_MAP )
659
666
660
667
return data , months_selected , inputs , meta
661
-
0 commit comments