Beispiel #1
0
                os.makedirs(outDir)

            # Just save the H2 estimate and MC values to reduce file space
            np.savez(outDir+'id%s_fwhm%s_power%s.npz' %(map_id,FWHM,noise_power),\
             H2=H2_est,H2_MC=H2_MC,ang=ang_est,A=A_est)
            print 'Map %s of %s complete in %s seconds' % (
                mi + 1, len(all_map_id), time.time() - start_time)
            del H2_est, H2_MC, ang_est, A_est, A_MC, output

    print 'Job %s of %s complete in %s seconds' % (index + 1, length,
                                                   time.time() - start_time)

    # send email notification
    if index == LEN - 1:
        from hades.NoiseParams import sendMail
        sendMail('Noise Parameter Space')

    sys.exit()


def check_files(map_size=a.map_size, sep=a.sep, freq=a.freq):
    import os
    paramFile = np.load(a.root_dir + '%sdeg%sBatchNoiseParams.npz' %
                        (map_size, sep))

    for mi, map_id in enumerate(paramFile['map_id']):
        print 'Checking tile %s of %s' % (mi + 1, len(paramFile['map_id']))

        for index in range(len(paramFile['FWHM'])):
            delensing_fraction = paramFile['delensing_fraction'][index]
            noise_power = paramFile['noise_power'][index]
Beispiel #2
0
		return estimator_wrap(map_id,l_step=l_step)
	
	output=runner(map_id)
	
	# Save output to file
	if not os.path.exists(outDir): # make directory
		os.makedirs(outDir)
		
	np.save(outDir+'%s_%s.npy' %(batch_id,param_id), output) # save output
	
	print "Task %s tile %s complete in %s seconds" %(param_id,batch_id,time.time()-start_time)
	
	if batch_id==len(l_step_dat)*len(goodIDs)-2:
		if a.send_email:
			from hades.NoiseParams import sendMail
			sendMail('Single Map Params')
			
def create_significances():
	""" Recreate significances from parameters."""
	import warnings
	for i in range(len(l_step_dat)):
		from hades.wrapper import hex_patch_anisotropy
		suffix='_'+str(i)
		try:
			sigs,sigsA=hex_patch_anisotropy(suffix=suffix)
		except ValueError:
			print 'err'
			continue
		print 'l_step %s, Hex sig: %s, A sig: %s' %(l_step_dat[i],sigs,sigsA)
		
Beispiel #3
0
	#	from hades.debiased_wrapper import tile_wrap
	#	output=tile_wrap(map_id)
	
	#print output	
	# Save output to file
	if not os.path.exists(outDir): # make directory
		os.makedirs(outDir)
		
	np.save(outDir+'%s.npy' %batch_id, output) # save output
	
	print "Job %s complete in %s seconds" %(batch_id,time.time()-start_time)
	
	if batch_id==len(goodIDs)-2:
		if a.send_email:
			from hades.NoiseParams import sendMail
			sendMail('Debiased Padded Single Map')



