#ALMA imaging script created by George J. Bendo for the ALMA Data #Processing Workshop at UCLan (23-24 January 2019). # #This script is similar to the typical scripts used for manual ALMA #data calibration. However, it has been slightly reformatted to provide #slightly more data processing information. # # # #To use this script, type the following lines in CASA: # #CASA <1>: mysteps=[N] #CASA <2>: execfile('scriptForImaging.py') # #The first line sets the data processing steps ("N") that will be #performed when the script is executed. For example, if mysteps=[1] #is typed into CASA before executing this script, then initial #flagging will be peformed. Multiple data processing steps can be #specified; for example, mysteps=[1,2,3] will peform steps 1, 2, and #3. To execute all steps, type mysteps=[]. #Preliminary data processing set-up. #These set of lines list the data processing steps that can be performed when #this script is executed. thesteps = [] step_title = {0: 'Continuum image for target ngc3256, spws [0, 1, 2, 3]', 1: 'Continuum subtraction for field ngc3256', 2: 'Cube for target ngc3256, spw 0', 3: 'Cube for target ngc3256, spw 1', 4: 'Cube for target ngc3256, spw 2', 5: 'Cube for target ngc3256, spw 3', 6: 'Export images to FITS format'} if 'applyonly' not in globals(): applyonly = False try: print 'List of steps to be executed ...', mysteps thesteps = mysteps except: print 'global variable mysteps not set.' if (thesteps==[]): thesteps = range(0,len(step_title)) print 'Executing all steps: ', thesteps #The next set of lines are used to set the visibility data to use for imaging #and to set the rest frequencies for each of the spectral windows. If any #spectral window contains a spectral line of interest, the rest frequency #should be set to the rest frequency of that spectral line. If the spectral #window contains no interesting spectral lines, then setting the rest frequency #to the central frequency of the window is appropriate. thevis = ['uid___A002_Xb046c2_X3b39.ms.split.cal'] therestfreqs = {0: '96.74GHz', 1: '97.980953GHz', 2: '108.0GHz', 3: '110.201354GHz'} #Step 0: Create the continuum image for the target. mystep = 0 if(mystep in thesteps): casalog.post('Step '+str(mystep)+' '+step_title[mystep],'INFO') print 'Step ', mystep, step_title[mystep] os.system('rm -rf ngc3256_sci.spw0_1_2_3.cont.I.manual*') tclean(vis = thevis, imagename = 'ngc3256_sci.spw0_1_2_3.cont.I.manual', field = 'ngc3256', stokes = 'I', spw = '0:0~60;85~110;130~239,1:0~80;110~239,2,3:30~40;70~110;140~170;200~239', outframe = 'LSRK', specmode = 'cont', nterms = 2, imsize = [240, 240], cell = '0.4arcsec', deconvolver = 'mtmfs', niter = 500, weighting = 'briggs', robust = 0.5, gridder = 'standard', pbcor = True, interactive = True ) os.system('ln -sf ngc3256_sci.spw0_1_2_3.cont.I.manual.image.tt0.pbcor ngc3256_sci.spw0_1_2_3.cont.I.manual.image.pbcor') os.system('ln -sf ngc3256_sci.spw0_1_2_3.cont.I.manual.pb.tt0 ngc3256_sci.spw0_1_2_3.cont.I.manual.pb') #Step 1: Perform a continuum subtraction on the visibility data. mystep = 1 if(mystep in thesteps): casalog.post('Step '+str(mystep)+' '+step_title[mystep],'INFO') print 'Step ', mystep, step_title[mystep] uvcontsub(vis = 'uid___A002_Xb046c2_X3b39.ms.split.cal', field = 'ngc3256', spw = '0,1,2,3', fitspw = '0:0~60;85~110;130~239,1:0~80;110~239,2,3:30~40;70~110;140~170;200~239', fitorder = 1, solint = 'int', excludechans = False, want_cont = False ) os.system('rm -rf uid___A002_Xb046c2_X3b39.ms.split.cal_ngc3256.contsub') os.system('mv uid___A002_Xb046c2_X3b39.ms.split.cal.contsub uid___A002_Xb046c2_X3b39.ms.split.cal_ngc3256.contsub') #Step 2: Create an image cube for spw 0. mystep = 2 if(mystep in thesteps): casalog.post('Step '+str(mystep)+' '+step_title[mystep],'INFO') print 'Step ', mystep, step_title[mystep] os.system('rm -rf ngc3256_sci.spw0.cube.I.manual*') tclean(vis = 'uid___A002_Xb046c2_X3b39.ms.split.cal_ngc3256.contsub', imagename = 'ngc3256_sci.spw0.cube.I.manual', field = 'ngc3256', stokes = 'I', spw = '0', outframe = 'LSRK', restfreq = therestfreqs[0], specmode = 'cube', imsize = [240, 240], cell = '0.4arcsec', deconvolver = 'hogbom', niter = 500, weighting = 'briggs', robust = 0.5, mask = '', gridder = 'standard', pbcor = True, threshold = '0.1mJy', width = 1, nchan = -1, interactive = True ) #Step 3: Create an image cube for spw 1. mystep = 3 if(mystep in thesteps): casalog.post('Step '+str(mystep)+' '+step_title[mystep],'INFO') print 'Step ', mystep, step_title[mystep] os.system('rm -rf ngc3256_sci.spw1.cube.I.manual*') tclean(vis = 'uid___A002_Xb046c2_X3b39.ms.split.cal_ngc3256.contsub', imagename = 'ngc3256_sci.spw1.cube.I.manual', field = 'ngc3256', stokes = 'I', spw = '1', outframe = 'LSRK', restfreq = therestfreqs[1], specmode = 'cube', imsize = [240, 240], cell = '0.4arcsec', deconvolver = 'hogbom', niter = 500, weighting = 'briggs', robust = 0.5, mask = '', gridder = 'standard', pbcor = True, threshold = '0.1mJy', width = 1, nchan = -1, interactive = True ) #Step 4: Create an image cube for spw 2. mystep = 4 if(mystep in thesteps): casalog.post('Step '+str(mystep)+' '+step_title[mystep],'INFO') print 'Step ', mystep, step_title[mystep] os.system('rm -rf ngc3256_sci.spw2.cube.I.manual*') tclean(vis = 'uid___A002_Xb046c2_X3b39.ms.split.cal_ngc3256.contsub', imagename = 'ngc3256_sci.spw2.cube.I.manual', field = 'ngc3256', stokes = 'I', spw = '2', outframe = 'LSRK', restfreq = therestfreqs[2], specmode = 'cube', imsize = [240, 240], cell = '0.4arcsec', deconvolver = 'hogbom', niter = 500, weighting = 'briggs', robust = 0.5, mask = '', gridder = 'standard', pbcor = True, threshold = '0.1mJy', width = 1, nchan = -1, interactive = False ) #Step 4: Create an image cube for spw 3. mystep = 5 if(mystep in thesteps): casalog.post('Step '+str(mystep)+' '+step_title[mystep],'INFO') print 'Step ', mystep, step_title[mystep] os.system('rm -rf ngc3256_sci.spw3.cube.I.manual*') tclean(vis = 'uid___A002_Xb046c2_X3b39.ms.split.cal_ngc3256.contsub', imagename = 'ngc3256_sci.spw3.cube.I.manual', field = 'ngc3256', stokes = 'I', spw = '3', outframe = 'LSRK', restfreq = therestfreqs[3], specmode = 'cube', imsize = [240, 240], cell = '0.4arcsec', deconvolver = 'hogbom', niter = 500, weighting = 'briggs', robust = 0.5, mask = '', gridder = 'standard', pbcor = True, threshold = '0.1mJy', width = 1, nchan = -1, interactive = True ) #Step 6: Export the images to FITS format./ mystep = 6 if(mystep in thesteps): casalog.post('Step '+str(mystep)+' '+step_title[mystep],'INFO') print 'Step ', mystep, step_title[mystep] myimages = ['ngc3256_sci.spw0.cube.I.manual', 'ngc3256_sci.spw0_1_2_3.cont.I.manual', 'ngc3256_sci.spw1.cube.I.manual', 'ngc3256_sci.spw2.cube.I.manual', 'ngc3256_sci.spw3.cube.I.manual'] for myimagebase in myimages: exportfits(imagename = myimagebase+'.image.pbcor', fitsimage = myimagebase+'.pbcor.fits', overwrite = True ) exportfits(imagename = myimagebase+'.pb', fitsimage = myimagebase+'.pb.fits', overwrite = True )