NRAO Home > CASA > CASA Cookbook and User Reference Manual

B.12 Executing Python scripts

Python scripts are simple text files containing lists of commands as if typed at the keyboard. Note: the auto-parentheses feature of IPython can not be used in scripts, that is, you should make sure all function calls have any opening and closing parentheses.

  # file is script.py  
  # My script to plot the observed visibilities  
  plotxy(’ngc5921.ms’,’uvdist’) #yaxis defaults to amplitude

This can be done by using the execfile command to execute this script. execfile will execute the script as though you had typed the lines at the CASA prompt.

  CASA [5]: execfile ’script.py’  
  --------> execfile(’script.py’)

If you don’t want to launch CASA and execute your script from the command line, you can use the ’-c’ option:

unix$   casapy -c ’script.py’


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