mirror of
https://github.com/Findus23/suntracking.git
synced 2024-08-27 19:52:18 +02:00
really fix timezone
This commit is contained in:
parent
7a5ca5a82a
commit
0a6a199d15
2 changed files with 4 additions and 2 deletions
3
guess.py
3
guess.py
|
@ -9,9 +9,10 @@ from astropy.time import Time
|
|||
|
||||
import config
|
||||
|
||||
tz=timezone(config.tz)
|
||||
|
||||
def time2altitude(time: datetime) -> float:
|
||||
astro_time = Time(time.astimezone(tz=timezone(config.tz)))
|
||||
astro_time = Time(tz.localize(time))
|
||||
altaz = coord.AltAz(location=config.loc, obstime=astro_time)
|
||||
sun = coord.get_sun(astro_time)
|
||||
return sun.transform_to(altaz).alt.degree
|
||||
|
|
|
@ -9,6 +9,7 @@ import config
|
|||
|
||||
loc = coord.EarthLocation(lon=config.lon,
|
||||
lat=config.lat, height=config.height)
|
||||
tz = timezone(config.tz)
|
||||
|
||||
with open("sonnenuntergang.txt") as f:
|
||||
content = f.readlines()
|
||||
|
@ -20,7 +21,7 @@ for line in lines:
|
|||
if "#" in line:
|
||||
print("skipped")
|
||||
continue
|
||||
parsetime = datetime.strptime("2018 " + line, "%Y %d.%m %H:%M").astimezone(tz=timezone(config.tz))
|
||||
parsetime = tz.localize(datetime.strptime("2018 " + line, "%Y %d.%m %H:%M"))
|
||||
print(parsetime.isoformat())
|
||||
time = Time(parsetime)
|
||||
print(time)
|
||||
|
|
Loading…
Reference in a new issue