Skip to content

Unexpected behaviour with sun_rise_set_transit_spa #2833

Description

@williamhobbs

Describe the bug
This may be related to #2238, #2820. For some longitudes pvlib.solarposition.sun_rise_set_transit_spa returns sunrise and sunset times that are on the same day, but for other latitudes longitudes, the sunset time is shifted one day later. I don't think this is expected, but maybe I'm missing something?

I see the same behavior with pvlib 0.15.2 and 0.15.3a1, which I think should include the fix from #2820.

To Reproduce
Steps to reproduce the behavior:

Install latest stable release:

pip install pvlib

then

import pandas as pd
import pvlib
times = pd.date_range("2000-01-01 05:00", "2000-01-02 05:00", freq='1h').tz_localize("UTC")
# try [longitude] of -100
pvlib.solarposition.sun_rise_set_transit_spa(times, 40, -100)[['sunrise', 'sunset']]

...

# try [longitude] of -110
pvlib.solarposition.sun_rise_set_transit_spa(times, 40, -110)[['sunrise', 'sunset']]

Upgrade to latest version:

pip uninstall pvlib -y
pip install git+https://github.com/pvlib/pvlib-python

restart, repeat the first steps with the new version.

Expected behavior
I expect the same behavior for both latitudes longitudes. Not sure if the two versions of pvlib should behave the same.

Screenshots
with latitude of -100:
Image

Note the different date for sunset after changing latitude to -110:

Image

And the same results with 0.15.3a1:

Image Image

Versions:

  • pvlib.__version__: '0.15.2' and '0.15.3a1'
  • pandas.__version__: '3.0.2'
  • python: 3.13.9

Additional context
Add any other context about the problem here.

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