Beispiel #1
0
def main(fname_config):

#Read configuration into classes
        Config = ConfigParser.ConfigParser()
        Config.read(fname_config)
        out = output(Config._sections['GlobalParameters'])

        Config.read('./ConfigFiles/'+Config.get('FreeFree','model')+'_config.ini')
        freefree = component(Config._sections['FreeFree'],out.nside)
        with open(out.output_dir+out.output_prefix+'freefree_config.ini','w') as configfile\
: Config.write(configfile)

        print('Computing free-free maps.')
        print '----------------------------------------------------- \n'
        if out.debug == True:
                print ''.join("%s: %s \n" % item   for item in vars(freefree).items())
                print '----------------------------------------------------- \n'
        
        conv_I = convert_units(freefree.template_units,out.output_units,out.output_frequency)
	
        scaled_map_ff = scale_freqs(freefree,out)*conv_I[...,np.newaxis]*freefree.em_template
        scaled_map_ff_pol = np.zeros((2,np.asarray(out.output_frequency).size,hp.nside2npix(out.nside)))

        if out.debug == True:
            ff = np.concatenate([scaled_map_ff[np.newaxis,...],scaled_map_ff_pol])
	    for i in range(0,len(out.output_frequency)):
		    hp.write_map(out.output_dir+out.output_prefix+'ff_%d'%(out.output_frequency[i])+'_'+str(out.nside)+'.fits',ff[:,i,:],coord='G',column_units=out.output_units)

        return np.concatenate([scaled_map_ff[np.newaxis,...],scaled_map_ff_pol])
Beispiel #2
0
def main(fname_config):

#Read in configuration file to classes.
    Config = ConfigParser.ConfigParser()
    Config.read(fname_config)
    out = output(Config._sections['GlobalParameters'])

    Config.read('./ConfigFiles/'+Config.get('SpinningDust','model')+'_config.ini')
    spdust_general = component(Config._sections['General'],out.nside)
    spdust1 = component(Config._sections['SpinningDust1'],out.nside)
    spdust2 = component(Config._sections['SpinningDust2'],out.nside)

    print('Computing spinning dust map.')
    print '----------------------------------------------------- \n'

    if out.debug == True:
        print ''.join("%s: %s \n" % item   for item in vars(spdust1).items())
        print ''.join("%s: %s \n" % item   for item in vars(spdust2).items())
        print '----------------------------------------------------- \n'
    with open(out.output_dir+out.output_prefix+'spdust_config.ini','w') as configfile: Config.write(configfile)
#Compute a map of the polarisation angle from the commander dust map polariationn angle. 
    
    pol_angle = np.arctan2(spdust_general.thermaldust_polu,spdust_general.thermaldust_polq)

#Units to do the scaling in MJysr and then bring the result back to the output units.
    conv1 = convert_units(spdust1.template_units, ['u','K_RJ'], spdust1.freq_ref)
    conv2 = convert_units(spdust2.template_units, ['u','K_RJ'], spdust2.freq_ref)
    conv_end = convert_units(['u','K_RJ'],out.output_units,out.output_frequency)
    unit_conversion1 = conv1*conv_end.reshape((len(out.output_frequency),1))
    unit_conversion2 = conv2*conv_end.reshape((len(out.output_frequency),1))

    scaled_map_spdust = scale_freqs(spdust1,out,pol=False)*spdust1.em_template*unit_conversion1 + scale_freqs(spdust2,out,pol=False)*spdust2.em_template*unit_conversion2
    scaled_map_spdust_pol = scaled_map_spdust[np.newaxis,...]*np.asarray([np.cos(pol_angle),np.sin(pol_angle)])[:,np.newaxis,:]*spdust_general.pol_frac

    if out.debug == True:
        for i in range(0,len(out.output_frequency)):
            hp.write_map(out.output_dir+'spdust_%d.fits'%(out.output_frequency[i]),scaled_map_spdust[i],coord='G',column_units=out.output_units)

    return np.concatenate([scaled_map_spdust[np.newaxis,...],scaled_map_spdust_pol])
Beispiel #3
0
def main(fname_config):

