Extracting scripts from these tutorials

From CASA Guides
Revision as of 14:39, 28 May 2010 by Jgallimo (talk | contribs)
Jump to navigationJump to search

The series of commands shown in each tutorial can be thought of as a data reduction script that can be run in CASA like so:

execfile('scriptname.py')

where 'scriptname.py' is the name of an ascii file containing all of the CASA commands you want to run.

Hopefully the scripts contained in this documentation are (a) useful and (b) work. They were however developed with CASA still a work in progress, and so scripts may break as commands, arguments, and keywords change. We developed this script extractor to allow us to easily extract scripts from these pages and run them. Feel free to try it--it's handy for general users too!

The only differences you will see between the commands in each tutorial and the extracted script are requests for response from you after each interactive command (plotants, plotcal, plotms, etc.). These are to ensure that the tables you access to make plots are closed properly before they are needed by some following task (otherwise, you may experience the dreaded "table lock" errors, that may cause problems with your script, or in some cases even your CASA session.)

Note: the intention is to extract CASA scripts for testing; commands which are to be run on the command line outside of CASA, or within other software packages, will not be extracted.


How to Get the Script Extractor

Download the script extraction code.

# in bash
ftp ftp.cv.nrao.edu
# log in anonymously with e-mail as password
cd NRAO-staff/jgallimo
get extractCASAscript.py

Wget may be even simpler if you have it installed.

# in bash
wget ftp://ftp.cv.nrao.edu:/NRAO-staff/jgallimo/extractCASAscript.py

How to Use the Script Extractor

Make your newly acquired python script executable.

# in bash
chmod u+x extractCASAscript.py

To run it, issue the python script name and give the URL as the argument. For example:

# in bash
./extractCASAscript.py http://casaguides.nrao.edu/index.php?title=Calibrating_a_VLA_5_GHz_continuum_survey

In csh, you need quotes around the URL:

# in csh
./extractCASAscript.py 'http://casaguides.nrao.edu/index.php?title=Calibrating_a_VLA_5_GHz_continuum_survey'


This command will automatically generate a script called "CalibratingaVLA5GHzcontinuumsurvey.py"

Version Notes

  • 30 Oct 2009: Script created -- jfg.
  • 17 Dec 2009: Fixed a bug that caused the script to drop brackets [] & {} incorrectly. Added script pauses for interactive commands viewer, plotms, plotxy, and plotcal. -- jfg
  • 25 Feb 2010: Some minor bug fixes. -- jfg
  • 19 April 2010: Better handling of interactive commands; allows for multi-line interactive commands.
  • 21 May 2010: On-going improvements, mostly handling conversion of html math symbols into usable characters.

--Jack Gallimore 21:13, 3 November 2009 (UTC)