Пример #1
0
def DChi( z, zp=0.0, cosm=Cosmology(), nz=100 ):
    """
    Calculates co-moving radial distance [Gpc] from zp to z using dx = cdt/a
    z    : float : redshift
    zp   ; float (0) : starting redshift
    cosm : Cosmology
    nz   : int (100) : number of z-values to use in calculation
    """
    zvals     = zvalues( zs=z, z0=zp, nz=nz )
    integrand = c.cperh0() * ( c.h0()/cosm.h0 ) / np.sqrt( cosm.m * np.power(1+zvals,3) + cosm.l )
    return c.intz( zvals, integrand ) / (1e9 * c.pc2cm() ) # Gpc, in comoving coordinates
Пример #2
0
 def __init__(self, cosm=Cosmology() ):
     """
     Stores h0 and omega information from cosm
     ------------------------------
     INPUTS
     ------------------------------
     cosm : Cosmology
     ------------------------------
     STORED VALUES
     h0, d, md
     """
     self.h0    = cosm.h0
     self.omega = cosm.d
     self.md    = cosm.d * c.rho_crit() * np.power( cosm.h0/c.h0(), 2 )
Пример #3
0
def CosmTauX( z, E=1.0, dist=dust.Dustdist(), scatm=ss.Scatmodel(), cosm=Cosmology(), nz=100 ):
    """
    FUNCTION CosmTauX( z, E=1.0, dist=dust.Dustdist(), scatm=ss.Scatmodel(), cosm=Cosmology(), nz=100 
    ---------------------------------
    INPUT
    z : redshift of source
    E : scalar or np.array [keV]
    dist  : dust.Dustdist or dust.Grain
    scatm : ss.Scatmodel
    cosm  : cosm.Cosmology
    ---------------------------------
    OUTPUT
    tauX : scalar or np.array [optical depth to X-ray scattering]
           = kappa( dn/da da ) cosmdens (1+z)^2 cdz/hfac
    """

    zvals     = zvalues( zs=z, nz=nz )
    md        = Cosmdens( cosm=cosm ).md
    spec      = dust.Dustspectrum( rad=dist, md=md )

    if np.size(E) > 1:
        result = np.array([])
        for ener in E:
            Evals = ener * (1+zvals)
            kappa     = ss.Kappascat( E=Evals, scatm=scatm, dist=spec ).kappa
            hfac      = np.sqrt( cosm.m * np.power( 1+zvals, 3 ) + cosm.l )
            integrand = kappa * md * np.power( 1+zvals, 2 ) * \
                c.cperh0() * ( c.h0()/cosm.h0 ) / hfac
            result    = np.append( result, c.intz( zvals, integrand ) )
    else:
        Evals     = E * (1 + zvals)
        kappa     = ss.Kappascat( E=Evals, scatm=scatm, dist=spec ).kappa
        hfac      = np.sqrt( cosm.m * np.power( 1+zvals, 3 ) + cosm.l )
        integrand = kappa * md * np.power( 1+zvals, 2 ) * c.cperh0() * ( c.h0()/cosm.h0 ) / hfac
        result    = c.intz( zvals, integrand )

    return result
Пример #4
0
 def __init__( self, h0=c.h0(), m=c.omega_m(), l=c.omega_l(), d=c.omega_d() ):
     """
     Cosmology object
     ------------------------------
     INPUTS (same as stored values)
     ------------------------------
     h0 : [km/s/Mpc] (default: constants.h0)
     m  : cosmic mass density (default: constants.omega_m)
     l  : lambda mass density (default: constants.omega_l)
     d  : cosmic dust density (default: constants.omega_d )
     """
     self.h0 = h0
     self.m  = m
     self.l  = l
     self.d  = d
Пример #5
0
def UniformIGM(halo, zs=4.0, cosm=cosmo.Cosmology(), nz=500):
    """
    FUNCTION UniformIGM( halo, zs=4.0, cosm=cosmo.Cosmology(), nz=500 )
    MODIFIES halo.htype, halo.dist, halo.intensity, halo.taux
    --------------------------------------------------------------------
    halo : Halo object
    zs   : float : redshift of source
    cosm : cosmo.Cosmology
    nz   : int : number of z-values to use in integration
    """
    E0 = halo.energy
    alpha = halo.alpha
    scatm = halo.scatm

    halo.htype = CosmHalo(zs=zs, cosm=cosm, igmtype="Uniform")  # Stores information about this halo calc
    halo.dist = dust.Dustspectrum(rad=halo.rad, md=cosmo.Cosmdens(cosm=cosm).md)

    Dtot = cosmo.DChi(zs, cosm=cosm, nz=nz)
    zpvals = cosmo.zvalues(zs=zs - zs / nz, z0=0, nz=nz)

    DP = np.array([])
    for zp in zpvals:
        DP = np.append(DP, cosmo.DChi(zs, zp=zp, cosm=cosm))

    X = DP / Dtot

    c_H0_cm = c.cperh0() * (c.h0() / cosm.h0)  # cm
    hfac = np.sqrt(cosm.m * np.power(1 + zpvals, 3) + cosm.l)

    Evals = E0 * (1 + zpvals)

    ## Single grain case

    if type(halo.rad) == dust.Grain:

        intensity = np.array([])

        f = 0.0
        cnt = 0.0
        na = np.size(alpha)
        for al in alpha:
            cnt += 1
            thscat = al / X  # np.size(thscat) = nz
            dsig = ss.Diffscat(theta=thscat, a=halo.dist.a, E=Evals, scatm=scatm).dsig
            itemp = c_H0_cm / hfac * np.power((1 + zpvals) / X, 2) * halo.dist.nd * dsig
            intensity = np.append(intensity, c.intz(zpvals, itemp))

    ## Dust distribution case

    elif type(halo.rad) == dust.Dustdist:

        avals = halo.dist.a
        intensity = np.array([])

        for al in alpha:
            thscat = al / X  # np.size(thscat) = nz

            iatemp = np.array([])
            for aa in avals:
                dsig = ss.Diffscat(theta=thscat, a=aa, E=Evals, scatm=scatm).dsig
                dtmp = c_H0_cm / hfac * np.power((1 + zpvals) / X, 2) * dsig
                iatemp = np.append(iatemp, c.intz(zpvals, dtmp))

            intensity = np.append(intensity, c.intz(avals, halo.dist.nd * iatemp))

    else:
        print "%% Must input type dust.Grain or dust.Dustdist"
        intensity = np.zeros(np.size(zpvals))

    # ----- Finally, set the halo intensity --------

    halo.intensity = intensity * np.power(c.arcs2rad(), 2)  # arcsec^-2
    halo.taux = cosmo.CosmTauX(zs, E=halo.energy, dist=halo.rad, scatm=halo.scatm, cosm=halo.htype.cosm)