コード例 #1
0
def annual_jp_seasonal_days(year):

    ref = ephem.previous_winter_solstice(str(year)) + 0.01

    result = []

    # Setsubun (節分, the day before the start of spring)
    result.append(
        (101, pytz.utc.localize(solar_term_finder(ref, 0).datetime()) -
         timedelta(days=1)))

    # Hachiju-hachi-ya (八十八夜, the 88th night after the start of spring)
    result.append(
        (102, pytz.utc.localize(solar_term_finder(ref, 0).datetime()) +
         timedelta(days=87)))

    # Nihyaku-toka (二百十日, the 210th day after the start of spring)
    result.append(
        (103,
         pytz.utc.localize(
             solar_term_finder(ref, 0).datetime() + timedelta(days=209))))

    # Nyubai (入梅, deg=80)
    result.append(
        (111, pytz.utc.localize(solar_term_finder_deg(ref, 80).datetime())))

    # Hangesho (半夏生, deg=100)
    result.append(
        (112, pytz.utc.localize(solar_term_finder_deg(ref, 100).datetime())))

    return result
コード例 #2
0
ファイル: Lich_EPHEM.py プロジェクト: huytuong010101/TuViAPI
def s2l(solarDate: ephem.Date, location: ephem.Observer,
        timezone: int) -> LUNAR_contract:
    solarDate += timezone * ephem.hour  # so we are working in the correct timezone

    lunar_leap = False

    previousNewMoon = ephem.previous_new_moon(solarDate)
    lunarDay = solarDate.day - ephem.Date(previousNewMoon).datetime().day + 1

    # Dong chi nam truoc
    previousWinterSolstice = ephem.previous_winter_solstice(solarDate)
    # Dong chi nam sau
    nextWinterSolstice = ephem.next_winter_solstice(solarDate)

    dayInLunarYear = ephem.previous_new_moon(
        nextWinterSolstice) - ephem.previous_new_moon(previousWinterSolstice)

    diff = int(dayInLunarYear / 29.)

    lunarMonth = diff + 11

    lunarYear = solarDate.year

    if dayInLunarYear > 365:
        lunar_leap = (lunarMonth == find_lunar_month_between(
            previousWinterSolstice, nextWinterSolstice))

    print(dayInLunarYear, previousWinterSolstice, nextWinterSolstice)
    return tuple(date(lunarYear, lunarMonth, lunarDay), lunar_leap)
コード例 #3
0
def annual_solar_terms(year,
                       boundary_previous=False,
                       boundary_following=False):

    ref = ephem.previous_winter_solstice(str(year)) + 0.01

    result = []
    for j in range(24):
        i = (j - 2) % 24
        d = pytz.utc.localize(solar_term_finder(ref, i).datetime())
        result.append((i, d))

    if boundary_previous:
        result.insert(
            0, (21,
                pytz.utc.localize(
                    solar_term_finder(ref, 21, reverse=True).datetime())))
        result.insert(
            0, (20,
                pytz.utc.localize(
                    solar_term_finder(ref, 20, reverse=True).datetime())))
    if boundary_following:
        ref2 = result[-1][1]
        result.append(
            (22, pytz.utc.localize(solar_term_finder(ref2, 22).datetime())))
        result.append(
            (23, pytz.utc.localize(solar_term_finder(ref2, 23).datetime())))

    return result
コード例 #4
0
def saveEquinoxDates(startDate):
    """ calculates the startdate of the equinoxs and solistices
    """
    spring = datetime.strptime(str(ephem.previous_spring_equinox(startDate)),
                               '%Y/%m/%d %H:%M:%S').strftime('%d.%m.%Y')
    summer = datetime.strptime(str(ephem.previous_summer_solstice(startDate)),
                               '%Y/%m/%d %H:%M:%S').strftime('%d.%m.%Y')
    autumn = datetime.strptime(str(ephem.previous_autumnal_equinox(startDate)),
                               '%Y/%m/%d %H:%M:%S').strftime('%d.%m.%Y')
    winter = datetime.strptime(str(ephem.previous_winter_solstice(startDate)),
                               '%Y/%m/%d %H:%M:%S').strftime('%d.%m.%Y')

    print_dbg(DEBUG, "current date    : %s" % startDate.strftime('%d.%m.%Y'))
    print_dbg(DEBUG, "spring_equinox  : %s" % spring)
    print_dbg(DEBUG, "summer_solstice : %s" % summer)
    print_dbg(DEBUG, "autumnal_equinox: %s" % autumn)
    print_dbg(DEBUG, "winter_solstice : %s" % winter)

    try:
        st = open(EQUINOX_OUT, 'w')
        s = spring + ' ' + summer + ' ' + autumn + ' ' + winter + '\n'
        st.write(s)
        st.close()

    except Exception as e:
        print_dbg(True, "saveEquinoxDates: Done with exception(s): %s." % e)

    return