def padded_wrap(map_id,map_size=a.map_size,\
	sep=a.sep,N_sims=a.N_sims,N_bias=a.N_bias,noise_power=a.noise_power,FWHM=a.FWHM,\
	slope=a.slope,l_step=a.l_step,lMin=a.lMin,lMax=a.lMax,rot=a.rot,freq=a.freq,\
	delensing_fraction=a.delensing_fraction,useTensors=a.useTensors,f_dust=a.f_dust,\
	rot_average=a.rot_average,useBias=a.useBias,padding_ratio=a.padding_ratio,unPadded=a.unPadded,flipU=a.flipU,root_dir=a.root_dir,\
	KKdebiasH2=a.KKdebiasH2,cutFactor=1.25,ffp10_spectrum=a.ffp10_spectrum):
	""" Compute the estimated angle, amplitude and polarisation fraction with noise, correcting for bias.
	Noise model is from Hu & Okamoto 2002 and errors are estimated using MC simulations, which are all saved.
	
	Input: map_id (tile number)
	map_size (tile width in degrees)
	sep (separation of tile centres in degrees)
Beispiel #4
0
    outDir = a.root_dir + 'BatchData/f%s_ms%s_s%s_fw%s_np%s_d%s/' % (
        freq, a.map_size, a.sep, a.FWHM, a.noise_power, a.delensing_fraction)

    if not os.path.exists(outDir):  # make directory
        os.makedirs(outDir)

    np.save(outDir + '%s.npy' % (batch_id % len(goodIDs)),
            output)  # save output

    print "Job %s complete in %s seconds" % (batch_id,
                                             time.time() - start_time)

    if batch_id == maxID - 2:
        if a.send_email:
            from hades.NoiseParams import sendMail
            sendMail('Single Map')


def reconstructor(map_size, sep, root_dir):
    """ Reconstruct the patch epsilon values for different frequencies."""
    from hades.params import BICEP
    a = BICEP()
    import numpy as np

    # Load good ids
    goodFile = root_dir + '%sdeg%sGoodIDs.npy' % (map_size, sep)
    goodIDs = np.load(goodFile)

    freqs = np.arange(50, 500, 50)
    sig = np.zeros(len(freqs))
    meanA = np.zeros(len(freqs))
Beispiel #5
0
        os.makedirs(outDir)

    for j in range(err_repeats):  # repeat for MC errors
        print 'f_dust %s tile %s healpy run %s starting for map_id %s' % (
            f_dust, batch_id, j, map_id)
        output = runner(map_id)
        np.save(outDir + '%s_%s_%s.npy' % (batch_id, param_id, j),
                output)  # save output

    print "Task %s tile %s complete in %s seconds" % (param_id, batch_id,
                                                      time.time() - start_time)

    if (map_id == len(goodIDs) - 1) and (param_id == len(a.f_dust_all) - 1):
        if a.send_email:
            from hades.NoiseParams import sendMail
            sendMail('Full Map Healpy Null Test')

def create_significances(map_size=a.map_size,sep=a.sep,FWHM=a.FWHM,noise_power=a.noise_power,delensing_fraction=a.delensing_fraction,freq=a.freq,root_dir=a.root_dir,\
  folder=None,plot=False):
    """ Recreate + plot significances from parameters."""
    if folder == None:
        folder = 'HealpyFullMapNullTestData'

    from hades.hex_wrap import patch_hexadecapole
    mean, err, monopole, true_monopole = [
        np.zeros(len(a.f_dust_all)) for _ in range(4)
    ]
    for i in range(len(a.f_dust_all)):
        trueA = []
        A = []
        sigs = []
Beispiel #6
0
    #	output=tile_wrap(map_id)

    #print output
    # Save output to file
    if not os.path.exists(outDir):  # make directory
        os.makedirs(outDir)

    np.save(outDir + '%s.npy' % batch_id, output)  # save output

    print "Job %s complete in %s seconds" % (batch_id,
                                             time.time() - start_time)

    if batch_id == len(goodIDs) - 2:
        if a.send_email:
            from hades.NoiseParams import sendMail
            sendMail('Healpy Full Map')



def wrapper(map_id,map_size=a.map_size,\
 sep=a.sep,N_sims=a.N_sims,N_bias=a.N_bias,noise_power=a.noise_power,FWHM=a.FWHM,\
 slope=a.slope,l_step=a.l_step,lMin=a.lMin,lMax=a.lMax,rot=a.rot,freq=a.freq,\
 delensing_fraction=a.delensing_fraction,useTensors=a.useTensors,f_dust=a.f_dust,\
 rot_average=a.rot_average,useBias=a.useBias,padding_ratio=a.padding_ratio,unPadded=a.unPadded,flipU=a.flipU,root_dir=a.root_dir,\
 KKdebiasH2=a.KKdebiasH2,cutFactor=1.35,camb_spectrum=a.camb_spectrum):
    """ Compute the estimated angle, amplitude and polarisation fraction with noise, correcting for bias.
	Noise model is from Hu & Okamoto 2002 and errors are estimated using MC simulations, which are all saved.
	
	This uses cutouts from input dust + lensing + noise map. (Pre-corrected for frequency dependence)
	
	Input: map_id (tile number)
Beispiel #7
0
        os.makedirs(outDir)

    for j in range(err_repeats):  # repeat for MC errors
        print 'f_dust %s tile %s run %s starting for map_id %s' % (
            f_dust, batch_id, j, map_id)
        output = runner(map_id)
        np.save(outDir + '%s_%s_%s.npy' % (batch_id, param_id, j),
                output)  # save output

    print "Task %s tile %s complete in %s seconds" % (param_id, batch_id,
                                                      time.time() - start_time)

    if (map_id == len(goodIDs) - 1) and (param_id == len(a.f_dust_all) - 1):
        if a.send_email:
            from hades.NoiseParams import sendMail
            sendMail('Single Map Null Test')

def create_significances(map_size=a.map_size,sep=a.sep,FWHM=a.FWHM,noise_power=a.noise_power,delensing_fraction=a.delensing_fraction,freq=a.freq,root_dir=a.root_dir,\
  folder=None,plot=False):
    """ Recreate + plot significances from parameters."""
    if folder == None:
        if a.true_lensing:
            folder = 'NullTestLensedBatchData'
        else:
            folder = 'NullTestBatchData'
    from hades.hex_wrap import patch_hexadecapole
    mean, err, monopole, true_monopole = [
        np.zeros(len(a.f_dust_all)) for _ in range(4)
    ]
    for i in range(len(a.f_dust_all)):
        trueA = []
