Skip to content

Off-by-one error in clear sky mid-month calculation for Linke turbidity #2287

Open
@josephmckinsey

Description

Description

On line 260 at

dayofyear = time_utc.dayofyear
, we see that _interpolate_turbidity uses time_utc.dayofyear which is 1-indexed. When the middle of the month is calculated, this uses 0-indexing.

Usually in other parts of the code, this is corrected by an offset of 1, but in this case, it is not.

Reproduction

For instance, this year, February 15th 12:00 PM was the midpoint of February. This is the 46th day of the year, so the index is 45.5 which is correctly calculated by _calendar_month_middles.

Expected Behavior

This can be seen for some midpoints which you would expect to be exactly what's in the HDF5 file, but are not. For example, we would expect $\frac{57}{20} = 2.85$ for these coordinates at this time:

>>> pvlib.clearsky.lookup_linke_turbidity(pd.DatetimeIndex([datetime.datetime(2024,2,15,12)]), 38, -93)
2024-02-15 12:00:00    2.861667

I imagine this is of very low priority, since these calculations only have the resolution of a single day, but I noticed it and thought I should make an issue.

  • pvlib.__version__ == '0.11.1'
  • pandas.__version__ == '2.2.3'
  • Python 3.13.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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