pvanalytics.quality.time.has_dst#

pvanalytics.quality.time.has_dst(events, tz, window=7, min_difference=45, missing='raise')#

Return True if events appears to have daylight savings shifts at the dates on which tz transitions to or from daylight savings time.

The mean event time in minutes since midnight is calculated over the window days before and after the date of each daylight savings transition in tz. For each date, the two mean event times (before and after) are compared, and if the difference is greater than min_difference then a shift has occurred on that date.

Parameters
  • events (Series) – Series with one timestamp for each day. The timestamp should correspond to an event that occurs at roughly the same time on each day. For example, you may pass sunrise, sunset, or solar transit time. events need not be localized.

  • tz (str) – Name of a timezone that observes daylight savings and has the same or similar UTC offset as the expected time zone for events.

  • window (int, default 7) – Number of days before and after the shift date to consider. When passing rounded timestamps in events it may be necessary to use a smaller window. [days]

  • min_difference (int, default 45) – Minimum difference between the mean event time before the shift date and the mean event time after the event time. If the difference is greater than min_difference a shift has occurred on that date. [minutes]

  • missing ({'raise', 'warn'}, default 'raise') – Whether to raise an exception or issue a warning when there is no data at a transition date. Can be ‘raise’ or ‘warn’. If ‘warn’ and there is no data adjacent to a transition date, False is returned for that date.

Returns

Boolean Series with the same index as events True for dates that appear to have daylight savings transitions.

Return type

Series

Raises

ValueError – If there is no data in the window days before or after a shift date in events.