if MODE == 'D': print 'Dual beam Method' FourComponentDualBeam(p450,p850,fwhm450MB,fwhm850MB,fwhm450SB,fwhm850SB,in450,in850,output_dir,file) elif MODE == 'K': print 'Kernel Method' KernelMethod(in450_fits,in450) cmd = 'mv %s %s'%('s450convolve.sdf',output_dir+'/'+method+'/process/'+file) os.system(cmd) ############### 3 -- Align the 450 map with the 850 map ############ print 3 #Align 450 onto 850 convolved maps (in 2 or 3D where necessary) #calculate noise from 'noise.py' module STDV_450 = noise.noise_by_data(in450,'FALSE') STDV_850 = noise.noise_by_data(in850,'FALSE') #deffine file names s850collapse = output_dir+'/'+method+'/process/'+file+'/s850collapse.sdf' s450collapse = output_dir+'/'+method+'/process/'+file+'/s450collapse.sdf' s450maskcollapse = output_dir+'/'+method+'/process/'+file+'/s450maskcollapse.sdf' s450align = output_dir+'/'+method+'/process/'+file+'/s450align.sdf' s450maskalign = output_dir+'/'+method+'/process/'+file+'/s450maskalign.sdf' s450mask = output_dir+'/'+method+'/process/'+file+'/s450mask.sdf' s850mask = output_dir+'/'+method+'/process/'+file+'/s850mask.sdf' #adapt for cases where 850 noise cannot be calculated if STDV_850 == 0.0: STDV_850 = STDV_450/5.5 print 'No noise for 850um. Value estimated from ratio and 450 level. STDV = '+str(STDV_850)
import noise s450mwc297 = 'serpens/MWC297/IR2/SerpensMWC297_20141219_s450_IR2extmask_s2_cal_JypixJH.sdf' s850mwc297 = 'serpens/MWC297/IR2/SerpensMWC297_20141219_s850_IR2extmask_s2_cal_JypixJH.sdf' s450main = 'serpens/serpensmain/IR2/SerpensMain_20141223_s450_IR2extmask_s2_cal_JypixJH.sdf' s850main = 'serpens/serpensmain/IR2/SerpensMain_20141223_s850_IR2extmask_s2_cal_JypixJH.sdf' s850mainnoco = 'serpens/serpensmain/IR2/SerpensMain_20150326_850_IR2_noco_JypixHK.sdf' s450E = 'serpens/serpensE/IR2/SerpensE_20141219_s450_IR2extmask_s2_cal_JypixJH.sdf' s850E = 'serpens/serpensE/IR2/SerpensE_20141219_s850_IR2extmask_s2_cal_JypixJH.sdf' s450N = 'serpens/serpensN/IR2/SerpensN_20141219_s450_IR2extmask_s2_cal_JypixJH.sdf' s850N = 'serpens/serpensN/IR2/SerpensN_20141219_s850_IR2extmask_s2_cal_JypixJH.sdf' noise.noise_by_data(s450main,'FASLE') noise.noise_by_data(s850main,'FASLE') noise.noise_by_data(s450mwc297,'FASLE') noise.noise_by_data(s850mwc297,'FASLE') noise.noise_by_data(s450E,'FASLE') noise.noise_by_data(s850E,'FASLE') noise.noise_by_data(s450N,'FASLE') noise.noise_by_data(s850N,'FASLE') noise.noise_by_data(s850mainnoco,'FASLE')
if not os.path.exists('SMM/'+region+'/temp'): os.makedirs('SMM/'+region+'/temp') ###open maps from FITS files to deffine DIM ### dim = PARGET(clumps,'dims','ndftrace') a = PARGET(s850,'fpixscale','ndftrace') print a[0] row = int(dim[1]) #rows of the table from NDFTRACE column = int(dim[0]) #columns of the table from NDFTRACE print 'Row: ',row print 'Column: ',column #CREATE noise map of constant level sigma = noise.noise_by_data(s850,'FALSE') sigmap = 'SMM/'+region+'/temp/sigmap.sdf' cmd = '%s/thresh in=%s out=%s thrlo=%d thrhi=%d newlo=%f newhi=%f %s'%(kapdir,s850,sigmap,0,0,sigma,sigma,'> /dev/null') os.system(cmd) #OPEN up the region specific clump list data = fits.open(clumpcat) DATA = data[1].data #LOOP through the clumps in a region for j in DATA: I = int(j[0]) print '===========================' print 'Clump #'+str(I)+' of '+region print '===========================' name = region+'-SMM'+str(I)
config = '^inparams.txt' #TEST 1 #### FIND BACK box = 80 FB = 'FW/temp/'+file+'FB.sdf' print '1 FIND BACK ' cmd = '%s/findback in=%s out=%s box=%s sub=TRUE %s'%(cupdir,map,FB,box,'> /dev/null') #os.system(cmd) MSK = 'FW/temp/'+file+'FB_MSK.sdf' mult = '%s/mult in1=%s in2=%s out=%s'%(kapdir,FB,mask,MSK) os.system(mult) clumps1 = 'FW/'+region+'clumpsFB.sdf' cat1 = 'FW/cat/'+region+'clump_catFB.fit' sigma1 = noise.noise_by_data(FB,'FALSE') print clumps1 cmd = '%s/findclumps in=%s out=%s outcat=%s method=FellWalker deconv=True config=%s RMS=%s '%(cupdir,MSK,clumps1,cat1,config,sigma1) os.system(cmd) #TEST 2 #### FINDBACK + MAKESNR print '2 FINDBACK + MAKESNR' FBsnr = 'FW/temp/'+file+'FBSNR.sdf' cmd = '%s/makesnr in=%s out=%s'%(kapdir,FB,FBsnr) os.system(cmd) #snrMSK = 'FW/temp/'+file+'SNR_MSK.sdf' #mult = '%s/mult in1=%s in2=%s out=%s'%(kapdir,FBsnr,mask,snrMSK) #os.system(mult) clumps2 = 'FW/'+region+'clumpsSNR.sdf' cat2 = 'FW/cat/'+region+'clump_catSNR.fit' sigma2 = noise.noise_by_snr(FBsnr,'FALSE')
### mask 850 maps to remove fringes MSK = 'FW/temp/'+file+'FB_MSK.sdf' mult = '%s/mult in1=%s in2=%s out=%s'%(kapdir,FB,mask,MSK) os.system(mult) print 'MANUAL SECTION: '+str(MSK)+' NOW' ''' #Now manually section FB maps, adding 'section' to the end of each file name in 'FW/temp/' #PART 2 #### FINDclumps print '===============================================' print 'Finding clumps in: '+file #Base 1sigma level sigma = noise.noise_by_data(map,'FALSE') print 'sigma noise: '+str(sigma) inmap = 'FW/temp/'+file+'FB_MSKsection.sdf' clumps = 'FW/'+region+'clumps.sdf' cat = 'FW/cat/'+region+'clump_cat.fit' config = '^inparams.txt' cmd = '%s/findclumps in=%s out=%s outcat=%s method=FellWalker deconv=True config=%s RMS=%s '%(cupdir,inmap,clumps,cat,config,sigma) os.system(cmd)
os.system(cmd4) cmd1 = '%s/add in1=%s in2=%s out=%s'%(kapdir,output_dir+'/process/'+file+'/s450normMB.sdf',output_dir+'/process/'+file+'/s450normSB.sdf', output_dir+'/process/'+file+'/s450convolve.sdf') cmd2 = '%s/add in1=%s in2=%s out=%s'%(kapdir,output_dir+'/process/'+file+'/s850normMB.sdf',output_dir+'/process/'+file+'/s850normSB.sdf', output_dir+'/process/'+file+'/s850convolve.sdf') os.system(cmd1) os.system(cmd2) ############### 3 -- Align the 450 map with the 850 map ############ print 3 #Align 450 onto 850 convolved maps (in 2 or 3D where necessary) percent = 5 SNR = 5 STDV_450 = noise.noise_by_data(input_dir+'/'+file450+'.sdf','FLASE') STDV_850 = noise.noise_by_data(input_dir+'/'+file850+'.sdf','FLASE') if STDV_850 == 0.0: TDV_850 = STDV_450/5.5 print 'No noise for 850um. Value estimated from ratio and 450 level' sigma450 = STDV_450*SNR sigma850 = STDV_850*SNR var450 = (STDV_450**2.0)*((alpha450**2.0) + (beta450**2.0))*(2./3.) var850 = (STDV_850**2.0)*((alpha850**2.0) + (beta850**2.0))*(2./3.) #Creating mask of input maps at 5sigma - for masking Align/collapse maps with cmd1 = '%s/thresh in=%s out=%s thrlo=%f newlo=%s thrhi=%f newhi=%f QUIET'%(kapdir,input_dir+'/'+file450+'.sdf',output_dir+'/process/'+file+'/s450mask.sdf',sigma450,'bad',sigma450,1)