How to use the skyfield.almanac 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 avpeery / Moon-Phase-Tracker / testing_seed_data.py View on Github external
def test_solstices():
    """Creates seasonal solstices in test database"""

    t0 = TS.utc(2020, 1, 1)
    t1 = TS.utc(2020, 12, 31)
    t, y = almanac.find_discrete(t0, t1, almanac.seasons(E))

    dates = t.utc_iso()
    solstice_names = [almanac.SEASON_EVENTS[yi] for yi in y]

    for (date, solstice_name) in zip(dates, solstice_names):
        date = date[:10]
        date = datetime.strptime(date, '%Y-%m-%d')

        solstice_occurence = Solstice(title = solstice_name, start = date)      
        
        db.session.add(solstice_occurence)

    db.session.commit()
github avpeery / Moon-Phase-Tracker / testing_seed_data.py View on Github external
def test_solstices():
    """Creates seasonal solstices in test database"""

    t0 = TS.utc(2020, 1, 1)
    t1 = TS.utc(2020, 12, 31)
    t, y = almanac.find_discrete(t0, t1, almanac.seasons(E))

    dates = t.utc_iso()
    solstice_names = [almanac.SEASON_EVENTS[yi] for yi in y]

    for (date, solstice_name) in zip(dates, solstice_names):
        date = date[:10]
        date = datetime.strptime(date, '%Y-%m-%d')

        solstice_occurence = Solstice(title = solstice_name, start = date)      
        
        db.session.add(solstice_occurence)

    db.session.commit()
github avpeery / Moon-Phase-Tracker / testing_seed_data.py View on Github external
def test_moon_phase_occurences():
    """Creates moon phase occurences in test database"""

    t0 = TS.utc(2020, 1, 1)
    t1 = TS.utc(2020, 12, 31)
    t, y = almanac.find_discrete(t0, t1, almanac.moon_phases(E))

    dates = t.utc_iso()
    moon_phase_names = [almanac.MOON_PHASES[yi] for yi in y]

    moon_phase_type = MoonPhaseType.query.first()
    full_moon_nickname = FullMoonNickname.query.first()

    for (date, moon_phase_name) in zip(dates, moon_phase_names):
        if moon_phase_name == 'Full Moon':
            date = date[:10]
            date = datetime.strptime(date, '%Y-%m-%d')
            if date.month == 1:
                moon_phase_occurence = MoonPhaseOccurence(start = date, moon_phase_type_id = moon_phase_type.moon_phase_type_id, full_moon_nickname_id = full_moon_nickname.full_moon_nickname_id)
            else:
                moon_phase_occurence = MoonPhaseOccurence(start = date, moon_phase_type_id = moon_phase_type.moon_phase_type_id)
            db.session.add(moon_phase_occurence)
github avpeery / Moon-Phase-Tracker / seed.py View on Github external
def load_solstices():
    """Uses skyfield library to calculate season solstices, and add to database"""

    t0 = TS.utc(2000, 1, 1)
    t1 = TS.utc(2050, 12, 31)
    t, y = almanac.find_discrete(t0, t1, almanac.seasons(E))

    dates = t.utc_iso()
    solstice_names = [almanac.SEASON_EVENTS[yi] for yi in y]

    for (date, solstice_name) in zip(dates, solstice_names):
        date = date[:10]
        date = datetime.strptime(date, '%Y-%m-%d')

        solstice_occurence = Solstice(title=solstice_name, start=date)      
        
        db.session.add(solstice_occurence)

    db.session.commit()
github avpeery / Moon-Phase-Tracker / seed.py View on Github external
def load_moon_phase_occurences():
    """Adds specific moon phase occurences from file to moon phase occurences table"""

    t0 = TS.utc(2000, 1, 1)
    t1 = TS.utc(2050, 12, 31)
    t, y = almanac.find_discrete(t0, t1, almanac.moon_phases(E))

    dates = t.utc_iso()
    moon_phase_names = [almanac.MOON_PHASES[yi] for yi in y]

    for (date, moon_phase_name) in zip(dates, moon_phase_names):
        date = date[:10]
        date = datetime.strptime(date, '%Y-%m-%d')

        moon_phase_type = MoonPhaseType.query.filter(MoonPhaseType.title == moon_phase_name).first()

        if moon_phase_type.title == 'Full Moon':
            full_moon_nickname = FullMoonNickname.query.filter(FullMoonNickname.nickname_month == date.month).first()

            moon_phase_occurence = MoonPhaseOccurence(start=date, moon_phase_type_id=moon_phase_type.moon_phase_type_id, full_moon_nickname_id=full_moon_nickname.full_moon_nickname_id)
        else:
            moon_phase_occurence = MoonPhaseOccurence(start=date, moon_phase_type_id=moon_phase_type.moon_phase_type_id)
github akkana / scripts / comet.py View on Github external
def print_event_table(observer, cometvec, alm, t0, t1):
    """For debugging, Print a chromological table of all rise/set events.
       Harder to read but useful for debugging and guaranteed to
       be in chronological order.
    """
    t, y = almanac.find_discrete(t0, t1, alm)
    for ti, yi in zip(t, y):
        alt, az, distance = \
            observer.at(ti).observe(cometvec).apparent().altaz()
        t = ti.utc_datetime().astimezone()
        d = t.strftime("%Y-%m-%d")
        print("Rise" if yi else " Set", d, t.strftime("%H:%M %Z"),
              "%3d°%2d'" % az.dms()[:2])
github peopledoc / workalendar / workalendar / astronomy.py View on Github external
def calculate_equinoxes(year, timezone='UTC'):
    """ calculate equinox with time zone """
    tz = pytz.timezone(timezone)

    load = Loader(get_skyfield_data_path())
    ts = load.timescale()
    planets = load('de421.bsp')

    t0 = ts.utc(year, 1, 1)
    t1 = ts.utc(year, 12, 31)
    datetimes, _ = almanac.find_discrete(t0, t1, almanac.seasons(planets))
    vernal_equinox = datetimes[0].astimezone(tz).date()
    autumn_equinox = datetimes[2].astimezone(tz).date()
    return vernal_equinox, autumn_equinox
github avpeery / Moon-Phase-Tracker / seed.py View on Github external
def load_moon_phase_occurences():
    """Adds specific moon phase occurences from file to moon phase occurences table"""

    t0 = TS.utc(2000, 1, 1)
    t1 = TS.utc(2050, 12, 31)
    t, y = almanac.find_discrete(t0, t1, almanac.moon_phases(E))

    dates = t.utc_iso()
    moon_phase_names = [almanac.MOON_PHASES[yi] for yi in y]

    for (date, moon_phase_name) in zip(dates, moon_phase_names):
        date = date[:10]
        date = datetime.strptime(date, '%Y-%m-%d')

        moon_phase_type = MoonPhaseType.query.filter(MoonPhaseType.title == moon_phase_name).first()

        if moon_phase_type.title == 'Full Moon':
            full_moon_nickname = FullMoonNickname.query.filter(FullMoonNickname.nickname_month == date.month).first()

            moon_phase_occurence = MoonPhaseOccurence(start=date, moon_phase_type_id=moon_phase_type.moon_phase_type_id, full_moon_nickname_id=full_moon_nickname.full_moon_nickname_id)
        else:
            moon_phase_occurence = MoonPhaseOccurence(start=date, moon_phase_type_id=moon_phase_type.moon_phase_type_id)         
        
        db.session.add(moon_phase_occurence)