Skip to content

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

Closed
@wholmgren

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

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