    Calculate the radius of a Lindblad resonance.

    Parameters
    ----------
    Pot : Potential instance or list of such instances
        Potential instance or list of such instances.
    OmegaP : float or Quantity
        Pattern speed.
    m : int or str, optional
        Order of the resonance (as in m(O-Op)=kappa (negative m for outer)).
        Use m='corotation' for corotation (default: 2).
    t : float or Quantity, optional
        Time (default: 0.0).
    **kwargs
        Additional arguments to be passed to scipy.optimize.brentq.

    Returns
    -------
    float or Quantity or None
        Radius of Lindblad resonance, None if there is no resonance.

    Notes
    -----
    - 2011-10-09 - Written - Bovy (IAS)


    Calculate the circular angular speed velocity at R in potential Pot.

    Parameters
    ----------
    Pot : Potential instance or list of such instances
        Potential instance or list of such instances.
    R : float or Quantity
        Galactocentric radius.
    t : float or Quantity, optional
        Time (default: 0.0).

    Returns
    -------
    float or Quantity
        Circular angular speed.

    Notes
    -----
    - 2011-10-09 - Written - Bovy (IAS)


    Return the accname potential name for use of this potential or list of potentials with NEMO.

    Parameters
    ----------
    Pot : Potential instance or list of such instances

    Returns
    -------
    str
        Acceleration name in the correct format to give to accname=

    Notes
    -----
    - 2014-12-18 - Written - Bovy (IAS)


    Return the accpars potential parameters for use of this potential or list of potentials with NEMO.

    Parameters
    ----------
    Pot : Potential instance or list of such instances
    vo : float
        Velocity unit in km/s.
    ro : float
        Length unit in kpc.

    Returns
    -------
    str
        Accpars string in the correct format to give to accpars.

    Notes
    -----
    - 2014-12-18 - Written - Bovy (IAS)


    Return an AMUSE representation of a galpy Potential or list of Potentials

    Parameters
    ----------
    Pot : Potential instance or list of such instances
        Potential(s) to convert to an AMUSE representation.
    t : float, optional
        Initial time in AMUSE (can be in internal galpy units or AMUSE units), by default 0.0.
    tgalpy : float, optional
        Initial time in galpy (can be in internal galpy units or AMUSE units); because AMUSE initial times have to be positive, this is useful to set if the initial time in galpy is negative, by default 0.0.
    reverse : bool, optional
        Set whether the galpy potential evolves forwards or backwards in time (default: False); because AMUSE can only integrate forward in time, this is useful to integrate backward in time in AMUSE, by default False.
    ro : float, optional
        Length unit in kpc, by default None.
    vo : float, optional
        Velocity unit in km/s, by default None.

    Returns
    -------
    AMUSE representation of Pot.

    Notes
    -----
    - 2019-08-04 - Written - Bovy (UofT)
    - 2019-08-12 - Implemented actual function - Webb (UofT)


    Turn off automatic returning of outputs in physical units.

    Parameters
    ----------
    Pot : Potential instance or list of such instances
        Potential(s) to turn off automatic returning of outputs in physical units.

    Returns
    -------
    None

    Notes
    -----
    - 2016-01-30 - Written - Bovy (UofT)


    Turn on automatic returning of outputs in physical units.

    Parameters
    ----------
    Pot : Potential instance or list of such instances
        Potential(s) to turn on automatic returning of outputs in physical units.
    ro : float or Quantity, optional
        Reference distance (kpc). Default is None.
    vo : float or Quantity, optional
        Reference velocity (km/s). Default is None.

    Returns
    -------
    None

    Notes
    -----
    - 2016-01-30 - Written - Bovy (UofT)


    Flatten a possibly nested list of Potential instances into a flat list.

    Parameters
    ----------
    Pot : list or Potential instance
        List (possibly nested) of Potential instances.

    Returns
    -------
    list
        Flattened list of Potential instances.

    Notes
    -----
    - 2018-03-14 - Written - Bovy (UofT).


    Check whether a potential or list thereof has a C implementation.

    Parameters
    ----------
    Pot : Potential instance or list of such instances
        Potential instance or list of such instances to check.
    dxdv : bool, optional
        If True, check whether the potential has dxdv implementation.
    dens : bool, optional
        If True, check whether the potential has its density implemented in C.

    Returns
    -------
    bool
        True if a C implementation exists, False otherwise.

    Notes
    -----
    - 2014-02-17 - Written - Bovy (IAS)
    - 2017-07-01 - Generalized to dxdv, added general support for WrapperPotentials, and added support for planarPotentials.


    Determine the dimensionality of this potential

    Parameters
    ----------
    Pot : Potential instance or list of such instances

    Returns
    -------
    int
        Minimum of the dimensionality of all potentials if list; otherwise Pot.dim

    Notes
    -----
    - 2016-04-19 - Written - Bovy (UofT)


    Determine whether this potential is non-axisymmetric

    Parameters
    ----------
    Pot : Potential instance or list of such instances

    Returns
    -------
    bool
        True or False depending on whether the potential is non-axisymmetric (note that some potentials might return True, even though for some parameter values they are axisymmetric)

    Notes
    -----
    - 2016-06-16 - Written - Bovy (UofT)


Decorator to convert velocities from km/s to kpc/Gyr


    Calculate the tidal radius for object of mass M assuming a circular orbit as

        .. math::

           r_t^3 = \\frac{GM_s}{\\Omega^2-\\mathrm{d}^2\\Phi/\\mathrm{d}r^2}

        where :math:`M_s` is the cluster mass, :math:`\\Omega` is the circular frequency, and :math:`\\Phi` is the gravitational potential. For non-spherical potentials, we evaluate :math:`\\Omega^2 = (1/r)(\\mathrm{d}\\Phi/\\mathrm{d}r)` and evaluate the derivatives at the given position of the cluster.

    Parameters
    ----------
    R : float or Quantity
        Galactocentric radius
    z : float or Quantity
        height
    phi : float or Quantity, optional
        azimuth (default: 0.0)
    t : float or Quantity, optional
        time (default: 0.0)
    M : float or Quantity, optional
        Mass of object (default: None)

    Returns
    -------
    float or Quantity
        Tidal Radius

    Notes
    -----
    - 2018-03-21 - Written - Webb (UofT)


    Calculate the tidal tensor Tij=-d(Psi)(dxidxj)

    Parameters
    ----------
    Pot : Potential instance or list of such instances
        Potential instance or list of such instances
    R : float or Quantity
        Galactocentric radius
    z : float or Quantity
        height
    phi : float or Quantity, optional
        azimuth (default: 0.0)
    t : float or Quantity, optional
        time (default: 0.0)
    eigenval : bool, optional
        return eigenvalues if true (default: False)

    Returns
    -------
    array, shape (3,3) or (3,)
        Tidal tensor or eigenvalues of the tidal tensor

    Notes
    -----
    - 2018-03-21 - Written - Webb (UofT)


    Calculate the zero-velocity curve: z such that Phi(R,z) + Lz/[2R^2] = E (assumes that F_z(R,z) = negative at positive z such that there is a single solution)

    Parameters
    ----------
    Pot : Potential instance or list of such instances
        Potential instance or list of such instances.
    R : float or Quantity
        Galactocentric radius.
    E : float or Quantity
        Energy.
    Lz : float or Quantity
        Angular momentum.
    phi : float or Quantity, optional
        Azimuth (default: 0.0).
    t : float or Quantity, optional
        Time (default: 0.0).

    Returns
    -------
    float
        z such that Phi(R,z) + Lz/[2R^2] = E.

    Notes
    -----
    - 2020-08-20 - Written - Bovy (UofT)


    Calculate the minimum and maximum radius for which the zero-velocity curve exists for this energy and angular momentum (R such that Phi(R,0) + Lz/[2R^2] = E)

    Parameters
    ----------
    Pot : Potential instance or list of such instances
        Potential instance or list of such instances.
    E : float or Quantity
        Energy.
    Lz : float or Quantity
        Angular momentum.
    phi : float or Quantity, optional
        Azimuth (default: 0.0).
    t : float or Quantity, optional
        Time (default: 0.0).

    Returns
    -------
    numpy.ndarray
        Solutions R such that Phi(R,0) + Lz/[2R^2] = E.

    Notes
    -----
    - 2020-08-20 - Written - Bovy (UofT)


    Calculate the half-mass radius, the radius of the spherical shell that contains half the total mass.

    Parameters
    ----------
    Pot : Potential instance or list thereof
        Potential instance or list of instances.
    t : float or Quantity, optional
        Time (default: 0.0).
    INF : numeric, optional
        Radius at which the total mass is calculated (internal units, just set this to something very large) (default: numpy.inf).

    Returns
    -------
    float
        Half-mass radius.

    Notes
    -----
    - 2021-03-18 - Written - Bovy (UofT)


find a starting interval for rhalf


    Calculate the dynamical time from tdyn^2 = 3pi/[G<rho>].

    Parameters
    ----------
    Pot : Potential instance or list thereof
        Potential instance or list of instances.
    R : float or Quantity
        Galactocentric radius.
    t : float or Quantity, optional
        Time (default: 0.0).

    Returns
    -------
    float
        Dynamical time.

    Notes
    -----
    - 2021-03-18 - Written - Bovy (UofT)


        Evaluate the radial density derivative x r^(2beta) for this potential.

        Parameters
        ----------
        r : float
            Spherical radius.
        beta : int, optional
            Power of r in the density derivative. Default is 0.

        Returns
        -------
        float
            The derivative of the density times r^(2beta).

        Notes
        -----
        - 2021-03-15 - Written - Lane (UofT)


Internal function that computes the fictitious forces in rectangular
        coordinates


        Evaluate cylindrical radial force F_R  (R,phi).

        Parameters
        ----------
        R : float or Quantity
            Cylindrical Galactocentric radius.
        phi : float or Quantity, optional
            Azimuth. Default is 0.0.
        t : float or Quantity, optional
            Time. Default is 0.0.
        v : numpy.ndarray, optional
            2D cylindrical velocity. Default is None.

        Returns
        -------
        float or Quantity
            Cylindrical radial force.

        Notes
        -----
        - 2023-05-29: Written by Bovy (UofT).


        Evaluate the azimuthal torque F_phi (R, phi, t, v).

        Parameters
        ----------
        R : float or Quantity
            Cylindrical Galactocentric radius.
        phi : float or Quantity, optional
            Azimuth. Default is 0.0.
        t : float or Quantity, optional
            Time. Default is 0.0.
        v : numpy.ndarray, optional
            2D cylindrical velocity. Default is None.

        Returns
        -------
        float or Quantity
            Azimuthal torque.

        Notes
        -----
        - 2023-05-29: Written - Bovy (UofT)


