TWHydraBand7 Calibration for CASA 3.3

From CASA Guides
Revision as of 16:42, 24 May 2011 by Cbrogan (talk | contribs)
Jump to navigationJump to search


Observing Log and Priors

External info
# In CASA
data=['X3c1.ms','X5d8.ms','X7ef.ms']
for vis in data:
  listobs(vis=vis,verbose=F)

Below we copy select parts of the listobs output reported in the CASA logger for reference.

X3c1.ms:
Data records: 278352       Total integration time = 6109.06 seconds
   Observed from   22-Apr-2011/00:01:52.9   to   22-Apr-2011/01:43:42.0 (UTC)

X5d8.ms:
Data records: 278406       Total integration time = 5995.01 seconds
   Observed from   22-Apr-2011/01:48:05.8   to   22-Apr-2011/03:28:00.8 (UTC)

X7ef.ms:
Data records: 255717       Total integration time = 5407.49 seconds
   Observed from   22-Apr-2011/03:30:39.7   to   22-Apr-2011/05:00:47.2 (UTC)

  ID   Code Name         RA            Decl           Epoch   SrcId 
  0    none 3c279        12:56:11.1666 -05.47.21.5247 J2000   0     
  1    none Titan        00:00:00.0000 +00.00.00.0000 J2000   1     
  2    none TW Hya       11:01:51.9063 -34.42.17.0212 J2000   2     
  3    none J1147-382=Q* 11:47:01.3815 -38.12.11.1179 J2000   3     
  4    none J1037-295=Q* 10:37:16.0899 -29.34.02.9888 J2000   4     

  SpwID  Chans Frame Ch1(MHz)    ChanWid(kHz)TotBW(kHz)  Ref(MHz)    Corrs   
  0           4 TOPO  184550      1500000     7500000     183300      I   
  1         128 TOPO  355740.062  15625       2000000     355732.25   XX  YY  
  2           1 TOPO  356716.625  1796875     1796875     355732.25   XX  YY  
  3         128 TOPO  356507.813  15625       2000000     356500      XX  YY  
  4           1 TOPO  357484.375  1796875     1796875     356500      XX  YY  
  5         128 TOPO  346792.187  15625       2000000     346800      XX  YY  
  6           1 TOPO  345784.375  1796875     1796875     346800      XX  YY  
  7         128 TOPO  345182.438  15625       2000000     345190.25   XX  YY  
  8           1 TOPO  344174.625  1796875     1796875     345190.25   XX  YY  
  9         128 TOPO  344386.763  15625       2000000     344394.575  XX  YY  
  10          1 TOPO  343378.95   1796875     1796875     344394.575  XX  YY  
  11        128 TOPO  346324.263  15625       2000000     346332.075  XX  YY  
  12          1 TOPO  345316.45   1796875     1796875     346332.075  XX  YY  
  13        128 TOPO  354402.388  15625       2000000     354394.575  XX  YY  
  14          1 TOPO  355378.95   1796875     1796875     354394.575  XX  YY  
  15        128 TOPO  356402.388  15625       2000000     356394.575  XX  YY  
  16          1 TOPO  357378.95   1796875     1796875     356394.575  XX  YY  
  17       3840 TOPO  356497.936  122.070312  468750      355732.25   XX  YY  
  18          1 TOPO  356732.189  468750      468750      355732.25   XX  YY  
  19       3840 TOPO  357734.314  122.070312  468750      356500      XX  YY  
  20          1 TOPO  357499.939  468750      468750      356500      XX  YY  
  21       3840 TOPO  346034.314  122.070312  468750      346800      XX  YY  
  22          1 TOPO  345799.939  468750      468750      346800      XX  YY  
  23       3840 TOPO  343955.936  122.070312  468750      345190.25   XX  YY  
  24          1 TOPO  344190.189  468750      468750      345190.25   XX  YY  

   ID=   0-3: 'DV04'='J505', 'DV06'='T704', 'DV07'='J510', 'DV08'='T703', 
   ID=   4-7: 'DV09'='N602', 'DV10'='N606', 'PM01'='T702', 'PM02'='T701', 
   ID=   8-8: 'PM03'='J504'