#Read in configuration file to classes.
	Config = ConfigParser.ConfigParser()
	Config.read(fname_config)
	out = output(Config._sections['GlobalParameters'])

	Config.read('./ConfigFiles/'+Config.get('Synchrotron','model')+'_config.ini')
	synch = component(Config._sections['Synchrotron'],out.nside)
	with open(out.output_dir+out.output_prefix+'synchrotron_config.ini','w') as configfile: Config.write(configfile)

	print('Computing synchrotron maps.')
	print '----------------------------------------------------- \n'
	if out.debug == True:
		print ''.join("%s: %s \n" % item   for item in vars(synch).items())
		print '----------------------------------------------------- \n'

#The unit conversion takes care of the scaling being done in uK_RJ. After scaling we convert to whatever the output units are.
	conv_I = convert_units(synch.template_units, ['u','K_RJ'], synch.freq_ref)
	conv_pol = convert_units(synch.template_units, ['u','K_RJ'], synch.pol_freq_ref) 
	conv2 = convert_units(['u','K_RJ'],out.output_units,out.output_frequency)
	unit_conversion_I = conv_I*conv2.reshape((len(out.output_frequency),1))
	unit_conversion_pol = conv_pol*conv2.reshape((len(out.output_frequency),1))
#Do the scaling.

	scaled_map_synch = scale_freqs(synch, out, pol=False)*synch.em_template*unit_conversion_I
	scaled_map_synch_pol = scale_freqs(synch, out, pol=True)[np.newaxis,...]*np.array([synch.polq_em_template,synch.polu_em_template])[:,np.newaxis,:]*unit_conversion_pol

#This section forces P/I<0.75. This is done using the same procedure as the PSM 1.7.8 psm_synchrotron.pro.

	P = np.sqrt(scaled_map_synch_pol[0,:,:]**2+scaled_map_synch_pol[1,:,:]**2)/scaled_map_synch
	F = 0.75*np.tanh(P/0.75)/P
	scaled_map_synch_pol[0,:,:]=F*scaled_map_synch_pol[0,:,:]
	scaled_map_synch_pol[1,:,:]=F*scaled_map_synch_pol[1,:,:]

#-------

	if out.debug == True:
		syn = np.concatenate([scaled_map_synch[np.newaxis,...],scaled_map_synch_pol])
		for i in range(0,len(out.output_frequency)):
			hp.write_map(out.output_dir+out.output_prefix+'synch_%d'%(out.output_frequency[i])+'_'+str(out.nside)+'.fits',syn[:,i,:],coord='G',column_units=out.output_units)

	return np.concatenate([scaled_map_synch[np.newaxis,...],scaled_map_synch_pol])
Beispiel #4
0
def scale_dust_pop(pop, out, Config):

    dust = component(Config._sections[pop], out.nside)
    print ("Computing dust maps.")
    print "----------------------------------------------------- \n"
    if out.debug == True:
        print "".join("%s: %s \n" % item for item in vars(dust).items())
        print "----------------------------------------------------- \n"

    conv_I = convert_units(dust.template_units, ["u", "K_RJ"], dust.freq_ref)
    conv_pol = convert_units(dust.template_units, ["u", "K_RJ"], dust.pol_freq_ref)
    conv2 = convert_units(["u", "K_RJ"], out.output_units, out.output_frequency)
    unit_conversion_I = conv_I * conv2.reshape((len(out.output_frequency), 1))
    unit_conversion_pol = conv_pol * conv2.reshape((len(out.output_frequency), 1))

    scaled_map_dust = scale_freqs(dust, out, pol=False) * dust.em_template * unit_conversion_I
    scaled_map_dust_pol = (
        scale_freqs(dust, out, pol=True)[np.newaxis, ...]
        * np.array([dust.polq_em_template, dust.polu_em_template])[:, np.newaxis, :]
        * unit_conversion_pol
    )

    if out.debug == True:
        dus = np.concatenate([scaled_map_dust[np.newaxis, ...], scaled_map_dust_pol])
        for i in range(0, len(out.output_frequency)):
            hp.write_map(
                out.output_dir
                + out.output_prefix
                + "dust_%d" % (out.output_frequency[i])
                + "_"
                + str(out.nside)
                + ".fits",
                dus[:, i, :],
                coord="G",
                column_units=out.output_units,
            )

    return np.concatenate([scaled_map_dust[np.newaxis, ...], scaled_map_dust_pol])