Python Links

CASA uses IPython with some pysh add-ons for its command line interface.

Use the links at the left for more information on Python or IPython.

Some basic features are:

  • filesystem navigation, shell access
    CASA [1]: pwd
    /export/home/corsair-vml/jmcmulli/framework/linux_gnu/lib
    CASA [2]: ls c*
    casa*  casac.so*  casa_setup.py  casa.sh*
    CASA [3]: bookmark data
    CASA [4]: cd ../..
    CASA [5]: pwd
    /export/home/corsair-vml/jmcmulli/framework
    CASA [6]: cd -b data
    (bookmark:data) -> /export/home/corsair-vml/jmcmulli/framework/linux_gnu/lib
    
  • application help - currently not enabled

    CASA [3]: pdoc im.feather
    feather function wrapper
    CASA [4]: pdef im.feather
    No definition header found for im.feather
    
  • namespace completion
    CASA [8]: im.< TAB >
    im.__class__         im.done              im.regionmask
    im.__delattr__       im.exprmask          im.residual
    im.__doc__           im.feather           im.restore
    im.__getattribute__  im.filter            im.sensitivity
    im.__hash__          im.fitpsf            im.setbeam
    im.__init__          im.ft                im.setdata
    im.__new__           im.linearmosaic      im.setimage
    im.__reduce__        im.make              im.setjy
    im.__reduce_ex__     im.makeimage         im.setmfcontrol
    im.__repr__          im.makemodelfromsd   im.setoptions
    im.__setattr__       im.mask              im.setscales
    im.__str__           im.mem               im.setsdoptions
    im.advise            im.nnls              im.setvp
    im.approximatepsf    im.open              im.smooth
    im.boxmask           im.pb                im.stop
    im.clean             im.pixon             im.summary
    im.clipimage         im.plotsummary       im.uvrange
    im.clipvis           im.plotuv            im.weight
    im.close             im.plotvis
    im.correct           im.plotweights
    CASA [8]: im.s< TAB >
    im.sensitivity   im.setjy         im.setsdoptions  im.summary
    im.setbeam       im.setmfcontrol  im.setvp
    im.setdata       im.setoptions    im.smooth
    im.setimage      im.setscales     im.stop
    CASA [8]: im.sets< TAB >
    im.setscales     im.setsdoptions
    
  • auto-parenthesis
    CASA [2]: im.feather 'output.im','n4826_mom0.im','n4826_12mmom0.im'
    --------> im.feather('output.im','n4826_mom0.im','n4826_12mmom0.im')
    
  • session logging
    CASA [7]: logstate
    File:   ipython.log
    Mode:   rotate
    State:  active
    CASA [8]: more ipython.log
    #log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
    #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
    #log# opts = Struct({'profile': 'pysh', 'logfile': 'ipython.log'})
    #log# args = ['casa_setup.py']
    #log# It is safe to make manual edits below here.
    #log#-----------------------------------------------------------------------
    im.setvp(True,True,'',False,casac.Quantity(360.0,'deg'),'')
    im.feather('output.im','n4826_mom0.im','n4826_12mmom0.im')
    ipmagic("pdoc im.feather")
    ipmagic("pdef im.feather")
    ipmagic("logstart ")
    __IP.call_alias('more','ipython.log')
    ipmagic("logstate ")
    __IP.call_alias('more','ipython.log')
    
  • numbered input/output with command history, full searching
    CASA [19]: x=1
    CASA [20]: y=3*x
    CASA [21]: z=x^2 + y^2
    CASA [22]: x
      Out[22]: 1
    CASA [23]: y
      Out[23]: 3
    CASA [24]: z
      Out[24]: 6
    CASA [25]: Out[23]
      Out[25]: 3
    CASA [26]: Out[22]
      Out[26]: 1
    
  • macro system for re-execution of previous input
    CASA [28]: hist
    1 : im.setvp(True,True,'',False,casac.Quantity(360.0,'deg'),'')
    2 : im.feather('output.im','n4826_mom0.im','n4826_12mmom0.im')
    3 : ipmagic("pdoc im.feather")
    4 : ipmagic("pdef im.feather")
    5 : ipmagic("logstart ")
    6 : __IP.call_alias('more','ipython.log')
    7 : ipmagic("logstate ")
    8 : __IP.call_alias('more','ipython.log')
    9 : im.setjy(fieldid=1, -1 -1, [0.0,0.0,0.0,0.0], '')
    10: im.setjy(fieldid=1, -1, [0.0,0.0,0.0,0.0], '')
    11: im.setjy(1, -1, [0.0,0.0,0.0,0.0], '')
    12: im.open('ngc5921_src.split.ms')
    13: im.setjy(1, -1, [0.0,0.0,0.0,0.0], '')
    14: im.open('ngc5921.ms')
    15: im.setjy(1, -1, [0.0,0.0,0.0,0.0], '')
    16: im.setjy(fieldid=1, -1, [0.0,0.0,0.0,0.0], '')
    17: im.setvp(dovp=True)
    18: im
    19: x=1
    20: y=3*x
    21: z=x^2 + y^2
    22: x
    23: y
    24: z
    25: Out[23]
    26: Out[22]
    27: im.open('wrongname')
    CASA [29]: macro example 1 2
    Macro `example` created. To execute, type its name (without quotes).
    Macro contents:
    im.setvp(True,True,'',False,casac.Quantity(360.0,'deg'),'')
    im.feather('output.im','n4826_mom0.im','n4826_12mmom0.im')
    CASA [30]: example
      Out[30]: Executing Macro...
    Thu Oct 27 16:58:49 2005    NORMAL Imager::setvp() (file /export/home/corsair-vml/jmcmulli/framework/code/synthesis/implement/MeasurementEquations/Imager.cc, line 1846):
    Setting voltage pattern parameters
    
    ...
    
  • customizable through ipythonrc file - see IPython link