r"""
        Evaluate the radial force.

        Parameters
        ----------
        R : float
            Galactocentric radius.
        phi : float, optional
            Azimuth (in radians). Default is 0.0.
        t : float, optional
            Time. Default is 0.0.
        v : numpy.ndarray, optional
            Velocity in cylindrical coordinates (vR, vT, vz). Default is None.

        Returns
        -------
        float or Quantity
            Radial force F_R(R(,\phi,t,v))

        Notes
        -----
        - 2023-09-29 - Written - Bovy (UofT)


r"""
        Evaluate the azimuthal torque.

        Parameters
        ----------
        R : float
            Galactocentric radius.
        phi : float, optional
            Azimuth (in radians). Default is 0.0.
        t : float, optional
            Time. Default is 0.0.
        v : numpy.ndarray, optional
            Velocity in cylindrical coordinates (vR, vT, vz). Default is None.

        Returns
        -------
        float or Quantity
            Azimuthal torque tau_phi(R(,\phi,t,v))

        Notes
        -----
        - 2029-05-29 - Written - Bovy (UofT)


        Evaluate the potential at R,z

        Parameters
        ----------
        R : float
            Galactocentric cylindrical radius
        z : float
            Vertical height
        phi : float, optional
            Azimuth (default: 0.0)
        t : float, optional
            Time (default: 0.0)

        Returns
        -------
        float
            Potential at (R, z)

        Notes
        -----
        - Started: 2010-07-10 by Bovy (NYU)


        Evaluate the radial force for this potential.

        Parameters
        ----------
        R : float
            Galactocentric cylindrical radius
        z : float
            Vertical height
        phi : float, optional
            Azimuth (default: 0.0)
        t : float, optional
            Time (default: 0.0)

        Returns
        -------
        float
            The radial force.

        Notes
        -----
        - 2010-07-10 - Written - Bovy (NYU)


        Evaluate the vertical force for this potential.

        Parameters
        ----------
        R : float
            Galactocentric cylindrical radius
        z : float
            Vertical height
        phi : float, optional
            Azimuth (default: 0.0)
        t : float, optional
            Time (default: 0.0)

        Returns
        -------
        float
            The vertical force.

        Notes
        -----
        - 2010-07-10 - Written - Bovy (NYU)


        Evaluate the spherical radial force for this potential using JAX.

        Parameters
        ----------
        r : float
            Galactocentric spherical radius.

        Returns
        -------
        float
            The radial force.

        Notes
        -----
        - 2021-02-14 - Written - Bovy (UofT)


        Evaluate the second radial derivative for this potential.

        Parameters
        ----------
        R : float
            Galactocentric cylindrical radius.
        z : float
            Vertical height.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            The second radial derivative.

        Notes
        -----
        - 2011-10-09 - Written - Bovy (NYU)


        Evaluate the second vertical derivative for this potential.

        Parameters
        ----------
        R : float
            Galactocentric cylindrical radius.
        z : float
            Vertical height.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            The second vertical derivative.

        Notes
        -----
        - 2012-07-26 - Written - Bovy (IAS@MPIA)


        Evaluate the mixed R,z derivative for this potential.

        Parameters
        ----------
        R : float
            Galactocentric cylindrical radius.
        z : float
            Vertical height.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            The mixed R,z derivative.

        Notes
        -----
        - 2013-08-28 - Written - Bovy (IAs)


        Evaluate the density for this potential.

        Parameters
        ----------
        R : float
            Galactocentric cylindrical radius.
        z : float
            Vertical height.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            The density.

        Notes
        -----
        - 2013-01-09 - Written - Bovy (IAS)


        Evaluate the radial density derivative for this potential.

        Parameters
        ----------
        r : float
            Spherical radius.
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            The density derivative.

        Notes
        -----
        - 2021-02-25 - Written - Bovy (UofT)


        Evaluate the second radial density derivative for this potential.

        Parameters
        ----------
        r : float
            Spherical radius.
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            The second density derivative.

        Notes
        -----
        - 2021-02-25: Written by Bovy (UofT)


        Evaluate the radial density derivative x r^(2beta) for this potential.

        Parameters
        ----------
        r : float
            Spherical radius.
        beta : int, optional
            Power of r (default: 0).

        Returns
        -------
        float
            The d (rho x r^{2beta} ) / d r derivative.

        Notes
        -----
        - 2021-02-14: Written by Bovy (UofT)


        Evaluate the surface density for this potential.

        Parameters
        ----------
        R : float
            Galactocentric cylindrical radius.
        z : float
            Vertical height.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            The surface density.

        Notes
        -----
        - 2018-08-19: Written by Bovy (UofT)


        Evaluate the mass within R for this potential.

        Parameters
        ----------
        R : float
            Galactocentric cylindrical radius.
        z : float, optional
            Vertical height (default: None).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            The mass enclosed.

        Notes
        -----
        - Written on 2014-07-02 by Bovy (IAS).


        Evaluate the potential at (R,z)

        Parameters
        ----------
        R : float
            Cylindrical Galactocentric radius
        z : float
            Vertical height
        phi : float, optional
            Azimuth (default: 0.0)
        t : float, optional
            Time (default: 0.0)

        Returns
        -------
        float
            Potential at (R,z)

        Notes
        -----
        - 2010-04-16 - Written - Bovy (NYU)
        - 2012-12-26 - New method using Gaussian quadrature between zeros - Bovy (IAS)
        - 2020-12-24 - New method using Ogata's Bessel integral formula - Bovy (UofT)


        Evaluate radial force K_R  (R,z)

        Parameters
        ----------
        R : float
            Cylindrical Galactocentric radius
        z : float
            Vertical height
        phi : float, optional
            Azimuth (default: 0.0)
        t : float, optional
            Time (default: 0.0)

        Returns
        -------
        float
            Radial force (R,z)

        Notes
        -----
        - 2010-04-16 - Written - Bovy (NYU)
        - 2012-12-26 - New method using Gaussian quadrature between zeros - Bovy (IAS)
        - 2020-12-24 - New method using Ogata's Bessel integral formula - Bovy (UofT)


        Evaluate vertical force K_z  (R,z)

        Parameters
        ----------
        R : float
            Cylindrical Galactocentric radius
        z : float
            Vertical height
        phi : float, optional
            Azimuth (default: 0.0)
        t : float, optional
            Time (default: 0.0)

        Returns
        -------
        float
            Vertical force (R,z)

        Notes
        -----
        - 2010-04-16 - Written - Bovy (NYU)
        - 2012-12-26 - New method using Gaussian quadrature between zeros - Bovy (IAS)
        - 2020-12-24 - New method using Ogata's Bessel integral formula - Bovy (UofT)


        Evaluate radial force K_R (R,z) R2 derivative

        Parameters
        ----------
        R : float
            Cylindrical Galactocentric radius
        z : float
            Vertical height
        phi : float, optional
            Azimuth (default: 0.0)
        t : float, optional
            Time (default: 0.0)

        Returns
        -------
        float
            -d K_R (R,z) d R

        Notes
        -----
        - 2012-12-27 - Written - Bovy (IAS)
        - 2020-12-24 - New method using Ogata's Bessel integral formula - Bovy (UofT)


        Evaluate vertical force K_Z (R,z) Z2 derivative

        Parameters
        ----------
        R : float
            Cylindrical Galactocentric radius
        z : float
            Vertical height
        phi : float, optional
            Azimuth (default: 0.0)
        t : float, optional
            Time (default: 0.0)

        Returns
        -------
        float
            -d K_Z (R,z) d Z

        Notes
        -----
        - 2012-12-26 - Written - Bovy (IAS)
        - 2020-12-24 - New method using Ogata's Bessel integral formula - Bovy (UofT)


        Evaluate mixed R,z derivative d2phi/dR/dz.

        Parameters
        ----------
        R : float
            Cylindrical Galactocentric radius
        z : float
            Vertical height
        phi : float, optional
            Azimuth (default: 0.0)
        t : float, optional
            Time (default: 0.0)

        Returns
        -------
        float
            d2phi/dR/dz

        Notes
        -----
        - 2013-08-28 - Written - Bovy (IAS)
        - 2020-12-24 - New method using Ogata's Bessel integral formula - Bovy (UofT)


Decorator to deal with zsym=True input; set odd=True if the function is an odd function of z (like zforce)


