Пример #1
0
 def uFROMx(self,param , referenceTime, mass):               
     """ Under construction
     Summary:: 
         Return the vector u(x), Eq.(A.1) from Chauvin et al. (2012), from a given vector x = (a, e, i, Omega, w, tp).
     Arguments::
         
     Return::
                  
     """ 
     #param = np.array([8.8,0.021,88.5,45,78,2453846.3])
     
     if param[2] == 0.0:
         param[2] = 1e-12
     
     #w = math.radians(param['periastron'])
     #omega = math.radians(param['longitudeAscendingNode'])
     #i = math.radians(param['inclinaison'])        
     period = np.sqrt(4*np.power(np.pi,2)*np.power(param[0]*const.au.value,3) / (const.G.value * mass*const.M_sun.value)) / (3600.*24.*365) # given in years (365 days/year, 24hrs/day)
     
             
     # TODO: The calculus of the mean anomaly should be performed from the method 'trueAnomaly' defined in the class Orbit. Therefore, one needs to use the inheritance.
     if isinstance(referenceTime,str): 
         referenceTime = Time(referenceTime,format='iso',scale='utc').jd 
         
     if isinstance(param[5],str): 
         param[5] = Time(param[5],format='iso',scale='utc').jd    
         
     meanAnomaly = np.mod(2*np.pi * ((referenceTime-param[5])/365) / period, 2*np.pi)
     if param[1] <= 0.05: # then we use an approximate expression of E as a function of  M and e
         eccentricAnomaly = meanAnomaly + (param[1] - np.power(param[1],3)/8) * math.sin(meanAnomaly) + np.power(param[1],2)/2 * math.sin(2 * meanAnomaly) + 3*np.power(param[1],3)/8 * math.sin(3 * meanAnomaly)
     else: # otherwise, we use the Markley algorithm
         ks = MarkleyKESolver() # call the Kepler equation solver
         eccentricAnomaly = ks.getE(meanAnomaly,param[1])
     
     temp = 2 * math.atan(math.sqrt((1+param[1])/(1-param[1])) * math.tan(eccentricAnomaly / 2)) # TODO il faut tester l'unicité de la solution
     nu0 = np.mod(temp,2*np.pi)  
     #print('nu0 vaut',math.degrees(nu0))               
     
     u1 = np.cos(math.radians(param[4]) + math.radians(param[3]) + nu0) / period 
     u2 = np.sin(math.radians(param[4]) + math.radians(param[3]) + nu0) / period 
     
     u3 = param[1] / np.sqrt(1 - np.power(param[1],2)) * np.cos(math.radians(param[4]) + math.radians(param[3]))
     u4 = param[1] / np.sqrt(1 - np.power(param[1],2)) * np.sin(math.radians(param[4]) + math.radians(param[3]))
     
     u5 = np.power(1 - np.power(param[1],2),0.25) * np.sin(0.5 * math.radians(param[2])) * np.cos(math.radians(param[4]) - math.radians(param[3]))
     u6 = np.power(1 - np.power(param[1],2),0.25) * np.sin(0.5 * math.radians(param[2])) * np.sin(math.radians(param[4]) - math.radians(param[3]))
     
     #uVector =  {'u1' : u1, 'u2' : u2, 'u3' : u3, 'u4' : u4, 'u5' : u5, 'u6' : u6}
     return np.array([u1,u2,u3,u4,u5,u6])
Пример #2
0
    def trueAnomaly(self,time): # TODO :: 1) tenir compte du format de time et self_periastronTime. 2) prendre en charge les array de time
        """ Under construction 
        Summary::
            Return the true anomaly of the planet at a given time according to 
            the orbit parameters and the time for passage to periastron
        Arguments::
            time: observation time at which we want to calculate the true anomaly. 
                  The format can be either ISO (e.g. '2000-01-01 00:00:00.0') or JD
                  (e.g. 2451544.5)
        
        Return::
        
        """       
        if isinstance(time,float) == False and isinstance(time,int) == False: 
            time = Time(time,format='iso',scale='utc').jd # conversion in JD 

        meanAnomaly = (2*np.pi * ((time-self.__periastronTime)/self.daysInOneYear) / self.__period) % (2*np.pi)
        ks = MarkleyKESolver() # call the Kepler equation solver
        eccentricAnomaly = ks.getE(meanAnomaly,self.__eccentricity)  

        mA1 = 2 * math.atan(math.sqrt((1+self.__eccentricity)/(1-self.__eccentricity)) * math.tan(eccentricAnomaly / 2)) # TODO il faut tester l'unicité de la solution
        return mA1 % (2*np.pi)