Skip to content

Error for get_pvgis_tmy with outputformat='csv'  #2344

Closed

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.

Activity

  1. added this to the milestone on Jan 28, 2025
  2. kandersolar commented on Feb 21, 2025

    @kandersolar
    MemberAuthor

    The issue seems to be that an additional metadata key/value pair has been added at the top of the CSV: Irradiance Time Offset (h). I will submit a PR to fix it shortly.

  3. modified the milestones: , v0.12.0 on Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions