Skip to content

solarposition.hour_angle is inefficient and fails on some pandas versions #598

Closed

Description

@wholmgren

Describe the bug
For some reason related to timezone handling, the solarposition.hour_angle function fails on pandas versions 0.15-0.18. We test 0.14 and latest. Apparently we were on pandas 0.19 or greater when this function was created.

Also, the loop over datetime values is probably slow.

    hours = np.array([(t - t.tz.localize(
        dt.datetime(t.year, t.month, t.day)
    )).total_seconds() / 3600. for t in times])

I think this gives the same result:

hours = (times.astype(int) - times.normalize().astype(int)) / 1e9 / 3600

Versions:

  • pvlib.__version__: 0.6.0
  • pandas.__version__:
  • python:

Additional context
probably should address #597 first

Activity

  1. added this to the 0.6.1 milestone on Oct 4, 2018
  2. mikofski commented on Oct 4, 2018

    @mikofski
    Member

    @wholmgren I believe this may be related to the pandas issues I observed in #583 - I noticed this hour_angle code, and I thought I should have addressed it then, but I didn't. It was my bad code from the Bird clear sky model, sorry!

  3. wholmgren commented on Oct 4, 2018

    @wholmgren
    MemberAuthor

    No worries, Mark. Do you want to address this and #597 in #583? Or do you think we should handle them separately?

  4. mikofski commented on Oct 4, 2018

    @mikofski
    Member

    I will address them, but I'd rather open a new PR to fix the hour_angle issues, unless you would prefer not

  5. wholmgren commented on Oct 4, 2018

    @wholmgren
    MemberAuthor

    New PR sounds good to me. Thanks!

  6. added a commit that references this issue on Oct 5, 2018
    ace0a17
  7. added a commit that references this issue on Oct 5, 2018
    5ee82b1
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