pythonastronomyskyfield

Is there a way to calculate transit times in Skyfield?


Skyfield currently offers a way to calculate rising and setting times of bodies. Does it offer a way to calculate the transit time of bodies?


Solution

  • Edit: Yes! Skyfield now directly supports transits, as described in a new section of its documentation:

    https://rhodesmill.org/skyfield/almanac.html#meridian-transits

    An example script:

    from skyfield import api
    from skyfield import almanac
    
    bluffton = api.Topos('40.8939 N', '83.8917 W')
    
    ts = api.load.timescale()
    t0 = ts.utc(2020, 11, 6)
    t1 = ts.utc(2020, 11, 7)
    
    eph = api.load('de421.bsp')
    f = almanac.meridian_transits(eph, eph['Mars'], bluffton)
    t, y = almanac.find_discrete(t0, t1, f)
    
    print(t.utc_strftime('%Y-%m-%d %H:%M'))
    print(y)
    print([almanac.MERIDIAN_TRANSITS[yi] for yi in y])
    

    And its output:

    ['2020-11-06 03:32', '2020-11-06 15:30']
    [1 0]
    ['Meridian transit', 'Antimeridian transit']