コード例 #1
0
ファイル: analyze_emcee.py プロジェクト: JohannesBuchner/dust
def multiscreen_tau(sample, d2g=0.009, scatm=ss.makeScatmodel("RG", "Drude")):
    result = []
    for walker in sample:
        logNHu, logNHs, a_u, a_s, p_u, p_s, x_s = walker
        MDu, MDs = np.power(10.0, logNHu) * c.mp() * d2g, np.power(10.0, logNHs) * c.mp() * d2g
        da_u, da_s = (a_u - AMIN) / 10.0, (a_s - AMIN) / 10.0
        Udust = dust.Dustdist(rad=np.arange(AMIN, a_u + da_u, da_u), p=p_u)
        Sdust = dust.Dustdist(rad=np.arange(AMIN, a_s + da_s, da_s), p=p_s)
        Ukappa = ss.Kappascat(E=1.0, dist=dust.Dustspectrum(rad=Udust, md=MDu), scatm=scatm).kappa[0]
        Skappa = ss.Kappascat(E=1.0, dist=dust.Dustspectrum(rad=Sdust, md=MDs), scatm=scatm).kappa[0]
        result.append(Ukappa * MDu + Skappa * MDs)
    return np.array(result)
コード例 #2
0
ファイル: analyze_emcee.py プロジェクト: JohannesBuchner/dust
def sample_logMD(sample, d2g=0.009, replace=False, mscreen=False):
    if mscreen:
        nhtot = np.power(10.0, sample[:, 2]) + np.power(10.0, sample[:, 3])
        logmd = np.log10(nhtot * c.mp() * d2g)
        if replace:
            result = np.copy(sample)
            result[:, 2] = sample[:, 2] + np.log10(c.mp() * d2g)
            result[:, 3] = sample[:, 3] + np.log10(c.mp() * d2g)
            return result
    else:
        logmd = sample[:, 0] + np.log10(c.mp() * d2g)
        if replace:
            result = np.copy(sample)
            result[:, 0] = logmd
            return result
    return logmd
コード例 #3
0
ファイル: analyze_emcee.py プロジェクト: JohannesBuchner/dust
def sample_tau(sample, d2g=0.009, mscreen=False):
    result = []
    for walker in sample:
        if mscreen:
            x1, x2, logNH1, logNH2, amax, p = walker
            nhtot = np.power(10.0, logNH1) + np.power(10.0, logNH2)
            md = nhtot * c.mp() * d2g
        else:
            logNH, amax, p = walker
            md = np.power(10.0, logNH) * c.mp() * d2g
        da = (amax - AMIN) / 100.0
        DD = dust.Dustdist(rad=np.arange(AMIN, amax + da, da), p=p)
        DS = dust.Dustspectrum(rad=DD, md=md)
        KK = ss.Kappascat(E=1.0, dist=DS).kappa[0]
        result.append(KK * md)
    return np.array(result)
コード例 #4
0
ファイル: galhalo.py プロジェクト: JohannesBuchner/dust
def DiscreteISM( halo, xg=0.5, NH=1.0e20, d2g=0.009 ):
    """
    FUNCTION DiscreteISM( halo, xg=0.5, NH=1.0e20, d2g=0.009 )
    MODIFIES halo.htype, halo.dist, halo.taux, halo.intensity
    ----------------------------------------------------------------------------
    halo : Halo object
    xg   : float : distance FROM source / distance between source and observer
    NH   : float : column density [cm^-2]
    d2g  : float : dust-to-gass mass ratio
    """
    E0    = halo.energy
    alpha = halo.alpha
    scatm = halo.scatm
    md    = NH * c.mp() * d2g

    halo.htype = GalHalo( xg=xg, NH=NH, d2g=d2g, ismtype='Screen' )
    halo.dist  = dust.Dustspectrum( rad=halo.rad, md=md )

    thscat = alpha / xg

    if type(halo.rad) == dust.Grain:
        dsig = ss.Diffscat( theta=thscat, a=halo.dist.a, E=E0, scatm=scatm ).dsig
        intensity = np.power( xg, -2.0 ) * dsig * halo.dist.nd

    elif type(halo.rad) == dust.Dustdist:
        avals  = halo.dist.a
        intensity = []
        for i in range( len(alpha) ):
            iatemp = np.zeros( shape=( len(avals),len(alpha) ) )
            for j in range( len(avals) ):
                dsig    = ss.Diffscat( theta=thscat, a=avals[j], E=E0, scatm=scatm ).dsig
                iatemp[j,:] = np.power(xg,-2.0) * dsig
            intensity.append( c.intz( avals, iatemp[:,i] * halo.dist.nd ) )
        intensity = np.array( intensity )
    else:
        print '%% Must input type dust.Grain or dust.Dustdist'
        intensity = np.zeros( np.size(xvals) )

    halo.intensity = intensity * np.power( c.arcs2rad(), 2 )  # arcsec^-2
    halo.taux      = ss.Kappascat( E=halo.energy, scatm=halo.scatm, dist=halo.dist ).kappa * md