Beispiel #8
0
    #	output=tile_wrap(map_id)

    #print output
    # Save output to file
    if not os.path.exists(outDir):  # make directory
        os.makedirs(outDir)

    np.save(outDir + '%s.npy' % batch_id, output)  # save output

    print "Job %s complete in %s seconds" % (batch_id,
                                             time.time() - start_time)

    if batch_id == len(goodIDs) - 2:
        if a.send_email:
            from hades.NoiseParams import sendMail
            sendMail('Healpy Single Map')



def wrapper(map_id,map_size=a.map_size,\
 sep=a.sep,N_sims=a.N_sims,N_bias=a.N_bias,noise_power=a.noise_power,FWHM=a.FWHM,\
 slope=a.slope,l_step=a.l_step,lMin=a.lMin,lMax=a.lMax,rot=a.rot,freq=a.freq,\
 delensing_fraction=a.delensing_fraction,useTensors=a.useTensors,f_dust=a.f_dust,\
 rot_average=a.rot_average,useBias=a.useBias,padding_ratio=a.padding_ratio,unPadded=a.unPadded,flipU=a.flipU,root_dir=a.root_dir,\
 KKdebiasH2=a.KKdebiasH2,cutFactor=1.35):
    """ Compute the estimated angle, amplitude and polarisation fraction with noise, correcting for bias.
	Noise model is from Hu & Okamoto 2002 and errors are estimated using MC simulations, which are all saved.
	
	This uses cutouts from input dust + lensing + noise map. (Pre-corrected for frequency dependence)
	
	Input: map_id (tile number)
Beispiel #9
0
	from hades.dedusting import compute_angle
	angle,ratio=compute_angle(map_id)
		
	# Save output to file
	if not os.path.exists(outDir): # make directory
		os.makedirs(outDir)
		
	np.save(outDir+'A%s.npy' %batch_id, angle) # save output
	np.save(outDir+'R%s.npy' %batch_id, ratio) # save output
	
	print "Job %s complete in %s seconds" %(batch_id,time.time()-start_time)
	
	if batch_id==len(goodIDs)-2:
		if a.send_email:
			from hades.NoiseParams import sendMail
			sendMail('Angle + Ratio Maps')




def compute_angle(map_id,padding_ratio=a.padding_ratio,map_size=a.map_size,sep=a.sep,freq=a.freq,\
                  f_dust=a.f_dust,lMax=a.lMax,lMin=a.lMin,l_step=a.l_step,FWHM=a.FWHM,noise_power=a.noise_power,\
                  slope=a.slope,delensing_fraction=a.delensing_fraction,useQU=a.useQU,N_bias=a.N_bias):
    """Compute the polarisation angle for a specific tile, creating a model B-power spectrum + cross-spectra
    in order to find the angle including the ambiguity in sin(2alpha), cos(2alpha) due to initial computation
    of sin(4alpha), cos(4alpha).
    
    Returns angle in degrees.
    """

    # Step 1, create actual B-mode map
Beispiel #10
0
		from hades.padded_debiased_wrap import padded_wrap
		output=padded_wrap(map_id)
	
	#print output	
	# Save output to file
	if not os.path.exists(outDir): # make directory
		os.makedirs(outDir)
		
	np.save(outDir+'%s.npy' %batch_id, output) # save output
	
	print "Job %s complete in %s seconds" %(batch_id,time.time()-start_time)
	
	if batch_id==len(goodIDs)-2:
		if a.send_email:
			from hades.NoiseParams import sendMail
			sendMail('Debiased Lensed Single Map')



def lensed_wrap(map_id,map_size=a.map_size,\
	sep=a.sep,N_sims=a.N_sims,N_bias=a.N_bias,noise_power=a.noise_power,FWHM=a.FWHM,\
	slope=a.slope,l_step=a.l_step,lMin=a.lMin,lMax=a.lMax,rot=a.rot,freq=a.freq,\
	delensing_fraction=a.delensing_fraction,useTensors=a.useTensors,f_dust=a.f_dust,\
	rot_average=a.rot_average,useBias=a.useBias,padding_ratio=a.padding_ratio,unPadded=a.unPadded,flipU=a.flipU,root_dir=a.root_dir,\
	KKdebiasH2=a.KKdebiasH2,cutFactor=1.35):
	""" Compute the estimated angle, amplitude and polarisation fraction with noise, correcting for bias.
	Noise model is from Hu & Okamoto 2002 and errors are estimated using MC simulations, which are all saved.
	
	Input: map_id (tile number)
	map_size (tile width in degrees)
	sep (separation of tile centres in degrees)