コード例 #5
0
def annual_solar_terms(year):
    ref = ephem.previous_winter_solstice(str(year)) + 0.01
    result = []
    
    for j in range(24):
        i = (j - 2) % 24
        d = pytz.utc.localize(solar_term_finder(ref, i).datetime())
        result.append((i, d))

    return result
コード例 #6
0
def annual_jp_higan_days(year):

    ref = ephem.previous_winter_solstice(str(year)) + 0.01

    result = []
    for j in range(2):
        i = j * 12 + 3
        d = pytz.utc.localize(solar_term_finder(ref, i).datetime())
        result.append((j + 11, d - timedelta(days=3), d + timedelta(days=3)))

    return result
コード例 #7
0
def annual_jp_higan_days(year):

    ref = ephem.previous_winter_solstice(str(year)) + 0.01

    result = []
    for j in range(2):
        i = j * 12 + 3
        d = pytz.utc.localize(solar_term_finder(ref, i).datetime())
        result.append((j+11, 
                       d - timedelta(days=3),
                       d + timedelta(days=3)))

    return result
コード例 #8
0
def annual_jp_doyo_days(year):
    
    ref = ephem.previous_winter_solstice(str(year)) + 0.01

    result = []
    for j in range(4):
        deg_start = (j * 90 + 27 - 90) % 360
        deg_end = (j * 90 + 45 - 90) % 360
        result.append((j+1, 
                       pytz.utc.localize(solar_term_finder_deg(ref, deg_start).datetime()),
                       pytz.utc.localize(solar_term_finder_deg(ref, deg_end).datetime())))

    return result
コード例 #9
0
def annual_jp_doyo_days(year):

    ref = ephem.previous_winter_solstice(str(year)) + 0.01

    result = []
    for j in range(4):
        deg_start = (j * 90 + 27 - 90) % 360
        deg_end = (j * 90 + 45 - 90) % 360
        result.append(
            (j + 1,
             pytz.utc.localize(
                 solar_term_finder_deg(ref, deg_start).datetime()),
             pytz.utc.localize(solar_term_finder_deg(ref,
                                                     deg_end).datetime())))

    return result
コード例 #10
0
def annual_solar_terms(year, boundary_previous=False, boundary_following=False):

    ref = ephem.previous_winter_solstice(str(year)) + 0.01

    result = []
    for j in range(24):
        i = (j - 2) % 24
        d = pytz.utc.localize(solar_term_finder(ref, i).datetime())
        result.append((i, d))

    if boundary_previous:
        result.insert(0, (21, pytz.utc.localize(solar_term_finder(ref, 21, reverse=True).datetime())))
        result.insert(0, (20, pytz.utc.localize(solar_term_finder(ref, 20, reverse=True).datetime())))
    if boundary_following:
        ref2 = result[-1][1]
        result.append((22, pytz.utc.localize(solar_term_finder(ref2, 22).datetime())))
        result.append((23, pytz.utc.localize(solar_term_finder(ref2, 23).datetime())))

    return result
コード例 #11
0
def annual_jp_seasonal_days(year):

    ref = ephem.previous_winter_solstice(str(year)) + 0.01

    result = []
    
    # Setsubun (節分, the day before the start of spring)
    result.append((101, pytz.utc.localize(solar_term_finder(ref, 0).datetime()) - timedelta(days=1)))

    # Hachiju-hachi-ya (八十八夜, the 88th night after the start of spring)
    result.append((102, pytz.utc.localize(solar_term_finder(ref, 0).datetime()) + timedelta(days=87)))

    # Nihyaku-toka (二百十日, the 210th day after the start of spring)
    result.append((103, pytz.utc.localize(solar_term_finder(ref, 0).datetime() + timedelta(days=209))))
    
    # Nyubai (入梅, deg=80)
    result.append((111, pytz.utc.localize(solar_term_finder_deg(ref, 80).datetime())))

    # Hangesho (半夏生, deg=100)
    result.append((112, pytz.utc.localize(solar_term_finder_deg(ref, 100).datetime())))

    return result
コード例 #12
0
def specified_solar_term(year, solar_term_id):

    ref = ephem.previous_winter_solstice(
        str(year)
    ) + 37.5  # the reference point is between "major cold" and "start of spring"
    return pytz.utc.localize(solar_term_finder(ref, solar_term_id).datetime())
コード例 #13
0
def specified_solar_term(year, solar_term_id):

    ref = ephem.previous_winter_solstice(str(year)) + 37.5   # the reference point is between "major cold" and "start of spring"
    return pytz.utc.localize(solar_term_finder(ref, solar_term_id).datetime())