Skip to content

Daylight saving timestamp issue in solarposition.ephemeris #307

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

Closed
anomam opened this issue Feb 7, 2017 · 3 comments
Closed

Daylight saving timestamp issue in solarposition.ephemeris #307

anomam opened this issue Feb 7, 2017 · 3 comments
Labels
Milestone

Comments

@anomam
Copy link
Contributor

anomam commented Feb 7, 2017

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.

@wholmgren
Copy link
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.

@wholmgren wholmgren added the bug label May 30, 2017
@wholmgren wholmgren added this to the 0.4.6 milestone May 30, 2017
@wholmgren wholmgren modified the milestones: 0.5.1, 0.4.6 Aug 7, 2017
@wholmgren wholmgren modified the milestones: 0.5.1, 0.5.2 Oct 12, 2017
@cwhanse
Copy link
Member

cwhanse commented May 7, 2018

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.

@wholmgren wholmgren modified the milestones: 0.5.2, 0.6.0 May 9, 2018
@wholmgren
Copy link
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
Labels
Projects
None yet
Development

No branches or pull requests

3 participants