Trouble Shooting Tsys Tables. Run these before you create FDM Tsys.

NOTE: the work arounds below assume that you have confirmed with plotms that the RAW DATA are fine, i.e. only problem is with Tsys

  • A useful set of plots to make:
au.plotbandpass('uid___A002_X3c7a84_X443.ms.tsys',overlay='time', 
                xaxis='freq', yaxis='amp',subplot=22,interactive=False,
                showatm=True,chanrange='5~122',showfdm=True,
                figfile='TsysPlotsOriginal/uid___A002_X3c7a84_X443.ms.tsys.png')

  • Replace one antenna with another. Here is an example from project 2011.0.00471.S:
  interTsys = aU.InterpolateTsys('uid___A002_X3c7a84_X1fb.ms.fixvis.tsys')
  lie=aU.StuffToLieAbout('uid___A002_X3c7a84_X1fb.ms.fixvis.tsys')
  lie.gain('DV13','DV09') # bad -> good is order

  • Replace one pol for one spw with the other pol from that spw. Here is an example from project 2011.0.00471.S, written for the old cal table format of casa < 3.4. (You can use au.replaceTsys if you are using a modern version of CASA.)
  calTable = 'uid___A002_X3c7a84_X443.ms.tsys'
  antenna = 5 # Antenna id
  spwsToFix = [15] # Original spw ids
  frompol = 'X'
  topol = 'Y'
  scaleFactor = 1.0
  # do not change anything below this point
  pols = ['X', 'Y']  # for now, assume this is always true
  frompol = pols.index(frompol)
  topol = pols.index(topol)
  tb.open(calTable+'/CAL_DESC')
  truespws = list(tb.getcol('SPECTRAL_WINDOW_ID')[0])
  tb.close()
  tb.open(calTable,nomodify=False)
  antennas = tb.getcol('ANTENNA1')
  spws = tb.getcol('CAL_DESC_ID')
  replaced = 0
  for i in range(len(antennas)):
      for spw in spwsToFix:
          if (antennas[i] == antenna and spws[i] == truespws.index(spw)):
              print "Replacing row %d" % (i)
              gain = tb.getcell('GAIN',i)
              gain[topol] = gain[frompol] * scaleFactor
              tb.putcell('GAIN',i,gain)
              replaced += 1

  print "Replaced %d rows" % (replaced)
  tb.close() 

  • Replace one pol of one antenna+spw+scan with the same pol+antenna+spw from a different scan. Here is an example from project 2011.0.00958.S, written for the old caltable format of casa < 3.4. (You can use au.replaceTsysScan if you are using a modern version of CASA).
  calTable = 'uid___A002_X3fa880_X8c2.ms.tsys'
  # Determine the scan numbers during which the good field and the discrepant field were observed:
  fromscan = 3 # good field
  toscan = 6   # discrepant field
  antenna = 8 # Antenna id = DV11
  spwsToFix = [11] # Original spw ids
  pol = 'X'  # pol to replace
  scaleFactor = 1.0
  # do not change anything below this point
  pols = ['X', 'Y']  # for now, assume this is always true
  pol = pols.index(pol)
  tb.open(calTable+'/CAL_DESC')
  truespws = list(tb.getcol('SPECTRAL_WINDOW_ID')[0])
  tb.close()
  tb.open(calTable,nomodify=False)
  antennas = tb.getcol('ANTENNA1')
  spws = tb.getcol('CAL_DESC_ID')
  scans = tb.getcol('SCAN_NUMBER')
  fromlist = []
  for i in range(len(antennas)):
    for spw in spwsToFix:
      if (antennas[i] == antenna and spws[i] == truespws.index(spw) and scans[i] == fromscan):
        print "Reading from row %d" % (i)
        gain = tb.getcell('GAIN',i)
        fromlist.append(gain[pol] * scaleFactor)

  replaced = 0
  for i in range(len(antennas)):
    for spw in spwsToFix:
      if (antennas[i] == antenna and spws[i] == truespws.index(spw) and scans[i] == toscan):
        print "Writing to row %d" % (i)
        gain = tb.getcell('GAIN',i)
        gain[pol] = fromlist[replaced]
        tb.putcell('GAIN',i,gain)
        replaced += 1

  print "Replaced %d rows" % (replaced)
  tb.close()

  • Interpolate across a Tsys Spike / atmospheric line in image sideband (to get channels use au.plotbandpass with channel instead of freq). See also au.removeTsysSpike. Here is an example from project 2011.0.00273.S:
 
  calTable = 'uid___A002_X4afc39_X8ce.ms.tsys'
  spw = 9 # Original spw
  startchan = 11 # where you really want to start -1
  endchan = 22 # 1+ where you really want to stop
  tb.open(calTable,nomodify=False)
  spws = tb.getcol('SPECTRAL_WINDOW_ID')
  replaced = 0
  for i in range(tb.nrows()):
      if (spws[i] == spw):
          print "Replacing row %d" % (i)
          gain = tb.getcell('FPARAM',i)
          for j in [0,1]:
              for chan in range(startchan,endchan):
                  gain[j][chan] = 0.5*(gain[j][startchan-1] + gain[j][endchan])
          tb.putcell('FPARAM',i,gain)
          replaced += 1

  print "Replaced %d rows" % (replaced)
  tb.close() 

  • Replace edge channels with the value from n (in this case 5) channels in
 
  edgeToReplace = 5
  calDescIdToFix = [0,1,2,3] 

  tb.open('uid___A002_X3f6a86_X5da.ms.tsys',nomodify=False)
  nrows = tb.nrows()
  for i in range(nrows) :
      calDesc = tb.getcell("SPECTRAL_WINDOW_ID",i)
      if calDesc in calDescIdToFix :
          gain = tb.getcell("FPARAM",i)
          for j in range(edgeToReplace) :
              gain[:,j] = gain[:,edgeToReplace]
              gain[:,-(j+1)] = gain[:,-(edgeToReplace+1)]
          tb.putcell("FPARAM",i,gain)

  tb.close()

  • Re-generate a new Tsys table (if one or more Tsys measurements are missing compared to expectations from the listobs output)
 
1) While logged into an HPC Lustre node, make sure you are running a bash shell, then run:
 source /lustre/naasc/opt/services/telcal/telcal_env.sh
2) Run: casapy-telcal 3) From CASA prompt: execfile(os.getenv('CASA_TELCAL')) 4) inp tc_atmosphere (to confirm that you can see the command) 5) au.repairSysCal('your_asdm_name') This will take awhile (an hour or more). When completed, try to importasdm this dataset, but using normal casapy, not casapy-telcal (which is too old). Then run the normal gencal for 'tsys' and examine the results.

-- CrystalBrogan - 2012-05-01

This topic: ALMA > WebHome > AlmaSci > AlmaTiger > ProceduresandLinks > TroubleTsys
Topic revision: 2015-08-03, ToddHunter
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding NRAO Public Wiki? Send feedback