Decorator to return scalar output for 1D functions (vcirc,etc.)


    Calculate the potential on a grid.

    Parameters
    ----------
    pot : Potential or list of such instances
        Potential object(s) to calculate the potential from.
    R : numpy.ndarray
        Grid in R.
    z : numpy.ndarray
        Grid in z.
    rforce : bool, optional
        If True, calculate the radial force instead. Default is False.
    zforce : bool, optional
        If True, calculate the vertical force instead. Default is False.

    Returns
    -------
    numpy.ndarray
        Potential on the grid (2D array).

    Notes
    -----
    - 2013-01-24 - Written - Bovy (IAS)
    - 2013-01-29 - Added forces - Bovy (IAS)


    Calculate spline coefficients for a 2D array.

    Parameters
    ----------
    array2d : numpy.ndarray
        2D array to calculate spline coefficients for.

    Returns
    -------
    ndarray
        New array with spline coefficients.

    Notes
    -----
    - 2013-01-24 - Written - Bovy (IAS)


    Use C to evaluate the interpolated potential.

    Parameters
    ----------
    pot : Potential or list of such instances
        The potential
    R : numpy.ndarray
        Galactocentric cylindrical radius.
    z : numpy.ndarray
        Galactocentric height.

    Returns
    -------
    numpy.ndarray
        Potential evaluated at R and z.

    Notes
    -----
    - 2013-01-24: Written - Bovy (IAS)


    Use C to evaluate the interpolated potential's forces

    Parameters
    ----------
    pot : Potential or list of such instances
        The potential
    R : numpy.ndarray
        Galactocentric cylindrical radius.
    z : numpy.ndarray
        Galactocentric height.
    zforce : bool, optional
        If True, return the vertical force, otherwise return the radial force. Default is False.

    Returns
    -------
    numpy.ndarray
        Force evaluated at R and z.

    Notes
    -----
    - 2013-01-29: Written - Bovy (IAS)


    Plot the rotation curve for this potential (in the z=0 plane for non-spherical potentials).

    Parameters
    ----------
    Pot : Potential or list of Potential instances
        Potential instance or list of such instances.
    Rrange : numpy.ndarray or Quantity
        Range in R to consider (needs to be in the units that you are plotting).
    grid : int, optional
        Number of grid points in R.
    phi : float or Quantity, optional
        Azimuth to use for non-axisymmetric potentials.
    savefilename : str, optional
        Save to or restore from this savefile (pickle).
    *args
        Arguments passed to `galpy.util.plot.plot`.
    **kwargs
        Keyword arguments passed to `galpy.util.plot.plot`.

    Returns
    -------
    matplotlib.Axes
        Axes on which the plot was drawn.

    Notes
    -----
    - 2010-07-10 - Written - Bovy (NYU)
    - 2016-06-15 - Added phi= keyword for non-axisymmetric potential - Bovy (UofT)


    Calculate the rotation curve for this potential (in the z=0 plane for non-spherical potentials).

    Parameters
    ----------
    Pot : Potential or list of Potential instances
        Potential instance or list of such instances.
    Rs : numpy.ndarray or float
        Radius(i).
    phi : float or Quantity, optional
        Azimuth to use for non-axisymmetric potentials.
    t : float or Quantity, optional
        Instantaneous time (default: 0.0)

    Returns
    -------
    numpy.ndarray
        Array of circular rotation velocities.

    Notes
    -----
    - 2011-04-13 - Written - Bovy (NYU)
    - 2016-06-15 - Added phi= keyword for non-axisymmetric potential - Bovy (UofT)


    Calculate the circular velocity at R in potential Pot.

    Parameters
    ----------
    Pot : Potential or list of Potential instances
        Potential instance or list of such instances.
    R : float or Quantity
        Galactocentric radius.
    phi : float or Quantity, optional
        Azimuth to use for non-axisymmetric potentials.
    t : float or Quantity, optional
        Instantaneous time (default: 0.0)
    Returns
    -------
    float or Quantity
        Circular rotation velocity.

    Notes
    -----
    - 2011-10-09 - Written - Bovy (IAS)
    - 2016-06-15 - Added phi= keyword for non-axisymmetric potential - Bovy (UofT)


    Calculate the derivative of the circular velocity wrt R at R in potential Pot.

    Parameters
    ----------
    Pot : Potential or list of Potential instances
        Potential instance or list of such instances.
    R : float or Quantity
        Galactocentric radius.
    phi : float or Quantity, optional
        Azimuth to use for non-axisymmetric potentials.
    t : float, optional
        Instantaneous time (default: 0)

    Returns
    -------
    float or Quantity
        Derivative of the circular rotation velocity wrt R.

    Notes
    -----
    - 2013-01-08 - Written - Bovy (IAS)
    - 2016-06-28 - Added phi= keyword for non-axisymmetric potential - Bovy (UofT)


        Evaluate the Coulomb logarithm ln Lambda.

        Parameters
        ----------
        r : float
            Spherical radius (natural units).
        v : float
            Current velocity in cylindrical coordinates (natural units).

        Returns
        -------
        lnLambda : float
            Coulomb logarithm.

        Notes
        -----
        - 2018-03-18 - Started - Bovy (UofT)


Return gamma. (eqn 3 in the paper)


Return numpy array from B1 up to and including Bn. (eqn. 6)


Return numpy array of dB/dR from B1 up to and including Bn.


Return numpy array from D1 up to and including Dn. (eqn. 7)


Return numpy array of dD/dR from D1 up to and including Dn.