An example session with CASA is as follows:

CASA [33]: im.setvp(True)
Thu Oct 27 17:00:10 2005    NORMAL Imager::setvp() (file /export/home/corsair-vml/jmcmulli/framework/code/synthesis/implement/MeasurementEquations/Imager.cc, line 1846):
Setting voltage pattern parameters

Thu Oct 27 17:00:10 2005    NORMAL Imager::setvp() (file /export/home/corsair-vml/jmcmulli/framework/code/synthesis/implement/MeasurementEquations/Imager.cc, line 1846):
Using system default voltage patterns for each telescope

  Out[33]: True
CASA [34]: im.feather 'output.im','n4826_mom0.im','n4826_12mmom0.im'
Thu Oct 27 17:00:19 2005    NORMAL imager::feather():

Feathering together high and low resolution images.

Thu Oct 27 17:00:19 2005      WARN ImageRegrid::regrid(...) (file /export/home/corsair-vml/jmcmulli/framework/code/include/images/Images/ImageRegrid.cc, line 1959):
Cannot regrid axis 4 because it is of unit length - removing from list

Thu Oct 27 17:00:20 2005    NORMAL imager::feather():
Using primary beam to determine weighting.

Thu Oct 27 17:00:20 2005    NORMAL imager::feather():
Determining scaling from SD restoring beam.

Thu Oct 27 17:00:20 2005    NORMAL imager::feather():
Applying additional scaling for ratio of the volumes of the high to the low resolution images : 0.0153742.

---------> im.feather('output.im','n4826_mom0.im','n4826_12mmom0.im')
  Out[34]: True

Example Error (the last line typically gives the needed user information):

CASA [27]: im.open('wrongname')
Thu Oct 27 16:55:23 2005    SEVERE :
Exception Reported: Table wrongname does not exist

  Out[27]: False
Please send any comments or questions about CASA or AIPS++ to aips2-requests@nrao.edu

Copyright © 1995-2000,2001,2002,2003,2004 Associated Universities Inc., Washington, D.C.

This code is available under the terms of the GNU General Public Lincense

Staff | Contact Us | Careers | Directories | Site Map | Help | Policies | Diversity | Search
Modified on Tuesday, 04-Feb-2014 15:36:11 MST