Examine Tsys and WVR Tables, Apply, and Split

# In CASA
FDM=[17,19,21,23]
FDMtables=['X3c1.tsys.fdm','X5d8.tsys.fdm','X7ef.tsys.fdm']
plotrange=[0,0,50,500]
antennas='1,2,3,4,5,6,7,8]
for caltable in FDMtables:
  for spw in FDM:
   plotcal(caltable=caltable,xaxis='freq',yaxis='amp',
        iteration='antenna',subplot=421,poln='',spw='%d'%spw,antenna=antennas,
        showgui=F,figfile='FDM%d_%s.png'%(spw,caltable),fontsize=8.0,
        plotrange=plotrange)


# In CASA
data=['X3c1.ms','X5d8.ms','X7ef.ms']
fdm='17,19,21,23'
sources=['0','1','2','4']
nocal='3' # This source had no Tsys measurements associated with it

For sources with Tsys measurements apply only to themselves

# In CASA
for vis in data:
  for field in sources:
    applycal(vis=vis,spw=fdm,field=field,gainfield=field,
        gaintable=['%s.tsys.fdm'%(vis.split('.')[0]),'wvr_%s.cal'%(vis.split('.')[0])],
        interp=['nearest','nearest'],flagbackup=F)

For sources without Tsys, couple them with best source with Tsys

# In CASA
for vis in data:
  applycal(vis=vis,spw=fdm,field=nocal,
        gaintable=['%s.tsys.fdm'%(vis.split('.')[0]),'wvr_%s.cal'%(vis.split('.')[0])],
        gainfield=['4',nocal],interp=['nearest','nearest'],flagbackup=F)

Check Tsys application

# In CASA
plotms(vis='X5d8.ms',spw='17,19,21,23',xaxis='frequency',yaxis='amp',field='0,1',
       avgtime='1e8',avgscan=T,coloraxis='field',ydatacolumn='data')

spw 19 with atmospheric absorption gets a strange upward hitch probably from the interpolation from TDM

# In CASA
for vis in data:
  split(vis=vis,outputvis='%s_wvrtsys.ms'%(vis.split('.')[0]),datacolumn='corrected',spw=fdm)


Initial Inspection and Flagging

# In CASA
data=['X3c1_wvrtsys.ms','X5d8_wvrtsys.ms','X7ef_wvrtsys.ms']

for vis in data:
  flagdata(vis=vis,autocorr=True, flagbackup=T)
  flagdata(vis=vis,mode='shadow',diameter=12.0, flagbackup=F)
  flagdata(vis=vis,antenna='DV04', flagbackup=F)
# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='',xaxis='time',yaxis='amp',field='',avgchannel='3840',
       coloraxis='field',iteraxis='spw')
# In CASA
plotms(vis='X5d8_wvrtsys.ms',spw='',xaxis='time',yaxis='amp',field='',avgchannel='3840',
       coloraxis='field',iteraxis='spw')
# In CASA
plotms(vis='X7ef_wvrtsys.ms',spw='',xaxis='time',yaxis='amp',field='',avgchannel='3840',
       coloraxis='field',iteraxis='spw')

In spw2 there are some low points. Locate suggests YY and PM03. Switch to coloraxis='corr'

# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='2',xaxis='time',yaxis='amp',field='',avgchannel='3840',
       coloraxis='corr')

To further check remove PM03 from the plot.

# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='2',xaxis='time',yaxis='amp',field='',avgchannel='3840',
       coloraxis='corr',antenna='!PM03')

Unzoom does not work, but flip to next page and back does.


# In CASA
data=['X3c1_wvrtsys.ms','X5d8_wvrtsys.ms','X7ef_wvrtsys.ms']

for vis in data:
  flagdata(vis=vis, flagbackup=T,
         spw=['2'],
         antenna=['PM03'],
         correlation=['YY'])

Check phase / delay

# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='',xaxis='frequency',yaxis='phase',field='0',antenna='DV06',
       avgtime='1e8',avgscan=T,coloraxis='baseline',iteraxis='spw',xselfscale=T)