r"""
        Evaluate the radial force.

        Parameters
        ----------
        R : float or Quantity
            Cylindrical radius.
        phi : float or Quantity, optional
            Azimuth (default 0.0).
        t : float  or Quantity, optional
            Time (default 0.0).

        Returns
        -------
        float or Quantity
            Cylindrical radial force F_R(R, (\phi, t)).

        Notes
        -----
        - 2010-07-13 - Written - Bovy (NYU)


        Evaluate the azimuthal torque = - d Phi / d phi.

        Parameters
        ----------
        R : float or Quantity
            Cylindrical radius.
        phi : float or Quantity, optional
            Azimuth (default 0.0).
        t : float or Quantity, optional
            Time (default 0.0).

        Returns
        -------
        float or Quantity
            Azimuthal torque tau_phi(R, (phi, t)).

        Notes
        -----
        - 2010-07-13 - Written - Bovy (NYU)


        Evaluate the second radial derivative.

        Parameters
        ----------
        R : float or Quantity
            Cylindrical radius.
        phi : float or Quantity, optional
            Azimuth (default 0.0).
        t : float or Quantity, optional
            Time (default 0.0).

        Returns
        -------
        float or Quantity
            Second radial derivative d2phi/dR2 of the potential.

        Notes
        -----
        - 2011-10-09 - Written - Bovy (IAS)


        Evaluate the second azimuthal derivative.

        Parameters
        ----------
        R : float or Quantity
            Cylindrical radius.
        phi : float or Quantity, optional
            Azimuth (default 0.0).
        t : float or Quantity, optional
            Time (default 0.0).

        Returns
        -------
        float or Quantity
            Second azimuthal derivative d2phi/dazi2 of the potential.

        Notes
        -----
        - 2014-04-06 - Written - Bovy (IAS)


        Evaluate the mixed radial and azimuthal derivative.

        Parameters
        ----------
        R : float or Quantity
            Cylindrical radius.
        phi : float or Quantity, optional
            Azimuth (default 0.0).
        t : float or Quantity, optional
            Time (default 0.0).

        Returns
        -------
        float or Quantity
            Mixed radial and azimuthal derivative d2phi/dR dazi of the potential.

        Notes
        -----
        - 2014-05-21 - Written - Bovy (IAS)


        Plot the potential.

        Parameters
        ----------
        Rrange : float or Quantity, optional
            Range (can be Quantity).
        grid : int, optional
            Number of points to plot.
        savefilename : str, optional
            Save to or restore from this savefile (pickle).
        *args : list
            Arguments to be passed to `galpy.util.plot.plot`.
        **kwargs : dict
            Keyword arguments to be passed to `galpy.util.plot.plot`.

        Returns
        -------
        plot

        Notes
        -----
        - 2010-07-13 - Written - Bovy (NYU)


        Evaluate the second azimuthal derivative for this potential.

        Parameters
        ----------
        R : float
            Galactocentric cylindrical radius.
        phi : float, optional
            Azimuth.
        t : float, optional
            Time.

        Returns
        -------
        float
            The second azimuthal derivative.

        Notes
        -----
        - 2011-10-17 - Written - Bovy (IAS)


        Evaluate the radial+azimuthal derivative for this potential.

        Parameters
        ----------
        R : float
            Galactocentric cylindrical radius.
        phi : float, optional
            Azimuth.
        t : float, optional
            Time.

        Returns
        -------
        float
            The radial+azimuthal derivative.

        Notes
        -----
        - 2011-10-17 - Written - Bovy (IAS)


        Calculate the circular velocity at R in potential Pot.

        Parameters
        ----------
        R : float or Quantity
            Galactocentric radius.
        phi : float or Quantity, optional
            Azimuth to use for non-axisymmetric potentials.
        t : float or Quantity, optional
            Time (default: 0.0)

        Returns
        -------
        float or Quantity
            Circular rotation velocity.

        Notes
        -----
        - 2011-10-09 - Written - Bovy (IAS)
        - 2016-06-15 - Added phi= keyword for non-axisymmetric potential - Bovy (UofT)


        Calculate the circular angular speed at R in potential Pot.

        Parameters
        ----------
        R : float or Quantity
            Galactocentric radius.
        t : float or Quantity, optional
            Time (default: 0.0)

        Returns
        -------
        float or Quantity
            Circular angular speed.

        Notes
        -----
        - Written on 2011-10-09 by Bovy (IAS).


        Calculate the epicycle frequency at R in this potential.

        Parameters
        ----------
        R : float or Quantity
            Galactocentric radius.
        t : float or Quantity, optional
            Time (default: 0.0).

        Returns
        -------
        float or Quantity
            Epicycle frequency.

        Notes
        -----
        - Written on 2011-10-09 by Bovy (IAS).


        Calculate the radius of a Lindblad resonance.

        Parameters
        ----------
        OmegaP : float or Quantity
            Pattern speed.
        m : int or str, optional
            Order of the resonance (as in m(O-Op)=kappa (negative m for outer)).
            Use m='corotation' for corotation.
        t : float or Quantity, optional
            Time (default: 0.0).
        **kwargs
            Additional arguments passed to `scipy.optimize.brentq`.

        Returns
        -------
        float or Quantity or None
            Radius of Lindblad resonance. None if there is no resonance.

        Notes
        -----
        - Written on 2011-10-09 by Bovy (IAS).


        Calculate the escape velocity at R for the potential.

        Parameters
        ----------
        R : float or Quantity
            Galactocentric radius.
        t : float or Quantity, optional
            Time (default: 0.0).

        Returns
        -------
        float or Quantity
            Escape velocity.

        Notes
        -----
        - Written on 2011-10-09 by Bovy (IAS).


        Plot the rotation curve for this potential.

        Parameters
        ----------
        Rrange : list or Quantity, optional
            Range to plot.
        grid : int, optional
            Number of points to plot.
        savefilename : str, optional
            Save to or restore from this savefile (pickle).
        *args, **kwargs :
            Arguments and keyword arguments for `galpy.util.plot.plot`.

        Returns
        -------
        matplotlib plot
            Plot to output device.

        Notes
        -----
        - 2010-07-13 - Written - Bovy (NYU)


        Plot the escape velocity curve for this potential.

        Parameters
        ----------
        Rrange : list or Quantity, optional
            Range to plot.
        grid : int, optional
            Number of points to plot.
        savefilename : str, optional
            Save to or restore from this savefile (pickle).
        *args, **kwargs :
            Arguments and keyword arguments for `galpy.util.plot.plot`.

        Returns
        -------
        matplotlib plot
            Plot to output device.

        Notes
        -----
        - 2010-07-13 - Written - Bovy (NYU)


        Evaluate the potential.

        Parameters
        ----------
        R : float
            Galactocentric radius.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            Potential at (R, phi, t).

        Notes
        -----
        - 2010-07-13 - Written - Bovy (NYU)


        Evaluate the radial force.

        Parameters
        ----------
        R : float
            Galactocentric radius.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            Radial force at (R, phi, t).

        Notes
        -----
        - Written on 2010-07-13 by Bovy (NYU).


        Evaluate the second radial derivative.

        Parameters
        ----------
        R : float
            Galactocentric radius.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            Second radial derivative at (R, phi, t).

        Notes
        -----
        - 2011-10-09: Written by Bovy (IAS).


    Convert an RZPotential to a planarPotential in the mid-plane (z=0).

    Parameters
    ----------
    RZPot : RZPotential instance or list of such instances
        Existing planarPotential instances are just copied to the output.

    Returns
    -------
    planarPotential instance(s)

    Notes
    -----
    - 2010-07-13 - Written - Bovy (NYU)


        Evaluate the potential.

        Parameters
        ----------
        R : float
            Cylindrical radius.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            Potential at (R, phi, t).

        Notes
        -----
        - 2016-06-02: Written - Bovy (UofT)


        Evaluate the radial force.

        Parameters
        ----------
        R : float
            Cylindrical radius.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            Radial force at (R, phi, t).

        Notes
        -----
        - Written on 2016-06-02 by Bovy (UofT)


        Evaluate the azimuthal torque.

        Parameters
        ----------
        R : float
            Cylindrical radius.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            Azimuthal torque at (R, phi, t).

        Notes
        -----
        - 2016-06-02: Written - Bovy (UofT)


        Evaluate the second radial derivative.

        Parameters
        ----------
        R : float
            Cylindrical radius.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            Second radial derivative at (R, phi, t).

        Notes
        -----
        - 2016-06-02: Written - Bovy (UofT)


        Evaluate the second azimuthal derivative.

        Parameters
        ----------
        R : float
            Cylindrical radius.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            Second azimuthal derivative at (R, phi, t).

        Notes
        -----
        - 2016-06-02: Written - Bovy (UofT)


        Evaluate the mixed radial-azimuthal derivative.

        Parameters
        ----------
        R : float
            Cylindrical radius.
        phi : float, optional
            Azimuth (default: 0.0).
        t : float, optional
            Time (default: 0.0).

        Returns
        -------
        float
            Mixed radial-azimuthal derivative at (R, phi, t).

        Notes
        -----
        - 2016-06-02: Written - Bovy (UofT)


        Return the pattern speed.

        Returns
        -------
        float
            Pattern speed.

        Notes
        -----
        - 2016-05-31: Written - Bovy (UofT)


    Convert an Potential to a planarPotential in the mid-plane (z=0).

    Parameters
    ----------
    Pot : Potential instance or list of such instances
        Existing planarPotential instances are just copied to the output.

    Returns
    -------
    planarPotential, planarAxiPotential, or planarDissipativeForce instance(s)

    Notes
    -----
    - 2016-06-11: Written - Bovy (UofT)


    Evaluate a (list of) planarPotential instance(s).

    Parameters
    ----------
    Pot : planarPotential or list of planarPotential
        A (list of) planarPotential instance(s).
    R : float or Quantity
        Cylindrical radius.
    phi : float or Quantity, optional
        Azimuth (default None).
    t : float or Quantity, optional
        Time (default 0.0).
    dR : int, optional
        If set to a non-zero integer, return the dR derivative instead. Default is 0.
    dphi : int, optional
        If set to a non-zero integer, return the dphi derivative instead. Default is 0.

    Returns
    -------
    float or Quantity
        Potential Phi(R(,phi,t)).

    Notes
    -----
    - 2010-07-13 - Written - Bovy (NYU)


    Evaluate the cylindrical radial force of a (list of) planarPotential instance(s).

    Parameters
    ----------
    Pot : (list of) planarPotential instance(s)
        The potential(s) to evaluate.
    R : float or Quantity
        Cylindrical radius.
    phi : float or Quantity, optional
        Azimuth (default: None).
    t : float or Quantity, optional
        Time (default: 0.0).
    v : numpy.ndarray or Quantity, optional
        Current velocity in cylindrical coordinates (default: None).
        Required when including dissipative forces.

    Returns
    -------
    float or Quantity
        The cylindrical radial force F_R(R, phi, t).

    Notes
    -----
    - 2010-07-13 - Written - Bovy (NYU)
    - 2023-05-29 - Added velocity input for dissipative forces - Bovy (UofT)


    Evaluate the phi torque of a (list of) planarPotential instance(s).

    Parameters
    ----------
    Pot : (list of) planarPotential instance(s)
        The potential(s) to evaluate.
    R : float or Quantity
        Cylindrical radius
    phi : float or Quantity, optional
        Azimuth (default: None)
    t : float or Quantity, optional
        Time (default: 0.0)
    v : numpy.ndarray or Quantity, optional
        Current velocity in cylindrical coordinates (default: None)
        Required when including dissipative forces.

    Returns
    -------
    float or Quantity
        The phitorque tau_phi(R, phi, t).

    Notes
    -----
    - 2010-07-13 - Written - Bovy (NYU)
    - 2023-05-29 - Added velocity input for dissipative forces - Bovy (UofT)


    Evaluate the second radial derivative of planarPotential instance(s).

    Parameters
    ----------
    Pot : (list of) planarPotential instance(s)
        The potential(s) to evaluate.
    R : float or Quantity
        Cylindrical radius
    phi : float or Quantity, optional
        Azimuth (default: None)
    t : float or Quantity, optional
        Time (default: 0.0)

    Returns
    -------
    float or Quantity
        The second potential derivative d2Phi/dR2(R, phi, t).

    Notes
    -----
    - 2010-10-09 - Written - Bovy (IAS)


r"""
    Calculate the Lin & Shu (1966) reduction factor: the reduced linear response of a kinematically-warm stellar disk to a perturbation

    Parameters
    ----------
    axiPot : Potential or list of Potential instances
        The background, axisymmetric potential
    R : float or Quantity
        Cylindrical radius
    sigmar : float or Quantity
        Radial velocity dispersion of the population
    nonaxiPot : Potential object, optional
        A non-axisymmetric Potential instance (such as SteadyLogSpiralPotential) that has functions that return OmegaP, m, and wavenumber. Either provide nonaxiPot or m, k, OmegaP.
    k : float or Quantity, optional
        Wavenumber (see Binney & Tremaine 2008). Either provide nonaxiPot or m, k, OmegaP.
    m : int, optional
        m in the perturbation's m x phi (number of arms for a spiral). Either provide nonaxiPot or m, k, OmegaP.
    OmegaP : float or Quantity, optional
        Pattern speed. Note that in the usual Lin-Shu formula \omega = m x OmegaP. Either provide nonaxiPot or m, k, OmegaP.

    Returns
    -------
    float
        The reduction factor

    Notes
    -----
    - 2014-08-23 - Written - Bovy (IAS)


    Plot a planar potential.

    Parameters
    ----------
    Pot : Potential or list of Potential instances
        Potential or list of potentials to plot
    Rrange : list or Quantity, optional
        Range in R to plot (default is [0.01, 5.0])
    xrange, yrange : list, optional
        Range in x and y to plot (can be Quantity) (default is [-5.0, 5.0])
    grid, gridx, gridy : int, optional
        Number of points to plot (default is 100). grid for 1D plots, gridx and gridy for 2D plots
    savefilename : str, optional
        Save to or restore from this savefile (pickle)
    ncontours : int, optional
        Number of contours to plot (if applicable)
    *args, **kwargs :
        Arguments and keyword arguments for `galpy.util.plot.plot` or `galpy.util.plot.dens2d`

    Returns
    -------
    plot to output device

    Notes
    -----
    - 2010-07-13 - Written - Bovy (NYU)


        Evaluate the radial density derivative x r^(2beta) for this potential.

        Parameters
        ----------
        r : float
            Spherical radius.
        beta : int, optional
            Power of r in the density derivative. Default is 0.

        Returns
        -------
        float
            The derivative of rho x r^{2beta} / d r.

        Notes
        -----
        - 2021-03-15 - Written - Lane (UofT)


        Calculate the energy portion of an isotropic Plummer distribution function.

        Parameters
        ----------
        E : float or Quantity
            The energy.

        Returns
        -------
        ndarray
            The value of the energy portion of the DF.

        Notes
        -----
        - 2020-10-01 - Written - Bovy (UofT)


        Calculate the energy portion of an isotropic NFW distribution function

        Parameters
        ----------
        E : float or Quantity
            The energy.

        Returns
        -------
        ndarray
            The value of the energy portion of the DF.

        Notes
        -----
        - 2021-02-01 - Written - Bovy (UofT)


        Sample from the DF

        Parameters
        ----------
        n : int
            Number of points to return.
        return_orbit : bool, optional
            If True, the output phase-space positions is an orbit.Orbit object. If False, the output is (R,vR,vT,z,vz,phi). Default is True.
        returndt : bool, optional
            If True, also return the time since the star was stripped. Default is False.
        integrate : bool, optional
            If True, integrate the orbits to the present time. If False, return positions at stripping (probably want to combine with returndt=True then to make sense of them!). Default is True.

        Returns
        -------
        Orbit, numpy.ndarray, or tuple
            Orbit instance or (R,vR,vT,z,vz,phi) of points on the stream in 6,N array (set of 6 Quantities when physical output is on); optionally the time is included as well. The ro/vo unit-conversion parameters and the zo/solarmotion parameters as well as whether physical outputs are on, match the settings of the progenitor Orbit given to the class initialization

        Notes
        -----
        - 2018-07-31 - Written - Bovy (UofT)
        - 2022-05-18 - Made output Orbit ro/vo/zo/solarmotion/roSet/voSet match that of the progenitor orbit - Bovy (UofT)
        - 2024-08-11 - Include the progenitor's potential - Yingtian Chen (Umich)


        Sample the positions and velocities around the progenitor
        Must be implemented in a subclass

        Parameters
        ----------
        xyzpt : array, shape (N,3)
            Positions of progenitor in the progenitor coordinates.
        vxyzpt : array, shape (N,3)
            Velocities of progenitor in the progenitor coordinates.
        dt : array, shape (N,)
            Time of sampling.

        Returns
        -------
        xst, yst, zst : array, shape (N,)
            Positions of points on the stream in the progenitor coordinates.
        vxst, vyst, vzst : array, shape (N,)
            Velocities of points on the stream in the progenitor coordinates.


        Sample the positions and velocities around the progenitor

        Parameters
        ----------
        xyzpt : array, shape (N,3)
            Positions of progenitor in the progenitor coordinates.
        vxyzpt : array, shape (N,3)
            Velocities of progenitor in the progenitor coordinates.
        dt : array, shape (N,)
            Time of sampling.

        Returns
        -------
        xst, yst, zst : array, shape (N,)
            Positions of points on the stream in the progenitor coordinates.
        vxst, vyst, vzst : array, shape (N,)
            Velocities of points on the stream in the progenitor coordinates.


