def _get_season(self): return min( (ephem.localtime(ephem.next_equinox(self.day_as_dt)) - self.day_as_dt).days, (self.day_as_dt - ephem.localtime(ephem.previous_equinox(self.day_as_dt))).days, (ephem.localtime(ephem.next_solstice(self.day_as_dt)) - self.day_as_dt).days, (self.day_as_dt - ephem.localtime(ephem.previous_solstice(self.day_as_dt))).days)
Created on 15 Dec 2013 @author: demetersztanko ''' from math import sin, cos, sqrt, atan2, radians, degrees import ephem # Radius of the earth R = 6373000.0 winterSolsticeDate = ephem.next_solstice('2014') stats = {'totalLength': 0.0, 'solsticeLength': 0.0, 'hist': []} stats['hist'] = [0.0 for i in range(0, 181)] dates = { 'winterSolstice': ephem.previous_solstice('2014'), 'summerSolstice': ephem.next_solstice('2014') } azimuthCache = dict() def getLength(segment): lat1 = radians(segment[0][1]) lon1 = radians(segment[0][0]) lat2 = radians(segment[1][1]) lon2 = radians(segment[1][0]) dlon = lon2 - lon1 dlat = lat2 - lat1
from datetime import * import ephem import abysmal """if I am going to package this for anyone else to use, i am going to need to package pyephem as well""" #define days & years today = date.today() working_date = datetime.today() #define solstices & equinoxes last_solstice = ephem.previous_solstice(today) #calculate solstice date last_solstice = last_solstice.datetime() #convert to datetime previous_equinox = ephem.previous_equinox(today) #calculate equinox date previous_equinox = previous_equinox.datetime() #convert to datetime next_solstice = ephem.next_solstice(today) #calculate solstice date next_solstice = next_solstice.datetime() #convert to datetime next_equinox = ephem.next_equinox(today) #calculate equinox date next_equinox = next_equinox.datetime() #convert to datetime #calculate cross-quarter high days def cross_quarter(last, next): midpoint = abs((next - last)) / 2 midpoint = next - midpoint if last < midpoint < next: #this insures that midpoint falls between return midpoint #the two endpoints else: midpoint = abs((next - last)) / 2 midpoint = last - midpoint
Created on 15 Dec 2013 @author: demetersztanko ''' from math import sin, cos, sqrt, atan2, radians, degrees import ephem # Radius of the earth R = 6373000.0 winterSolsticeDate = ephem.next_solstice('2014') stats= {'totalLength': 0.0, 'solsticeLength': 0.0, 'hist': []} stats['hist'] = [0.0 for i in range(0, 181)] dates = { 'winterSolstice': ephem.previous_solstice('2014'), 'summerSolstice': ephem.next_solstice('2014') } azimuthCache = dict() def getLength(segment): lat1 = radians(segment[0][1]) lon1 = radians(segment[0][0]) lat2 = radians(segment[1][1]) lon2 = radians(segment[1][0]) dlon = lon2 - lon1 dlat = lat2 - lat1 a = (sin(dlat / 2)) ** 2 + cos(lat1) * cos(lat2) * (sin(dlon / 2)) ** 2
from datetime import * import ephem import abysmal """if I am going to package this for anyone else to use, i am going to need to package pyephem as well""" #define days & years today = date.today() working_date = datetime.today() #define solstices & equinoxes last_solstice = ephem.previous_solstice(today) #calculate solstice date last_solstice = last_solstice.datetime() #convert to datetime previous_equinox = ephem.previous_equinox(today) #calculate equinox date previous_equinox = previous_equinox.datetime() #convert to datetime next_solstice = ephem.next_solstice(today) #calculate solstice date next_solstice = next_solstice.datetime() #convert to datetime next_equinox = ephem.next_equinox(today) #calculate equinox date next_equinox = next_equinox.datetime() #convert to datetime #calculate cross-quarter high days def cross_quarter(last, next): midpoint=abs((next-last))/2 midpoint=next-midpoint if last < midpoint < next: #this insures that midpoint falls between return midpoint #the two endpoints else: midpoint=abs((next-last))/2 midpoint=last-midpoint
import ephem #establish today today = date.today() working_date = datetime.today() secondzerozero = ephem.Date( '2010/12/21') #full moon total lunar eclipse on winter solstice s00 = secondzerozero.datetime() #convert it to format that can math #establish date of origin pin = ephem.next_solstice('2010/12/20') #establish date of origin strip_pin = pin.datetime() #convert to datetime for calculations #print strip_pin #define solstices & equinoxes last_solstice = ephem.previous_solstice(working_date) #calculate solstice date last_solstice = last_solstice.datetime() #convert to datetime #print last_solstice #calculates the time between two dates. def daily_difference(first, second): #calculate number of days x = abs(second.date() - first.date()) #remove timedelta stamp daily_difference = x.days #produce results return daily_difference def get_Abysmal_Date(y):
# -*- coding: utf-8 -*- """ Created on Sat Jun 13 14:02:04 2020 https://rhodesmill.org/pyephem/quick.html#equinoxes-solstices @author: PC """ import ephem d1 = ephem.next_equinox('2000') print(d1) d2 = ephem.next_solstice(d1) print(d2) t = d2 - d1 print("Spring lasted %.1f days" % t) print(ephem.previous_solstice('2000')) print(ephem.next_solstice('2000')) print(ephem.previous_equinox('2000')) print(ephem.next_equinox('2000')) print(ephem.previous_vernal_equinox('2000')) print(ephem.next_vernal_equinox('2000'))
def ecliptlong(year, month, day, do_print=False): # See https://en.wikipedia.org/wiki/Position_of_the_Sun#Ecliptic_coordinates # Days since Jan 1, 2000: n = sum(list(gcal2jd(year,month,day)) + [0.5]) - 2451545.0 L = 280.460 + 0.9856474 * n while L > 360.: L -= 360. while L < 0.: L += 360. L_rad = (L / 180.) * pi g = 357.528 + 0.9856003 * n while g > 360.: g -= 360. while g < 0.: g += 360. g_rad = (g / 180.) * pi lam = L + 1.915 * sin(g_rad) + 0.020 * sin(2*g_rad) while lam > 360.: lam -= 360. if (do_print): seasons = { 0:'SPRING', 1:'SUMMER', 2:'AUTUMN', 3:'WINTER' } astrosign = lam / 30. octant = lam / 45. season = seasons[int(octant//2) % 4] xquarter = seasons[((octant+1)%8)//2] print("For day = {:04}/{:02}/{:02}:".format(year, month,day)) print("ecliptic longitude =", lam) print("astrological sign position =", astrosign) print("ecliptic octant =", octant) print("astronomical season =", season) print("cross-quarter season =", xquarter) try: from convertdate import persian pyear, pmonth, pday = persian.from_gregorian(year, month, day) print("Persian date = {} {}, {}".format(pday, {1:'aries', 2:'taurus', 3:'gemini', 4:'cancer', 5:'leo', 6:'virgo', 7:'libra', 8:'scorpio', 9:'sagittarius', 10:'capricorn', 11:'aquarius', 12:'pisces'}[pmonth], pyear)) except: pass try: import ephem sun = ephem.Sun() ymdstr = "{:04}/{:02}/{:02}".format(year, month, day) sun.compute(ymdstr, ymdstr) eph_lam = float(ephem.Ecliptic(sun).lon) / pi * 180. eph_sign = eph_lam / 30. print("ephem ecliptic longitude =", eph_lam) print("ephem astrological sign position =", eph_sign) print("ephem previous solstice =", ephem.previous_solstice(ymdstr)) print("ephem previous equinox =", ephem.previous_equinox(ymdstr)) print("ephem next solstice =", ephem.next_solstice(ymdstr)) print("ephem next equinox =", ephem.next_equinox(ymdstr)) except: pass return lam
from datetime import * import ephem #establish today today = date.today() working_date = datetime.today() secondzerozero = ephem.Date('2012/12/21') s00 = secondzerozero.datetime() #establish date of origin pin = ephem.next_solstice('2012')#establish date of origin strip_pin = pin.datetime() #convert to datetime for calculations #define solstices & equinoxes last_solstice = ephem.previous_solstice(working_date) #calculate solstice date last_solstice = last_solstice.datetime() #convert to datetime #calculates the time between two dates. def daily_difference(first, second): #calculate number of days x = abs(second.date()- first.date()) #remove timedelta stamp daily_difference = x.days #produce results return daily_difference def get_Abysmal_Date(y): year = y.year month = '12' year = str(y.year)