Skip to content

Error for get_pvgis_tmy with outputformat='csv'  #2344

@kandersolar

Description

@kandersolar

A recent remote-data CI run (https://github.com/pvlib/pvlib-python/actions/runs/12470840782/job/34806707387?pr=2258#step:6:78) experienced a test failure:

>       pvgis_data = get_pvgis_tmy(45, 8, outputformat='csv', map_variables=False)

pvlib/tests/iotools/test_pvgis.py:488: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pvlib/iotools/pvgis.py:518: in get_pvgis_tmy
    data, months_selected, inputs, meta = _parse_pvgis_tmy_csv(src)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

src = <_io.BytesIO object at 0x7fe3530318f0>

    def _parse_pvgis_tmy_csv(src):
        # the first 3 rows are latitude, longitude, elevation
        inputs = {}
        # 'Latitude (decimal degrees): 45.000\r\n'
        inputs['latitude'] = float(src.readline().split(b':')[1])
        # 'Longitude (decimal degrees): 8.000\r\n'
        inputs['longitude'] = float(src.readline().split(b':')[1])
        # Elevation (m): 1389.0\r\n
        inputs['elevation'] = float(src.readline().split(b':')[1])
        # then there's a 13 row comma separated table with two columns: month, year
        # which contains the year used for that month in the
        src.readline()  # get "month,year\r\n"
        months_selected = []
        for month in range(12):
            months_selected.append(
>               {'month': month+1, 'year': int(src.readline().split(b',')[1])})
E           ValueError: invalid literal for int() with base 10: b'year\r\n'

Seems like PVGIS changed the format of their CSV TMY output.

Note that the default case in get_pvgis_tmy (outputformat='json') works without issue, so this issue probably does not affect many users.

Side note: why do we support all these formats? Seems like we could simplify that module a lot by choosing whichever one we like best and deprecating the outputformat parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions