Skip to content

Fix PVGIS TMY tests #2305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/sphinx/source/whatsnew/v0.11.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Documentation

Testing
~~~~~~~
* Updated test files to track new PVGIS 5.3 data. (:pull:`2305`)


Requirements
Expand All @@ -70,3 +71,4 @@ Contributors
* Mark Mikofski (:ghuser:`mikofski`)
* matsuobasho (:ghuser:`matsuobasho`)
* Echedey Luis (:ghuser:`echedey-ls`)
* Kevin Anderson (:ghuser:`kandersolar`)
8,761 changes: 8,761 additions & 0 deletions pvlib/data/pvgis_tmy_test.csv

Large diffs are not rendered by default.

8,761 changes: 0 additions & 8,761 deletions pvlib/data/pvgis_tmy_test.dat

This file was deleted.

8,789 changes: 0 additions & 8,789 deletions pvlib/data/tmy_45.000_8.000_2005_2020.csv

This file was deleted.

8,768 changes: 0 additions & 8,768 deletions pvlib/data/tmy_45.000_8.000_2005_2020.epw

This file was deleted.

1 change: 0 additions & 1 deletion pvlib/data/tmy_45.000_8.000_2005_2020.json

This file was deleted.

8,761 changes: 0 additions & 8,761 deletions pvlib/data/tmy_45.000_8.000_2005_2020.txt

This file was deleted.

8,789 changes: 8,789 additions & 0 deletions pvlib/data/tmy_45.000_8.000_2005_2023.csv

Large diffs are not rendered by default.

8,768 changes: 8,768 additions & 0 deletions pvlib/data/tmy_45.000_8.000_2005_2023.epw

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pvlib/data/tmy_45.000_8.000_2005_2023.json

Large diffs are not rendered by default.

8,761 changes: 8,761 additions & 0 deletions pvlib/data/tmy_45.000_8.000_2005_2023.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pvlib/data/tmy_45.000_8.000_userhorizon.json

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions pvlib/iotools/pvgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,6 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
metadata : list or dict
file metadata, ``None`` for basic

Note
----
The PVGIS website uses 10 years of data to generate the TMY, whereas the
API accessed by this function defaults to using all available years. This
means that the TMY returned by this function may not be identical to the
one generated by the website. To replicate the website requests, specify
the corresponding 10 year period using ``startyear`` and ``endyear``.
Specifying ``endyear`` also avoids the TMY changing when new data becomes
available.

Raises
------
requests.HTTPError
Expand Down
18 changes: 9 additions & 9 deletions pvlib/tests/iotools/test_pvgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def test_read_pvgis_hourly_empty_file():
# PVGIS TMY tests
@pytest.fixture
def expected():
return pd.read_csv(DATA_DIR / 'pvgis_tmy_test.dat', index_col='time(UTC)')
return pd.read_csv(DATA_DIR / 'pvgis_tmy_test.csv', index_col='time(UTC)')


@pytest.fixture
Expand All @@ -315,18 +315,18 @@ def userhorizon_expected():
@pytest.fixture
def month_year_expected():
return [
2014, 2011, 2008, 2011, 2009, 2011, 2020, 2006, 2006, 2013, 2007, 2018]
2018, 2007, 2009, 2013, 2008, 2006, 2011, 2010, 2020, 2006, 2007, 2016]


@pytest.fixture
def inputs_expected():
return {
'location': {'latitude': 45.0, 'longitude': 8.0, 'elevation': 250.0},
'meteo_data': {
'radiation_db': 'PVGIS-SARAH2',
'radiation_db': 'PVGIS-SARAH3',
'meteo_db': 'ERA5',
'year_min': 2005,
'year_max': 2020,
'year_max': 2023,
'use_horizon': True,
'horizon_db': 'DEM-calculated'}}

Expand Down Expand Up @@ -564,14 +564,14 @@ def test_read_pvgis_horizon_invalid_coords():


def test_read_pvgis_tmy_map_variables(pvgis_tmy_mapped_columns):
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2020.json'
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.json'
actual, _, _, _ = read_pvgis_tmy(fn, map_variables=True)
assert all(c in pvgis_tmy_mapped_columns for c in actual.columns)


def test_read_pvgis_tmy_json(expected, month_year_expected, inputs_expected,
meta_expected):
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2020.json'
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.json'
# infer outputformat from file extensions
pvgis_data = read_pvgis_tmy(fn, map_variables=False)
_compare_pvgis_tmy_json(expected, month_year_expected, inputs_expected,
Expand All @@ -588,7 +588,7 @@ def test_read_pvgis_tmy_json(expected, month_year_expected, inputs_expected,


def test_read_pvgis_tmy_epw(expected, epw_meta):
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2020.epw'
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.epw'
# infer outputformat from file extensions
pvgis_data = read_pvgis_tmy(fn, map_variables=False)
_compare_pvgis_tmy_epw(expected, epw_meta, pvgis_data)
Expand All @@ -603,7 +603,7 @@ def test_read_pvgis_tmy_epw(expected, epw_meta):

def test_read_pvgis_tmy_csv(expected, month_year_expected, inputs_expected,
meta_expected, csv_meta):
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2020.csv'
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.csv'
# infer outputformat from file extensions
pvgis_data = read_pvgis_tmy(fn, map_variables=False)
_compare_pvgis_tmy_csv(expected, month_year_expected, inputs_expected,
Expand All @@ -620,7 +620,7 @@ def test_read_pvgis_tmy_csv(expected, month_year_expected, inputs_expected,


def test_read_pvgis_tmy_basic(expected, meta_expected):
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2020.txt'
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.txt'
# XXX: can't infer outputformat from file extensions for basic
with pytest.raises(ValueError, match="pvgis format 'txt' was unknown"):
read_pvgis_tmy(fn, map_variables=False)
Expand Down
Loading