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

Ouverte Adaptée aux débutants
#2,935 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
72/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python
Domaine
data

Piste de recherche

Commence par _get_sample_intervals dans pvlib/tools.py, que detect_clearsky et prilliman partagent, et par la fonction kimber dans pvlib/soiling.py où elle convertit l'index avec tz_convert(None). Exécute les deux reproductions du ticket pour confirmer les erreurs. C'est terminé lorsque les deux s'exécutent sans erreur sur un index avec fuseau horaire couvrant un changement d'heure et sur un index sans fuseau horaire, et que les tests existants dans test_clearsky.py, test_soiling.py, test_temperature.py et test_tools.py passent toujours.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

https://github.com/pvlib/pvlib-python/blob/0f6631ac73da3833e9020df54776c467759cfb39/pvlib/tools.py#L432-L435

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

https://github.com/pvlib/pvlib-python/blob/0f6631ac73da3833e9020df54776c467759cfb39/pvlib/soiling.py#L197

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:

  • both new tests fail on main and pass with the change;
  • test_clearsky.py, test_soiling.py, test_temperature.py and test_tools.py pass on pandas 3.1.0 and 2.3.3;
  • on the commit before #2924 (d6075f6), both examples run fine.

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

Langage dominant
Python
Étoiles
1.7k
Forks
1.2k
Merge moyen
2 j 13 h
PR mergées (30 j)
11

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de pvlib/pvlib-python

Toutes les issues de pvlib/pvlib-python

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.