# In CASA
plotms(vis='X5d8_wvrtsys.ms',spw='',xaxis='frequency',yaxis='phase',field='0',antenna='DV06',
       avgtime='1e8',avgscan=T,coloraxis='baseline',iteraxis='spw',xselfscale=T)
# In CASA
plotms(vis='X7ef_wvrtsys.ms',spw='',xaxis='frequency',yaxis='phase',field='0',antenna='DV06',
       avgtime='1e8',avgscan=T,coloraxis='baseline',iteraxis='spw',xselfscale=T)

Now look for birdies

Titan and 3C279

# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='',xaxis='frequency',yaxis='amp',field='0,1',
       avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw',xselfscale=T)

TW Hydra and Phase cals

# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='',xaxis='frequency',yaxis='amp',field='2,3,4',
       avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw',xselfscale=T,yselfscale=T)


Quick check that other two datasets are the same

Titan and 3C279

# In CASA
plotms(vis='X5d8_wvrtsys.ms',spw='',xaxis='frequency',yaxis='amp',field='0,1',
       avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw',xselfscale=T)
# In CASA
plotms(vis='X7ef_wvrtsys.ms',spw='',xaxis='frequency',yaxis='amp',field='0,1',
       avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw',xselfscale=T)

TW Hydra and Phase cals

# In CASA
plotms(vis='X5d8_wvrtsys.ms',spw='',xaxis='frequency',yaxis='amp',field='2,3,4',
       avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw',xselfscale=T,yselfscale=T)

birdies seem weaker, some gone

# In CASA
plotms(vis='X7ef_wvrtsys.ms',spw='',xaxis='frequency',yaxis='amp',field='2,3,4',
       avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw',xselfscale=T,yselfscale=T)

Change to channel space to get channels for flagging

TW Hydra and Phase cals

# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='',xaxis='channel',yaxis='amp',field='2,3,4',
       avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw')
# In CASA
data=['X3c1_wvrtsys.ms','X5d8_wvrtsys.ms','X7ef_wvrtsys.ms']

for vis in data:
  flagdata(vis=vis, flagbackup=T,
         spw=['0:1067~1068;1279~1280;2367~2368;3775~3776',
              '1:1279~1280;2367~2368;3775~3776',
              '2:1279~1280;3775~3776',
              '3:831~832;1535~1536;2367~2368;3775~3776;3839~3839'])

Force reload and check that flagging has been done as anticipated.

Concatenate the Data

Here we will concatenate the three datasets for convience. WARNING: it is not always safe to do this [explain].

# In CASA
data=['X3c1_wvrtsys.ms','X5d8_wvrtsys.ms','X7ef_wvrtsys.ms']
concat(vis=data,concatvis='Band7multi_april22.ms')
# In CASA
listobs(vis='Band7multi_april22.ms',verbose=F)
SpwID  #Chans Frame Ch1(MHz)    ChanWid(kHz)TotBW(kHz)  Ref(MHz)    Corrs   
 0        3840 TOPO  356497.936  122.070312  468750      355732.25   XX  YY  
 1        3840 TOPO  357734.314  122.070312  468750      356500      XX  YY  
 2        3840 TOPO  346034.314  122.070312  468750      346800      XX  YY  
 3        3840 TOPO  343955.936  122.070312  468750      345190.25   XX  YY

Fix Titan Coordinates

Note that in the near future this step will be unnecessary.

It is temporarily necessary to correct the positions of ephemeris objects observed by ALMA, as they are currently erroneously written to the data with coordinates of 00:00:00.0000 +00.00.00.0000 J2000 (see listobs output in TWHydraBand7_Calibration#Observing_Log_and_Priors). For this data we need to correct Titan which we observed as the absolute flux calibrator. It is important to apply the fix after concatenation of the data, or Titan will be at slightly different positions in all three datasets.

For Linux OS initialize CASA script with

# In CASA
execfile(os.getenv("CASAPATH").split(' ')[0]+"/lib/python2.6/recipes/fixplanets.py")

For Mac OSX initialize CASA script with

# In CASA
execfile(os.getenv("CASAPATH").split(' ')[0]+"/Resources/python/recipes/fixplanets.py")

Now fix the position of Titan

# In CASA
fixplanets('Band7multi_april22.ms', 'Titan', True)

Check the header information again to see that the information for Titan has changed.

# In CASA
listobs(vis='Band7multi_april22.ms',verbose=F)
2011-05-23 17:23:52 INFO listobs	  ID   Code Name         RA            Decl           Epoch   SrcId 
2011-05-23 17:23:52 INFO listobs	  0    none 3c279        12:56:11.1666 -05.47.21.5247 J2000   0     
2011-05-23 17:23:52 INFO listobs	  1    none Titan        12:49:26.5120 -02.22.10.8190 J2000   1     
2011-05-23 17:23:52 INFO listobs	  2    none TW Hya       11:01:51.9063 -34.42.17.0212 J2000   2     
2011-05-23 17:23:52 INFO listobs	  3    none J1147-382=Q* 11:47:01.3815 -38.12.11.1179 J2000   3     
2011-05-23 17:23:52 INFO listobs	  4    none J1037-295=Q* 10:37:16.0899 -29.34.02.9888 J2000   4     

Flag Calibrator Spectral Features

# In CASA
plotms(vis='Band7multi_april22.ms',spw='',xaxis='channel',yaxis='amp',field='0',
       avgtime='1e8',coloraxis='field',iteraxis='spw')
# In CASA
plotms(vis='Band7multi_april22.ms',spw='',xaxis='channel',yaxis='amp',field='1',
       avgtime='1e8',coloraxis='field',iteraxis='spw')

Flag strong spectral features in the calibrators being careful about backing up flag tables so flagged regions can be restored later

# In CASA
flagmanager(vis='Band7multi_april22.ms',mode='save',versionname='before_calspectralflags')

Flag absorption features

# In CASA
flagdata(vis='Band7multi_april22.ms',
         spw=['1:2000~3840','2:1945~1960'])
# In CASA
flagmanager(vis='Band7multi_april22.ms',mode='save',versionname='before_emissionflags')

Flag emission features

<source lang="python">
# In CASA
flagdata(vis='Band7multi_april22.ms',
         field=['1','1'],
         spw=['2:300~3660','3:1000~3000'])

Check if you like that the right things have been flagged.

# In CASA
plotms(vis='Band7multi_april22.ms',spw='',xaxis='channel',yaxis='amp',field='0,1',
       avgtime='1e8',coloraxis='field',iteraxis='spw')

Set Up the Flux Calibrator Model

# In CASA
setjy(vis='Band7multi_april22.ms',field='1',
      standard='Butler-JPL-Horizons 2010',scalebychan=F)

Bandpass

gaincal(vis='Band7multi_april22.ms',caltable='bpphase.gcal',

       field='0',spw='0~3:900~1100',refant='DV06',
       calmode='p',solint='int',minsnr=2.0,minblperant=4)

bandpass(vis='Band7multi_april22.ms',caltable='bandpass.bcal',

       field='0',spw=,combine=,refant='DV06',
       solint='inf',solnorm=T,minblperant=4,fillgaps=17,
       gaintable=['bpphase.gcal'])

Gain Calibration

gaincal(vis='Band7multi_april22.ms',caltable='intphase.gcal',

       field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
       calmode='p',solint='int',minsnr=2.0,minblperant=4,
       gaintable=['bandpass.bcal'])

gaincal(vis='Band7multi_april22.ms',caltable='scanphase.gcal',

       field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
       calmode='p',solint='inf',minsnr=2.0,minblperant=4,
       gaintable=['bandpass.bcal'])

gaincal(vis='Band7multi_april22.ms',caltable='amp.gcal',

       field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
       calmode='ap',solint='inf',minsnr=2.0,minblperant=4,
       gaintable=['bandpass.bcal','intphase.gcal'])

fluxscale(vis='Band7multi_april22.ms',caltable='amp.gcal',

       fluxtable='flux.cal',reference='1',refspwmap=[0,1,3,3])


Applycal and Inspect

flagmanager(vis='Band7multi_april22.ms',mode='restore',versionname='before_calspectralflags')

applycal(vis='Band7multi_april22.ms',field='0',

       gaintable=['bandpass.bcal','intphase.gcal','flux.cal'],
       interp=['nearest','nearest','nearest'],
       gainfield=['0','0','0'],flagbackup=T)

applycal(vis='Band7multi_april22.ms',field='1',

        gaintable=['bandpass.bcal','intphase.gcal','flux.cal'],
       interp=['nearest','nearest','nearest'],
        gainfield=['0','1','1'],flagbackup=T)
  1. Secondary Phase cal

applycal(vis='Band7multi_april22.ms',field='3',

       gaintable=['bandpass.bcal','scanphase.gcal','flux.cal'],
       interp=['nearest','nearest','nearest'],
       gainfield=['0','4','4'],flagbackup=T)
  1. Primary Phase cal

applycal(vis='Band7multi_april22.ms',field='4',

       gaintable=['bandpass.bcal','intphase.gcal','flux.cal'],
       interp=['nearest','nearest','nearest'],
       gainfield=['0','4','4'],flagbackup=T)


applycal(vis='Band7multi_april22.ms',field='2',

       interp=['nearest','linear','linear'],
       gaintable=['bandpass.bcal','scanphase.gcal','flux.cal'],
       gainfield=['0','3,4','3,4'],flagbackup=T)
  1. Check results

plotms(vis='Band7multi_april22.ms',spw=,xaxis='time',yaxis='amp',field=,avgchannel='3840',

      coloraxis='field',iteraxis='spw',ydatacolumn='corrected')
  1. Pretty good but some high points at end of 1st SB. Look at only phase cals to simplify plot

plotms(vis='Band7multi_april22.ms',spw=,xaxis='time',yaxis='phase',field='3,4',avgchannel='3840',

      coloraxis='field',iteraxis='spw',ydatacolumn='corrected')

applycal(vis='Band7multi_april22.ms',field='3',

       gaintable=['bandpass.bcal','intphase.gcal','flux.cal'],
       interp=['nearest','nearest','nearest'],
       gainfield=['0','3','3'],flagbackup=T)

plotms(vis='Band7multi_april22.ms',spw=,xaxis='time',yaxis='phase',field='3,4',avgchannel='3840',

      coloraxis='field',iteraxis='spw',ydatacolumn='corrected')

plotms(vis='Band7multi_april22.ms',spw=,xaxis='time',yaxis='amp',field='3,4',avgchannel='3840',

      coloraxis='field',iteraxis='spw',ydatacolumn='corrected')

plotms(vis='Band7multi_april22.ms',spw=,xaxis='uvdist',yaxis='amp',field='2',avgchannel='3840',

      coloraxis='field',iteraxis='spw',ydatacolumn='corrected')


plotms(vis='Band7multi_april22.ms',spw=,xaxis='frequency',yaxis='amp',field='2',

      avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw',
      ydatacolumn='corrected',xselfscale=T)

plotms(vis='Band7multi_april22.ms',spw=,xaxis='frequency',yaxis='amp',field='0',

      avgtime='1e8',avgscan=T,coloraxis='field',ydatacolumn='corrected',
      iteraxis='spw',xselfscale=T)

plotms(vis='Band7multi_april22.ms',spw='2,3',xaxis='frequency',yaxis='amp',field='0,1',

      avgtime='1e8',avgscan=T,coloraxis='field',ydatacolumn='corrected')

plotms(vis='Band7multi_april22.ms',spw=,xaxis='frequency',yaxis='amp',field='3,4',

      avgtime='1e8',avgscan=T,coloraxis='field',ydatacolumn='corrected')


  1. CO 3-2 rest freq 345.79599 GHz
  2. HCO+ 4-3 rest freq 356.7342 GHz
  1. Check velocity of TWHydra should be around 2.88 km/s

plotms(vis='Band7multi_april22.ms',spw='2',xaxis='velocity',yaxis='amp',field='2',

      avgtime='1e8',avgscan=T,transform=T,freqframe='LSRK',restfreq='345.79599GHz')

plotms(vis='Band7multi_april22.ms',spw='0',xaxis='velocity',yaxis='amp',field='2',

     avgtime='1e8',avgscan=T,transform=T,freqframe='LSRK',restfreq='356.7342GHz')