2626URL = 'https://re.jrc.ec.europa.eu/api/'
2727
2828# Dictionary mapping PVGIS names to pvlib names
29- PVGIS_VARIABLE_MAP = {
29+ VARIABLE_MAP = {
3030 'G(h)' : 'ghi' ,
3131 'Gb(n)' : 'dni' ,
3232 'Gd(h)' : 'dhi' ,
@@ -112,10 +112,11 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
112112 documentation [2]_ for more info.
113113 url: str, default: :const:`pvlib.iotools.pvgis.URL`
114114 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/
116117 map_variables: bool, default: True
117118 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` .
119120 timeout: int, default: 30
120121 Time in seconds to wait for server response before timeout
121122
@@ -138,10 +139,10 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
138139 Hint
139140 ----
140141 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.
145146
146147 Notes
147148 -----
@@ -172,6 +173,12 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
172173 --------
173174 pvlib.iotools.read_pvgis_hourly, pvlib.iotools.get_pvgis_tmy
174175
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+
175182 References
176183 ----------
177184 .. [1] `PVGIS <https://ec.europa.eu/jrc/en/pvgis>`_
@@ -228,7 +235,7 @@ def _parse_pvgis_hourly_json(src, map_variables):
228235 data = data .drop ('time' , axis = 1 )
229236 data = data .astype (dtype = {'Int' : 'int' }) # The 'Int' column to be integer
230237 if map_variables :
231- data = data .rename (columns = PVGIS_VARIABLE_MAP )
238+ data = data .rename (columns = VARIABLE_MAP )
232239 return data , inputs , metadata
233240
234241
@@ -270,7 +277,7 @@ def _parse_pvgis_hourly_csv(src, map_variables):
270277 data .index = pd .to_datetime (data ['time' ], format = '%Y%m%d:%H%M' , utc = True )
271278 data = data .drop ('time' , axis = 1 )
272279 if map_variables :
273- data = data .rename (columns = PVGIS_VARIABLE_MAP )
280+ data = data .rename (columns = VARIABLE_MAP )
274281 # All columns should have the dtype=float, except 'Int' which should be
275282 # integer. It is necessary to convert to float, before converting to int
276283 data = data .astype (float ).astype (dtype = {'Int' : 'int' })
@@ -297,7 +304,7 @@ def read_pvgis_hourly(filename, pvgis_format=None, map_variables=True):
297304 ``pvgis_format`` is required and must be in ``['csv', 'json']``.
298305 map_variables: bool, default True
299306 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` .
301308
302309 Returns
303310 -------
@@ -369,8 +376,9 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
369376 userhorizon = None , startyear = None , endyear = None , url = URL ,
370377 map_variables = None , timeout = 30 ):
371378 """
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]_.
374382
375383 Parameters
376384 ----------
@@ -396,7 +404,7 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
396404 base url of PVGIS API, append ``tmy`` to get TMY endpoint
397405 map_variables: bool
398406 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` .
400408 timeout : int, default 30
401409 time in seconds to wait for server response before timeout
402410
@@ -428,13 +436,12 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
428436 the error message in the response will be raised as an exception,
429437 otherwise raise whatever ``HTTP/1.1`` error occurred
430438
431- See also
439+ See Also
432440 --------
433441 read_pvgis_tmy
434442
435443 References
436444 ----------
437-
438445 .. [1] `PVGIS <https://ec.europa.eu/jrc/en/pvgis>`_
439446 .. [2] `PVGIS TMY tool <https://ec.europa.eu/jrc/en/PVGIS/tools/tmy>`_
440447 .. [3] `PVGIS horizon profile tool
@@ -492,7 +499,7 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
492499 )
493500 map_variables = False
494501 if map_variables :
495- data = data .rename (columns = PVGIS_VARIABLE_MAP )
502+ data = data .rename (columns = VARIABLE_MAP )
496503
497504 return data , months_selected , inputs , meta
498505
@@ -566,7 +573,7 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
566573 be in ``['csv', 'epw', 'json', 'basic']``.
567574 map_variables: bool
568575 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` .
570577
571578
572579 Returns
@@ -584,12 +591,12 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
584591 ------
585592 ValueError
586593 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']``
589596 TypeError
590597 if ``pvgis_format`` is ``None`` and ``filename`` is a buffer
591598
592- See also
599+ See Also
593600 --------
594601 get_pvgis_tmy
595602 """
@@ -655,7 +662,6 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
655662 )
656663 map_variables = False
657664 if map_variables :
658- data = data .rename (columns = PVGIS_VARIABLE_MAP )
665+ data = data .rename (columns = VARIABLE_MAP )
659666
660667 return data , months_selected , inputs , meta
661-
0 commit comments