Пример #1
0
 def calczmax(self,*args,**kwargs):
     """
     NAME:
        calczmax
     PURPOSE:
        calculate the maximum height
     INPUT:
        Either:
           a) R,vR,vT,z,vz
           b) Orbit instance: initial condition used if that's it, orbit(t)
              if there is a time given as well
     OUTPUT:
        zmax
     HISTORY:
        2012-06-01 - Written - Bovy (IAS)
     """
     #Set up the actionAngleAxi object
     meta= actionAngle(*args)
     if isinstance(self._pot,list):
         thispot= [p.toPlanar() for p in self._pot]
     else:
         thispot= self._pot.toPlanar()
     if isinstance(self._pot,list):
         thisverticalpot= [p.toVertical(meta._R) for p in self._pot]
     else:
         thisverticalpot= self._pot.toVertical(meta._R)
     aAAxi= actionAngleAxi(*args,pot=thispot,
                            verticalPot=thisverticalpot,
                            gamma=self._gamma)
     return aAAxi.calczmax(**kwargs)
Пример #2
0
 def __init__(self,*args,**kwargs):
     """
     NAME:
        __init__ DONE
     PURPOSE:
        initialize an actionAngleSpherical object
     INPUT:
        Either:
           a) R,vR,vT
           b) Orbit instance: initial condition used if that's it, orbit(t)
              if there is a time given as well
           pot= potential or list of potentials (planarPotentials)
     OUTPUT:
     HISTORY:
        2011-03-03 - Written - Bovy (NYU)
     """
     actionAngle.__init__(self,*args,**kwargs)
     if not kwargs.has_key('pot'):
         raise IOError("Must specify pot= for actionAngleSpherical")
     self._pot= kwargs['pot']
     #Also set up an actionAngleAxi object for EL and rap/rperi calculations
     axiR= m.sqrt(self._R**2.+self._z**2.)
     axivT= self.J2()[0]/axiR
     axivR= (self._x*self._vx+self._y*self._vy+self._z*self._vz)/axiR
     self._axi= actionAngleAxi(axiR,axivR,axivT,pot=self._pot)
     return None
Пример #3
0
 def calcRapRperi(self,*args,**kwargs):
     """
     NAME:
        calcRapRperi
     PURPOSE:
        calculate the apocenter and pericenter radii
     INPUT:
        Either:
           a) R,vR,vT,z,vz
           b) Orbit instance: initial condition used if that's it, orbit(t)
              if there is a time given as well
     OUTPUT:
        (rperi,rap)
     HISTORY:
        2013-11-27 - Written - Bovy (IAS)
     """
     #Set up the actionAngleAxi object
     if isinstance(self._pot,list):
         thispot= [p.toPlanar() for p in self._pot if not isinstance(p,planarPotential)]
         thispot.extend([p for p in self._pot if isinstance(p,planarPotential)])
     elif not isinstance(self._pot,planarPotential):
         thispot= self._pot.toPlanar()
     else:
         thispot= self._pot
     aAAxi= actionAngleAxi(*args,pot=thispot,
                            gamma=self._gamma)
     return aAAxi.calcRapRperi(**kwargs)
Пример #4
0
 def JR(self, *args, **kwargs):
     """
     NAME:
        JR
     PURPOSE:
        evaluate the action jr
     INPUT:
        Either:
           a) R,vR,vT,z,vz
           b) Orbit instance: initial condition used if that's it, orbit(t)
              if there is a time given as well
        scipy.integrate.quadrature keywords
     OUTPUT:
        Jr
     HISTORY:
        2012-07-30 - Written - Bovy (IAS@MPIA)
     """
     #Set up the actionAngleAxi object
     meta = actionAngle(*args)
     if isinstance(self._pot, list):
         thispot = [p.toPlanar() for p in self._pot]
     else:
         thispot = self._pot.toPlanar()
     aAAxi = actionAngleAxi(*args, pot=thispot, gamma=self._gamma)
     return aAAxi.JR(**kwargs)
Пример #5
0
 def __call__(self, *args, **kwargs):
     """
     NAME:
        __call__
     PURPOSE:
        evaluate the actions (jr,lz,jz)
     INPUT:
        Either:
           a) R,vR,vT,z,vz
           b) Orbit instance: initial condition used if that's it, orbit(t)
              if there is a time given as well
        scipy.integrate.quadrature keywords
     OUTPUT:
        (jr,lz,jz), where jr=[jr,jrerr], and jz=[jz,jzerr]
     HISTORY:
        2012-07-26 - Written - Bovy (IAS@MPIA)
     """
     #Set up the actionAngleAxi object
     meta = actionAngle(*args)
     if isinstance(self._pot, list):
         thispot = [p.toPlanar() for p in self._pot]
     else:
         thispot = self._pot.toPlanar()
     if isinstance(self._pot, list):
         thisverticalpot = [p.toVertical(meta._R) for p in self._pot]
     else:
         thisverticalpot = self._pot.toVertical(meta._R)
     aAAxi = actionAngleAxi(*args,
                            pot=thispot,
                            verticalPot=thisverticalpot,
                            gamma=self._gamma)
     return (aAAxi.JR(**kwargs), aAAxi._R * aAAxi._vT, aAAxi.Jz(**kwargs))
