NRAO Home > CASA > CASA Cookbook and User Reference Manual

1.4.2 Running Tasks and Tools

Tools are functions linked to the Python interface which must be called by name with arguments. Tasks have higher-level capabilities than tools. Tasks require input parameters which maybe be specified when you call the task as a function, or be set as parameters in the interface. A task, like a tool, is a function under Python and may be written in Python, C, or C++ (the CASA toolkit is made up of C++ functions).

There are two distinct ways to run tasks. You can either set the global CASA parameters relevant to the task and tell the task to “go”, or you can call the task as a function with one or more arguments specified. These two invocation methods differ in whether the global parameter values are used or not.

For example,

    default(’plotxy’)  
    vis=’ngc5921.ms’  
    xaxis=’channel’  
    yaxis=’amp’  
    datacolumn=’data’  
    go

will execute plotxy with the set values for the parameters (see § 1.4.5). Instead of using go command (§ 1.4.5.3) to invoke the task, you can also call the task with no arguments, e.g.

    default(’plotxy’)  
    vis=’ngc5921.ms’  
    xaxis=’channel’  
    yaxis=’amp’  
    datacolumn=’data’  
    plotxy()

which will also use the global parameter values.

Second, one may call tasks and tools by name with parameters set on the same line. Parameters may be set either as explicit <parameter>=<value> arguments, or as a series of comma delimited <value>s in the correct order for that task or tool. Note that missing parameters will use the default values for that task. For example, the following are equivalent:

  # Specify parameter names for each keyword input:  
    plotxy(vis=’ngc5921.ms’,xaxis=’channel’,yaxis=’amp’,datacolumn=’data’)  
  # when specifying the parameter name, order doesn’t matter, e.g.:  
    plotxy(xaxis=’channel’,vis=’ngc5921.ms’,datacolumn=’data’,yaxis=’amp’)  
  # use parameter order for invoking tasks  
    plotxy(’ngc5921.ms’,’channel’,’amp’,’data’)

This non-use of globals when calling as a function is so that robust scripts can be written. One need only cut-and-paste the calls and need not worry about the state of the global variables or what has been run previously. It is also more like the standard behavior of function calls in Python and other languages.

Tools can only be called in this second manner by name, with arguments (§ 1.4.6). Tools never use the global parameters and the related mechanisms of inp and go.

   1.4.2.1 Aborting Synchronous Tasks


More information about CASA may be found at the CASA web page

Copyright © 2010 Associated Universities Inc., Washington, D.C.

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


Home | Contact Us | Directories | Site Map | Help | Privacy Policy | Search