def T_line(z,line_name="CII",fduty=1.0): mass_bin, dndlnM= hmf(z) L_line= mhalo_to_lline(mass_bin, z, line_name=line_name) L_line*=p.Lsun nu_rest_line_Hz=p.nu_rest(line_name)*p.Ghz_to_hz integrand=dndlnM * L_line integration=simps(integrand, np.log(mass_bin)) factor=fduty*(p.c_in_m**3/8.0/np.pi)*((1+z)**2/(p.kb_si*nu_rest_line_Hz**3*p.cosmo.H_z(z))) result=factor*integration return result
def I_line(z,line_name="CII"): #mass_range=np.logspace(np.log10(Mmin), np.log10(Mmax),num=500) mass_bin, dndlnM= hmf(z) L_line = mhalo_to_lline(mass_bin, z, line_name=line_name) L_line *= p.Lsun #factor= (p.c_in_m)/(4*p.Ghz_to_hz*np.pi*p.nu_rest(line_name=line_name)*p.cosmo.H_z(z)) factor= (p.c_in_m)/(4*p.Ghz_to_hz*np.pi*p.nu_rest(line_name=line_name)*p.cosmo.H_z(z)) integrand=factor * dndlnM * L_line integration=simps(integrand, np.log(mass_bin)) return (integration)/(p.jy_unit)# In Jy/sr unit
def nu_obs_to_z(nu_obs, line_name='CII'): """ This function evaluates the redshift of a particular line emission corresponding to the observed frequency. return: redshift of line emission. """ nu_rest_line = p.nu_rest(line_name=line_name) assert ( nu_obs <= nu_rest_line ), "Observed frequency cannot be smaller than the %s rest frame frequency. In that case z will be negative, which is non physical" % ( line_name) z = (nu_rest_line / nu_obs) - 1 return z
def inu(z, line_name='CII'): mass_bin, dndlnM= hmf(z) L_line= mhalo_to_lline(mass_bin, z, line_name=line_name) L_line*=p.Lsun #factor= (p.c_in_m)/(4*p.Ghz_to_hz*np.pi*p.nu_rest(line_name=line_name)*p.cosmo.H_z(z)) dl_bi_dnu= (p.c_in_m)*(1+z)**2/(p.Ghz_to_hz*p.nu_rest(line_name=line_name)*p.cosmo.H_z(z)) da=p.cosmo.D_co(z) # For a flat universe dl=p.cosmo.D_luminosity(z) #factor= (p.c_in_m)/(4*p.Ghz_to_hz*np.pi*p.nu_rest(line_name=line_name)) integrand=(dndlnM * L_line * da**2 * dl_bi_dnu) / (4 * np.pi * dl**2) integration=simps(integrand, np.log(mass_bin)) return integration/(p.jy_unit)
def V_pix(z, theta_min, delta_nu, line_name='CII'): ''' z: redshift lambda_line: frequncy of line emission in micrometer theta_min: beam size in arc-min delta_nu: the frequency resolution in GHz ''' theta_rad = theta_min * p.minute_to_radian nu = p.nu_rest(line_name) * p.Ghz_to_hz delta_nu *= p.Ghz_to_hz lambda_line = freq_to_lambda(nu) y = lambda_line * (1 + z)**2 / cosmo.H_z(z) res = cosmo.D_co(z)**2 * y * (theta_rad)**2 * delta_nu return res * (p.m_to_mpc)**3
def V_surv(z, S_area, B_nu, line_name='CII'): ''' Calculates the survey volume in MPc. z: redshift lambda_line: frequncy of line emission in micrometer A_s: Survey area in degree**2 B_nu: Total frequency band width resolution in GHz return: Survey volume. ''' nu = p.nu_rest(line_name) * p.Ghz_to_hz B_nu *= p.Ghz_to_hz Sa_rad = S_area * (p.degree_to_radian)**2 lambda_line = freq_to_lambda(nu) y = lambda_line * (1 + z)**2 / cosmo.H_z(z) res = cosmo.D_co(z)**2 * y * (Sa_rad) * B_nu return res * (p.m_to_mpc)**3
def calc_intensity_3d(boxsize, ngrid, halocat_file, halo_redshift, line_name='CII', halo_cutoff_mass=1e11, use_scatter=False, halocat_file_type='npz', intensity_unit='jy/sr'): ''' Calculate luminosity for input parameters ''' #low_mass_log=0.0 cellsize = boxsize / ngrid V_cell = (cellsize)**3 halomass, halo_cm = lu.make_halocat(halocat_file, filetype=halocat_file_type, boxsize=boxsize) nhalo = len(halomass) x_halos = halo_cm[range(0, nhalo * 3, 3)] y_halos = halo_cm[range(1, nhalo * 3, 3)] z_halos = halo_cm[range(2, nhalo * 3, 3)] print('Minimum halo mass:', halomass.min()) print('Maximum halo mass:', halomass.max()) #halomass_filter=halomass #mh=halomass) #logmh=np.array([int(logmh[key]) for key in range(nhalo)]) mass_cut = halomass >= halo_cutoff_mass halomass = halomass[mass_cut] x_halos_cut = x_halos[mass_cut] y_halos_cut = y_halos[mass_cut] z_halos_cut = z_halos[mass_cut] halo_cm = np.concatenate([x_halos_cut, y_halos_cut, z_halos_cut]) hcut_len = len(halomass) lcp = np.zeros(hcut_len) for i in range(hcut_len): lcp[i] = mhalo_to_lline(halomass[i], halo_redshift, line_name=line_name, use_scatter=use_scatter) grid_lum = lu.grid(halo_cm, lcp, boxsize, ngrid, ndim=3) #print("shape of grid_lum", np.shape(grid_lum)) prefac = p.c_in_m / (4 * np.pi * p.nu_rest(line_name=line_name) * p.Ghz_to_hz * p.cosmo.H_z(halo_redshift)) #print("shape of prefac", np.shape(prefac)) if (intensity_unit == "jy" or intensity_unit == "Jy" or intensity_unit == "JY"): grid_intensity = prefac * ( grid_lum * p.Lsun / (V_cell * p.mpc_to_m**3)) / p.jy_unit #transformed to jansky unit if (intensity_unit == "jy/sr" or intensity_unit == "Jy/sr" or intensity_unit == "JY/sr"): grid_intensity = prefac * (grid_lum * p.Lsun / (V_cell * p.mpc_to_m**3)) / p.jy_unit / ( 4 * np.pi) # JY/sr unit return grid_intensity
def L_co_log(sfr, alpha, beta): nu_co_line = p.nu_rest(line_name) L_ir_sun = sfr * 1e10 L_coprime = (L_ir_sun * 10**(-beta))**(1 / alpha) L_co = 4.9e-5 * (nu_co_line / 115.27)**3 * L_coprime return np.log10(L_co)