Beispiel #1
0
def GGas_sat_spectrum(mass_func, z, F, rho_gas, rho_mean, n, population, ngal, k_x, r_x, m_x, T_dm, T_g, T_tot):
	
	"""
	Calculates the power spectrum for the component given in the name. Following the construction from Mohammed, but to general power of k!
	In practice the contributions from k > 50 are so small it is not worth doing it.
	Extrapolates the power spectrum to get rid of the knee, which is a Taylor series artifact.
	"""
	
	n = n + 2
	
	k_x = np.longdouble(k_x)
	
	#T = np.ones((n/2, len(m_x)))
	spec = np.ones(len(k_x))
	integ = np.ones((n/2, len(m_x)))
	T_comb1 = np.ones((n/2, len(m_x)))
	T_comb2 = np.ones((n/2, len(m_x)))
	comp = np.ones((n/2, len(k_x)), dtype=np.longdouble)
	
	# Calculating all the needed T's! 
	"""
	for i in range(0, n/2, 1):
		T[i,:] = T_n(i, rho_mean, z, m_x, r_x)
	"""		
	norm = 1.0/((T_tot[0,:])**2.0)
	
	for k in range(0, n/2, 1):
		#print ('k:'), k
		#print ('-----------')
		T_combined1 = np.ones((k+1, len(m_x)))
		T_combined2 = np.ones((k+1, len(m_x)))
		
		for j in range(0, k+1, 1):
			
			T_combined1[j,:] = T_dm[j,:] * T_g[k-j,:]
			
			 
		T_comb1[k,:] = np.sum(T_combined1, axis=0)
		T_comb2[k,:] = 1.0#T_g[k,:]#np.sum(T_combined2, axis=0)
		
		#print T_comb[k,:]
		
		integ[k,:] = norm*(population*mass_func.dndlnm*T_comb1[k,:]*T_comb2[k,:])/(F*rho_gas*ngal)
		comp[k,:] = Integrate(integ[k,:], m_x) * (k_x**(k*2.0)) * (-1.0)**(k)
	
	spec = np.sum(comp, axis=0)
	spec[spec >= 10.0**10.0] = np.nan
	spec[spec <= 0.0] = np.nan
	
	spec_ext = extrap1d(np.float64(k_x), np.float64(spec), 0.002, 2)
	
	
	return spec_ext
def extend_curves(freqs, curves, new_freqs, Noct=0):
    """ Extrapolates (freqs,curves) by using  a new frequency bands 'new_freqs'.
        Noct will smooth the resulting curves in 1/Noct, Noct=0 will not.
    """
    new_curves = np.zeros((curves.shape[0], len(new_freqs)))
    for i, curve in enumerate(curves):
        I = interp1d(freqs, curve)
        X = extrap1d(I)
        if Noct:
            new_curves[i] = smooth(new_freqs, X(new_freqs), Noct)
        else:
            new_curves[i] = X(new_freqs)
    return new_curves
Beispiel #3
0
def GGas_TwoHalo(mass_func, z, F, rho_gas, rho_mean, n, k_x, r_x, m_x, T_g, T_tot): # This is ok!
	
	"""
	Calculates the power spectrum for the component given in the name. Following the construction from Mohammed, but to general power of k!
	In practice the contributions from k > 50 are so small it is not worth doing it.
	Extrapolates the power spectrum to get rid of the knee, which is a Taylor series artifact.
	"""
	
	"""
	Norm = rho_stars in this case!
	"""
	
	n = n + 2
	
	k_x = np.longdouble(k_x)
	
	#T = np.ones((n/2, len(m_x)))
	spec = np.ones(len(k_x))
	integ = np.ones((n/2, len(m_x)))
	T_comb = np.ones((n/2, len(m_x)))
	comp = np.ones((n/2, len(k_x)))
	
	# Calculating all the needed T's! 
	"""
	for i in range(0, n/2, 1):
		T[i,:] = T_n(i, rho_mean, z, m_x, r_x)
	"""		
	norm = 1.0/(T_tot[0,:])
	
	for k in range(0, n/2, 1):
		
		T_comb[k,:] = T_g[k,:]
		
		integ[k,:] = norm*(mass_func.dndlnm*T_comb[k,:]*halo.Bias_Tinker10(mass_func,r_x))/(F*rho_gas)#/m_x)/(rho_stars) # Fivided by m or not?
		comp[k,:] = Integrate(integ[k,:], m_x) * (k_x**(k*2.0)) * (-1.0)**(k)
	
	spec = np.sum(comp, axis=0)
	spec[spec >= 10.0**10.0] = np.nan
	spec[spec <= 0.0] = np.nan
	
	spec_ext =  extrap1d(np.float64(k_x), np.float64(spec), 0.01, 2)
	
	#P2 = (np.exp(mass_func.power)/norm)*(Integrate((mass_func.dndlnm*T_stars2*Bias_Tinker10(mass_func,r_x)/m_x),m_x))
	
    #print (Integrate((mass_func.dndlnm*population*Bias_Tinker10(mass_func,r_x)/m_x),m_x))/norm
	print ("Two halo term calculated - gas.")
	
	return spec_ext*np.exp(mass_func.power)
Beispiel #4
0
def GS_cen_spectrum(mass_func, z, rho_stars, rho_mean, n, population, ngal, k_x, r_x, m_x, T_stars, T_tot):
	
	"""
	Calculates the power spectrum for the component given in the name. Following the construction from Mohammed, but to general power of k!
	In practice the contributions from k > 50 are so small it is not worth doing it.
	Extrapolates the power spectrum to get rid of the knee, which is a Taylor series artifact.
	"""
	
	n = n + 2
	
	k_x = np.longdouble(k_x)
	
	#T = np.ones((n/2, len(m_x)))
	spec = np.ones(len(k_x))
	integ = np.ones((n/2, len(m_x)))
	T_comb = np.ones((n/2, len(m_x)))
	comp = np.ones((n/2, len(k_x)), dtype=np.longdouble)
	
	# Calculating all the needed T's! 
	"""
	for i in range(0, n/2, 1):
		T[i,:] = T_n(i, rho_mean, z, m_x, r_x)
	"""		
	norm = 1.0/(T_tot[0,:])
	
	for k in range(0, n/2, 1):
		
		T_comb[k,:] = T_stars[k,:]
		
		integ[k,:] = norm*(population*mass_func.dndlnm*T_comb[k,:])/(rho_stars*ngal)
		comp[k,:] = Integrate(integ[k,:], m_x) * (k_x**(k*2.0)) * (-1.0)**(k)

	spec = np.sum(comp, axis=0)
	spec[spec >= 10.0**10.0] = np.nan
	spec[spec <= 0.0] = np.nan
	
	spec_ext = extrap1d(np.float64(k_x), np.float64(spec), 0.01, 3)
	
	return spec_ext