示例#1
0
def dvc_dzdomega(z):
    '''
    comoving volume element
    dV_c/(d\Omega dz) at redshift z (Mpc^3/h^3)
    Args:
        z, redshift, float.
    Returns:
        float, comoving volume element (Mpc^3/h^3)
    '''
    return C*1e-3/COSMO.Hz(z)*LITTLEH\
    *COSMO.luminosityDistance(z)**2./(1.+z)**2.
示例#2
0
def zmstar_lilly13(mstar, z, params):
    '''
    equation 40 from Lilly et al. 2013
    Args:
        mstar,float,stellar mass (msolar/h)
        z, float, redshift
        params, dictionary of parameters
    Returns:
        float, metallicity of galactic gas following the MZR from
        Lilly et al. 2013.
    '''
    y = 10.**params['LILLY13']['LOGYIELD']
    z0 = params['LILLY13']['Z0DY'] * y
    lam=params['LILLY13']['LOADING10']\
    *(mstar/LITTLEH/1e10)**params['LILLY13']['LOADINGPOW']
    eps=params['LILLY13']['DEPLETION10']**-1.\
    *(mstar/LITTLEH/1e10)**params['LILLY13']['DEPLETIONPOW']\
    *(1+z)**params['LILLY13']['DEPLETION_EV_POW']
    r = params['LILLY13']['RETURN_FRAC']
    alphaeps = params['LILLY13']['DEPLETION_EV_POW']
    if z <= 2:
        ssfr = 1. / (1. - r) * 0.07 * (mstar / LITTLEH /
                                       10**10.5)**(-0.1) * (1. + z)**3.
        dlogmudz = (3. - alphaeps) / (1 + z)
    else:
        ssfr = 1. / (1. - r) * 0.3 * (mstar / LITTLEH /
                                      10**10.5)**(-0.1) * (1. + z)**(5. / 3.)
        dlogmudz = (5. / 3. - alphaeps) / (1 + z)
    mu = ssfr / eps
    dzdt = -COSMO.Hz(z) * (1. + z) / KPC * 1e9 * YEAR  #convert H(z) to Gyr^-1
    zeq = np.log10(z0 + y / (1. + lam / (1. - r) + mu + dlogmudz * dzdt / eps /
                             (1. - r)))
    return zeq
示例#3
0
def power_lin(k, z):
    '''
    linear matter power spectrum
    Args:
        k, float, wavenumber (comoving h/Mpc)
        z, float, redshift
    Returns:
        linear matter power spectrum (Mpc/h)^3
    '''
    return COSMO.matterPowerSpectrum(k, z)
示例#4
0
def mTb_emiss(z21, rhohi=1.):
    '''
    mean emission brightness temperature (K)
    Args:
        z21, float,redshift
        rhohi, hi density in Msol Mpc^-3 h^2
    Returns:
        brightness temperature (K)
    '''
    return 3.*HPLANCK*1e-3*C**3.*A10/(32.*PI*KBOLTZMANN*MP*F21**2.)\
    *(1+z21)**2./COSMO.Hz(z21)/(KPC*1e3)**2.*MSOL*rhohi\
    *LITTLEH**2.
示例#5
0
def dldsobs_agn(freq_obs, zem, alpha, F0=1.4e9):
    '''
    Compute the derivive of luminosity with respect to observed flux
    for agn.
    Args:
        freq_obs observed frequency
        zem, emission redshift.
        alpha, power law for emission: L=L0(f/F0)^alpha
        F0, reference frequency
    Returns: dL/dS_obs (W/Hz/Jy)
    '''
    output = 4.*PI*COSMO.luminosityDistance(zem)**2.\
    *(F0/(1.+zem)/freq_obs)**alpha/(1.+zem)/LITTLEH**2.#This is output in Mpc^2
    output = output * JY * (1e3 * KPC)**2.
    return output
示例#6
0
def instrument_counts(z, survey_area, smin, smax, channel_width, rms, params):
    '''
    Calculate the number of absorbers per comoving redshift interval
    detected at the nsigma level.
    Args:
        z, redshift
        survey_area, area of survey (steradians)
        channel_width, specral resolution (Hz)
        rms, noise level/beam per spectral channel (Jy/bm)
        params, dictionary of model parameters
        nsigma, detection threshold above rms.
    Returns:
        Number of detected absorbers per redshift interval.
    '''
    s_min = rms * 10.**SNR_INTERP_MIN
    g = lambda x: rb.dn_dlogs_domega(10.**x,z)\
    *dn_dr(10.**x/rms,channel_width,z,params)
    output = integrate.quad(g, np.max([np.log10(smin), s_min]),
                            np.log10(smax))[0]  #dN/dr_com
    output = survey_area * output * C * 1e-3 / COSMO.Hz(z) * LITTLEH  #dN/dz
    return output
示例#7
0
def dn_dz_tau(tau, z, params):
    '''
    number of absorbers per redshift interval with optical depths greater than
    tau.
    Args:
        tau, optical depth
        z, redshift
        params, dictionary of model parameters
    Returns: number of absorbers per redshift interval (along LoS) with optical
        depths greater than tau
    '''
    splkey = ('dn_dz_tau', z) + dict2tuple(params)
    if not SPLINE_DICT.has_key(splkey):
        tauvals = np.logspace(TAU_INTERP_MIN, TAU_INTERP_MAX, N_INTERP_TAU)
        dnvals = np.zeros_like(tauvals)
        for taunum, tauval in enumerate(tauvals):
            g=lambda x:sigma_tau(tauval,10.**x,z,params)*massfunc(10.**x,z)\
            *C*1e-3/COSMO.Hz(z)*LITTLEH
            dnvals[taunum] = integrate.quad(g, M_INTERP_MIN, M_INTERP_MAX)[0]
        SPLINE_DICT[splkey] = interp.interp1d(np.log(tauvals), dnvals)
    return SPLINE_DICT[splkey](np.log(tau))
示例#8
0
def dn_dlogtau_dz(tau, z, params, recompute=False):
    '''
    compute the number of optical depth features per redshift interval
    per optical depth interval.
    Args:
        z, redshift
        tau, optical depth
        params, model parameters
    Returns:
        average number of optical depth features between tau and tau+d_tau
        and redshift z and dz in a los on the sky.
    '''
    splkey = ('dn_dlogtau_domega_dz', z) + dict2tuple(params)
    if not SPLINE_DICT.has_key(splkey) or recompute:
        tauvals = np.logspace(TAU_INTERP_MIN, TAU_INTERP_MAX, N_INTERP_TAU)
        dnvals = np.zeros_like(tauvals)
        for taunum, tauval in enumerate(tauvals):
            g=lambda x: massfunc(10.**x,z)*dsigma_dtau(tauval,10.**x,z,params)\
            *tauval*np.log(10.)
            dnvals[taunum]=integrate.quad(g,M_INTERP_MIN,M_INTERP_MAX)[0]\
            *1e-3*C/COSMO.Hz(z)*LITTLEH
        print dnvals
        SPLINE_DICT[splkey] = interp.interp1d(np.log(tauvals), dnvals)
    return SPLINE_DICT[splkey](np.log(tau))