def actionsFreqsAngles(self, *args, **kwargs): """ NAME: actionsFreqsAngles PURPOSE: evaluate the actions, frequencies, and angles (jr,lz,jz,Omegar,Omegaphi,Omegaz,ar,ap,az) 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 fixed_quad= (False) if True, use n=10 fixed_quad integration scipy.integrate.quadrature keywords OUTPUT: (jr,lz,jz,Omegar,Omegaphi,Omegaz,ar,aphi,az) HISTORY: 2013-12-29 - Written - Bovy (IAS) """ fixed_quad = kwargs.pop('fixed_quad', False) if len(args) == 5: #R,vR.vT, z, vz pragma: no cover raise IOError("You need to provide phi when calculating angles") 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 phi = meta._phi if isinstance(R, float): R = nu.array([R]) vR = nu.array([vR]) vT = nu.array([vT]) z = nu.array([z]) vz = nu.array([vz]) phi = nu.array([phi]) if self._c: #pragma: no cover pass else: Lz = R * vT Lx = -z * vT Ly = z * vR - R * vz L2 = Lx * Lx + Ly * Ly + Lz * Lz E = evaluatePotentials( R, z, self._pot) + vR**2. / 2. + vT**2. / 2. + vz**2. / 2. L = nu.sqrt(L2) #Actions Jphi = Lz Jz = L - nu.fabs(Lz) #Jr requires some more work #Set up an actionAngleAxi object for EL and rap/rperi calculations axiR = nu.sqrt(R**2. + z**2.) axivT = L / axiR #these are really spherical coords, called axi bc they go in actionAngleAxi axivR = (R * vR + z * vz) / axiR axivz = (z * vR - R * vz) / axiR Jr = [] Or = [] Op = [] ar = [] az = [] #Calculate the longitude of the ascending node asc = self._calc_long_asc(z, R, axivz, phi, Lz, L) for ii in range(len(axiR)): axiaA = actionAngleAxi(axiR[ii], axivR[ii], axivT[ii], pot=self._2dpot) (rperi, rap) = axiaA.calcRapRperi() EL = axiaA.calcEL() E, L = EL Jr.append(self._calc_jr(rperi, rap, E, L, fixed_quad, **kwargs)) #Radial period Rmean = m.exp((m.log(rperi) + m.log(rap)) / 2.) if Jr[-1] < 10.**-9.: #Circular orbit Or.append(epifreq(self._pot, axiR[ii])) Op.append(omegac(self._pot, axiR[ii])) else: Or.append( self._calc_or(Rmean, rperi, rap, E, L, fixed_quad, **kwargs)) Op.append( self._calc_op(Or[-1], Rmean, rperi, rap, E, L, fixed_quad, **kwargs)) #Angles ar.append( self._calc_angler(Or[-1], axiR[ii], Rmean, rperi, rap, E, L, axivR[ii], fixed_quad, **kwargs)) az.append( self._calc_anglez(Or[-1], Op[-1], ar[-1], z[ii], axiR[ii], Rmean, rperi, rap, E, L, Lz[ii], axivR[ii], axivz[ii], fixed_quad, **kwargs)) Op = nu.array(Op) Oz = copy.copy(Op) Op[vT < 0.] *= -1. ap = copy.copy(asc) ar = nu.array(ar) az = nu.array(az) ap[vT < 0.] -= az[vT < 0.] ap[vT >= 0.] += az[vT >= 0.] ar = ar % (2. * nu.pi) ap = ap % (2. * nu.pi) az = az % (2. * nu.pi) return (nu.array(Jr), Jphi, Jz, nu.array(Or), Op, Oz, ar, ap, az)
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 fixed_quad= (False) if True, use n=10 fixed_quad integration scipy.integrate.quadrature keywords OUTPUT: (jr,lz,jz) HISTORY: 2013-12-28 - Written - Bovy (IAS) """ fixed_quad = kwargs.pop('fixed_quad', False) 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]) if self._c: #pragma: no cover pass else: Lz = R * vT Lx = -z * vT Ly = z * vR - R * vz L2 = Lx * Lx + Ly * Ly + Lz * Lz E = evaluatePotentials( R, z, self._pot) + vR**2. / 2. + vT**2. / 2. + vz**2. / 2. L = nu.sqrt(L2) #Actions Jphi = Lz Jz = L - nu.fabs(Lz) #Jr requires some more work #Set up an actionAngleAxi object for EL and rap/rperi calculations axiR = nu.sqrt(R**2. + z**2.) axivT = L / axiR axivR = (R * vR + z * vz) / axiR Jr = [] for ii in range(len(axiR)): axiaA = actionAngleAxi(axiR[ii], axivR[ii], axivT[ii], pot=self._2dpot) (rperi, rap) = axiaA.calcRapRperi() EL = axiaA.calcEL() E, L = EL Jr.append(self._calc_jr(rperi, rap, E, L, fixed_quad, **kwargs)) return (nu.array(Jr), Jphi, Jz)
def actionsFreqs(self, *args, **kwargs): """ NAME: actionsFreqs PURPOSE: evaluate the actions and frequencies (jr,lz,jz,Omegar,Omegaphi,Omegaz) 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 fixed_quad= (False) if True, use n=10 fixed_quad integration scipy.integrate.quadrature keywords OUTPUT: (jr,lz,jz,Omegar,Omegaphi,Omegaz) HISTORY: 2013-12-28 - Written - Bovy (IAS) """ fixed_quad = kwargs.pop('fixed_quad', False) 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]) if self._c: #pragma: no cover pass else: Lz = R * vT Lx = -z * vT Ly = z * vR - R * vz L2 = Lx * Lx + Ly * Ly + Lz * Lz E = evaluatePotentials( R, z, self._pot) + vR**2. / 2. + vT**2. / 2. + vz**2. / 2. L = nu.sqrt(L2) #Actions Jphi = Lz Jz = L - nu.fabs(Lz) #Jr requires some more work #Set up an actionAngleAxi object for EL and rap/rperi calculations axiR = nu.sqrt(R**2. + z**2.) axivT = L / axiR axivR = (R * vR + z * vz) / axiR Jr = [] Or = [] Op = [] for ii in range(len(axiR)): axiaA = actionAngleAxi(axiR[ii], axivR[ii], axivT[ii], pot=self._2dpot) (rperi, rap) = axiaA.calcRapRperi() EL = axiaA.calcEL() E, L = EL Jr.append(self._calc_jr(rperi, rap, E, L, fixed_quad, **kwargs)) #Radial period if Jr[-1] < 10.**-9.: #Circular orbit Or.append(epifreq(self._pot, axiR[ii])) Op.append(omegac(self._pot, axiR[ii])) continue Rmean = m.exp((m.log(rperi) + m.log(rap)) / 2.) Or.append( self._calc_or(Rmean, rperi, rap, E, L, fixed_quad, **kwargs)) Op.append( self._calc_op(Or[-1], Rmean, rperi, rap, E, L, fixed_quad, **kwargs)) Op = nu.array(Op) Oz = copy.copy(Op) Op[vT < 0.] *= -1. return (nu.array(Jr), Jphi, Jz, nu.array(Or), Op, Oz)