Exemplo n.º 1
0
 def _EccZmaxRperiRap(self, *args, **kwargs):
     """
     NAME:
        EccZmaxRperiRap (_EccZmaxRperiRap)
     PURPOSE:
        evaluate the eccentricity, maximum height above the plane, peri- and apocenter in the Staeckel approximation
     INPUT:
        Either:
           a) R,vR,vT,z,vz[,phi]:
              1) floats: phase-space value for single object (phi is optional) (each can be a Quantity)
              2) numpy.ndarray: [N] phase-space values for N objects (each can be a Quantity)
           b) Orbit instance: initial condition used if that's it, orbit(t) if there is a time given as well as the second argument 
        delta= (object-wide default) can be used to override the object-wide focal length; can also be an array with length N to allow different delta for different phase-space points
        u0= (None) if object-wide option useu0 is set, u0 to use (if useu0 and useu0 is None, a good value will be computed)
        c= (object-wide default, bool) True/False to override the object-wide setting for whether or not to use the C implementation
     OUTPUT:
        (e,zmax,rperi,rap)
     HISTORY:
        2017-12-12 - Written - Bovy (UofT)
     """
     delta = kwargs.get('delta', self._delta)
     umin, umax, vmin = self._uminumaxvmin(*args, **kwargs)
     rperi = bovy_coords.uv_to_Rz(umin, nu.pi / 2., delta=delta)[0]
     rap_tmp, zmax = bovy_coords.uv_to_Rz(umax, vmin, delta=delta)
     rap = nu.sqrt(rap_tmp**2. + zmax**2.)
     e = (rap - rperi) / (rap + rperi)
     return (e, zmax, rperi, rap)
Exemplo n.º 2
0
 def _EccZmaxRperiRap(self,*args,**kwargs):
     """
     NAME:
        EccZmaxRperiRap (_EccZmaxRperiRap)
     PURPOSE:
        evaluate the eccentricity, maximum height above the plane, peri- and apocenter in the Staeckel approximation
     INPUT:
        Either:
           a) R,vR,vT,z,vz[,phi]:
              1) floats: phase-space value for single object (phi is optional) (each can be a Quantity)
              2) numpy.ndarray: [N] phase-space values for N objects (each can be a Quantity)
           b) Orbit instance: initial condition used if that's it, orbit(t) if there is a time given as well as the second argument 
        delta= (object-wide default) can be used to override the object-wide focal length; can also be an array with length N to allow different delta for different phase-space points
        u0= (None) if object-wide option useu0 is set, u0 to use (if useu0 and useu0 is None, a good value will be computed)
        c= (object-wide default, bool) True/False to override the object-wide setting for whether or not to use the C implementation
     OUTPUT:
        (e,zmax,rperi,rap)
     HISTORY:
        2017-12-12 - Written - Bovy (UofT)
     """
     delta= kwargs.get('delta',self._delta)
     umin, umax, vmin= self._uminumaxvmin(*args,**kwargs)
     rperi= bovy_coords.uv_to_Rz(umin,nu.pi/2.,delta=delta)[0]
     rap_tmp, zmax= bovy_coords.uv_to_Rz(umax,vmin,delta=delta)
     rap= nu.sqrt(rap_tmp**2.+zmax**2.)
     e= (rap-rperi)/(rap+rperi)
     return (e,zmax,rperi,rap)
Exemplo n.º 3
0
def test_Rz_to_uv():
    u, v= numpy.arccosh(5./3.), numpy.pi/6.
    ut,vt= bovy_coords.Rz_to_uv(*bovy_coords.uv_to_Rz(u,v,delta=3.),delta=3.)
    assert numpy.fabs(ut-u) < 10.**-10., 'Rz_to_uvz conversion did not work as expected'
    assert numpy.fabs(vt-vt) < 10.**-10., 'Rz_to_uv conversion did not work as expected'
    #Also test for arrays
    os= numpy.ones(2)
    ut,vt= bovy_coords.Rz_to_uv(*bovy_coords.uv_to_Rz(u*os,v*os,delta=3.),delta=3.)
    assert numpy.all(numpy.fabs(ut-u) < 10.**-10.), 'Rz_to_uvz conversion did not work as expected'
    assert numpy.all(numpy.fabs(vt-vt) < 10.**-10.), 'Rz_to_uv conversion did not work as expected'
    return None
Exemplo n.º 4
0
def test_uv_to_Rz():
    u, v= numpy.arccosh(5./3.), numpy.pi/6.
    R,z= bovy_coords.uv_to_Rz(u,v,delta=3.)
    assert numpy.fabs(R-2.) < 10.**-10., 'uv_to_Rz conversion did not work as expected'
    assert numpy.fabs(z-2.5*numpy.sqrt(3.)) < 10.**-10., 'uv_to_Rz conversion did not work as expected'
    #Also test for arrays
    os= numpy.ones(2)
    R,z= bovy_coords.uv_to_Rz(os*u,os*v,delta=3.)
    assert numpy.all(numpy.fabs(R-2.) < 10.**-10.), 'uv_to_Rz conversion did not work as expected'
    assert numpy.all(numpy.fabs(z-2.5*numpy.sqrt(3.)) < 10.**-10.), 'uv_to_Rz conversion did not work as expected'
    return None
