Skip to content

Improve performance of solarposition.ephemeris #512

Closed

Description

@cwhanse

solarposition.ephemeris returns results in dataframe with a localized time index, rather than UTC time. This results in slow performance because the dataframe is assembled from Series and np.arrays that are calculated using UTC time, requiring a timezone conversion.

To Reproduce
Change line 693 from
DFOut = pd.DataFrame(index=time)

to

DFOut = pd.DataFrame(index=time_utc)

to observe the speedup: roughly 23 sec calculation time for 500k timesteps with index=time, and <5 seconds for index=time_utc

  • pvlib.__version__: 0.5.2
  • pandas.__version__: 0.20.3

Recommend that solarposition.ephemeris return a dataframe indexed in UTC time.

Activity

  1. wholmgren commented on Jul 27, 2018

    @wholmgren
    Member

    The returned index is the same as the input index, and is not necessarily localized. I think the bottleneck is the same as in #502 -- in each case the DataFrame index is not the same as the first Series index. I agree with the proposed change, but suggest that we also add

    DFOut.index = time

    following the construction of the DataFrame. So the whole thing would look like

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

    Have not tested it, but I think it would work.

  2. added this to the 0.6.0 milestone on Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions