6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

astropyで初日の出の時間を計算する🌅

Posted at

日の出の時間は大気中の光の屈折や、太陽の視半径にも影響を受けるが、これらのパラメータは適当な定数とした。

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))

結果。

2018-01-01 06:52:44.560696

これで安心して寝ていられる。🎍

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?