Exemplo n.º 5
0
def test_Rz_to_coshucosv():
    u, v= numpy.arccosh(5./3.), numpy.pi/3.
    R,z= bovy_coords.uv_to_Rz(u,v,delta=3.)
    coshu,cosv= bovy_coords.Rz_to_coshucosv(R,z,delta=3.)
    assert numpy.fabs(coshu-5./3.) < 10.**-10., 'Rz_to_coshucosv conversion did notwork as expected'
    assert numpy.fabs(cosv-0.5) < 10.**-10., 'Rz_to_coshucosv conversion did notwork as expected'
    #Also test for arrays
    os= numpy.ones(2)
    coshu,cosv= bovy_coords.Rz_to_coshucosv(R*os,z*os,delta=3.)
    assert numpy.all(numpy.fabs(coshu-5./3.) < 10.**-10.), 'Rz_to_coshucosv conversion did notwork as expected'
    assert numpy.all(numpy.fabs(cosv-0.5) < 10.**-10.), 'Rz_to_coshucosv conversion did notwork as expected'
    return None
Exemplo n.º 6
0
def estimate_orbit_params(orbit, pot=MWPotential2014, delta=0.375, c=True):
    '''
    use the staeckel approximation to estimate orbital parameters for an orbit
    '''
    try:
        if not c:
            aASS = actionAngleStaeckelSingle(orbit, pot=pot, delta=delta)
            umin, umax = aASS.calcUminUmax()
            vmin = aASS.calcVmin()
            rperi = bovy_coords.uv_to_Rz(umin,
                                         numpy.pi / 2.,
                                         delta=aASS._delta)[0]
            rap_tmp, zmax = bovy_coords.uv_to_Rz(umax, vmin, delta=aASS._delta)
            rap = numpy.sqrt(rap_tmp**2. + zmax**2.)
            e = (rap - rperi) / (rap + rperi)
            return [rperi, rap, zmax, e]
        else:
            aAS = actionAngleStaeckel(pot=pot, delta=delta)
            e, zmax, rperi, rap = aAS.EccZmaxRperiRap(orbit)
            return [rperi, rap, zmax, e]
    except UnboundError:
        return [np.nan, np.nan, np.nan, np.nan]
Exemplo n.º 7
0
def FZStaeckel(u,v,pot,delta): #pragma: no cover because unused
    """
    NAME:
       FZStaeckel
    PURPOSE:
       return the vertical force
    INPUT:
       u - confocal u
       v - confocal v
       pot - potential
       delta - focus
    OUTPUT:
       FZ(u,v)
    HISTORY:
       2012-11-30 - Written - Bovy (IAS)
    """
    R,z= bovy_coords.uv_to_Rz(u,v,delta=delta)
    return _evaluatezforces(pot,R,z)
Exemplo n.º 8
0
def potentialStaeckel(u,v,pot,delta):
    """
    NAME:
       potentialStaeckel
    PURPOSE:
       return the potential
    INPUT:
       u - confocal u
       v - confocal v
       pot - potential
       delta - focus
    OUTPUT:
       Phi(u,v)
    HISTORY:
       2012-11-29 - Written - Bovy (IAS)
    """
    R,z= bovy_coords.uv_to_Rz(u,v,delta=delta)
    return _evaluatePotentials(pot,R,z)
Exemplo n.º 9
0
def FRStaeckel(u, v, pot, delta):  #pragma: no cover because unused
    """
    NAME:
       FRStaeckel
    PURPOSE:
       return the radial force
    INPUT:
       u - confocal u
       v - confocal v
       pot - potential
       delta - focus
    OUTPUT:
       FR(u,v)
    HISTORY:
       2012-11-30 - Written - Bovy (IAS)
    """
    R, z = bovy_coords.uv_to_Rz(u, v, delta=delta)
    return _evaluateRforces(pot, R, z)
Exemplo n.º 10
0
def potentialStaeckel(u, v, pot, delta):
    """
    NAME:
       potentialStaeckel
    PURPOSE:
       return the potential
    INPUT:
       u - confocal u
       v - confocal v
       pot - potential
       delta - focus
    OUTPUT:
       Phi(u,v)
    HISTORY:
       2012-11-29 - Written - Bovy (IAS)
    """
    R, z = bovy_coords.uv_to_Rz(u, v, delta=delta)
    return _evaluatePotentials(pot, R, z)
Exemplo n.º 11
0
def FRStaeckel(u,v,pot,delta):
    """
    NAME:
       FRStaeckel
    PURPOSE:
       return the radial force
    INPUT:
       u - confocal u
       v - confocal v
       pot - potential
       delta - focus
    OUTPUT:
       FR(u,v)
    HISTORY:
       2012-11-30 - Written - Bovy (IAS)
    """
    R,z= bovy_coords.uv_to_Rz(u,v,delta=delta)
    return evaluateRforces(R,z,pot)