Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1277

Python • twilight times

$
0
0
Hi all

Completely new to programming, I try to get twilight times for a specific region (Brussels) using astral.

So far I have

Code:

import datetimeimport zoneinfofrom astral import LocationInfofrom astral.sun import suntimezone = zoneinfo.ZoneInfo("Europe/Brussels")city = LocationInfo("Brussels", "Belgium", "Europe/Brussels", 50.84, 4.35)s = sun(city.observer, date=datetime.date(2025, 3, 17), tzinfo=timezone)print((    f'Dawn:    {s["dawn"]}\n'    f'Sunrise: {s["sunrise"]}\n'    f'Noon:    {s["noon"]}\n'    f'Sunset:  {s["sunset"]}\n'    f'Dusk:    {s["dusk"]}\n' ))
However, I don't know how to get the values for the twilight.
I have been looking on the page of astral https://sffjunkie.github.io/astral/pack ... l.geocoder
and I have tried adding

Code:

    f'Twilight:    {s["twilight"]}\n'

to the print command, but that doesn't work. I also can't call other things like blue_hour or golden_hour, azimuth, which are in the manual.

I tried importing twilight from astral.twilight (etc... ) ... (this might be a wild guess...), without success.

Anyone know how I should program things to get for instance twilight-information?

Statistics: Posted by diedhert — Mon Mar 17, 2025 7:49 pm



Viewing all articles
Browse latest Browse all 1277

Trending Articles