def make_Ihalo_dict( rad=dust.adist(), ener=1.0, \ theta=power_angles(), scatm=ss.Scatmodel(), nx=1000 ): """ def make_Ihalo_dict( rad[np.array], ener[float], theta[np.array], scatm[ss.Scatmodel], nx[int] ) RETURNS : A dictionary of Ihalo objects, with grain sizes as keys. """ if np.size(ener) > 1: print 'Error: Can only choose one value for energy' return if np.size(theta) < 2: print 'Error: Must give more than one theta value' return if np.size(rad) == 1: print 'Error: Input "rad" must be an iterable object.' return keys = [] halo_objs = [] for aval in rad: keys.append( aval ) halo_objs.append( Ihalo( theta=theta, rad=aval, ener=ener, scatm=scatm, nx=nx ) ) return dict( zip(keys,halo_objs) )
def cosmdustspectrum( amin=0.1, amax=1.0, na=100., p=4.0, rho=3.0, cosm=Cosmology() ): """ FUNCTION cosmdustspectrum( amin=0.1, amax=1.0, na=100., p=4.0, rho=3.0, cosm=Cosmology() ) ----------------------------- amin, amax : [microns] na : int (# of dust grain sizes to use) p : scalar for dust power law dn/da \propto a^-p rho : grain density [g cm^-3] cosm : Cosmology ----------------------------- RETURNS : dust.Dustspectrum """ return dust.Dustspectrum( rad = dust.Dustdist( rad=dust.adist( amin=amin, amax=amax, na=na ), p=p, rho=rho ), md = Cosmdens( cosm=cosm ).md )
def make_WD01_Dustspectrum( R_V=3.1, bc=0.0, rad=dust.adist(), type='Graphite', gal='MW' ): """ make_WD01_Dustspectrum( R_V [float], bc [float], rad [np.array : grain sizes (um)], type [string : 'Graphite' or 'Silicate'] ) gal [string : 'MW', 'LMC', or 'SMC'], ------------------------------------------- Returns a dust.Dustspectrum object containing a (grain sizes), nd (dn/da), and md (total mass density of dust) """ if type == 'Graphite': rho_d = 2.2 #g cm^-3 elif type == 'Silicate': rho_d = 3.8 else: print 'Error: Dust type not recognized' return dist = dust.Dustdist( rad=rad, rho=rho_d, p=4 ) result = dust.Dustspectrum( rad=dist ) ANGS2MICRON = 1.e-10 * 1.e6 a = dist.a a_cm = dist.a * c.micron2cm() NA = np.size( a ) (alpha, beta, a_t, a_c, C) = get_dist_params( R_V=R_V, bc=bc, type=type, gal=gal ) if type == 'Graphite': mc = 12. * 1.67e-24 # Mass of carbon atom in grams (12 m_p) rho = 2.24 # g cm^-3 sig = 0.4 a_01 = 3.5*ANGS2MICRON # 3.5 angstroms in units of microns a_01_cm = a_01 * c.micron2cm() bc1 = 0.75 * bc * 1.e-5 B_1 = (3.0/(2*np.pi)**1.5) * np.exp(-4.5 * 0.4**2) / (rho*a_01_cm**3 * 0.4) \ * bc1 * mc / (1 + special.erf( 3*0.4/np.sqrt(2) + np.log(a_01/3.5e-4)/(0.4*np.sqrt(2)) ) ) a_02 = 30.0*ANGS2MICRON # 30 angtroms in units of microns a_02_cm = a_02 * c.micron2cm() bc2 = 0.25 * bc * 1.e-5 B_2 = (3.0/(2*np.pi)**1.5) * np.exp(-4.5 * 0.4**2) / (rho*a_02_cm**3 * 0.4) \ * bc2 * mc / (1 + special.erf( 3*0.4/np.sqrt(2) + np.log(a_02/3.5e-4)/(0.4*np.sqrt(2)) ) ) D = (B_1/a_cm) * np.exp( -0.5*( np.log(a/a_01)/sig )**2 ) + \ (B_2/a_cm) * np.exp( -0.5*( np.log(a/a_02)/sig )**2 ) Case_vsg = np.where( a < 3.5*ANGS2MICRON ) if np.size(Case_vsg) != 0: D[Case_vsg] = 0.0 Case_g = np.zeros( NA ) case1g = np.where( np.logical_and(a > 3.5*ANGS2MICRON, a < a_t ) ) case2g = np.where( a >= a_t ) if np.size(case1g) != 0: Case_g[case1g] = 1.0 if np.size(case2g) != 0: Case_g[case2g] = np.exp( -( (a[case2g]-a_t) / a_c )**3 ) if beta >= 0: F_g = 1 + beta * a / a_t if beta < 0: F_g = 1.0 / (1 - beta * a / a_t) Dist_WD01 = D + C/a_cm * (a/a_t)**alpha * F_g * Case_g #cm^-4 per n_H if type == 'Silicate': Case_s = np.zeros( NA ) case1s = np.where( np.logical_and( a > 3.5*ANGS2MICRON, a < a_t ) ) case2s = np.where( a >= a_t ) if np.size(case1s) != 0: Case_s[case1s] = 1.0 if np.size(case2s) != 0: Case_s[case2s] = np.exp( -( (a[case2s]-a_t)/a_c )**3 ) F_s = np.zeros( NA ) if beta >= 0: F_s = 1 + beta * a / a_t if beta < 0: F_s = 1. / (1 - beta * a / a_t) Dist_WD01 = C/a_cm * (a/a_t)**alpha * F_s * Case_s #cm^-4 per n_H ## Modify result Dustspectrum so we get a proper WD01 dist! mg = 4.0/3.0*np.pi*a_cm**3 * rho_d # mass of each dust grain Md = c.intz( a_cm, Dist_WD01 * mg ) result.nd = Dist_WD01 * c.micron2cm() # cm^-3 per um per n_H result.md = Md return result