Skip to content

Location.get_clearsky, irradiance.extraradiation, and solarposition.ephemeris failures in pandas 0.20 #325

Closed
@wholmgren

Description

@wholmgren

The DatetimeIndex attribute behavior changed in 0.20, and this leads to problems in the Location.get_clearsky dni_extra calculation and thus the clearsky calculation.

        if dni_extra is None:
            dni_extra = irradiance.extraradiation(times.dayofyear)

pandas 0.19.2

In [2]: times = pd.date_range(start='20140624', freq='6H', periods=4, tz='US/Arizona')

In [3]: times.dayofyear
Out[3]: array([175, 175, 175, 175], dtype=int32)

In [5]: pvlib.irradiance.extraradiation(times.dayofyear)
Out[5]: array([ 1321.16558348,  1321.16558348,  1321.16558348,  1321.16558348])

pandas 0.20.1

In [2]: times = pd.date_range(start='20140624', freq='6H', periods=4, tz='US/Arizona')

In [3]: times.dayofyear
Out[3]: Int64Index([175, 175, 175, 175], dtype='int64')

In [5]: pvlib.irradiance.extraradiation(times.dayofyear)
Out[5]: Float64Index([1321.16558348, 1321.16558348, 1321.16558348, 1321.16558348], dtype='float64')

Simply passing times (no .dayofyear) will return a Series, and everything works again. I don't know why I chose to use times.dayofyear instead of just times when building this method. Maybe irradiance.extraradiation didn't accept Series back then?

Next, the solarposition.ephemeris function contains

    DayOfYear = time_utc.dayofyear
    DecHours = (time_utc.hour + time_utc.minute/60. + time_utc.second/3600. +
                time_utc.microsecond/3600.e6)

Wrapping these variables with calls to np.array should ensure they're the right type.

I'll make a PR soon.

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