<commit_before># jeans.py: utilities related to the Jeans equations
import numpy
from scipy import integrate
from galpy.potential_src.Potential import evaluateDensities, \
    evaluateRforces
from galpy.potential_src.Potential import flatten as flatten_pot
from galpy.util.bovy_conversion import physical_conversion, \
    potential_physical_input
@potential_physical_input
@physical_conversion('velocity',pop=True)
def sigmar(Pot,r,dens=None,beta=0.):
    """
    NAME:

       sigmar

    PURPOSE:

       Compute the radial velocity dispersion using the spherical Jeans equation

    INPUT:

       Pot - potential or list of potentials (evaluated at R=r,z=0, sphericity not checked)

       r - Galactocentric radius (can be Quantity)

       dens= (None) tracer density profile (function of r); if None, the density is assumed to be that corresponding to the potential

       beta= (0.) anisotropy; can be a constant or a function of r
       
    OUTPUT:

       sigma_r(r)

    HISTORY:

       2018-07-05 - Written - Bovy (UofT)

    """
    Pot= flatten_pot(Pot)
    if dens is None:
        dens= lambda r: evaluateDensities(Pot,r,0.,use_physical=False)
    if callable(beta):
        intFactor= lambda x: numpy.exp(2.*integrate.quad(lambda y: beta(y)/y,
                                       1.,x)[0])
    else: # assume to be number
        intFactor= lambda x: x**(2.*beta)
    return numpy.sqrt(integrate.quad(lambda x: -intFactor(x)*dens(x)
                                     *evaluateRforces(Pot,x,0.,
                                                      use_physical=False),
                                     r,numpy.inf)[0]/
                      dens(r)/intFactor(r))
<commit_msg>Switch to evaluating the potential at R,z=r/sqrt(2) in spherical Jeans, as a possibly better approx. for halo objects in a disk+halo potential<commit_after># jeans.py: utilities related to the Jeans equations
import numpy
from scipy import integrate
from galpy.potential_src.Potential import evaluateDensities, \
    evaluaterforces
from galpy.potential_src.Potential import flatten as flatten_pot
from galpy.util.bovy_conversion import physical_conversion, \
    potential_physical_input
_INVSQRTTWO= 1./numpy.sqrt(2.)
@potential_physical_input
@physical_conversion('velocity',pop=True)
def sigmar(Pot,r,dens=None,beta=0.):
    """
    NAME:

       sigmar

    PURPOSE:

       Compute the radial velocity dispersion using the spherical Jeans equation

    INPUT:

       Pot - potential or list of potentials (evaluated at R=r/sqrt(2),z=r/sqrt(2), sphericity not checked)

       r - Galactocentric radius (can be Quantity)

       dens= (None) tracer density profile (function of r); if None, the density is assumed to be that corresponding to the potential

       beta= (0.) anisotropy; can be a constant or a function of r
       
    OUTPUT:

       sigma_r(r)

    HISTORY:

       2018-07-05 - Written - Bovy (UofT)

    """
    Pot= flatten_pot(Pot)
    if dens is None:
        dens= lambda r: evaluateDensities(Pot,r*_INVSQRTTWO,r*_INVSQRTTWO,
                                          use_physical=False)
    if callable(beta):
        intFactor= lambda x: numpy.exp(2.*integrate.quad(lambda y: beta(y)/y,
                                       1.,x)[0])
    else: # assume to be number
        intFactor= lambda x: x**(2.*beta)
    return numpy.sqrt(integrate.quad(lambda x: -intFactor(x)*dens(x)
                                     *evaluaterforces(Pot,
                                                      x*_INVSQRTTWO,
                                                      x*_INVSQRTTWO,
                                                      use_physical=False),
                                     r,numpy.inf)[0]/
                      dens(r)/intFactor(r))

{'fraction_non_alphanumeric': 0.0857746107152283, 'fraction_numerical': 0.010029031406703616, 'mean_word_length': 2.0638641875505255, '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': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3354743', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1049, 'n_words': 310}