def power(ell, theta, clump=True): eps_f = theta[0] eps_DM = theta[1] f_star = theta[2] S_star = theta[3] A_C = theta[4] alpha0 = theta[5] n_nt = theta[6] beta = theta[7] gamma_mod0 = theta[8] gamma_mod_zslope = theta[9] x_break = theta[10] x_smooth = theta[11] n_nt_mod = theta[12] clump0 = theta[13] clump_zslope = theta[14] x_clump = theta[15] alpha_clump1 = theta[16] alpha_clump2 = theta[17] xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f * 1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, clump_zslope, x_clump, alpha_clump1, alpha_clump2) model = xx_power.return_yy_power(ell) # [erg cm^-2 s^-1 str^-1]^2 return model
def cxb(theta): eps_f = theta[0] eps_DM = theta[1] f_star = theta[2] S_star = theta[3] A_C = theta[4] alpha0 = theta[5] n_nt = theta[6] beta = theta[7] gamma_mod0 = theta[8] gamma_mod_zslope = theta[9] x_break = theta[10] x_smooth = theta[11] n_nt_mod = theta[12] clump0 = theta[13] clump_zslope = theta[14] x_clump = theta[15] alpha_clump1 = theta[16] alpha_clump2 = theta[17] xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f * 1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, clump_zslope, x_clump, alpha_clump1, alpha_clump2) return (xx_power.return_total_xsb() / (4.0 * math.pi))
def pressure_profile(x, mass, redshift, theta): eps_f = theta[0] eps_DM = theta[1] f_star = theta[2] S_star = theta[3] A_C = theta[4] A_nt = theta[5] B_nt = theta[6] gamma_nt = theta[7] gamma_mod0 = theta[8] gamma_mod_zslope = theta[9] x_break = theta[10] x_smooth = theta[11] n_nt_mod = theta[12] clump0 = theta[13] alpha_clump = theta[14] beta_clump = theta[15] gamma_clump = theta[16] xx_power.set_Flender_params(eps_f * 1e-6, eps_DM, f_star, S_star, A_C, A_nt, B_nt, gamma_nt, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, alpha_clump, beta_clump, gamma_clump) #xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f*1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, clump_zslope, x_clump, alpha_clump1, alpha_clump2) pressure = xx_power.return_pressure_profile(x, redshift, mass) return pressure
def density_profile(x, mass, redshift, theta): eps_f = theta[0] eps_DM = theta[1] f_star = theta[2] S_star = theta[3] A_C = theta[4] A_nt = theta[5] B_nt = theta[6] gamma_nt = theta[7] gamma_mod0 = theta[8] gamma_mod_zslope = theta[9] x_break = theta[10] x_smooth = theta[11] n_nt_mod = theta[12] clump0 = theta[13] alpha_clump = theta[14] beta_clump = theta[15] gamma_clump = theta[16] xx_power.set_Flender_params(eps_f * 1e-6, eps_DM, f_star, S_star, A_C, A_nt, B_nt, gamma_nt, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, alpha_clump, beta_clump, gamma_clump) density = xx_power.return_density_profile(x, redshift, mass) # in cm^-3 density = density * mmw * m_p # g cm^-3 E = np.sqrt(Omega_m * (1 + redshift)**3 + Omega_l) density /= rho_crit * E**2 # \rho/\rho_crit(z) return density
def lnlike(theta, x, y, invcov): ''' double alpha0; // fiducial : 0.18 double n_nt; // fiducial : 0.80 double beta; // fiducial : 0.50 double eps_f; // fiducial : 3.97e-6 double eps_DM; // fiducial : 0.00 double f_star; // fiducial : 0.026 double S_star; // fiducial : 0.12 double A_C; // fiducial : 1.00 double gamma_mod0; // fiducial : 0.10 double gamma_mod_zslope; // fiducial : 1.72 double x_break; // fiducial : 0.195 double x_smooth; // fiducial : 0.01 ''' eps_f, f_star, S_star, gamma_mod0, clump0, alpha_clump, beta_clump, gamma_clump = theta eps_f = 10**eps_f f_star = 10**f_star S_star = 10**S_star gamma_mod0 = 10**gamma_mod0 clump0 = 10**clump0 alpha_clump = 10**alpha_clump beta_clump = 10**beta_clump gamma_clump = 10**gamma_clump #fix DM profile eps_DM = 3e-5 A_C = 1.0 #fix non-thermal pressure term A_nt = 0.452 B_nt = 0.841 gamma_nt = 1.628 x_smooth = 0.01 x_break = 0.195 #gamma_mod0 = 0.10 gamma_mod_zslope = 1.72 #S_star = 0.12 #clumping terms #clump0 = 0.0 #alpha_clump = 1.0 #beta_clump = 6.0 #gamma_clump = 3.0 xx_power.set_Flender_params(eps_f * 1e-6, eps_DM, f_star, S_star, A_C, A_nt, B_nt, gamma_nt, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, clump0, alpha_clump, beta_clump, gamma_clump) model = xx_power.return_xx_power_alt(x) #sn = np.full(x.shape, 10.0**log_noise, dtype = np.float64) #model += sn #model /= beam(x) diff = np.array(y - model, dtype=np.float64) lnl = -0.5 * np.dot(diff, np.dot(invcov, np.transpose(diff))) return lnl
def xray_flux(mass, redshift, theta): eps_f = theta[0] eps_DM = theta[1] f_star = theta[2] S_star = theta[3] A_C = theta[4] alpha0 = theta[5] n_nt = theta[6] beta = theta[7] gamma_mod0 = theta[8] gamma_mod_zslope = theta[9] x_break = theta[10] x_smooth = theta[11] n_nt_mod = theta[12] clump0 = theta[13] alpha_clump = theta[14] beta_clump = theta[15] gamma_clump = theta[16] xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f * 1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, alpha_clump, beta_clump, gamma_clump) flux = xx_power.return_flux(redshift, mass) m500 = xx_power.Mvir_to_Mdeltac(redshift, mass, 500.0) return flux, m500
def cxb(theta): eps_f = theta[0] eps_DM = theta[1] f_star = theta[2] S_star = theta[3] A_C = theta[4] A_nt = theta[5] B_nt = theta[6] gamma_nt = theta[7] gamma_mod0 = theta[8] gamma_mod_zslope = theta[9] x_break = theta[10] x_smooth = theta[11] n_nt_mod = theta[12] clump0 = theta[13] alpha_clump = theta[14] beta_clump = theta[15] gamma_clump = theta[16] xx_power.set_Flender_params(eps_f * 1e-6, eps_DM, f_star, S_star, A_C, A_nt, B_nt, gamma_nt, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, alpha_clump, beta_clump, gamma_clump) return (xx_power.return_total_xsb())
def power(ell, theta, clump=True): eps_f = theta[0] eps_DM = theta[1] f_star = theta[2] S_star = theta[3] A_C = theta[4] A_nt = theta[5] B_nt = theta[6] gamma_nt = theta[7] gamma_mod0 = theta[8] gamma_mod_zslope = theta[9] x_break = theta[10] x_smooth = theta[11] n_nt_mod = theta[12] clump0 = theta[13] alpha_clump = theta[14] beta_clump = theta[15] gamma_clump = theta[16] xx_power.set_Flender_params(eps_f * 1e-6, eps_DM, f_star, S_star, A_C, A_nt, B_nt, gamma_nt, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, alpha_clump, beta_clump, gamma_clump) #model = xx_power.return_xx_power(ell) # [erg cm^-2 s^-1 str^-1]^2 model_alt = xx_power.return_xx_power_alt(ell) # [erg cm^-2 s^-1 str^-1]^2 return model_alt
def lnlike(theta, x, y, invcov): ''' double alpha0; // fiducial : 0.18 double n_nt; // fiducial : 0.80 double beta; // fiducial : 0.50 double eps_f; // fiducial : 3.97e-6 double eps_DM; // fiducial : 0.00 double f_star; // fiducial : 0.026 double S_star; // fiducial : 0.12 double A_C; // fiducial : 1.00 double gamma_mod0; // fiducial : 0.10 double gamma_mod_zslope; // fiducial : 1.72 double x_break; // fiducial : 0.195 double x_smooth; // fiducial : 0.01 double n_nt_mod; // fiducial : 0.80 ''' #alpha0, n_nt, beta, eps_f, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod = theta #xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f*1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod) #eps_f, f_star, S_star, gamma_mod0, gamma_mod_zslope, clump0, clump_zslope = theta log_noise = theta #fix DM profile eps_DM = 0.006 A_C = 1.0 eps_f = 5.0 f_star = 0.026 S_star = 0.12 #fix non-thermal pressure term alpha0 = 0.18 n_nt = 0.80 beta = 0.50 x_smooth = 0.01 n_nt_mod = 0.80 x_break = 0.195 gamma_mod0 = 0.10 gamma_mod_zslope = 1.72 #clumping terms clump0 = 0.0 clump_zslope = 0.0 x_clump = 1.23 alpha_clump1 = 0.88 alpha_clump2 = 3.85 xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f*1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, clump_zslope, x_clump, alpha_clump1, alpha_clump2 ) model = xx_power.return_xx_power(x) # [erg cm^-2 s^-1 str^-1]^2 sn = np.full(x.shape, 10.0**log_noise, dtype = np.float64) model = sn diff = np.array(y-model, dtype=np.float64) lnl = -0.5*np.dot(diff, np.dot(invcov, np.transpose(diff))) return lnl
def power_spectrum(x, *theta): ''' double alpha0; // fiducial : 0.18 double n_nt; // fiducial : 0.80 double beta; // fiducial : 0.50 double eps_f; // fiducial : 3.97e-6 double eps_DM; // fiducial : 0.00 double f_star; // fiducial : 0.026 double S_star; // fiducial : 0.12 double A_C; // fiducial : 1.00 double gamma_mod0; // fiducial : 0.10 double gamma_mod_zslope; // fiducial : 1.72 double x_break; // fiducial : 0.195 double x_smooth; // fiducial : 0.01 double n_nt_mod; // fiducial : 0.80 ''' #alpha0, n_nt, beta, eps_f, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod = theta #xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f*1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod) #eps_f, f_star, S_star, gamma_mod0, gamma_mod_zslope, clump0, clump_zslope = theta eps_f, f_star, S_star, clump0, clump_zslope = theta #fix DM profile eps_DM = 0.006 A_C = 1.0 #fix non-thermal pressure term alpha0 = 0.18 n_nt = 0.80 beta = 0.50 x_smooth = 0.01 n_nt_mod = 0.80 x_break = 0.195 gamma_mod0 = 0.10 gamma_mod_zslope = 1.72 #clumping terms #clump0 = 0.0 #clump_zslope = 0.0 x_clump = 1.23 alpha_clump1 = 0.88 alpha_clump2 = 3.85 xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f * 1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, clump_zslope, x_clump, alpha_clump1, alpha_clump2) model = xx_power.return_xx_power(x, flux_lim) # [erg cm^-2 s^-1 str^-1]^2 return model
def power(ell): ''' double alpha0; // fiducial : 0.18 double n_nt; // fiducial : 0.80 double beta; // fiducial : 0.50 double eps_f; // fiducial : 3.97e-6 double eps_DM; // fiducial : 0.00 double f_star; // fiducial : 0.026 double S_star; // fiducial : 0.12 double A_C; // fiducial : 1.00 double gamma_mod0; // fiducial : 0.10 double gamma_mod_zslope; // fiducial : 1.72 double x_break; // fiducial : 0.195 double x_smooth; // fiducial : 0.01 double n_nt_mod; // fiducial : 0.80 ''' #Shaw model param eps_f = 3.97e-6 eps_DM = 0.00 f_star = 0.026 S_star = 0.12 A_C = 1.00 gamma_mod0 = 0.10 gamma_mod_zslope = 1.72 #fix non-thermal pressure term alpha0 = 0.18 n_nt = 0.80 beta = 0.50 x_smooth = 0.01 n_nt_mod = 0.80 x_break = 0.1 #clumping terms clump0 = 0.0 clump_zslope = 0.0 x_clump = 1.0 alpha_clump1 = 0.0 alpha_clump2 = 0.0 xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f * 1.e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, clump_zslope, x_clump, alpha_clump1, alpha_clump2) model = xx_power.return_xx_power(ell, flux_lim) # [erg cm^-2 s^-1 str^-1]^2 #model = xx_power.return_xx_power(ell) # [erg cm^-2 s^-1 str^-1]^2 return model
def ysz_m(mass, redshift, theta): eps_f = theta[0] eps_DM = theta[1] f_star = theta[2] S_star = theta[3] A_C = theta[4] alpha0 = theta[5] n_nt = theta[6] beta = theta[7] gamma_mod0 = theta[8] gamma_mod_zslope = theta[9] x_break = theta[10] x_smooth = theta[11] n_nt_mod = theta[12] clump0 = theta[13] alpha_clump = theta[14] beta_clump = theta[15] gamma_clump = theta[16] xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f * 1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, alpha_clump, beta_clump, gamma_clump) ysz = [] m500 = [] for m in mass: ysz.append(yy_power.return_Ysz(redshift, m)) m500.append(xx_power.Mvir_to_Mdeltac(redshift, m, 500.0)) ysz = np.array(ysz) m500 = np.array(m500) E = np.sqrt(Omega_m * (1 + redshift)**3 + Omega_l) ysz = ysz * E**(-2. / 3.) return ysz, m500
def xxpower(ell, theta, survey=None): eps_f = theta[0] eps_DM = theta[1] f_star = theta[2] S_star = theta[3] A_C = theta[4] alpha0 = theta[5] n_nt = theta[6] beta = theta[7] gamma_mod0 = theta[8] gamma_mod_zslope = theta[9] x_break = theta[10] x_smooth = theta[11] n_nt_mod = theta[12] clump0 = theta[13] clump_zslope = theta[14] x_clump = theta[15] alpha_clump1 = theta[16] alpha_clump2 = theta[17] xx_power.set_Flender_params(alpha0, n_nt, beta, 1e-6 * eps_f, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, clump_zslope, x_clump, alpha_clump1, alpha_clump2) cl = xx_power.return_xx_power(ell) # [erg cm^-2 s^-1 str^-1]^2 if survey == None: psn = 0 else: psn = beam(ell, fwhm=survey_fwhm[survey]) * survey_psn[survey] var = (2. / ((2. * ell + 1) * survey_fsky[survey])) * (cl)**2 return cl, var
def tx_m(mass, redshift, theta): eps_f = theta[0] eps_DM = theta[1] f_star = theta[2] S_star = theta[3] A_C = theta[4] alpha0 = theta[5] n_nt = theta[6] beta = theta[7] gamma_mod0 = theta[8] gamma_mod_zslope = theta[9] x_break = theta[10] x_smooth = theta[11] n_nt_mod = theta[12] clump0 = theta[13] alpha_clump = theta[14] beta_clump = theta[15] gamma_clump = theta[16] xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f * 1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, alpha_clump, beta_clump, gamma_clump) tx = [] m500 = [] for m in mass: tx.append(xx_power.return_Tx(redshift, m)) m500.append(xx_power.Mvir_to_Mdeltac(redshift, m, 500.0)) tx = np.array(tx) m500 = np.array(m500) return tx, m500
def mgas_m(mass, redshift, theta): eps_f = theta[0] eps_DM = theta[1] f_star = theta[2] S_star = theta[3] A_C = theta[4] A_nt = theta[5] B_nt = theta[6] gamma_nt = theta[7] gamma_mod0 = theta[8] gamma_mod_zslope = theta[9] x_break = theta[10] x_smooth = theta[11] n_nt_mod = theta[12] clump0 = theta[13] alpha_clump = theta[14] beta_clump = theta[15] gamma_clump = theta[16] xx_power.set_Flender_params(eps_f * 1e-6, eps_DM, f_star, S_star, A_C, A_nt, B_nt, gamma_nt, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, alpha_clump, beta_clump, gamma_clump) mgas = [] m500 = [] for m in mass: mgas.append(xx_power.return_Mgas(redshift, m)) m500.append(xx_power.Mvir_to_Mdeltac(redshift, m, 500.0)) mgas = np.array(mgas) m500 = np.array(m500) return mgas, m500
def power_model (x, params) : # set cosmology and linear power spectrum H0=70.000000 Omega_M=0.279000 Omega_b=0.046100 w0=-1.000000 Omega_k=0.000000 n_s=0.972000 nH = 1.e22 inputPk="../input_pk/wmap9_fid_matterpower_z0.dat" xx_power.init_cosmology(H0, Omega_M, Omega_b, w0, Omega_k, n_s, nH, inputPk) ''' double alpha0; // fiducial : 0.18 double n_nt; // fiducial : 0.80 double beta; // fiducial : 0.50 double eps_f; // fiducial : 3.97e-6 double eps_DM; // fiducial : 0.00 double f_star; // fiducial : 0.026 double S_star; // fiducial : 0.12 double A_C; // fiducial : 1.00 double gamma_mod0; // fiducial : 0.10 double gamma_mod_zslope; // fiducial : 1.72 double x_break; // fiducial : 0.195 double x_smooth; // fiducial : 0.01 double n_nt_mod; // fiducial : 0.80 ''' #alpha0, n_nt, beta, eps_f, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod = theta #xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f*1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod) #eps_f, f_star, S_star, gamma_mod0, gamma_mod_zslope, clump0, clump_zslope = theta eps_f, f_star, S_star, clump0, noise = params[0], params[1], params[2], params[3], param[4] #fix DM profile eps_DM = 0.006 A_C = 1.0 #fix non-thermal pressure term alpha0 = 0.18 n_nt = 0.80 beta = 0.50 x_smooth = 0.01 n_nt_mod = 0.80 x_break = 0.195 gamma_mod0 = 0.10 gamma_mod_zslope = 1.72 #clumping terms #clump0 = 0.0 clump_zslope = 0.0 x_clump = 1.23 alpha_clump1 = 0.88 alpha_clump2 = 3.85 xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f*1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, clump_zslope, x_clump, alpha_clump1, alpha_clump2, noise) model = xx_power.return_xx_power(x) # [erg cm^-2 s^-1 str^-1]^2 return model
def lnlike(theta, x, y, invcov): ''' double alpha0; // fiducial : 0.18 double n_nt; // fiducial : 0.80 double beta; // fiducial : 0.50 double eps_f; // fiducial : 3.97e-6 double eps_DM; // fiducial : 0.00 double f_star; // fiducial : 0.026 double S_star; // fiducial : 0.12 double A_C; // fiducial : 1.00 double gamma_mod0; // fiducial : 0.10 double gamma_mod_zslope; // fiducial : 1.72 double x_break; // fiducial : 0.195 double x_smooth; // fiducial : 0.01 double n_nt_mod; // fiducial : 0.80 ''' #alpha0, n_nt, beta, eps_f, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod = theta #xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f*1e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod) #eps_f, f_star, S_star, gamma_mod0, gamma_mod_zslope, clump0, clump_zslope = theta clump0, alpha_clump, beta_clump, gamma_clump = theta eps_f = 3.97 f_star = 0.026 clump0 = 10**clump0 S_star = 0.12 alpha_clump = 10**alpha_clump beta_clump = 10**beta_clump gamma_clump = 10**gamma_clump #fix DM profile eps_DM = 3e-5 A_C = 1.0 #fix non-thermal pressure term alpha0 = 0.18 n_nt = 0.80 beta = 0.50 x_smooth = 0.01 n_nt_mod = 0.80 x_break = 0.195 gamma_mod0 = 0.10 gamma_mod_zslope = 1.72 #S_star = 0.12 #clumping terms #clump0 = 0.0 #alpha_clump = 1.0 #beta_clump = 6.0 #gamma_clump = 3.0 xx_power.set_Flender_params(alpha0, n_nt, beta, eps_f * 1.e-6, eps_DM, f_star, S_star, A_C, gamma_mod0, gamma_mod_zslope, x_break, x_smooth, n_nt_mod, clump0, alpha_clump, beta_clump, gamma_clump) model = xx_power.return_xx_power_alt(x) # [erg cm^-2 s^-1 str^-1]^2 #sn = np.full(x.shape, 10.0**log_noise, dtype = np.float64) #model += sn #model /= beam(x) diff = np.array(y - model, dtype=np.float64) lnl = -0.5 * np.dot(diff, np.dot(invcov, np.transpose(diff))) return lnl