contraction_agama.py
def density_from_enclosed_mass( r_bins, enclosed_mass, out_r_bins ):
    """ Converts an array of enclosed masses to 3D densities.
   
   Args:
      r_bins             : the radial bins at which the enclosed mass is defined.
      enclosed_mass      : array of enclosed masses.
      out_r_bins         : array of radial distances at which the density will be interpolated.
   Returns:
      Array of densities at the location of the output radial distances.
   """
    bin_mass = enclosed_mass[1:] - enclosed_mass[:-1]
    shell_vol= 4.*np.pi/3. * (r_bins[1:]**3 - r_bins[:-1]**3)
    bin_dens = bin_mass / shell_vol
    r_vals = np.sqrt( r_bins[1:] * r_bins[:-1] )
    return np.interp( out_r_bins, r_vals, bin_dens )
 Converts an array of enclosed masses to 3D densities.
   
   Args:
      r_bins             : the radial bins at which the enclosed mass is defined.
      enclosed_mass      : array of enclosed masses.
      out_r_bins         : array of radial distances at which the density will be interpolated.
   Returns:
      Array of densities at the location of the output radial distances.
   
Converts an array of enclosed masses to 3D densities.
Converts an array of enclosed masses to 3D densities .
def density_from_enclosed_mass( r_bins, enclosed_mass, out_r_bins ):
    bin_mass = enclosed_mass[1:] - enclosed_mass[:-1]
    shell_vol= 4.*np.pi/3. * (r_bins[1:]**3 - r_bins[:-1]**3)
    bin_dens = bin_mass / shell_vol
    r_vals = np.sqrt( r_bins[1:] * r_bins[:-1] )
    return np.interp( out_r_bins, r_vals, bin_dens )
def density_from_enclosed_mass ( r_bins , enclosed_mass , out_r_bins ) : bin_mass = enclosed_mass [ 1 : ] - enclosed_mass [ : - 1 ] shell_vol = 4. * np . pi / 3. * ( r_bins [ 1 : ] ** 3 - r_bins [ : - 1 ] ** 3 ) bin_dens = bin_mass / shell_vol r_vals = np . sqrt ( r_bins [ 1 : ] * r_bins [ : - 1 ] ) return np . interp ( out_r_bins , r_vals , bin_dens )
Converts an array of enclosed masses to 3D densities.
Converts an array of enclosed masses to 3D densities .
""" Converts an array of enclosed masses to 3D densities.
   
   Args:
      r_bins             : the radial bins at which the enclosed mass is defined.
      enclosed_mass      : array of enclosed masses.
      out_r_bins         : array of radial distances at which the density will be interpolated.
   Returns:
      Array of densities at the location of the output radial distances.
   """
Array of densities at the location of the output radial distances.
Array of densities at the location of the output radial distances .
r_bins
enclosed_mass
out_r_bins
r_bins             
the radial bins at which the enclosed mass is defined.
the radial bins at which the enclosed mass is defined .
enclosed_mass      
array of enclosed masses.
array of enclosed masses .
out_r_bins         
array of radial distances at which the density will be interpolated.
array of radial distances at which the density will be interpolated .