コード例 #5
0
ファイル: cmindex.py プロジェクト: RGTippens/dust
 def rp( self, E ):
     mm1 = self.rho / ( 2.0*c.mp() ) * c.re()/(2.0*np.pi) * np.power( c.kev2lam()/E , 2 )
     return mm1+1
コード例 #6
0
ファイル: test.py プロジェクト: mboquien/dust
import numpy as np
import matplotlib.pyplot as plt

print('importing...')
import sigma_scat as ss
import dust
import constants as c

print('setting input...')
# column density
NH   = 1.e21
# dust-to-gas ratio
d2g = 0.009
# use proton mass to get dust column mass
dust_mass = NH * c.mp() * d2g 
# energy range to evaluate over (in keV)
ERANGE    = np.power( 10.0, np.arange(-0.6,1.0,0.005) )
MD = dust_mass * 10.0 # for N_H = 1.e22

# define densities
# g cm^-3; see Draine book
RHO_SIL, RHO_GRA, RHO_AVG = 3.8, 2.2, 3.0 

print('defining dust distributions...')

# dust radius range to compute (in um)
# up to 0.25 um
MRN_RANGE = np.arange(0.005,0.25001,0.05)

# larger range going up to 1.5 um
BIG_RANGE = np.arange(0.005, 1.5, 0.05)
コード例 #7
0
ファイル: galhalo.py プロジェクト: JohannesBuchner/dust
def UniformISM( halo, NH=1.0e20, d2g=0.009, nx=1000, usepathdiff=False ):
    """
    FUNCTION UniformISM( halo, NH=1.0e20, d2g=0.009, nx=1000, usepathdiff=False )
    MODIFIES halo.htype, halo.dist, halo.taux, halo.intensity
    ----------------------------------------------------------------------------
    halo : Halo object
    NH   : float : column density [cm^-2]
    d2g  : float : dust-to-gass mass ratio
    nx   : int : number of values to use in integration
    usepathdiff : boolean : True = use extinction due to path difference e^(-tau*path_diff)
    """
    E0    = halo.energy
    alpha = halo.alpha
    scatm = halo.scatm
    md    = NH * c.mp() * d2g

    halo.htype = GalHalo( NH=NH, d2g=d2g, ismtype='Uniform' )
    halo.dist  = dust.Dustspectrum( rad=halo.rad, md=md )
    halo.taux  = ss.Kappascat( E=halo.energy, scatm=halo.scatm, dist=halo.dist ).kappa * md

    dx    = 1.0 / nx
    xvals = np.arange( 0.0, 1.0, dx ) + dx

    #--- Single grain case ---

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

        intensity = np.array([])
        for al in alpha:
            thscat = al / xvals  # np.size(thscat) = nx
            dsig   = ss.Diffscat( theta=thscat, a=halo.dist.a, E=E0, scatm=scatm ).dsig

            delta_tau = 0.0
            if usepathdiff:
                print 'Using path difference'
                delta_x   = path_diff( al, xvals )
                delta_tau = halo.taux * delta_x
                print np.max( delta_x )

            itemp  = np.power( xvals, -2.0 ) * dsig * halo.dist.nd * np.exp( -delta_tau )
            intensity = np.append( intensity, c.intz( xvals, itemp ) )

    #--- Dust distribution case ---

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

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

        for al in alpha:
            thscat = al / xvals  # np.size(thscat) = nx
            iatemp    = np.array([])
            for aa in avals:
                dsig  = ss.Diffscat( theta=thscat, a=aa, E=E0, scatm=scatm ).dsig

                delta_tau = 0.0
                if usepathdiff:
                    print 'Using path difference'
                    delta_x   = path_diff( al, xvals )
                    delta_tau = halo.taux * delta_x
                    print max( delta_x )

                dtemp  = np.power( xvals, -2.0 ) * dsig * np.exp( -delta_tau )
                iatemp = np.append( iatemp, c.intz( xvals, dtemp ) )

            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(xvals) )
        
    # Set the halo intensity

    halo.intensity  = intensity * np.power( c.arcs2rad(), 2 )  # arcsec^-2