Solve the model W(r) at npt points (note: not equally spaced in
        either r or W, because combination of two ODEs for different r ranges)


Density as a function of W


        Calculate the f(Q) portion of an Osipkov-Merritt NFW distribution function

        Parameters
        ----------
        Q : float or Quantity
            The Osipkov-Merritt 'energy' E-L^2/[2ra^2]

        Returns
        -------
        ndarray
            The value of the f(Q) portion of the DF

        Notes
        -----
        - 2021-02-09 - Written - Bovy (UofT)


        Calculate the energy portion of an isotropic Hernquist distribution function

        Parameters
        ----------
        E : float or Quantity
            The energy.

        Returns
        -------
        numpy.ndarray
            The value of the energy portion of the DF.

        Notes
        -----
        - 2020-08-09 - Written - James Lane (UofT)


        Calculate the f(Q) portion of an Osipkov-Merritt Hernquist distribution function

        Parameters
        ----------
        Q : float or numpy.ndarray
            The Osipkov-Merritt 'energy' E-L^2/[2ra^2] (can be Quantity)

        Returns
        -------
        float or numpy.ndarray
            The value of the f(Q) portion of the DF

        Notes
        -----
        - 2020-11-12 - Written - Bovy (UofT)


Call the DF, marginalizing over perpendicular velocity


Call the DF, marginalizing over line-of-sight velocity


        Evaluate the target Sigma_R^2(R)

        Parameters
        ----------
        R : float or Quantity
            Radius at which to evaluate.
        log : bool, optional
            If True, return the log (default: False).

        Returns
        -------
        float
            Target Sigma_R^2(R).

        Notes
        -----
        - 2010-03-28 - Written - Bovy (NYU)


        Evaluate the target surface mass at R.

        Parameters
        ----------
        R : float or Quantity
            Radius at which to evaluate.
        log : bool, optional
            If True, return the log (default: False).

        Returns
        -------
        float or Quantity
            Target surface mass at R.

        Notes
        -----
        - 2010-03-28 - Written - Bovy (NYU)


        Evaluate the target surface mass along the line of sight given Galactic longitude and distance.

        Parameters
        ----------
        d : float or Quantity
            Distance along the line of sight.
        l : float or Quantity
            Galactic longitude in degrees, unless deg=False.
        deg : bool, optional
            If False, l is in radians. Default is True.
        log : bool, optional
            If True, return the logarithm of the surface mass. Default is False.

        Returns
        -------
        float or Quantity
            Surface mass times distance.

        Notes
        -----
        - 2011-03-23 - Written - Bovy (NYU)


        Evaluate the surface mass along the line of sight (LOS) given Galactic longitude and distance.

        Parameters
        ----------
        d : float or Quantity
            Distance along the line of sight.
        l : float or Quantity
            Galactic longitude (in deg, unless deg=False).
        nsigma : float, optional
            Number of sigma to integrate the velocities over.
        target : bool, optional
            If True, use target surfacemass (default).
        romberg : bool, optional
            If True, use a romberg integrator (default: False).
        deg : bool, optional
            If False, l is in radians.
        relative : bool, optional
            If True, return d.

        Returns
        -------
        float
            Sigma(d,l) x d

        Notes
        -----
        - 2011-03-24 - Written - Bovy (NYU)


        Sample a distance along the line of sight

        Parameters
        ----------
        l : float or Quantity
            Galactic longitude.
        n : int, optional
            Number of distances to sample.
        maxd : float or Quantity, optional
            Maximum distance to consider (for the rejection sampling).
        target : bool, optional
            If True, sample from the 'target' surface mass density, rather than the actual surface mass density (default=True).

        Returns
        -------
        list
            List of samples.

        Notes
        -----
        - 2011-03-24 - Written - Bovy (NYU)


        Sample a radial and azimuthal velocity at R

        Parameters
        ----------
        R : float or Quantity
            Galactocentric distance.
        n : int, optional
            Number of distances to sample.
        nsigma : float, optional
            Number of sigma to rejection-sample on.
        target : bool, optional
            If True, sample using the 'target' sigma_R rather than the actual sigma_R (default=True).

        Returns
        -------
        list
            List of samples.

        Notes
        -----
        - 2011-03-24 - Written - Bovy (NYU)


        Sample along a given LOS

        Parameters
        ----------
        los : float or Quantity
            Line of sight Galactic longitude.
        n : int, optional
            Number of distances to sample.
        deg : bool, optional
            If False, los is in radians.
        maxd : float or Quantity, optional
            Maximum distance to consider (for the rejection sampling).
        nsigma : float, optional
            Number of sigma to integrate the velocities over.
        targetSurfmass : bool, optional
            If True, use target surface mass (default=True).
        targetSigma2 : bool, optional
            If True, use target sigma_R^2 (default=True).

        Returns
        -------
        list
            List of Orbits sampled.

        Notes
        -----
        - target=False uses target distribution for derivatives (this is a detail)
        - 2011-03-24 - Written - Bovy (NYU)


        Estimate the asymmetric drift (vc-mean-vphi) from an approximation to the Jeans equation.

        Parameters
        ----------
        R : float or Quantity
            Radius at which to calculate the asymmetric drift.

        Returns
        -------
        float
            Asymmetric drift at R.

        Notes
        -----
        - 2011-04-02 - Written - Bovy (NYU).


        Calculate the surface-mass at R by marginalizing over velocity

        Parameters
        ----------
        R : float or Quantity
            Radius at which to calculate the surfacemass density.
        romberg : bool, optional
            If True, use a romberg integrator (default: False)
        nsigma : float, optional
            Number of sigma to integrate the velocities over
        relative : bool, optional
            If True, return the relative surface mass at R (default: False)

        Returns
        -------
        float
            Surface mass at R

        Notes
        -----
        - 2011-03-XX - Bovy (NYU)


        Calculate the product sigma_R^2 x surface-mass at R by marginalizing over velocity.

        Parameters
        ----------
        R : float or Quantity
            Radius at which to calculate the sigma_R^2 x surfacemass density.
        romberg : bool, optional
            If True, use a romberg integrator (default: False).
        nsigma : float, optional
            Number of sigma to integrate the velocities over.
        relative : bool, optional
            If True, return the relative density (default: False).

        Returns
        -------
        float
            Sigma_R^2 x surface-mass at R.

        Notes
        -----
        - 2010-03-XX - Written - Bovy (NYU).


        Calculate the an arbitrary moment of the velocity distribution at R times the surfacmass

        Parameters
        ----------
        R: float or Quantity
            Galactocentric radius at which to calculate the moment.
        n: int
            vR^n in the moment
        m: int
            vT^m in the moment
        nsigma : int, optional
            number of sigma to integrate the velocities over
        romberg : bool, optional
            If True, use a romberg integrator (default: False)
        deriv : str, optional
            Calculates derivative of the moment wrt R or phi (default: None)

        Returns
        -------
        float or Quantity
            <vR^n vT^m  x surface-mass> at R (no support for units)

        Notes
        -----
        - 2011-03-30 - Written - Bovy (NYU)


Non-physical version of vmomentsurfacemass, otherwise the same


        Calculate the Oort function A.

        Parameters
        ----------
        R : float or Quantity
            Radius at which to calculate A.
        phi : float, optional
            Azimuth (default: 0.0).
        nsigma : int, optional
            Number of sigma to integrate the velocities over.
        romberg : bool, optional
            If True, use a romberg integrator (default: False).

        Returns
        -------
        float or Quantity
            Oort A at R.

        Notes
        -----
        - 2011-04-19 - Written - Bovy (NYU)


        Calculate the Oort function B.

        Parameters
        ----------
        R : float
            Radius at which to calculate B (can be Quantity).
        romberg : bool, optional
            If True, use a romberg integrator (default: False).
        nsigma : float, optional
            Number of sigma to integrate the velocities over.
        phi : float, optional
            Azimuth angle (in radians) at which to calculate B.

        Returns
        -------
        float or Quantity
            Oort B at R.

        Notes
        -----
        - 2011-04-19 - Written - Bovy (NYU).


        Calculate the Oort function C.

        Parameters
        ----------
        R : float or Quantity
            Radius at which to calculate C (can be Quantity).
        nsigma : int, optional
            Number of sigma to integrate the velocities over.
        romberg : bool, optional
            If True, use a romberg integrator (default: False).
        phi : float, optional
            Azimuth (default: 0.0).

        Returns
        -------
        float or Quantity
            Oort C at R.

        Notes
        -----
        - 2011-04-19 - Written - Bovy (NYU)


        Calculate the Oort function K.

        Parameters
        ----------
        R : float
            Radius at which to calculate K (can be Quantity).
        phi : float, optional
            Azimuth angle (in radians) at which to calculate K.
        nsigma : int, optional
            Number of sigma to integrate the velocities over.
        romberg : bool, optional
            If True, use a romberg integrator (default: False).

        Returns
        -------
        float or Quantity
            Oort K at R.

        Notes
        -----
        - 2011-04-19 - Written - Bovy (NYU)


        Calculate sigma_R^2 at R by marginalizing over velocity.

        Parameters
        ----------
        R : float
            Radius at which to calculate sigma_R^2 density.
        romberg : bool, optional
            If True, use a romberg integrator (default: False).
        nsigma : int, optional
            Number of sigma to integrate the velocities over.
        phi : float, optional
            Azimuth angle at which to calculate sigma_R^2 density.

        Returns
        -------
        float or Quantity
            Sigma_R^2 at R.

        Notes
        -----
        - 2010-03-XX - Written - Bovy (NYU)


        Calculate sigma_T^2 at R by marginalizing over velocity

        Parameters
        ----------
        R : float
            Radius at which to calculate sigma_T^2 (can be Quantity)
        romberg : bool, optional
            If True, use a romberg integrator (default: False)
        nsigma : int, optional
            Number of sigma to integrate the velocities over
        phi : float, optional
            Azimuth (default: 0.0)

        Returns
        -------
        float or Quantity
            Sigma_T^2 at R

        Notes
        -----
        - 2011-03-30 - Written - Bovy (NYU)


        Calculate sigma_R^2 at R by marginalizing over velocity.

        Parameters
        ----------
        R : float
            Radius at which to calculate sigma_R^2.
        romberg : bool, optional
            If True, use a romberg integrator (default: False).
        nsigma : int, optional
            Number of sigma to integrate the velocities over.
        phi : float, optional
            Azimuth (default: 0.0).

        Returns
        -------
        float or Quantity
            Sigma_R^2 at R.

        Notes
        -----
        - 2011-03-30 - Written - Bovy (NYU).


        Calculate the mean tangential velocity at a given radius by marginalizing over velocity.

        Parameters
        ----------
        R : float
            Radius at which to calculate the mean tangential velocity.
        romberg : bool, optional
            If True, use a Romberg integrator. Default is False.
        nsigma : float, optional
            Number of sigma to integrate the velocities over.
        phi : float, optional
            Azimuth angle at which to calculate the mean tangential velocity.

        Returns
        -------
        float or Quantity
            The mean tangential velocity at the given radius.

        Notes
        -----
        - 2011-03-30 - Written - Bovy (NYU)


        Calculate <vR> at R by marginalizing over velocity.

        Parameters
        ----------
        R : float
            Radius at which to calculate <vR>.
        romberg : bool, optional
            If True, use a romberg integrator (default: False).
        nsigma : float, optional
            Number of sigma to integrate the velocities over.
        phi : float, optional
            Azimuth angle at which to calculate <vR>.

        Returns
        -------
        float or Quantity
            <vR> at R.

        Notes
        -----
        - 2011-03-30 - Written - Bovy (NYU).


        Calculate skew in vT at R by marginalizing over velocity

        Parameters
        ----------
        R : float
            Radius at which to calculate <vR>
        romberg : bool, optional
            If True, use a romberg integrator (default: False)
        nsigma : float, optional
            Number of sigma to integrate the velocities over
        phi : float, optional
            Azimuth (default: 0.0)

        Returns
        -------
        float
            Skew in vT

        Notes
        -----
        - 2011-12-07 - Written - Bovy (NYU)


        Calculate skew in vR at R by marginalizing over velocity.

        Parameters
        ----------
        R : float or Quantity
            Radius at which to calculate <vR>.
        romberg : bool, optional
            If True, use a romberg integrator (default: False).
        nsigma : float, optional
            Number of sigma to integrate the velocities over.
        phi : float, optional
            Azimuth (in radians) at which to calculate the skew in vR.

        Returns
        -------
        float
            Skew in vR.

        Notes
        -----
        - 2011-12-07 - Written - Bovy (NYU).


        Calculate excess kurtosis in vT at R by marginalizing over velocity

        Parameters
        ----------
        R : float or Quantity
            Radius at which to calculate <vR>
        romberg : bool, optional
            If True, use a romberg integrator (default: False)
        nsigma : float, optional
            Number of sigma to integrate the velocities over
        phi : float, optional
            (default: 0.0)

        Returns
        -------
        float
            kurtosisvT

        Notes
        -----
        - 2011-12-07 - Written - Bovy (NYU)


        Calculate excess kurtosis in vR at R by marginalizing over velocity

        Parameters
        ----------
        R : float or Quantity
            Radius at which to calculate <vR>
        romberg : bool, optional
            If True, use a romberg integrator (default: False)
        nsigma : float, optional
            Number of sigma to integrate the velocities over
        phi : float or Quantity, optional
            Azimuth (default: 0.0)

        Returns
        -------
        float
            KurtosisvR

        Notes
        -----
        - 2011-12-07 - Written - Bovy (NYU)


        Calculate the radial frequency based on energy and angular momentum and return the pericenter and apocenter radii.

        Parameters
        ----------
        E : float
            Energy.
        L : float
            Angular momentum.

        Returns
        -------
        tuple
            Tuple containing:
            - wR(E.L) : float
                Radial frequency.
            - rap : float
                Apocenter radius.
            - rperi : float
                Pericenter radius.

        Notes
        -----
        - 2010-07-11 - Written - Bovy (NYU)


        Sample n*nphi points from this disk DF.

        Parameters
        ----------
        n : int, optional
            Number of desired samples. Default is 1.
        rrange : list, optional
            If you only want samples in this rrange, set this keyword (only works when asking for an (RZ)Orbit).
        returnROrbit : bool, optional
            If True, return a planarROrbit instance: [R,vR,vT] (default).
        returnOrbit : bool, optional
            If True, return a planarOrbit instance (including phi).
        nphi : float, optional
            Number of azimuths to sample for each E,L.
        los : float, optional
            Line of sight sampling along this line of sight.
        losdeg : bool, optional
            If True, los is in degrees (default).
        nsigma : int, optional
            Number of sigma to rejection-sample on.
        maxd : float, optional
            Maximum distance to consider (for the rejection sampling).
        target : bool, optional
            If True, use target surface mass and sigma2 profiles (default).

        Returns
        -------
        list
            n*nphi list of [[E,Lz],...] or list of planar(R)Orbits.
            CAUTION: lists of EL need to be post-processed to account for the
                    \\kappa/\\omega_R discrepancy

        Notes
        -----
        - 2010-07-10 - Started  - Bovy (NYU)


        Quickly estimate the mean radial velocity at a given radius R.

        Parameters
        ----------
        R : float
            Radius at which to evaluate (/ro).
        phi : float, optional
            Azimuth angle (not used).
        log : bool, optional
            If True, return the logarithm of the target Sigma_R^2(R).

        Returns
        -------
        float
            The target Sigma_R^2(R).

        Notes
        -----
        - 2010-03-28 - Written - Bovy (NYU)


        Quickly estimate the mean tangential velocity at a given radius.

        Parameters
        ----------
        R : float
            Radius at which to evaluate (/ro).
        phi : float, optional
            Azimuth angle (not used).
        log : bool, optional
            If True, return the logarithm of the estimate.

        Returns
        -------
        float
            The estimated mean tangential velocity.

        Notes
        -----
        - 2010-03-28 - Written - Bovy (NYU)


        Quickly estimate SigmaR2.

        Parameters
        ----------
        R : float
            Radius at which to evaluate (/ro).
        phi : float, optional
            Azimuth (not used).
        log : bool, optional
            If True, return the log (default: False).

        Returns
        -------
        float
            Target Sigma_R^2(R).

        Notes
        -----
        - 2010-03-28 - Written - Bovy (NYU)


        Quickly estimate SigmaT2.

        Parameters
        ----------
        R : float
            Radius at which to evaluate (/ro).
        phi : float, optional
            Azimuth (not used).
        log : bool, optional
            If True, return the log (default: False).

        Returns
        -------
        float
            Target Sigma_R^2(R).

        Notes
        -----
        - 2010-03-28 - Written - Bovy (NYU)


        Evaluate the distribution function.

        Parameters
        ----------
        E : float or Quantity
            Energy.
        L : float or Quantity
            Angular momentum.
        logSigmaR : float, optional
            Logarithm of the radial velocity dispersion.
        logsigmaR2 : float, optional
            Logarithm of the square of the radial velocity dispersion.

        Returns
        -------
        float
            DF(E,L)

        Notes
        -----
        - 2010-03-10 - Written - Bovy (NYU).
        - 2010-03-28 - Moved to dehnenDF - Bovy (NYU).


        Sample n*nphi points from this DF.

        Parameters
        ----------
        n : int, optional
            Number of desired samples (specifying this rather than calling
            this routine n times is more efficient). Default is 1.
        rrange : list or tuple, optional
            If you only want samples in this rrange, set this keyword
            (only works when asking for an (RZ)Orbit). Default is None.
        returnROrbit : bool, optional
            If True, return a planarROrbit instance: [R,vR,vT] (default).
            Default is True.
        returnOrbit : bool, optional
            If True, return a planarOrbit instance (including phi).
            Default is False.
        nphi : float, optional
            Number of azimuths to sample for each E,L. Default is 1.0.
        los : float or Quantity, optional
            If set, sample along this line of sight (deg) (assumes that the Sun is located at R=1,phi=0).
            Default is None.
        losdeg : bool, optional
            If False, los is in radians (default=True). Default is True.
        nsigma : int, optional
            Number of sigma to rejection-sample on. Default is None.
        targetSurfmass : bool, optional
            If True, use target surface mass profile. Default is True.
        targetSigma2 : bool, optional
            If True, use target sigma2 profile. Default is True.
        maxd : float or Quantity, optional
            Maximum distance to consider (for the rejection sampling). Default is None.
        **kwargs : dict, optional
            Additional keyword arguments.

        Returns
        -------
        out : list
            n*nphi list of [[E,Lz],...] or list of planar(R)Orbits.
            CAUTION: lists of EL need to be post-processed to account for the
            \\kappa/\\omega_R discrepancy; EL not returned in physical units.

        Notes
        -----
        - 2010-07-10 - Started  - Bovy (NYU)


        Evaluate the distribution function.

        Parameters
        ----------
        E : float
            Energy (/vo^2).
        L : float
            Angular momentum (/ro/vo).
        logSigmaR : float, optional
            Logarithm of the radial velocity dispersion squared.
        logsigmaR2 : float, optional
            Logarithm of the radial velocity dispersion squared.

        Returns
        -------
        float
            DF(E,L).

        Notes
        -----
        - 2010-05-09 - Written - Bovy (NYU)


Internal function that is the integrand for the sigma-squared times
    surface mass integration


Internal function that is the integrand for the velocity moment times
    surface mass integration


Internal function that is the integrand for the derivative of velocity
    moment times surface mass integration


Internal function that calculates E and L given velocities normalized by the velocity dispersion


Internal function for bovy_dblquad


    Compute a double integral using Romberg integration for the one-dimensional integrals and a specified tolerance.

    Parameters
    ----------
    func : callable
        Function of two variables to integrate.
    a : float
        Lower limit of integration in the outer integral.
    b : float
        Upper limit of integration in the outer integral.
    gfun : callable
        Function of one variable that returns the lower limit of integration in the inner integral for a given value of the outer variable.
    hfun : callable
        Function of one variable that returns the upper limit of integration in the inner integral for a given value of the outer variable.
    args : tuple, optional
        Extra arguments to pass to the integrand function.
    tol : float, optional
        Desired absolute tolerance.

    Returns
    -------
    float
        The value of the double integral.

    Notes
    -----
    - 2010-03-11 - Written - Bovy (NYU)


        Calculate the correction in Sigma and sigma2 at R.

        Parameters
        ----------
        R : float
            Galactocentric radius (/ro).
        log : bool, optional
            If True, return the log of the correction.

        Returns
        -------
        tuple
            (Sigma correction, sigma2 correction).

        Notes
        -----
        - 2010-03-10 - Written - Bovy (NYU)


        Calculate the derivative of the log of the correction in Sigma and sigma2 at R.

        Parameters
        ----------
        R : float
            Galactocentric radius(/ro)

        Returns
        -------
        numpy.ndarray
            [d log(Sigma correction)/dR, d log(sigma2 correction)/dR]

        Notes
        -----
        - 2010-03-10 - Written - Bovy (NYU)


Internal function that calculates the corrections


    Calculate the energy and angular momentum.

    Parameters
    ----------
    vR : float
        Radial velocity.
    vT : float
        Rotational velocity.
    R : float
        Galactocentric radius.
    beta : float
        Parameter that determines the shape of the rotation curve.
    dftype : str, optional
        Type of disk distribution function. Default is "dehnen".

    Returns
    -------
    tuple
        Energy and angular momentum.

    Notes
    -----
    - 2010-03-10 - Written - Bovy (NYU)


    Return the axisymmetric potential at R/Ro.

    Parameters
    ----------
    R : float
        Galactocentric radius.
    beta : float, optional
        Rotation curve power-law.

    Returns
    -------
    float
        Pot(R)/vo**2.

    Notes
    -----
    - 2010-03-01 - Written - Bovy (NYU)


    h(x) for ARS sampling of the input surfacemass profile

    Parameters
    ----------
    x : float
        R(/ro)
    args : tuple
        surfaceSigma - surfaceSigmaProfile instance
        dfcorr - DFcorrection instance

    Returns
    -------
    float
        log(x)+log surface(x) + log(correction)

    Notes
    -----
    - 2010-07-11 - Written - Bovy (NYU)


    h'(x) for ARS sampling of the input surfacemass profile

    Parameters
    ----------
    x : float
        R(/ro)
    args : tuple
        surfaceSigma - surfaceSigmaProfile instance
        dfcorr - DFcorrection instance

    Returns
    -------
    float
        derivative of log(x)+log surface(x) + log(correction) wrt x

    Notes
    -----
    - 2010-07-11 - Written - Bovy (NYU)


Convert d and l to R and phi, l is in radians


Equation to solve to find the max vT at R


        Compute the differential energy distribution dM/dE: the amount of mass per unit energy

        Parameters
        ----------
        E : float or numpy.ndarray
            Energy; can be a Quantity

        Returns
        -------
        float, numpy.ndarray, or Quantity
            The differential energy distribution

        Notes
        -----
        - 2023-05-23 - Written - Bovy (UofT)


        Calculate an arbitrary moment of the velocity distribution at r times the density.

        Parameters
        ----------
        r : float
            Spherical radius at which to calculate the moment.
        n : float
            vr^n, where vr = v x cos eta.
        m : float
            vt^m, where vt = v x sin eta.

        Returns
        -------
        float or Quantity
            <vr^n vt^m x density> at r.

        Notes
        -----
        - 2020-09-04 - Written - Bovy (UofT)


        Calculate the radial velocity dispersion at radius r.

        Parameters
        ----------
        r : float
            Spherical radius at which to calculate the radial velocity dispersion.

        Returns
        -------
        float or Quantity
            The radial velocity dispersion at radius r.

        Notes
        -----
        - 2020-09-04 - Written - Bovy (UofT)


        Calculate the tangential velocity dispersion at radius r.

        Parameters
        ----------
        r : float
            Spherical radius at which to calculate the tangential velocity dispersion.

        Returns
        -------
        float or Quantity
            The tangential velocity dispersion at radius r.

        Notes
        -----
        - 2020-09-04 - Written - Bovy (UofT)


        Calculate the anisotropy at radius r.

        Parameters
        ----------
        r : float
            Spherical radius at which to calculate the anisotropy.

        Returns
        -------
        float
            Anisotropy at radius r.

        Notes
        -----
        - 2020-09-04 - Written - Bovy (UofT)


        Sample the DF

        Parameters
        ----------
        R : float, numpy.ndarray, Quantity, or None, optional
            If set, sample velocities at this radius. If array, sample velocities at these radii, ignoring n.
        z : float, numpy.ndarray, Quantity, or None, optional
            If set, sample velocities at this height. If array, sample velocities at these heights, ignoring n.
        phi : float, numpy.ndarray, Quantity, or None, optional
            If set, sample velocities at this azimuth. If array, sample velocities at these azimuths, ignoring n.
        n : int, optional
            Number of samples to generate. Default is 1.
        return_orbit : bool, optional
            If True, return an orbit.Orbit instance. If False, return a tuple of (R,vR,vT,z,vz,phi). Default is True.
        rmin : float, Quantity, optional
            Minimum radius at which to sample. Default is 0.

        Returns
        -------
        orbit.Orbit instance or tuple
            If return_orbit is True, an orbit.Orbit instance. Otherwise, a tuple of (R,vR,vT,z,vz,phi).

        Notes
        -----
        - When specifying position, it is necessary to specify both R and z; if phi is not set in this case, it is sampled
        - 2020-07-22 - Written - Lane (UofT)


Generate radial position samples from potential
        Note - the function interpolates the normalized CMF onto the variable
        xi defined as:

        .. math:: \\xi = \\frac{r/a-1}{r/a+1}

        so that xi is in the range [-1,1], which corresponds to an r range of
        [0,infinity)


Create the interpolator object for calculating radii from the CMF
        Note - must use self.xi_to_r() on any output of interpolator
        Note - the function interpolates the normalized CMF onto the variable
        xi defined as:

        .. math:: \\xi = \\frac{r-1}{r+1}

        so that xi is in the range [-1,1], which corresponds to an r range of
        [0,infinity)


Generate spherical angle samples


Generate velocity samples: typically the total velocity, but not for OM


Generate samples of angles that set radial vs tangential
        velocities


