简体   繁体   中英

How to convert UTC and longitude to mean solar local time python

I am trying to convert my UTC time and longitude into a mean solar local time in python.

Inputs:

utc = ['2000-08-20 07:15:12.000']  #utc time

lon = [-89.91054415]               #longitude

I used astropy.time to get my utc time which is a string.

I found a solution here using pyephem. It does take into account daylight savings time if that's a concern.

from ephem import Sun, Observer, pi, hours

dt = '2016/08/27 19:19'

sun = Sun()
sun.compute(dt)

boston = Observer()
boston.lat = '42.37'
boston.lon = '-71.03'
boston.date = dt
ra, dec = boston.radec_of('0', '-90')

print 'Sun right ascension:', sun.ra
print 'Boston nadir right ascension:', ra
print 'Solar time:', hours((ra - sun.ra) % (2 * pi)), 'hours'

Explanatory Supplement to the Astronomical Almanac 3rd ed. page 239 states that the local mean solar time, LMSoT, is related to UT and the observer's east longitude by

LMSoT = UT + ƛ

UT is usually taken to mean UT1. To convert UTC to UT1 refer to Bulletin A at https://www.iers.org/IERS/EN/DataProducts/EarthOrientationData/eop.html

For 2016/08/27 UT1 - UTC = -0.243031. Original poster is only working to milliseconds, so round to -0.243. 2016/08/27 19:19:00.000 UTC = 19:18:59.757 UT1.

Boston latitude, -71.03°, converted to time, = -4 h 44 m 7.200 s

Boston LMSoT = 19:18:59.757 - 4:44:7.2000 = 14:34:52.557

The original poster could simplify the procedure, depending on the actual accuracy needed. In particular, UTC is always within 0.9 s of UT1, so if accuracy to the second is not required, the step of looking up UT1 - UTC could be skipped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM