How to use the skyfield.almanac.find_discrete function in skyfield

To help you get started, we’ve selected a few skyfield examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github skyfielders / python-skyfield / design / satellite_passes.py View on Github external
print(' ', ti.utc_jpl(), yi)

offset = 0
assert list(y[offset:offset+3]) == [0, 1, 2]

pass_start, pass_end = t[offset+0], t[offset+2]

def f(t):
    length = t.tt.shape[0]
    t._nutation_angles = iau2000b(t.tt)
    return sat.at(t).is_sunlit(eph)

f.rough_period = 0.001

T0 = time()
t2, y2 = almanac.find_discrete(pass_start, pass_end, f, epsilon=half_second)
print(time() - T0, 'seconds to find moment of entering shadow:')

for ti, yi in zip(t2, y2):
    print(' ', ti.utc_jpl(), 'entered sunlight' if yi else 'entered shadow')

one_second = 1.0 / 24.0 / 3600.0
tt = np.arange(pass_start.tt, pass_end.tt, one_second)

T0 = time()
t = ts.tt_jd(tt)
t._nutation_angles = iau2000b(t.tt)
satpos = (sat - topos).at(t)
is_sunlit = satpos.is_sunlit(eph)
DT = time() - T0

print(DT, 'to compute is_sunlit() for every second of {}-second pass'
github akkana / scripts / comet.py View on Github external
def find_twilights(adate, alm_twilights):
    """Find twilight times at dawn and dusk on the given day.
       Return a skyvec Time.
    """

    # Convert to an aware datetime in the local timezone
    t0 = adate.utc_datetime().astimezone()

    # Start at midnight
    t0 = t0.replace(hour=0, minute=0, second=0, microsecond=0)
    t1 = t0 + timedelta(days=1)

    times, events = almanac.find_discrete(ts.utc(t0), ts.utc(t1),
                                              alm_twilights)

    twilights = []
    # Using Astronomical twilight makes sense, but maybe the
    # user wants to be a little more ambitious in searching
    for i, e in enumerate(events):
        if almanac.TWILIGHTS[e] == WHICH_TWILIGHT:
            twilights.append(times[i])

    return twilights
github akkana / scripts / comet.py View on Github external
def print_rises_sets(observer, cometvec, alm, t0, t1):
    """Print rises and sets in separate columns, easier to read."""
    t, y = almanac.find_discrete(t0, t1, alm)

    fmt = "%-10s    %-10s %-8s   %-10s %-8s   %-14s"
    print(fmt % ("Date", "Rise", "Azimuth", "Set", "Azimuth",
                 "Distance"))

    def reset_strings():
        nonlocal risetime, riseaz, settime, setaz, datestr
        risetime = ''
        riseaz = ''
        settime = ''
        setaz = ''
        datestr = ''

    reset_strings()

    for ti, yi in zip(t, y):