コード例 #1
0
ファイル: planarOrbit.py プロジェクト: ritabanc/galpy
 def E(self, *args, **kwargs):
     """
     NAME:
        E
     PURPOSE:
        calculate the energy
     INPUT:
        pot=
        t= time at which to evaluate E
     OUTPUT:
        energy
     HISTORY:
        2010-09-15 - Written - Bovy (NYU)
     """
     if not kwargs.has_key('pot') or kwargs['pot'] is None:
         try:
             pot = self._pot
         except AttributeError:
             raise AttributeError("Integrate orbit or specify pot=")
         if kwargs.has_key('pot') and kwargs['pot'] is None:
             kwargs.pop('pot')
     else:
         pot = kwargs['pot']
         kwargs.pop('pot')
     if isinstance(pot, Potential):
         thispot = RZToplanarPotential(pot)
     elif isinstance(pot, list):
         thispot = []
         for p in pot:
             if isinstance(p, Potential):
                 thispot.append(RZToplanarPotential(p))
             else:
                 thispot.append(p)
     else:
         thispot = 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 evaluateplanarPotentials(thiso[0],thispot,
                                         phi=thiso[3],t=t)\
                                         +thiso[1]**2./2.\
                                         +thiso[2]**2./2.
     else:
         return nu.array([evaluateplanarPotentials(thiso[0,ii],thispot,
                                                   phi=thiso[3,ii],
                                                   t=t[ii])\
                              +thiso[1,ii]**2./2.\
                              +thiso[2,ii]**2./2. for ii in range(len(t))])
コード例 #2
0
 def E(self, *args, **kwargs):
     """
     NAME:
        E
     PURPOSE:
        calculate the energy
     INPUT:
        t - (optional) time at which to get the radius
        pot= potential instance or list of such instances
     OUTPUT:
        energy
     HISTORY:
        2010-09-15 - Written - Bovy (NYU)
        2011-04-18 - Added t - 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 isinstance(pot, Potential):
         thispot = RZToplanarPotential(pot)
     elif isinstance(pot, list):
         thispot = []
         for p in pot:
             if isinstance(p, Potential):
                 thispot.append(RZToplanarPotential(p))
             else:
                 thispot.append(p)
     else:
         thispot = 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 _evaluateplanarPotentials(thispot,thiso[0],
                                          t=t)\
                                         +thiso[1]**2./2.\
                                         +thiso[2]**2./2.
     else:
         return nu.array([_evaluateplanarPotentials(thispot,thiso[0,ii],
                                                   t=t[ii])\
                              +thiso[1,ii]**2./2.\
                              +thiso[2,ii]**2./2. for ii in range(len(t))])
コード例 #3
0
ファイル: planarOrbit.py プロジェクト: derkal/galpy
 def E(self,*args,**kwargs):
     """
     NAME:
        E
     PURPOSE:
        calculate the energy
     INPUT:
        pot=
        t= time at which to evaluate E
     OUTPUT:
        energy
     HISTORY:
        2010-09-15 - Written - Bovy (NYU)
     """
     if not kwargs.has_key('pot') or kwargs['pot'] is None:
         try:
             pot= self._pot
         except AttributeError:
             raise AttributeError("Integrate orbit or specify pot=")
         if kwargs.has_key('pot') and kwargs['pot'] is None:
             kwargs.pop('pot')          
     else:
         pot= kwargs['pot']
         kwargs.pop('pot')
     if isinstance(pot,Potential):
         thispot= RZToplanarPotential(pot)
     elif isinstance(pot,list):
         thispot= []
         for p in pot:
             if isinstance(p,Potential): thispot.append(RZToplanarPotential(p))
             else: thispot.append(p)
     else:
         thispot= 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 evaluateplanarPotentials(thiso[0],thispot,
                                         phi=thiso[3],t=t)\
                                         +thiso[1]**2./2.\
                                         +thiso[2]**2./2.
     else:
         return nu.array([evaluateplanarPotentials(thiso[0,ii],thispot,
                                                   phi=thiso[3,ii],
                                                   t=t[ii])\
                              +thiso[1,ii]**2./2.\
                              +thiso[2,ii]**2./2. for ii in range(len(t))])
コード例 #4
0
ファイル: planarOrbit.py プロジェクト: smoh/galpy
 def E(self,*args,**kwargs):
     """
     NAME:
        E
     PURPOSE:
        calculate the energy
     INPUT:
        t - (optional) time at which to get the radius
        pot= potential instance or list of such instances
     OUTPUT:
        energy
     HISTORY:
        2010-09-15 - Written - Bovy (NYU)
        2011-04-18 - Added t - 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 isinstance(pot,Potential):
         thispot= RZToplanarPotential(pot)
     elif isinstance(pot,list):
         thispot= []
         for p in pot:
             if isinstance(p,Potential): thispot.append(RZToplanarPotential(p))
             else: thispot.append(p)
     else:
         thispot= 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 _evaluateplanarPotentials(thispot,thiso[0],
                                          t=t)\
                                         +thiso[1]**2./2.\
                                         +thiso[2]**2./2.
     else:
         return nu.array([_evaluateplanarPotentials(thispot,thiso[0,ii],
                                                   t=t[ii])\
                              +thiso[1,ii]**2./2.\
                              +thiso[2,ii]**2./2. for ii in range(len(t))])