def getkepRV(phases, ecc, omega, gamma, K): ks = pyasl.MarkleyKESolver() # Initializes the Keplarian Solver #theta = [] # Makes empty list for theta NOT NEEDED KepRVCurve = [] # Makes empty list for RV curve data ## Run Keplarian solver MarkleyKESolver() to find the mean anomaly as a function ## of phase [M_ph], the eccentric anomaly E_ph, and the True anomaly, Tru, or ## theta, the missing piece of the RV curve calculation for phase in phases: # Loop over phases MeAn = 2. * np.pi * phase # Solve for mean anomaly, M(phase) EcAn = ks.getE(MeAn, ecc) # Solve for eccentric anomaly, E # Compute the true anomaly cosTru = (np.cos(EcAn) - ecc) / (1 - ecc * np.cos(EcAn)) sinTru = (np.sqrt(1 - ecc**2) * np.sin(EcAn)) / (1 - ecc * np.cos(EcAn)) Tru = np.arctan2(sinTru, cosTru) RV = gamma + K * (ecc * np.cos(omega) + np.cos(Tru + omega)) ## How exciting, now we've got all the pieces needed to solve for the Keplarian ## projected RV curve! #result = np.add(system,costhetaplusomega) # NO THIS WON'T WORK KepRVCurve.append(RV) # add RV curve to the empty list return KepRVCurve
def front(): if request.method == 'GET': return render_template("front.html") else: ks = pyasl.MarkleyKESolver() sat_no = request.form['sat_no'] df = pd.read_csv('sornew.csv') df = df.loc[df['PRN'] == int(sat_no)] df = df[['Del_n', 'e', 'sqrt(A)', 'i0', 'omega', 'M0']] M0 = df['M0'].values[0] e = df['e'].values[0] print("Eccentric anomaly: ", ks.getE(M0, e)) for col in df.columns: df1 = df[[col]] # df1 = df1.loc[:,len(df1)] plt.xlabel(col) plt.plot(df1) plt.savefig('static/plot/' + col + '.png', format='png') plt.cla() Image_folder = os.path.join('static', 'plot') return render_template("root.html")
def XYZf(t, T0, P, e, omegaA, OmegaL, a, i): #position ks = pyasl.MarkleyKESolver() n = 2 * np.pi / P M = n * (t - T0) Ea = [] for Meach in M: Eeach = ks.getE(Meach, e) #eccentric anomaly Ea.append(ks.getE(Meach, e)) Ea = np.array(Ea) cosE = np.cos(Ea) cosf = (-cosE + e) / (-1 + cosE * e) sinf = np.sqrt((-1 + cosE * cosE) * (-1 + e * e)) / (-1 + cosE * e) mask = (Ea < np.pi) sinf[mask] = -sinf[mask] cosoA = np.cos(omegaA) sinoA = np.sin(omegaA) cosOL = np.cos(OmegaL) sinOL = np.sin(OmegaL) cosfoA = cosf * cosoA - sinf * sinoA sinfoA = cosf * sinoA + sinf * cosoA r = a * (1.0 - e * e) / (1.0 + e * cosf) X = r * (cosfoA * cosOL - np.cos(i) * sinfoA * sinOL) Y = r * (np.cos(i) * cosOL * sinfoA + cosfoA * sinOL) Z = r * (np.sin(i) * sinfoA) return X, Y, Z
def ma2ea(self, ma): ks = pyasl.MarkleyKESolver() if isinstance(ma, float): ea = ks.getE(ma, self.ecc) else: ea_list = [ks.getE(_ma, self.ecc) for _ma in ma] ea = np.array(ea_list) return ea
def eccentric_anomaly_function(time, ellipticity, t_periastron, speed): ks = pyasl.MarkleyKESolver() eccentricities = [] for t in time: phase = speed * (t - t_periastron) phase = phase % (2 * np.pi) ecc = ks.getE(phase, ellipticity) eccentricities.append(ecc) return eccentricities
def rvs_keplerian(times, K, period, ecc, omega, t0=None, tau=None): if t0 is None and tau is None: print ('# give either t0 or rau.') return None if tau is None: E0 = 2*np.arctan(np.sqrt((1.-ecc)/(1.+ecc))*np.tan(0.25*np.pi-0.5*omega)) M = E0 - ecc*np.sin(E0) + 2*np.pi*(times-t0)/period elif t0 is None: M = 2*np.pi*(times-tau)/period ks = pyasl.MarkleyKESolver() E = np.array([ks.getE(_m, ecc) for _m in M]) f = 2*np.arctan(np.sqrt((1.+ecc)/(1.-ecc))*np.tan(0.5*E)) rvs = K*(np.cos(omega+f)+ecc*np.cos(omega)) return rvs
def rvcoref(t, T0, P, e, omegaA, K, i): # semi amplitude is defined by K*sin(i) ks = pyasl.MarkleyKESolver() n = 2 * np.pi / P M = n * (t - T0) Ea = [] for Meach in M: Eeach = ks.getE(Meach, e) #eccentric anomaly Ea.append(ks.getE(Meach, e)) Ea = np.array(Ea) cosE = np.cos(Ea) cosf = (-cosE + e) / (-1 + cosE * e) sinf = np.sqrt((-1 + cosE * cosE) * (-1 + e * e)) / (-1 + cosE * e) mask = (Ea < np.pi) sinf[mask] = -sinf[mask] cosfpo = cosf * np.cos(omegaA) - sinf * np.sin(omegaA) face = 1.0 / np.sqrt(1.0 - e * e) Ksini = K * np.sin(i) model = Ksini * face * (cosfpo + e * np.cos(omegaA)) return model
###################### ## functions for plotting orbits ###################### import numpy as np from PyAstronomy import pyasl ks = pyasl.MarkleyKESolver() def orbit_model(a, e, inc, w, bigw, P, T, t): #plot results A = a * (np.cos(bigw) * np.cos(w) - np.sin(bigw) * np.cos(inc) * np.sin(w)) B = a * (np.sin(bigw) * np.cos(w) + np.cos(bigw) * np.cos(inc) * np.sin(w)) F = a * (-np.cos(bigw) * np.sin(w) - np.sin(bigw) * np.cos(inc) * np.cos(w)) G = a * (-np.sin(bigw) * np.sin(w) + np.cos(bigw) * np.cos(inc) * np.cos(w)) #Calculate the mean anamoly for each t in model: t0 = np.linspace(t[0], t[0] + P, 1000) M = [] for i in t0: m_anom = 2 * np.pi / P * (i - T) M.append(m_anom) M = np.asarray(M) #eccentric anamoly calculated for each t (using kepler function): E = [] for j in M: e_anom = ks.getE(j, e) E.append(e_anom) E = np.asarray(E)