Skip to content

detect_clearsky and prilliman fail on DST days, kimber fails on tz-naive data (since #2924) #2935

Open

Description

@aarmens702-hub

On main (0f6631a, pandas 3.1.0), both of these worked before #2924 and now raise:

import pandas as pd
import pvlib

loc = pvlib.location.Location(49.28, -123.12, tz='America/Vancouver')
times = pd.date_range('2026-03-07', '2026-03-10', freq='1min',
                      tz=loc.tz, inclusive='left')
ghi = loc.get_clearsky(times)['ghi']
pvlib.clearsky.detect_clearsky(ghi, ghi)
# NotImplementedError: algorithm does not yet support unequal time intervals...

rain = pd.Series(0.0, index=pd.date_range('2026-01-01', periods=720, freq='h'))
pvlib.soiling.kimber(rain)
# TypeError: Cannot convert tz-naive timestamps, use tz_localize to localize

In _get_sample_intervals, tz_localize(None) turns the index into local clock time, so the 1-minute data gets a 61-minute step where the clocks change. temperature.prilliman uses the same helper, so it fails the same way.

pvlib-python/pvlib/tools.py

Lines 432 to 435 in 0f6631a

deltas = (
np.diff(times.tz_localize(None).to_numpy()) # tz-naive np.datetime64
/ np.timedelta64(1, '60s')
)

kimber uses tz_convert(None), which raises on a tz-naive index:

rain_index_vals = rainfall.index.tz_convert(None).to_numpy()

What I'd suggest: subtract the timestamps directly. That gives elapsed time for both naive and tz-aware indexes.

# tools._get_sample_intervals
deltas = (times[1:] - times[:-1]) / pd.Timedelta('60s')

# soiling.kimber
timestep_interval = rainfall.index[1] - rainfall.index[0]
day_fraction = timestep_interval / pd.Timedelta(hours=24)

Plus two tests: detect_clearsky on a DST day should match the same data in UTC, and kimber with a tz-naive index should match the existing expected output.

I tried this locally:

I didn't find an existing issue for this. Happy to open a PR if this sounds right.

AI disclosure: I used Claude Code (an AI coding agent) to find and trace this, run the examples and tests on my machine, and draft this note.

@echedey-ls @kandersolar

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions