listobs(vis='SNR_G55_10s.ms', listfile='SNR_G55_10s.listobs') plotants(vis='SNR_G55_10s.ms', figfile='SNR_G55_10s.plotants.png') #This is an error in casa guide since the plot is different--> should be freq vs amp #plotms(vis='SNR_G55_10s.ms', field='1', xaxis='time', yaxis='amp', coloraxis='spw',plotfile='field_01_time_vs_amp.png') plotms(vis='SNR_G55_10s.ms', field='1', xaxis='frequency', yaxis='amp', coloraxis='spw',plotfile='Figure_02.png') #To narrow down where the RFI occurs let's now have a look at the data in amplitude vs frequency, plotted separately per each scan: plotms(vis='SNR_G55_10s.ms', scan='30,75,120,165,190,235,303', antenna='ea24', xaxis='freq', yaxis='amp', coloraxis='spw', iteraxis='scan',plotfile='ea24_freq_vs_amp.png') #Amplitude vs. frequency plot of L-Band, spectral window 0, for scan 190 plotms(vis='SNR_G55_10s.ms', spw='0', scan='190', xaxis='freq',yaxis='amp',plotfile='Figure_4b.png') #msview() #We will now apply these online flags to the data by employing flagcmd, but first, let's create a plot of the flags to get an idea of what will be flagged. flagcmd(vis='SNR_G55_10s.ms', inpmode='table', reason='any', action='plot', plotfile='flaggingreason_vs_time.png') #Now that we've plotted the online flags, we will apply them to the MS. flagcmd(vis='SNR_G55_10s.ms', inpmode='table', reason='any', action='apply', flagbackup=False) # Plot of elevation vs. time. plotms(vis='SNR_G55_10s.ms', xaxis='time', yaxis='elevation', antenna='0&1;2&3', spw='*:31', coloraxis='field', title='Elevation vs. Time', plotfile='Figure_09.png') #Shadowing flagdata(vis='SNR_G55_10s.ms', mode='shadow', tolerance=0.0, flagbackup=False) #Zero Amplitude Data--->In addition to shadowing, there may be times during which the correlator writes out pure zero-valued data. In order to remove this bad data, we run flagdata to remove any pure zeroes: flagdata(vis='SNR_G55_10s.ms', mode='clip', clipzeros=True, flagbackup=False) #It's common for the array to settle down at the start of a scan. Quacking is used to remove data at scan boundaries, the same edit can be applied to all scans for all baselines. flagdata(vis='SNR_G55_10s.ms', mode='quack', quackinterval=5.0, quackmode='beg', flagbackup=False) #Now that we've applied online flags, clipped zero amplitude data, removed shadowed data, and quacked the data, we will create a backup of the flags by setting the parameter versionname='after_online_flagging' : flagmanager(vis='SNR_G55_10s.ms', mode='save', versionname='after_online_flagging') #Before hannning smoothing plotms(vis='SNR_G55_10s.ms', scan='190', antenna='ea24', spw='0~2', xaxis='freq', yaxis='amp', coloraxis='spw', title='Before Hanning', correlation='RR,LL', plotrange=[1.2,1.8,-0.01,0.25], plotfile='amp_v_freq.beforeHanning.png') #Hanning smoothing command hanningsmooth(vis='SNR_G55_10s.ms', outputvis='SNR_G55_10s-hanning.ms', datacolumn='data') #After hanning smoothing plotms(vis='SNR_G55_10s-hanning.ms', scan='190', antenna='ea24', spw='0~2', xaxis='freq', yaxis='amp', coloraxis='spw', title='After Hanning', correlation='RR,LL', plotrange=[1.2,1.8,-0.01,0.25], plotfile='amp_v_freq.afterHanning.png') #Before tfcrop plotms(vis='SNR_G55_10s-hanning.ms', scan='190', antenna='ea24', xaxis='freq', iteraxis='scan', yaxis='amp', ydatacolumn='data', plotfile='amp_v_freq_before_tfcrop.png', title='Before TFCrop', coloraxis='spw', plotrange=[1.2,2,-0.01,0.25]) flagdata(vis='SNR_G55_10s-hanning.ms', mode='tfcrop', spw='0', datacolumn='data', action='calculate', display='both', flagbackup=False) flagdata(vis='SNR_G55_10s-hanning.ms', mode='tfcrop', spw='0', datacolumn='data', action='apply', display='', flagbackup=False) flagdata(vis='SNR_G55_10s-hanning.ms', mode='tfcrop', spw='1~3', datacolumn='data', action='apply', display='both', flagbackup=False) #After Tfcrop plotms(vis='SNR_G55_10s-hanning.ms', scan='190', antenna='ea24', xaxis='freq', iteraxis='scan', yaxis='amp', ydatacolumn='data', plotfile='amp_v_freq_after_tfcrop.png', title='After TFCrop', correlation='RR,LL', coloraxis='spw', plotrange=[1.2,2,-0.01,0.25]) #We now calculate the amount of data flagged so far in our Measurement Set by using the flagdata task with parameter mode='summary' and assign the returned Python dictionary to the variable flagInfo. flagInfo = flagdata(vis='SNR_G55_10s-hanning.ms', mode='summary') print("\n %2.1f%% of G55.7+3.4, %2.1f%% of 3C147, and %2.1f%% of J1925+2106 are flagged. \n" % (100.0 * flagInfo['field']['G55.7+3.4']['flagged'] / flagInfo['field']['G55.7+3.4']['total'], 100.0 * flagInfo['field']['0542+498=3C147']['flagged'] / flagInfo['field']['0542+498=3C147']['total'], 100.0 * flagInfo['field']['J1925+2106']['flagged'] / flagInfo['field']['J1925+2106']['total'])) # cpaste print("Spectral windows are flagged as follows:") for spw in range(0,4): print("SPW %s: %2.1f%%" % (spw, 100.0 * flagInfo['spw'][str(spw)]['flagged'] / flagInfo['spw'][str(spw)]['total'])) #First, run gaincal to solve for an initial set of antenna-based phases over a narrow range of channels. To find channels for each spectral window that are relatively RFI-free over the course of the observing session, look at the data with plotms. Use only a narrow channel range. plotms(vis='SNR_G55_10s-hanning.ms', scan='42,65,88,11,134,157', antenna='ea24', xaxis='channel', yaxis='amp', iteraxis='spw') gaincal(vis='SNR_G55_10s-hanning.ms', caltable='SNR_G55_10s-hanning.initPh', field='J1925+2106', solint=' int ', spw='0:20~24,1:49~52,2:38~41,3:41~44', refant='ea24', minblperant=3, minsnr=3.0, calmode='p') # Figure 14 shows the phases do not change much over the course of the observing session. plotms(vis='SNR_G55_10s-hanning.initPh', xaxis='time', yaxis='phase', iteraxis='spw', antenna='ea01,ea05,ea10,ea24', coloraxis='Antenna1',plotfile='Figure_14.png') #Since the plots look fairly reasonable, we will now create a time-averaged bandpass solution for the complex gain calibration source using the bandpass task. bandpass(vis='SNR_G55_10s-hanning.ms', caltable='SNR_G55_10s-hanning.initBP', field='J1925+2106', solint=' inf ', combine='scan', refant='ea24', minblperant=3, minsnr=10.0, gaintable='SNR_G55_10s-hanning.initPh', interp='nearest', solnorm=False) plotms(vis='SNR_G55_10s-hanning.initBP',xaxis='freq', yaxis='amp', iteraxis='antenna', coloraxis='corr',gridrows=2,plotfile='freq_vs_amp_antennas_fig_15a.png') #We notice that antennas ea01 and ea05 have a point that is offset from the rest (Figures 15a,c). Let's plot just these two antennas, locate the point on the plot, and flag it interactively through plotms. The interactive flagging within plotms will not create a backup, therefore it may be wise to use flagmanager before doing so (see Section Flagmanager earlier in this tutorial). flagmanager(vis='SNR_G55_10s-hanning.initBP', mode='save', versionname='before_flagging') plotms(vis='SNR_G55_10s-hanning.initBP',xaxis='freq', yaxis='amp', iteraxis='antenna', antenna='ea01,ea05', coloraxis='corr', gridrows=2,plotfile='Figure_16.png') applycal(vis='SNR_G55_10s-hanning.ms', gaintable='SNR_G55_10s-hanning.initBP', calwt=False) #Running RFlag on bandpass calibrated data plotms(vis='SNR_G55_10s-hanning.ms', scan='190' , antenna='ea24', xaxis='freq', yaxis='amp', ydatacolumn='corrected', coloraxis='spw', title='Before RFlag', plotfile='amp_v_freq.beforeRFlag.png') flagdata(vis='SNR_G55_10s-hanning.ms', mode='rflag', spw='0', datacolumn='corrected', action='calculate', display='both', flagbackup=False) tget(flagdata) inp flagdata(vis='SNR_G55_10s-hanning.ms', mode='rflag', spw='0', datacolumn='corrected', freqdevscale=2.5, timedevscale=3.5, action='apply', display='both', flagbackup=False) flagdata(vis='SNR_G55_10s-hanning.ms', mode='extend', spw='0', extendpols=True, action='apply', display='', flagbackup=False) flagdata(vis='SNR_G55_10s-hanning.ms', mode='extend', spw='0', growtime=50.0, growfreq=90.0, action='apply', display='', flagbackup=False) flagdata(vis='SNR_G55_10s-hanning.ms', mode='rflag', spw='1,3', datacolumn='corrected', freqdevscale=4.0, timedevscale=4.0, action='apply', display='both', flagbackup=False) flagdata(vis='SNR_G55_10s-hanning.ms', mode='extend', spw='1,3', extendpols=True, action='apply', display='', flagbackup=False) flagdata(vis='SNR_G55_10s-hanning.ms', mode='extend', spw='1,3', growtime=50.0, growfreq=90.0, action='apply', display='', flagbackup=False) flagdata(vis='SNR_G55_10s-hanning.ms', mode='rflag', spw='2', datacolumn='corrected', freqdevscale=2.5, timedevscale=2.5, action='apply', display='both', flagbackup=False) flagdata(vis='SNR_G55_10s-hanning.ms', mode='extend', spw='2', extendpols=True, action='apply', display='', flagbackup=False) flagdata(vis='SNR_G55_10s-hanning.ms', mode='extend', spw='2', growtime=50.0, growfreq=90.0, action='apply', display='', flagbackup=False) plotms(vis='SNR_G55_10s-hanning.ms', scan='190' , antenna='ea24', xaxis='freq', yaxis='amp', ydatacolumn='corrected', coloraxis='spw', title='After RFlag', plotfile='amp_v_freq.afterRFlag.png', plotrange=[1.2,2,0,2.5]) flagmanager(vis='SNR_G55_10s-hanning.ms', mode='save', versionname='before_interactive_flagging') plotms(vis='SNR_G55_10s-hanning.ms', scan='50~100', xaxis='uvdist', yaxis='amp', ydatacolumn='corrected', coloraxis = 'spw',plotfile='uvdist_vs_amp_50_100.png') #msview() flagdata(vis='SNR_G55_10s-hanning.ms', scan='87,88', antenna='ea16', flagbackup=True) plotms(vis='SNR_G55_10s-hanning.ms', scan='50~100', xaxis='uvdist', yaxis='amp', ydatacolumn='corrected', coloraxis = 'spw',plotfile='uvdist_vs_amp_50_100_flagged.png') flagInfo = flagdata(vis='SNR_G55_10s-hanning.ms', mode='summary', action='calculate', display='report', spwchan=True) print("\n %2.1f%% of G55.7+3.4, %2.1f%% of 3C147, and %2.1f%% of J1925+2106 are flagged. \n" % (100.0 * flagInfo['field']['G55.7+3.4']['flagged'] / flagInfo['field']['G55.7+3.4']['total'], 100.0 * flagInfo['field']['0542+498=3C147']['flagged'] / flagInfo['field']['0542+498=3C147']['total'], 100.0 * flagInfo['field']['J1925+2106']['flagged'] / flagInfo['field']['J1925+2106']['total'])) # cpaste print("Spectral windows are flagged as follows:") for spw in range(0,4): print("SPW %s: %2.1f%%" % (spw, 100.0 * flagInfo['spw'][str(spw)]['flagged'] / flagInfo['spw'][str(spw)]['total']))