Function that gives the max velocity in the DF at r;
        typically equal to vesc, but not necessarily for finite systems
        such as King


        Calculate a grid of the velocity sampling function v^2*f(E) over many
        radii. The radii are fractional with respect to some scale radius
        which characteristically describes the size of the potential,
        and the velocities are fractional with respect to the escape velocity
        at each radius r. This information is saved in a 2D interpolator which
        represents the inverse cumulative distribution at many radii. This
        allows for sampling of v/vesc given an input r/a

        Parameters
        ----------
        r_a_start : float, optional
            Radius grid start location in units of log10(r/a). Default is -3.
        r_a_end : float, optional
            Radius grid end location in units of log10(r/a). Default is 3.
        n_r_a : int, optional
            Number of radius grid points to use. Default is 120.
        n_v_vesc : int, optional
            Number of velocity grid points to use. Default is 100.

        Returns
        -------
        scipy.interpolate.RectBivariateSpline
            Interpolator for v/vesc given an input r/a.

        Notes
        -----
        - 2020-07-24 - Written - Lane (UofT)


        Set up the interpolator for r(phi)

        Parameters
        ----------
        r_a_min : float, optional
            Minimum r/a. Default is 1e-6.
        r_a_max : float, optional
            Maximum r/a. Default is 1e6.
        nra : int, optional
            Number of points to use in the r/a grid. Default is 10001.

        Returns
        -------
        scipy.interpolate.InterpolatedUnivariateSpline
            Interpolator for r(phi).

        Notes
        -----
        - 2023-02-23 - Written - Lane (UofT)


        Calculate the distribution function for an isotropic DF.

        Parameters
        ----------
        *args : tuple of (E,L,Lz) with L and Lz optionalA

        Returns
        -------
        float
            The distribution function evaluated at E.

        Notes
        -----
        - 2020-07 - Written - Lane (UofT)


        Calculate the an arbitrary moment of the velocity distribution at (R,phi) times the surfacmass

        Parameters
        ----------
        R : float
            Radius at which to calculate the moment (in natural units).
        phi : float, optional
            Azimuth (rad unless deg=True).
        n : int
            vR^n.
        m : int
            vT^m.
        t : float, optional
            Time at which to evaluate the DF (can be a list or ndarray; if this is the case, list needs to be in descending order and equally spaced).
        nsigma : float, optional
            Number of sigma to integrate the velocities over (based on an estimate, so be generous, but not too generous).
        deg : bool, optional
            Azimuth is in degree (default=False).
        epsrel : float, optional
            scipy.integrate keyword (the integration calculates the ratio of this vmoment to that of the initial DF).
        epsabs : float, optional
            scipy.integrate keyword (the integration calculates the ratio of this vmoment to that of the initial DF).
        grid : bool, optional
            If set to True, build a grid and use that to evaluate integrals; if set to a grid-objects (such as returned by this procedure), use this grid; if this was created for a list of times, moments are calculated for each time.
        gridpoints : int, optional
            Number of points to use for the grid in 1D (default=101).
        returnGrid : bool, optional
            If True, return the grid object (default=False).
        hierarchgrid : bool, optional
            If True, use a hierarchical grid (default=False).
        nlevels : int, optional
            Number of hierarchical levels for the hierarchical grid.
        print_progress : bool, optional
            If True, print progress updates.
        integrate_method : str, optional
            orbit.integrate method argument.
        deriv : str, optional
            None, 'R', or 'phi': calculates derivative of the moment wrt R or phi **onnly with grid options**.

        Returns
        -------
        float or numpy.ndarray
            <vR^n vT^m  x surface-mass> at R,phi (no support for units).

        Notes
        -----
        - grid-based calculation is the only one that is heavily tested (although the test suite also tests the direct calculation)
        - 2011-03-30 - Written - Bovy (NYU)


        Calculate the vertex deviation of the velocity distribution at (R,phi)

        Parameters
        ----------
        R : float
            radius at which to calculate the moment (can be Quantity)
        t : float, optional
            time at which to evaluate the DF (can be a list or ndarray; if this is the case, list needs to be in descending order and equally spaced) (can be Quantity), by default 0.0
        nsigma : float, optional
            number of sigma to integrate the velocities over (based on an estimate, so be generous), by default None
        deg : bool, optional
            azimuth is in degree (default=False); do not set this when giving phi as a Quantity, by default False
        epsrel : float, optional
            scipy.integrate keywords (the integration calculates the ratio of this vmoment to that of the initial DF), by default 1.0e-02
        epsabs : float, optional
            scipy.integrate keywords (the integration calculates the ratio of this vmoment to that of the initial DF), by default 1.0e-05
        phi : float, optional
            azimuth (rad unless deg=True; can be Quantity), by default 0.0
        grid : bool or evolveddiskdfGrid or evolveddiskdfHierarchicalGrid, optional
            if set to True, build a grid and use that to evaluate integrals; if set to a grid-objects (such as returned by this procedure), use this grid, by default None
        gridpoints : int, optional
            number of points to use for the grid in 1D (default=101), by default 101
        returnGrid : bool, optional
            if True, return the grid object (default=False), by default False
        sigmaR2 : float, optional
            if set the vertex deviation is simply calculated using these, by default None
        sigmaT2 : float, optional
            if set the vertex deviation is simply calculated using these, by default None
        sigmaRT : float, optional
            if set the vertex deviation is simply calculated using these, by default None
        surfacemass : None, optional
            Not used, by default None
        hierarchgrid : bool, optional
            if True, use a hierarchical grid (default=False), by default False
        nlevels : int, optional
            number of hierarchical levels for the hierarchical grid, by default 2
        integrate_method : str, optional
            orbit.integrate method argument, by default "dopr54_c"

        Returns
        -------
        float or tuple
            vertex deviation in rad or tuple of vertex deviation in rad and grid object

        Notes
        -----
        - 2011-03-31 - Written - Bovy (NYU)


        Calculate the mean vR of the velocity distribution at (R,phi)

        Parameters
        ----------
        R : float
            radius at which to calculate the moment(/ro) (can be Quantity)
        phi : float, optional
            azimuth (rad unless deg=True; can be Quantity) (default=0.0)
        t : float or array, optional
            time at which to evaluate the DF (can be a list or ndarray; if this is the case, list needs to be in descending order and equally spaced) (can be Quantity) (default=0.0)
        surfacemass : float, optional
            if set use this pre-calculated surfacemass (default=None)
        nsigma : float, optional
            number of sigma to integrate the velocities over (based on an estimate, so be generous) (default=None)
        deg : bool, optional
            azimuth is in degree (default=False); do not set this when giving phi as a Quantity
        epsrel : float, optional
            scipy.integrate keywords (the integration calculates the ratio of this vmoment to that of the initial DF) (default=1.0e-02)
        epsabs : float, optional
            scipy.integrate keywords (the integration calculates the ratio of this vmoment to that of the initial DF) (default=1.0e-05)
        grid : bool or evolveddiskdfGrid or evolveddiskdfHierarchicalGrid, optional
            if set to True, build a grid and use that to evaluate integrals; if set to a grid-objects (such as returned by this procedure), use this grid (default=None)
        gridpoints : int, optional
            number of points to use for the grid in 1D (default=101)
        returnGrid : bool, optional
            if True, return the grid object (default=False)
        hierarchgrid : bool, optional
            if True, use a hierarchical grid (default=False)
        nlevels : int, optional
            number of hierarchical levels for the hierarchical grid (default=2)
        integrate_method : str, optional
            orbit.integrate method argument (default="dopr54_c")

        Returns
        -------
        float or tuple
            mean vR

        Notes
        -----
        -2011-03-31 - Written - Bovy (NYU)


        Calculate the mean vT of the velocity distribution at (R,phi)

        Parameters
        ----------
        R : float
            radius at which to calculate the moment(/ro) (can be Quantity)
        phi : float, optional
            azimuth (rad unless deg=True; can be Quantity) (default=0.0)
        t : float or array, optional
            time at which to evaluate the DF (can be a list or ndarray; if this is the case, list needs to be in descending order and equally spaced) (can be Quantity) (default=0.0)
        surfacemass : float, optional
            if set use this pre-calculated surfacemass (default=None)
        nsigma : float, optional
            number of sigma to integrate the velocities over (based on an estimate, so be generous) (default=None)
        deg : bool, optional
            azimuth is in degree (default=False); do not set this when giving phi as a Quantity
        epsrel : float, optional
            scipy.integrate keywords (the integration calculates the ratio of this vmoment to that of the initial DF) (default=1.0e-02)
        epsabs : float, optional
            scipy.integrate keywords (the integration calculates the ratio of this vmoment to that of the initial DF) (default=1.0e-05)
        grid : bool or evolveddiskdfGrid or evolveddiskdfHierarchicalGrid, optional
            if set to True, build a grid and use that to evaluate integrals; if set to a grid-objects (such as returned by this procedure), use this grid (default=None)
        gridpoints : int, optional
            number of points to use for the grid in 1D (default=101)
        returnGrid : bool, optional
            if True, return the grid object (default=False)
        hierarchgrid : bool, optional
            if True, use a hierarchical grid (default=False)
        nlevels : int, optional
            number of hierarchical levels for the hierarchical grid (default=2)
        integrate_method : str, optional
            orbit.integrate method argument (default="dopr54_c")

        Returns
        -------
        float or tuple
            mean vT

        Notes
        -----
        -2011-03-31 - Written - Bovy (NYU)


        Calculate the radial variance of the velocity distribution at (R,phi)

        Parameters
        ----------
        R : float
            Radius at which to calculate the moment (can be Quantity)
        t : float, optional
            Time at which to evaluate the DF (can be a list or ndarray; if this is the case, list needs to be in descending order and equally spaced) (can be Quantity)
        nsigma : float, optional
            Number of sigma to integrate the velocities over (based on an estimate, so be generous)
        deg : bool, optional
            Azimuth is in degree (default=False); do not set this when giving phi as a Quantity
        phi : float, optional
            Azimuth (rad unless deg=True; can be Quantity)
        epsrel : float, optional
            Scipy.integrate keyword (the integration calculates the ratio of this vmoment to that of the initial DF)
        epsabs : float, optional
            Scipy.integrate keyword (the integration calculates the ratio of this vmoment to that of the initial DF)
        grid : bool or evolveddiskdfGrid or evolveddiskdfHierarchicalGrid, optional
            If set to True, build a grid and use that to evaluate integrals; if set to a grid-objects (such as returned by this procedure), use this grid
        gridpoints : int, optional
            Number of points to use for the grid in 1D (default=101)
        returnGrid : bool, optional
            If True, return the grid object (default=False)
        surfacemass : float, optional
            If set use this pre-calculated surfacemass
        meanvR : float, optional
            If set use this pre-calculated mean vR
        hierarchgrid : bool, optional
            If True, use a hierarchical grid (default=False)
        nlevels : int, optional
            Number of hierarchical levels for the hierarchical grid
        integrate_method : str, optional
            orbit.integrate method argument

        Returns
        -------
        float or tuple
            Variance of vR. If returnGrid is True, return a tuple with the variance of vR and the grid object.

        Notes
        -----
        - 2011-03-31 - Written - Bovy (NYU)


        Calculate the rotational-velocity variance of the velocity distribution at (R,phi)

        Parameters
        ----------
        R : float
            Radius at which to calculate the moment (can be Quantity)
        phi : float, optional
            Azimuth (rad unless deg=True; can be Quantity), by default 0.0
        t : float or array, optional
            Time at which to evaluate the DF (can be a list or ndarray; if this is the case, list needs to be in descending order and equally spaced) (can be Quantity), by default 0.0
        surfacemass : float, optional
            If set use this pre-calculated surfacemass and mean rotational velocity, by default None
        meanvT : float, optional
            If set use this pre-calculated surfacemass and mean rotational velocity, by default None
        nsigma : float, optional
            Number of sigma to integrate the velocities over (based on an estimate, so be generous), by default None
        deg : bool, optional
            Azimuth is in degree (default=False); do not set this when giving phi as a Quantity, by default False
        epsrel : float, optional
            Scipy.integrate keywords (the integration calculates the ratio of this vmoment to that of the initial DF), by default 1.0e-02
        epsabs : float, optional
            Scipy.integrate keywords (the integration calculates the ratio of this vmoment to that of the initial DF), by default 1.0e-05
        grid : bool or evolveddiskdfGrid or evolveddiskdfHierarchicalGrid, optional
            If set to True, build a grid and use that to evaluate integrals; if set to a grid-objects (such as returned by this procedure), use this grid, by default None
        gridpoints : int, optional
            Number of points to use for the grid in 1D (default=101), by default 101
        returnGrid : bool, optional
            If True, return the grid object (default=False), by default False
        hierarchgrid : bool, optional
            If True, use a hierarchical grid (default=False), by default False
        nlevels : int, optional
            Number of hierarchical levels for the hierarchical grid, by default 2
        integrate_method : str, optional
            orbit.integrate method argument, by default "dopr54_c"

        Returns
        -------
        float or tuple
            Variance of vT or tuple of variance of vT and grid object

        Notes
        -----
        - 2011-03-31 - Written - Bovy (NYU)


        Calculate the radial-rotational co-variance of the velocity distribution at (R,phi)

        Parameters
        ----------
        R : float
            Radius at which to calculate the moment (can be Quantity)
        phi : float, optional
            Azimuth (rad unless deg=True; can be Quantity), by default 0.0
        t : float or array, optional
            Time at which to evaluate the DF (can be a list or ndarray; if this is the case, list needs to be in descending order and equally spaced) (can be Quantity), by default 0.0
        surfacemass : float, optional
            If set use this pre-calculated surfacemass and mean rotational velocity, by default None
        meanvT : float, optional
            If set use this pre-calculated surfacemass and mean rotational velocity, by default None
        nsigma : float, optional
            Number of sigma to integrate the velocities over (based on an estimate, so be generous), by default None
        deg : bool, optional
            Azimuth is in degree (default=False); do not set this when giving phi as a Quantity, by default False
        epsrel : float, optional
            Scipy.integrate keywords (the integration calculates the ratio of this vmoment to that of the initial DF), by default 1.0e-02
        epsabs : float, optional
            Scipy.integrate keywords (the integration calculates the ratio of this vmoment to that of the initial DF), by default 1.0e-05
        grid : bool or evolveddiskdfGrid or evolveddiskdfHierarchicalGrid, optional
            If set to True, build a grid and use that to evaluate integrals; if set to a grid-objects (such as returned by this procedure), use this grid, by default None
        gridpoints : int, optional
            Number of points to use for the grid in 1D (default=101), by default 101
        returnGrid : bool, optional
            If True, return the grid object (default=False), by default False
        hierarchgrid : bool, optional
            If True, use a hierarchical grid (default=False), by default False
        nlevels : int, optional
            Number of hierarchical levels for the hierarchical grid, by default 2
        integrate_method : str, optional
            orbit.integrate method argument, by default "dopr54_c"

        Returns
        -------
        float or tuple
            Covariance of vR and vT or tuple of covariance of vR and vT and grid object

        Notes
        -----
        - 2011-03-31 - Written - Bovy (NYU)