import re import glob finalvis= '../semipass/calibrated_X1d0.ms' # Use plotms to identify line and continuum spectral windows. #>>> If you have a project with multiple fields, you will want to run #>>> the following plotms command separately for each source. If the #>>> spectra for each field are significantly different from each other, #>>> it may be necessary to make separate average continuum and #>>> continuum-subtracted measurement sets for each field. #plotms(vis=finalvis, xaxis='channel', yaxis='amplitude', # ydatacolumn='data', # avgtime='1e8', avgscan=True, avgchannel='1', # iteraxis='spw' ) # Set spws to be used to form continuum contspws = '17,19,21,23' # Flag the "line channels" flagchannels='19:63~72' # only applicable to Tune147 data #for thisvis in finalvisall: # flagmanager(vis=thisvis,mode='save', # versionname='before_cont_flags') # initweights(vis=thisvis,wtmode='weight',dowtsp=True) # if (thisvis != '../minimosaic/calibrated_X164.ms' and thisvis != '../minimosaic/calibrated_X184.ms'): # flagdata(vis=thisvis,mode='manual', # spw=flagchannels,flagbackup=False) # else: # print 'hi' #for thisvis in ['../minimosaic/calibrated_X164.ms','../minimosaic/calibrated_X184.ms']: # flagmanager(vis=thisvis,mode='restore', # versionname='before_cont_flags') flagmanager(vis=finalvis,mode='save', versionname='before_cont_flags') initweights(vis=finalvis,wtmode='weight',dowtsp=True) flagdata(vis=finalvis,mode='manual', spw=flagchannels,flagbackup=False) #>>> In CASA 4.4 and higher, the behavior of the avgchannel parameter #>>> has changed. Now when you plot binned channels, plotms displays #>>> the "bin" number rather than the average channel number of each #>>> bin. A ticket has been filed to revert this back to the previous #>>> (more sensible) behavior, but this behavior hasn't been fixed as of CASA 5.1. #>>> If you don't see any obvious lines in the above plot, you may to try #>>> to set avgbaseline=True with uvrange (e.g., <100m). Limiting the #>>> uvrange to the short baselines greatly improves the visibility of #>>> lines with extended emission. #>>> If you have multiple sources, the line channel ranges may be #>>> different for different sources. Thus you would need to repeat the #>>> process below for each source. # If you have complex line emission and no dedicated continuum # windows, you will need to flag the line channels prior to averaging. #flagdata(vis=finalvis,mode='manual', # spw=flagchannels,flagbackup=False) # check that flags are as expected, NOTE must check reload on plotms # gui if its still open. #contvis='calibrated_minimosaic_final_cont.ms' #rmtables(contvis) #os.system('rm -rf ' + contvis + '.flagversions') contvis= 'calibrated_X1d0_cont_CORR.ms' conttimevis='calibrated_X1d0_conttime_CORR.ms' #>>> Note that to mitigate bandwidth smearing, please keep the width #>>> of averaged channels less than 125MHz in Band 3, 4, and 6, and 250MHz #>>> in Band 7 for both TDM and FDM modes. For example, for a 2GHz TDM window #>>> with 15.625 MHz channels, this means that the maximum width parameter #>>> should be 8 channels for Bands 3, 4, and 6 and 16 channels for Band 7. #>>> This is especially important for any long baseline data. These limits #>>> have been designed to have minimize the reduction of the peak flux to #>>> 95%. See the "for continuum" header for more information on the imaging #>>> wiki for more infomration. #>>> Note that in CASA 5.1, split2 is now split. Previously split2 was #>>> needed to deal correctly with channelized weights. split(vis=finalvis, spw=contspws, outputvis=contvis, width=[8,8,8,8], # timebin='10s', datacolumn='data') split(vis=finalvis, spw=contspws, outputvis=conttimevis, width=[8,8,8,8], timebin='10s', datacolumn='data') # Check the weights. You will need to change antenna and field to # appropriate values plotms(vis=contvis, yaxis='wtsp',xaxis='freq',spw='',antenna='DA43',field='0') ## If you flagged any line channels, restore the previous flags #for thisvis in finalvisall: flagmanager(vis=finalvis,mode='restore', versionname='before_cont_flags') # Inspect continuum for any problems #plotms(vis=contvis,xaxis='uvdist',yaxis='amp',coloraxis='spw')