Exemple #1
0
 def E(self,*args,**kwargs):
     """
     NAME:
        E
     PURPOSE:
        calculate the energy
     INPUT:
        t - (optional) time at which to get the radius
        pot= linearPotential instance or list thereof
     OUTPUT:
        energy
     HISTORY:
        2010-09-15 - Written - Bovy (NYU)
     """
     if not 'pot' in kwargs or kwargs['pot'] is None:
         try:
             pot= self._pot
         except AttributeError:
             raise AttributeError("Integrate orbit or specify pot=")
         if 'pot' in kwargs and kwargs['pot'] is None:
             kwargs.pop('pot')          
     else:
         pot= kwargs.pop('pot')
     if len(args) > 0:
         t= args[0]
     else:
         t= 0.
     #Get orbit
     thiso= self(*args,**kwargs)
     onet= (len(thiso.shape) == 1)
     if onet:
         return evaluatelinearPotentials(pot,thiso[0],
                                         t=t,use_physical=False)\
                                         +thiso[1]**2./2.
     else:
         return nu.array([evaluatelinearPotentials(pot,thiso[0,ii],
                                                   t=t[ii],
                                                   use_physical=False)\
                              +thiso[1,ii]**2./2.\
                              for ii in range(len(t))])
Exemple #2
0
 def E(self, *args, **kwargs):
     """
     NAME:
        E
     PURPOSE:
        calculate the energy
     INPUT:
        t - (optional) time at which to get the radius
        pot= linearPotential instance or list thereof
     OUTPUT:
        energy
     HISTORY:
        2010-09-15 - Written - Bovy (NYU)
     """
     if not 'pot' in kwargs or kwargs['pot'] is None:
         try:
             pot = self._pot
         except AttributeError:
             raise AttributeError("Integrate orbit or specify pot=")
         if 'pot' in kwargs and kwargs['pot'] is None:
             kwargs.pop('pot')
     else:
         pot = kwargs.pop('pot')
     if len(args) > 0:
         t = args[0]
     else:
         t = 0.
     #Get orbit
     thiso = self(*args, **kwargs)
     onet = (len(thiso.shape) == 1)
     if onet:
         return evaluatelinearPotentials(pot,thiso[0],
                                         t=t,use_physical=False)\
                                         +thiso[1]**2./2.
     else:
         return nu.array([evaluatelinearPotentials(pot,thiso[0,ii],
                                                   t=t[ii],
                                                   use_physical=False)\
                              +thiso[1,ii]**2./2.\
                              for ii in range(len(t))])
Exemple #3
0
def potentialVertical(z, pot):
    """
    NAME:
       potentialVertical
    PURPOSE:
       return the potential
    INPUT:
       z - height (/ro)
       pot - potential
    OUTPUT:
       Phi_z(z)
    HISTORY:
       2012-06-01 - Written - Bovy (IAS)
    """
    return evaluatelinearPotentials(z, pot)
Exemple #4
0
 def density(self,x,pot):
     """
     NAME:
        density
     PURPOSE:
        evaluate the DF
     INPUT:
        x - at x
        pot - potential
     OUTPUT:
        rho(x)
     HISTORY:
        2010-07-12 - Written - Bovy (NYU)
     """
     return self._norm*sc.exp(-evaluatelinearPotentials(x,pot)/self._sigma2)
def potentialVertical(z,pot):
    """
    NAME:
       potentialVertical
    PURPOSE:
       return the potential
    INPUT:
       z - height (/ro)
       pot - potential
    OUTPUT:
       Phi_z(z)
    HISTORY:
       2012-06-01 - Written - Bovy (IAS)
    """
    return evaluatelinearPotentials(pot,z,use_physical=False)
Exemple #6
0
 def plotE(self,*args,**kwargs):
     """
     NAME:
        plotE
     PURPOSE:
        plot E(.) along the orbit
     INPUT:
        pot - Potential instance or list of instances in which the orbit was
              integrated
        d1= - plot Ez vs d1: e.g., 't', 'x', 'vx'
        +bovy_plot.bovy_plot inputs
     OUTPUT:
        figure to output device
     HISTORY:
        2010-07-10 - Written - Bovy (NYU)
     """
     labeldict= {'t':r'$t$','R':r'$R$','vR':r'$v_R$','vT':r'$v_T$',
                 'z':r'$z$','vz':r'$v_z$','phi':r'$\phi$',
                 'x':r'$x$','y':r'$y$','vx':r'$v_x$','vy':r'$v_y$'}
     if not kwargs.has_key('pot'):
         try:
             pot= self._pot
         except AttributeError:
             raise AttributeError("Integrate orbit first or specify pot=")
     else:
         pot= kwargs['pot']
         kwargs.pop('pot')
     if kwargs.has_key('d1'):
         d1= kwargs['d1']
         kwargs.pop('d1')
     else:
         d1= 't'
     self.Es= [evaluatelinearPotentials(self.orbit[ii,0],pot,t=self.t[ii])+
              self.orbit[ii,1]**2./2.
              for ii in range(len(self.t))]
     if not kwargs.has_key('xlabel'):
         kwargs['xlabel']= labeldict[d1]
     if not kwargs.has_key('ylabel'):
         kwargs['ylabel']= r'$E$'
     if d1 == 't':
         plot.bovy_plot(nu.array(self.t),nu.array(self.Es)/self.Es[0],
                        *args,**kwargs)
     elif d1 == 'x':
         plot.bovy_plot(self.orbit[:,0],nu.array(self.Es)/self.Es[0],
                        *args,**kwargs)
     elif d1 == 'vx':
         plot.bovy_plot(self.orbit[:,1],nu.array(self.Es)/self.Es[0],
                        *args,**kwargs)
Exemple #7
0
 def density(self, x, pot):
     """
     NAME:
        density
     PURPOSE:
        evaluate the DF
     INPUT:
        x - at x
        pot - potential
     OUTPUT:
        rho(x)
     HISTORY:
        2010-07-12 - Written - Bovy (NYU)
     """
     return self._norm * sc.exp(
         -evaluatelinearPotentials(x, pot) / self._sigma2)
Exemple #8
0
def _ars_hx_1d(x,args):
    """Internal function that evaluates h(x) for ARS"""
    pot,sigma2= args
    return -evaluatelinearPotentials(x,pot)/sigma2
Exemple #9
0
def _onedNormalizeIntegrandRaw(x,pot,sigma2):
    """Internal function that has the normalization integrand for 1D (untransformed)"""
    return sc.exp(-evaluatelinearPotentials(x,pot)/sigma2)
Exemple #10
0
def _ars_hx_1d(x, args):
    """Internal function that evaluates h(x) for ARS"""
    pot, sigma2 = args
    return -evaluatelinearPotentials(x, pot) / sigma2
Exemple #11
0
def _onedNormalizeIntegrandRaw(x, pot, sigma2):
    """Internal function that has the normalization integrand for 1D (untransformed)"""
    return sc.exp(-evaluatelinearPotentials(x, pot) / sigma2)