Skip to content

Commit 7348be8

Browse files
authored
Update PVGIS docs and test to comply with PVGIS version 5.2 (#1502)
* Updated PVGIS docs * Update test_pvgis.py * Replace CMSAF testfile with SARAH2 * Set components=0 for json output in test_pvgis * Specify url in args_pv_json
1 parent e659a5a commit 7348be8

File tree

4 files changed

+85
-79
lines changed

4 files changed

+85
-79
lines changed

pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_CM_10kWp_CIS_5_2a_2013_2014.json

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"inputs": {"location": {"latitude": 45.0, "longitude": 8.0, "elevation": 250.0}, "meteo_data": {"radiation_db": "PVGIS-SARAH2", "meteo_db": "ERA-Interim", "year_min": 2013, "year_max": 2014, "use_horizon": true, "horizon_db": null, "horizon_data": "DEM-calculated"}, "mounting_system": {"two_axis": {"slope": {"value": "-", "optimal": "-"}, "azimuth": {"value": "-", "optimal": "-"}}}, "pv_module": {"technology": "CIS", "peak_power": 10.0, "system_loss": 5.0}}, "outputs": {"hourly": [{"time": "20130101:0010", "P": 0.0, "G(i)": 0.0, "H_sun": 0.0, "T2m": -0.97, "WS10m": 1.52, "Int": 0.0}, {"time": "20130101:0110", "P": 0.0, "G(i)": 0.0, "H_sun": 0.0, "T2m": -1.06, "WS10m": 1.45, "Int": 0.0}, {"time": "20130101:0210", "P": 0.0, "G(i)": 0.0, "H_sun": 0.0, "T2m": -1.03, "WS10m": 1.45, "Int": 0.0}, {"time": "20130101:0310", "P": 0.0, "G(i)": 0.0, "H_sun": 0.0, "T2m": -0.48, "WS10m": 1.31, "Int": 0.0}, {"time": "20130101:0410", "P": 0.0, "G(i)": 0.0, "H_sun": 0.0, "T2m": -0.09, "WS10m": 1.24, "Int": 0.0}, {"time": "20130101:0510", "P": 0.0, "G(i)": 0.0, "H_sun": 0.0, "T2m": -0.38, "WS10m": 1.17, "Int": 0.0}, {"time": "20130101:0610", "P": 0.0, "G(i)": 0.0, "H_sun": 0.0, "T2m": 0.29, "WS10m": 1.03, "Int": 0.0}, {"time": "20130101:0710", "P": 0.0, "G(i)": 0.0, "H_sun": 0.0, "T2m": 1.0, "WS10m": 0.62, "Int": 0.0}, {"time": "20130101:0810", "P": 1187.2, "G(i)": 129.59, "H_sun": 8.06, "T2m": 0.97, "WS10m": 0.97, "Int": 0.0}, {"time": "20130101:0910", "P": 3950.1, "G(i)": 423.28, "H_sun": 14.8, "T2m": 1.89, "WS10m": 0.69, "Int": 0.0}]}, "meta": {"inputs": {"location": {"description": "Selected location", "variables": {"latitude": {"description": "Latitude", "units": "decimal degree"}, "longitude": {"description": "Longitude", "units": "decimal degree"}, "elevation": {"description": "Elevation", "units": "m"}}}, "meteo_data": {"description": "Sources of meteorological data", "variables": {"radiation_db": {"description": "Solar radiation database"}, "meteo_db": {"description": "Database used for meteorological variables other than solar radiation"}, "year_min": {"description": "First year of the calculations"}, "year_max": {"description": "Last year of the calculations"}, "use_horizon": {"description": "Include horizon shadows"}, "horizon_db": {"description": "Source of horizon data"}}}, "mounting_system": {"description": "Mounting system", "choices": "fixed, vertical_axis, inclined_axis, two_axis", "fields": {"slope": {"description": "Inclination angle from the horizontal plane", "units": "degree"}, "azimuth": {"description": "Orientation (azimuth) angle of the (fixed) PV system (0 = S, 90 = W, -90 = E)", "units": "degree"}}}, "pv_module": {"description": "PV module parameters", "variables": {"technology": {"description": "PV technology"}, "peak_power": {"description": "Nominal (peak) power of the PV module", "units": "kW"}, "system_loss": {"description": "Sum of system losses", "units": "%"}}}}, "outputs": {"hourly": {"type": "time series", "timestamp": "hourly averages", "variables": {"P": {"description": "PV system power", "units": "W"}, "G(i)": {"description": "Global irradiance on the inclined plane (plane of the array)", "units": "W/m2"}, "H_sun": {"description": "Sun height", "units": "degree"}, "T2m": {"description": "2-m air temperature", "units": "degree Celsius"}, "WS10m": {"description": "10-m total wind speed", "units": "m/s"}, "Int": {"description": "1 means solar radiation values are reconstructed"}}}}}}

pvlib/iotools/pvgis.py

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
URL = '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

Comments
 (0)