Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

astral.sun.sun method shows dst for noon but not for sunrise and sunset #97

Open
rampam opened this issue Dec 16, 2024 · 0 comments
Open

Comments

@rampam
Copy link

rampam commented Dec 16, 2024

Using astral.sun.sun methods to calculate the sunrise, noon and sunset times for each day for the duration of the year using the script below,

from astral import LocationInfo
from astral.sun import sun
from datetime import datetime, timezone, timedelta, date
  

# Example usage
latitude = 53.4808  # Example: Manchester, UK
longitude = -2.2426
time_zone = "Europe/London"

location = LocationInfo(name="Custom Location", region="Custom Region",
                        timezone=time_zone, latitude=latitude, longitude=longitude)
for m in range(1,13):
    for d in range(1,32):
        try:
            date = datetime(2024,m,d,tzinfo=timezone.utc)
            st = sun(location.observer, date=date, tzinfo=location.timezone)
            r,n,s = st["sunrise"], st["noon"], st["sunset"]
            print(date,r,n,s, sep='\t')
        except ValueError:
            pass

The noon time shows the daylight saving time(dst) when printing, but not the sunset and sunrise times. When these sunrise, noon and sunset times are plotted, the issue becomes visible. Is there difference in how noon time and sunrise/sunset times are calcuated?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant