times = M.get_current_derived_parameters(['tau_rec', 'conformal_age']) tau_rec = times['tau_rec'] tau_0 = times['conformal_age'] tau1 = np.logspace(math.log10(tau_ini), math.log10(tau_rec), tau_num_early) tau2 = np.logspace(math.log10(tau_rec), math.log10(tau_0), tau_num_late)[1:] tau2[-1] *= 0.999 # this tiny shift avoids interpolation errors tau = np.concatenate((tau1, tau2)) tau_num = len(tau) # # use table of background and thermodynamics quantitites to define some functions # returning some characteristic scales # (of Hubble crossing, sound horizon crossing, etc.) at different time # background = M.get_background() # load background table #print background.viewkeys() thermodynamics = M.get_thermodynamics() # load thermodynamics table #print thermodynamics.viewkeys() # background_tau = background[ 'conf. time [Mpc]'] # read conformal times in background table background_z = background['z'] # read redshift background_aH = 2. * math.pi * background['H [1/Mpc]'] / ( 1. + background['z']) / M.h() # read 2pi * aH in [h/Mpc] background_ks = 2. * math.pi / background['comov.snd.hrz.'] / M.h( ) # read 2pi/(comoving sound horizon) in [h/Mpc] background_rho_m_over_r = (background['(.)rho_b'] + background['(.)rho_cdm']) / ( background['(.)rho_g'] + background['(.)rho_ur'] ) # read rho_r / rho_m (to find time of equality) background_rho_l_over_m = background['(.)rho_lambda'] / ( background['(.)rho_b'] + background['(.)rho_cdm']
times = M.get_current_derived_parameters(['tau_rec','conformal_age']) tau_rec=times['tau_rec'] tau_0 = times['conformal_age'] tau1 = np.logspace(math.log10(tau_ini),math.log10(tau_rec),tau_num_early) tau2 = np.logspace(math.log10(tau_rec),math.log10(tau_0),tau_num_late)[1:] tau2[-1] *= 0.999 # this tiny shift avoids interpolation errors tau = np.concatenate((tau1,tau2)) tau_num = len(tau) # # use table of background and thermodynamics quantitites to define some functions # returning some characteristic scales # (of Hubble crossing, sound horizon crossing, etc.) at different time # background = M.get_background() # load background table #print background.viewkeys() thermodynamics = M.get_thermodynamics() # load thermodynamics table #print thermodynamics.viewkeys() # background_tau = background['conf. time [Mpc]'] # read conformal times in background table background_z = background['z'] # read redshift background_aH = 2.*math.pi*background['H [1/Mpc]']/(1.+background['z'])/M.h() # read 2pi * aH in [h/Mpc] background_ks = 2.*math.pi/background['comov.snd.hrz.']/M.h() # read 2pi/(comoving sound horizon) in [h/Mpc] background_rho_m_over_r = (background['(.)rho_b']+background['(.)rho_cdm']) /(background['(.)rho_g']+background['(.)rho_ur']) # read rho_r / rho_m (to find time of equality) background_rho_l_over_m = background['(.)rho_lambda'] /(background['(.)rho_b']+background['(.)rho_cdm']) # read rho_m / rho_lambda (to find time of equality) thermodynamics_tau = thermodynamics['conf. time [Mpc]'] # read confromal times in thermodynamics table thermodynamics_kd = 2.*math.pi/thermodynamics['r_d']/M.h() # read 2pi(comoving diffusion scale) in [h/Mpc] # # define a bunch of interpolation functions based on previous quantities # background_z_at_tau = interp1d(background_tau,background_z) background_aH_at_tau = interp1d(background_tau,background_aH)
'omega_cdm': 0.1201075, 'A_s': 2.100549e-09, 'n_s': 0.9660499, 'tau_reio': 0.05430842, 'thermodynamics_verbose': 1 } ############## # # call CLASS # ############### M = Class() M.set(common_settings) M.compute() derived = M.get_current_derived_parameters(['tau_rec', 'conformal_age']) thermo = M.get_thermodynamics() print(thermo.keys()) # In[ ]: tau = thermo['conf. time [Mpc]'] g = thermo['g [Mpc^-1]'] # to make the reionisation peak visible, rescale g by 100 for late times g[:500] *= 100 ################# # # start plotting # ################# # plt.xlim([1.e2, derived['conformal_age']])