Updating a script to work with CASA 4.2: Difference between revisions

From CASA Guides
Jump to navigationJump to search
No edit summary
Line 1: Line 1:


In the ALMA archive for Cycle 0 data, the packaged calibration script found in the '''scripts'' directory is written for execution in CASA 3.4. While it possible to use the packaged calibration script as it is in CASA 3.4, it is now recommended to use CASA 4.2 for data processing. To change the packaged calibration script into a CASA 4.2 script, it must be manually modified using a text editor, following the instructions below:
In the ALMA archive for Cycle 0 data, the packaged calibration script found in the scripts directory is written for execution in CASA 3.4. While it possible to use the packaged calibration script as it is in CASA 3.4, it is now recommended to use CASA 4.2 for data processing. To change the packaged calibration script into a CASA 4.2 script, it must be manually modified using a text editor, following the instructions below:


* Change the list of steps at the beginning of the script to
* Change the list of steps at the beginning of the script to

Revision as of 11:37, 31 March 2014

In the ALMA archive for Cycle 0 data, the packaged calibration script found in the scripts directory is written for execution in CASA 3.4. While it possible to use the packaged calibration script as it is in CASA 3.4, it is now recommended to use CASA 4.2 for data processing. To change the packaged calibration script into a CASA 4.2 script, it must be manually modified using a text editor, following the instructions below:

  • Change the list of steps at the beginning of the script to
step_title = {0: 'listobs',
              1: 'A priori flagging',
              2: 'Generation and time averaging of the WVR cal table',
              3: 'Generation of the Tsys cal table',
              4: 'Generation of the antenna position cal table',
              5: 'Application of the WVR, Tsys and antpos cal tables',
              6: 'Split out science SPWs and time average',
              7: 'Listobs, clear pointing table, and save original flags',
              8: 'Initial flagging',
              9: 'Putting a model for the flux calibrator(s)',
              10: 'Save flags before bandpass cal',
              11: 'Bandpass calibration',
              12: 'Save flags before gain cal',
              13: 'Gain calibration',
              14: 'Save flags before applycal cal',
              15: 'Application of the bandpass and gain cal tables'}
  • add "import os" and "if 'applyonly' not in globals(): applyonly = False" on line 27. The code under the steps list should now read:
import os
if 'applyonly' not in globals(): applyonly = False  #(AM) added
try:
  print 'List of steps to be executed ...', mysteps
  thesteps = mysteps
except:
  print 'global variable mysteps not set.'
  • comment out any call to aU and es tasks (aU.plotWVRSolutions, aU.plotbandpass, es.checkCalTable,...)
  • In step 7:
    • the label of the step must be changed to 9 ('mystep = 9')
    • add 'if not os.path.exists('measurementset.ms.split.flagversions/Original.flags'):' above the flagmanager call, and ident the flagmanager call. It should now read :
  if not os.path.exists('measurementset.ms.split.flagversions/Original.flags'):
    flagmanager(vis = 'measurementset.ms.split',
      mode = 'save',
      versionname = 'Original')
  • In step 8:
    • the label of the step must be changed to 10 ('mystep = 10')
    • any call to tflagdata must be changed to flagdata
  • In step 9:
    • the label of the step must be changed to 11 ('mystep = 11')
    • if applicable (when a Solar System Object is used as a flux calibrator), in setjy change the parameter standard = 'Butler-JPL-Horizons 2010' to standard = 'Butler-JPL-Horizons 2012'
  • In step 10:
    • the label of the step must be changed to 12 ('mystep = 12')
  • In step 11:
    • the label of the step must be changed to 13 ('mystep = 13')
    • in the gaincal calls, change any calmode='ap' parameter to calmode='a'
  • In step 12:
    • the label of the step must be changed to 14 ('mystep = 14')
  • In step 13:
    • the label of the step must be changed to 15 ('mystep = 15')
    • change the clearcal command to delmod (inputs are unchanged)
    • in the gaincal calls, change any calmode='ap' parameter to calmode='a'
  • In step 14:
    • the label of the step must be changed to 16 ('mystep = 16')
  • In step 15:
    • the label of the step must be changed to 16 ('mystep = 16')
  • In step 16:
    • the label of the step must be changed to 16 ('mystep = 16')


In our TW HYdra example, there are 3 measurement sets in the raw data directory that are ready for calibration, and 3 corresponding calibration scripts in the scripts directory, all written for CASA 3.4. You can find [here] those datasets updated to CASA 4.2, which can be used to calibrate and combine these data sets in CASA 4.2. They can be run in CASA 4.2 as follows.

# In CASA 4.2
 thesteps = [9,10,11,12,13,14,15,16,17,18]
 execfile('uid___A002_X554543_X207.ms.scriptForCalibration_4.2.py')
 execfile('uid___A002_X554543_X3d0.ms.scriptForCalibration_4.2.py')
 execfile('uid___A002_X554543_X667.ms.scriptForCalibration_4.2.py')
 execfile('scriptForFluxCalibration_4.2.py')