Skip to content

Daylight saving timestamp issue in solarposition.ephemeris #307

Closed

Description

@anomam

In solarposition.ephemeris:

    # make output DataFrame
    DFOut = pd.DataFrame(index=time)
    DFOut['apparent_elevation'] = ApparentSunEl
    DFOut['elevation'] = SunEl
    DFOut['azimuth'] = SunAz
    DFOut['apparent_zenith'] = 90 - ApparentSunEl
    DFOut['zenith'] = 90 - SunEl
    DFOut['solar_time'] = SolarTime

I get an error when assigning ApparentSunEl to the DFOut column:

ValueError: cannot reindex from a duplicate axis

and I believe the reason comes from the fact that DFOut uses time as index and ApparentSunEl uses time_utc as index; and I think it raises an error because in my case time uses daylight saving and contains duplicate indices. Using ApparentSunEl.values instead should solve the issue.

Activity

  1. wholmgren commented on Feb 7, 2017

    @wholmgren
    Member

    I'm guessing that the same thing happens with solarposition.pyephem. I don't think it should happen with solarposition.spa_python. We'll probably need .values on all of the columns.

    It would be good to add a test of each method that uses duplicated labels due to DST. You could copy this test

    https://github.com/pvlib/pvlib-python/blob/master/pvlib/test/test_solarposition.py#L321-L342

    but use a 2 element times index that occurs on the hour before and the hour of DST. You'd also copy the fixture expected_solpos_multi to create expected_solpos_dst_transition or something like that.

  2. added this to the 0.4.6 milestone on May 30, 2017
  3. modified the milestones: 0.5.1, 0.4.6 on Aug 7, 2017
  4. modified the milestones: 0.5.1, 0.5.2 on Oct 12, 2017
  5. cwhanse commented on May 7, 2018

    @cwhanse
    Member

    Old issue, but in my opinion requires no change to ephemeris. Times in data should be localized and daylight savings conflicts resolved by the user prior to this function. Maybe this is a requirement for the future pvlib.io.

    I recommend closing.

  6. modified the milestones: 0.5.2, 0.6.0 on May 9, 2018
  7. wholmgren commented on Aug 14, 2018

    @wholmgren
    Member

    This might be fixed by #529. I'm going to close for now but please reopen if you continue seeing the issue and plan to make a pull request with a fix.

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