def __init__(self, window_name): self.window_name = window_name self.solar_system = solarsystem.Heliocentric(Data.year, Data.month, Data.day, Data.hour, Data.minute, 0, view='rectangular') self.planet_name = self.solar_system.planetnames() self.positions = [] for key in self.solar_system.planets(): self.positions.append(self.solar_system.planets()[key]) self.name_and_coords = {}
# # Planets positioning # # Getting the current time now = datetime.datetime.utcnow() year = now.year month = now.month day = now.day hour = now.hour minute = now.minute # Getting the current positions of the planets H = solarsystem.Heliocentric(year=year, month=month, day=day, hour=hour, minute=minute, view='rectangular') planets = H.planets() # Deleting useless plane del planets["Pluto"] del planets["Ceres"] del planets["Chiron"] del planets["Eris"] for planet_name in planets: # Getting the position of the planet pos = planets[planet_name] x = pos[0]
def __init__(self, innerplanet, outerplanet, time): """ Parameters: innerplanet (str): name of inner planet outerplanet (str): name of outer planet time (datetime): timestamp (UTC) """ self.innerplanet = innerplanet.capitalize() self.outerplanet = outerplanet.capitalize() self.time = time #Get heliocentric ecliptic planet positions at time: #(Longitude (l, deg), Latitude (b, deg), Distance (r, AU)) H = solarsystem.Heliocentric(year=time.year, month=time.month, day=time.day, hour=time.hour, minute=time.minute + time.second / 60 + time.microsecond / 1e6) planets = H.planets() #Get heliocentric ecliptic planet positions: #(Longitude (l, deg), Latitude (b, deg), Distance (r, AU)) O = planets[outerplanet] I = planets[innerplanet] E = planets["Earth"] #Convert to spherical position vector: #[r (AU, b (radians), l (radians)] rvec = lambda P: np.array( [P[2], P[1] * np.pi / 180, P[0] * np.pi / 180]) rO = rvec(O) rI = rvec(I) rE = rvec(E) #Convert to Cartesian coordinates (x,y,z in AU) xvec = lambda rP: np.array([ rP[0] * np.cos(rP[1]) * np.cos(rP[2]), rP[0] * np.cos(rP[1]) * np. sin(rP[2]), rP[0] * np.sin(rP[1]) ]) xO = xvec(rO) xI = xvec(rI) xE = xvec(rE) #Get positions relative to outer planet xO_Sun = -xO xO_I = xI - xO xO_E = xE - xO #Align x-axis with Sun for relative planet positions #With two rotation matrices: x' = BAx A = np.array([[-np.cos(rO[2]), -np.sin(rO[2]), 0], [np.sin(rO[2]), -np.cos(rO[2]), 0], [0, 0, 1]]) B = np.array([[np.cos(rO[1]), 0, -np.sin(rO[1])], [0, 1, 0], [np.sin(rO[1]), 0, np.cos(rO[1])]]) BA = np.matmul(B, A) xvecprime = lambda xO_P: np.matmul(BA, xO_P) xO_Sun_prime = xvecprime(xO_Sun) #Passes a sanity check xO_I_prime = xvecprime(xO_I) xO_E_prime = xvecprime(xO_E) self.xSun = xO_Sun_prime self.xI = xO_I_prime self.xE = xO_I_prime #Convert back to spherical coordinates #for on-sky positions as seen from O [r (AU,b (radians),l (radians)] rvecprime = lambda xvecp: np.array([ np.sqrt(np.sum(xvecp**2.)), np.arctan(xvecp[2] / np.sqrt(np.sum(xvecp[:2]**2))), -np.arctan( xvecp[1] / xvecp[0]) ]) rO_Sun_prime = rvecprime(xO_Sun_prime) #Passes a sanity check rO_I_prime = rvecprime(xO_I_prime) #Passes a sanity check rO_E_prime = rvecprime(xO_E_prime) #Praise Boas! self.rSun = rO_Sun_prime self.rI = rO_I_prime self.rE = rO_I_prime #Angular separation between inner planet and Sun (radians) self.theta = np.arccos( np.dot(xO_Sun_prime, xO_I_prime) / (rO_Sun_prime[0] * rO_I_prime[0])) #Angular diameters of inner planet and Sun (radians) self.angdiam_Sun = 2 * const.R_sun.to(u.AU) / (rO_Sun_prime[0] * u.AU) self.angdiam_I = planetdiameter[innerplanet] * u.km.to( u.AU) / rO_I_prime[0] #Are we in transit? self.intransit = ((self.theta < (self.angdiam_Sun + self.angdiam_I) / 2.) & (rO_I_prime[0] < rO_Sun_prime[0])) #Fraction of distance toward Solar limb (0 at center) r = self.theta / (self.angdiam_Sun / 2.0) self.mu = np.sqrt(1 - r**2.) #Light travel time delay to Earth (seconds) self.timedelay = ((rO_I_prime[0] + rO_E_prime[0]) * u.AU / const.c).to( u.s).value
'Eris': (23.567429379498012, -11.726867709299205, 95.9913888974132) } year = 2020 month = 1 day = 1 hour = 12 minute = 0 UT = 0 dst = 0 view = 'horizontal' H = solarsystem.Heliocentric(year=year, month=month, day=day, hour=hour, minute=minute, UT=UT, dst=dst, view=view) planets = H.planets() view = 'rectangular' H = solarsystem.Heliocentric(year=year, month=month, day=day, hour=hour, minute=minute, UT=UT, dst=dst, view=view) planets2 = H.planets()