def astronomical_dates(year): y = str(year) march = ephem.next_spring_equinox(y).datetime().date() june = ephem.next_summer_solstice(y).datetime().date() sept = ephem.next_autumn_equinox(y).datetime().date() dec = ephem.next_winter_solstice(y).datetime().date() return dict(march=march, june=june, sept=sept, dec=dec)
def EquinoxSolsticeJD(year, angle): if 0 <= angle < 90: date = ephem.next_vernal_equinox(year) elif 90 <= angle < 180: date = ephem.next_summer_solstice(year) elif 180 <= angle < 270: date = ephem.next_autumn_equinox(year) else: date = ephem.next_winter_solstice(year) JD = ephem.julian_date(date) return JD
def annee_de_la_revolution(date): """ Find corresponding revolutionnary year of current date """ # Time are in UT (time at Greenwich meridian, so 0°) # but we want the equinox at Paris meridian time so 2°20'13,82" (the one used in 1792) # using the IGN value 2°20'13,82", add 14ms... # see http://geodesie.ign.fr/contenu/fichiers/Meridiens_greenwich_paris.pdf (fr) # => +0.15581138888888888888 hour == .00649214120370370370 lasteq = ephem.Date(ephem.previous_autumn_equinox(date) + 0.00649214120370370370) nexteq = ephem.Date(ephem.next_autumn_equinox(date) + 0.00649214120370370370) # print(lasteq, nexteq) neq_dt = nexteq.datetime() if neq_dt.year == date.year and neq_dt.month == date.month and neq_dt.day == date.day: #the autumn equinox is the day we ask for (but after 00:00), so the lasteq is the current day lasteq = nexteq year = ((lasteq - ephem.Date(FRENCH_REVOLUTIONARY_EPOCH)) / TROPICAL_YEAR) + 1 return (int(year), lasteq.datetime().date())
def update(self): date = ephem.Date(datetime.now().date()) self.seasondata.update({ 'Autumnal (Fall) Equinox': ephem.next_autumn_equinox(date).datetime().date() }) self.moondata.update({ 'First Quarter': ephem.next_first_quarter_moon(date).datetime().date() }) self.moondata.update( {'Full Moon': ephem.next_full_moon(date).datetime().date()}) self.moondata.update({ 'Last Quarter': ephem.next_last_quarter_moon(date).datetime().date() }) self.moondata.update( {'New Moon': ephem.next_new_moon(date).datetime().date()}) self.seasondata.update({ 'Vernal (Spring) Equinox': ephem.next_spring_equinox(date).datetime().date() }) self.seasondata.update({ 'Summer Solstice': ephem.next_summer_solstice(date).datetime().date() }) self.seasondata.update({ 'Winter Solstice': ephem.next_winter_solstice(date).datetime().date() }) moon_keys = sorted(self.moondata.keys(), key=lambda y: (self.moondata[y])) moon_keys.reverse() b = {} state1 = True while moon_keys: a = moon_keys.pop() b.update({a: self.moondata[a]}) if self.moondata[a] != datetime.now().date() and state1: self.nextphase = [ a, self.moondata[a], daysaway(self.moondata[a]) ] state1 = False if self.moondata[a] == datetime.now().date(): self.currentphase = a ##### elif self.moondata = b season_keys = sorted(self.seasondata.keys(), key=lambda y: (self.seasondata[y])) season_keys.reverse() b = {} state2 = True while season_keys: a = season_keys.pop() b.update({a: self.seasondata[a]}) if self.seasondata[a] != datetime.now().date() and state2: self.nextseason = [ a, self.seasondata[a], daysaway(self.seasondata[a]) ] state2 = False self.seasondata = b if self.nextphase[0] == 'Last Quarter' and datetime.now().date( ) < self.nextphase[1]: self.currentphase = 'Waning Gibbus' if self.nextphase[0] == 'Last Quarter' and datetime.now().date( ) == self.nextphase[1]: self.currentphase = 'Last Quarter' if self.nextphase[0] == 'New Moon' and datetime.now().date( ) < self.nextphase[1]: self.currentphase = 'Waning Crescent' if self.nextphase[0] == 'New Moon' and datetime.now().date( ) == self.nextphase[1]: self.currentphase = 'New Moon' if self.nextphase[0] == 'First Quarter' and datetime.now().date( ) < self.nextphase[1]: self.currentphase = 'Waxing Crescent' if self.nextphase[0] == 'First Quarter' and datetime.now().date( ) == self.nextphase[1]: self.currentphase = 'First Quarter' if self.nextphase[0] == 'Full Moon' and datetime.now().date( ) < self.nextphase[1]: self.currentphase = 'Waxing Gibbus' if self.nextphase[0] == 'Full Moon' and datetime.now().date( ) == self.nextphase[1]: self.currentphase = 'Full Moon'
import ephem year = 1923 while year <= 1924: print(year) eq1 = ephem.next_spring_equinox(str(year)) eq3 = ephem.next_autumn_equinox(str(year)) eq2 = ephem.next_summer_solstice(str(year)) eq4 = ephem.next_winter_solstice(str(year)) eq5 = ephem.next_spring_equinox(str(year + 1)) print("spring equinox: %s" % eq1) da = eq1 while da < eq2: fm = ephem.next_full_moon(da) if fm > eq2: break print(" full moon: %s" % fm) da = fm print("summer solstice: %s" % eq2) da = eq2 while da < eq3: fm = ephem.next_full_moon(da) if fm > eq3: break print(" full moon: %s" % fm) da = fm print("autumn equinox: %s" % eq3) while da < eq4: fm = ephem.next_full_moon(da) if fm > eq4: break print(" full moon: %s" % fm)