Пример #6
0
 def Jz(self,*args,**kwargs):
     """
     NAME:
        Jz
     PURPOSE:
        evaluate the action jz
     INPUT:
        Either:
           a) R,vR,vT,z,vz
           b) Orbit instance: initial condition used if that's it, orbit(t)
              if there is a time given as well
        scipy.integrate.quadrature keywords
     OUTPUT:
        jz,jzerr
     HISTORY:
        2012-07-27 - Written - Bovy (IAS@MPIA)
     """
     #Set up the actionAngleAxi object
     meta= actionAngle(*args)
     if isinstance(self._pot,list):
         thispot= [p.toPlanar() for p in self._pot]
     else:
         thispot= self._pot.toPlanar()
     if isinstance(self._pot,list):
         thisverticalpot= [p.toVertical(meta._R) for p in self._pot]
     else:
         thisverticalpot= self._pot.toVertical(meta._R)
     aAAxi= actionAngleAxi(*args,pot=thispot,
                            verticalPot=thisverticalpot,
                            gamma=self._gamma)
     return aAAxi.Jz(**kwargs)
Пример #7
0
 def __call__(self,*args,**kwargs):
     """
     NAME:
        __call__
     PURPOSE:
        evaluate the actions (jr,lz,jz)
     INPUT:
        Either:
           a) R,vR,vT,z,vz
           b) Orbit instance: initial condition used if that's it, orbit(t)
              if there is a time given as well
        scipy.integrate.quadrature keywords
        _justjr, _justjz= if True, only calculate the radial or vertical action (internal use)
     OUTPUT:
        (jr,lz,jz), where jr=[jr,jrerr], and jz=[jz,jzerr]
     HISTORY:
        2012-07-26 - Written - Bovy (IAS@MPIA)
     """
     if ((self._c and not (kwargs.has_key('c') and not kwargs['c']))\
             or (ext_loaded and ((kwargs.has_key('c') and kwargs['c'])))) \
             and _check_c(self._pot):
         if len(args) == 5: #R,vR.vT, z, vz
             R,vR,vT, z, vz= args
         elif len(args) == 6: #R,vR.vT, z, vz, phi
             R,vR,vT, z, vz, phi= args
         else:
             meta= actionAngle(*args)
             R= meta._R
             vR= meta._vR
             vT= meta._vT
             z= meta._z
             vz= meta._vz
         if isinstance(R,float):
             R= nu.array([R])
             vR= nu.array([vR])
             vT= nu.array([vT])
             z= nu.array([z])
             vz= nu.array([vz])
         Lz= R*vT
         jr, jz, err= actionAngleAdiabatic_c.actionAngleAdiabatic_c(\
             self._pot,self._gamma,R,vR,vT,z,vz)
         if err == 0:
             return (jr,Lz,jz)
         else: #pragma: no cover
             raise RuntimeError("C-code for calculation actions failed; try with c=False")
     else:
         if kwargs.has_key('c') and kwargs['c'] and not self._c:
             warnings.warn("C module not used because potential does not have a C implementation",galpyWarning) #pragma: no cover
         if kwargs.has_key('c'): kwargs.pop('c')
         if (len(args) == 5 or len(args) == 6) \
                 and isinstance(args[0],nu.ndarray):
             ojr= nu.zeros((len(args[0])))
             olz= nu.zeros((len(args[0])))
             ojz= nu.zeros((len(args[0])))
             for ii in range(len(args[0])):
                 if len(args) == 5:
                     targs= (args[0][ii],args[1][ii],args[2][ii],
                             args[3][ii],args[4][ii])
                 elif len(args) == 6:
                     targs= (args[0][ii],args[1][ii],args[2][ii],
                             args[3][ii],args[4][ii],args[5][ii])
                 tjr,tlz,tjz= self(*targs,**copy.copy(kwargs))
                 ojr[ii]= tjr
                 ojz[ii]= tjz
                 olz[ii]= tlz
             return (ojr,olz,ojz)
         else:
             #Set up the actionAngleAxi object
             meta= actionAngle(*args)
             if isinstance(self._pot,list):
                 thispot= [p.toPlanar() for p in self._pot]
             else:
                 thispot= self._pot.toPlanar()
             if isinstance(self._pot,list):
                 thisverticalpot= [p.toVertical(meta._R) for p in self._pot]
             else:
                 thisverticalpot= self._pot.toVertical(meta._R)
             aAAxi= actionAngleAxi(*args,pot=thispot,
                                    verticalPot=thisverticalpot,
                                    gamma=self._gamma)
             if kwargs.get('_justjr',False):
                 kwargs.pop('_justjr')
                 return (aAAxi.JR(**kwargs),nu.nan,nu.nan)
             elif kwargs.get('_justjz',False):
                 kwargs.pop('_justjz')
                 return (nu.nan,nu.nan,aAAxi.Jz(**kwargs))
             else:
                 return (aAAxi.JR(**kwargs),aAAxi._R*aAAxi._vT,aAAxi.Jz(**kwargs))