<commit_before>import numpy as nu
import galpy.util.bovy_plot as plot
from Potential import PotentialError, Potential
from plotRotcurve import plotRotcurve
from plotEscapecurve import plotEscapecurve
class planarPotential:
    """Class representing 2D (R,\phi) potentials"""
    def __init__(self,amp=1.):
        self._amp= 1.
        self.dim= 2
        self.isNonAxi= True #Gets reset by planarAxiPotential
        self.isRZ= False
        self.hasC= False
        return None

    def __call__(self,R,phi=0.,t=0.):
        """
        NAME:
           __call__
        PURPOSE:
           evaluate the potential
        INPUT: 
           R
           phi
           t
        OUTPUT:
           Phi(R(,phi,t)))
        HISTORY:
           2010-07-13 - Written - Bovy (NYU)
        """
        try:
            return self._amp*self._evaluate(R,phi=phi,t=t)
        except AttributeError:
            raise PotentialError("'_evaluate' function not implemented for this potential")

    def Rforce(self,R,phi=0.,t=0.):
        """
        NAME:
           Rforce
        PURPOSE:
           evaluate the radial force
        INPUT:
           R
           phi
           t
        OUTPUT:
           F_R(R,(\phi,t)))
        HISTORY:
           2010-07-13 - Written - Bovy (NYU)
        """
        try:
            return self._amp*self._Rforce(R,phi=phi,t=t)
        except AttributeError:
            raise PotentialError("'_Rforce' function not implemented for this potential")

    def phiforce(self,R,phi=0.,t=0.):
        """
        NAME:
           phiforce
        PURPOSE:
           evaluate the phi force
        INPUT:
           R
           phi
           t
        OUTPUT:
           F_\phi(R,(\phi,t)))
        HISTORY:
           2010-07-13 - Written - Bovy (NYU)
        """
        try:
            return self._amp*self._phiforce(R,phi=phi,t=t)
        except AttributeError:
            raise PotentialError("'_phiforce' function not implemented for this potential")


class planarAxiPotential(planarPotential):
    """Class representing axisymmetric planar potentials"""
    def __init__(self,amp=1.):
        planarPotential.__init__(self,amp=amp)
        self.isNonAxi= False
        return None
    
    def _phiforce(self,R,phi=0.,t=0.):
        return 0.

    def plot(self,*args,**kwargs):
        """
        NAME:
           plot
        PURPOSE:
           plot the potential
        INPUT:
           Rrange - range
           grid - number of points to plot
           savefilename - save to or restore from this savefile (pickle)
           +bovy_plot(*args,**kwargs)<commit_msg>circular velocity for planar potentials<commit_after>import numpy as nu
import galpy.util.bovy_plot as plot
from Potential import PotentialError, Potential
from plotRotcurve import plotRotcurve
from plotEscapecurve import plotEscapecurve
class planarPotential:
    """Class representing 2D (R,\phi) potentials"""
    def __init__(self,amp=1.):
        self._amp= 1.
        self.dim= 2
        self.isNonAxi= True #Gets reset by planarAxiPotential
        self.isRZ= False
        self.hasC= False
        return None

    def __call__(self,R,phi=0.,t=0.):
        """
        NAME:
           __call__
        PURPOSE:
           evaluate the potential
        INPUT: 
           R
           phi
           t
        OUTPUT:
           Phi(R(,phi,t)))
        HISTORY:
           2010-07-13 - Written - Bovy (NYU)
        """
        try:
            return self._amp*self._evaluate(R,phi=phi,t=t)
        except AttributeError:
            raise PotentialError("'_evaluate' function not implemented for this potential")

    def Rforce(self,R,phi=0.,t=0.):
        """
        NAME:
           Rforce
        PURPOSE:
           evaluate the radial force
        INPUT:
           R
           phi
           t
        OUTPUT:
           F_R(R,(\phi,t)))
        HISTORY:
           2010-07-13 - Written - Bovy (NYU)
        """
        try:
            return self._amp*self._Rforce(R,phi=phi,t=t)
        except AttributeError:
            raise PotentialError("'_Rforce' function not implemented for this potential")

    def phiforce(self,R,phi=0.,t=0.):
        """
        NAME:
           phiforce
        PURPOSE:
           evaluate the phi force
        INPUT:
           R
           phi
           t
        OUTPUT:
           F_\phi(R,(\phi,t)))
        HISTORY:
           2010-07-13 - Written - Bovy (NYU)
        """
        try:
            return self._amp*self._phiforce(R,phi=phi,t=t)
        except AttributeError:
            raise PotentialError("'_phiforce' function not implemented for this potential")


class planarAxiPotential(planarPotential):
    """Class representing axisymmetric planar potentials"""
    def __init__(self,amp=1.):
        planarPotential.__init__(self,amp=amp)
        self.isNonAxi= False
        return None
    
    def _phiforce(self,R,phi=0.,t=0.):
        return 0.

    def vcirc(self,R):
        """
        
        NAME:
        
            vcirc
        
        PURPOSE:
        
            calculate the circular velocity at R in potential Pot

        INPUT:
        
            Pot - Potential instance or list of such instances
        
            R - Galactocentric radius
        
        OUTPUT:
        
            circular rotation velocity
        
        HISTORY:
        
            2011-10-09 - Written - Bovy (IAS)
        
        """
        return nu.sqrt(R*-self.Rforce(R))       

    def plot(self,*args,**kwargs):
        """
        NAME:
           plot
        PURPOSE:
           plot the potential
        INPUT:
           Rrange - range
           grid - number of points to plot
           savefilename - save to or restore from this savefile (pickle)
           +bovy_plot(*args,**kwargs)
{'fraction_non_alphanumeric': 0.09142561983471074, 'fraction_numerical': 0.014462809917355372, 'mean_word_length': 1.5311546840958605, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '657006', 'n_tokens_mistral': 1814, 'n_tokens_neox': 1659, 'n_words': 418}