Created
December 30, 2017 11:06
-
-
Save nanki/84a7e054052da2e25eca314d7ae96928 to your computer and use it in GitHub Desktop.
astropyで初日の出の時間を計算する🌅 ref: https://qiita.com/nanki/items/97191fee71ec5a3255f5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import astropy.coordinates | |
import astropy.units as u | |
from astropy.coordinates import EarthLocation, AltAz | |
from astropy.time import Time | |
from datetime import datetime | |
from scipy import optimize | |
tt = EarthLocation(lat=35.6585 * u.deg, lon=139.7455 * u.deg, height=250 * u.m) | |
def alt(timestamp): | |
t = Time(timestamp, format='unix') | |
sun = astropy.coordinates.get_sun(t) | |
return sun.transform_to(AltAz(obstime=t, location=tt, pressure=1013 * u.hPa)).alt / u.deg + 16 / 60 | |
hinode = optimize.bisect(alt, datetime(2018, 1, 1).timestamp(), datetime(2018, 1, 1, 9).timestamp()) | |
print(datetime.fromtimestamp(hinode)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2018-01-01 06:52:44.560696 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment