Extracting scripts from these tutorials: Difference between revisions

From CASA Guides
Jump to navigationJump to search
(Created page with 'Hopefully the scripts contained in this cookbook are (a) useful and (b) work. They were however developed with CASA still a work in progress, and so scripts may break as commands…')
 
 
(78 intermediate revisions by 15 users not shown)
Line 1: Line 1:
Hopefully the scripts contained in this cookbook 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.  
The series of commands shown in each tutorial can be written to a single casapy script using the CASA Guides script extractor. The script extractor is described here.


The code linked below is a rudimentary python script to extract CASA code from a given cookbook page and save it as a script. To run it, download to "extractCASAscript.py," and make sure it is executable.
__TOC__
 
== Introduction ==
 
The script extractor will produce a Python script that can be invoked inside casapy.  The extractor ignores all CASA Guide source code that is not Python.  Special UNIX commands (such as 'ls' and 'less') supported by CASA but not by Python are commented out, and interactive pauses are inserted when GUIs are invoked. (The interactive pause is necessary to avoid table lock errors that are produced when multiple tasks are run simultaneously.)
 
If you are using OSX, you must have Python 2.7.13 or greater. Due to OSX security updates, the script extractor will not work with earlier versions of Python.
 
== How to Get the Script Extractor ==
 
<!--
[https://github.com/jaredcrossley/CASA-Guides-Script-Extractor/blob/master/extractCASAscript.py script extractor]
-->
 
For most uses, the single python script [https://github.com/CasaGuides/CASA-Guides-Script-Extractor/blob/master/extractCASAscript.py script extractor] is all you will need.  This Python module is maintained in a github repository as part of a simple, automated benchmark testing system.  If you like, you can browse the [https://github.com/CasaGuides/CASA-Guides-Script-Extractor whole repository] also.
 
== How to Use the Script Extractor ==
 
Make your newly acquired Python script executable.


<source lang="bash">
<source lang="bash">
Line 8: Line 26:
</source>
</source>


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


<source lang="bash">
<source lang="bash">
# in bash
# in bash or csh
extractCASAscript.py http://casapedia.wikia.com/wiki/Example:_Calibrating_a_VLA_continuum_survey
./extractCASAscript.py 'http://casaguides.nrao.edu/index.php?title=Calibrating_a_VLA_5_GHz_continuum_survey'
</source>
</source>


This command will automatically generate a script called <tt>CalibratingaVLA5GHzcontinuumsurvey.py</tt>.  This script can be run in CASA:


This command will automatically generate a script called "Calibrating_a_VLA_Continuum_Survey.py."
<source lang="python">
# in CASA
execfile('CalibratingaVLA5GHzcontinuumsurvey.py')
</source>


Download the script extraction code.
== Support ==


<source lang="bash">
Questions and bug reports should be submitted to either the [https://help.nrao.edu/ NRAO] or [https://help.almascience.org/ ALMA] helpdesks.
# in bash
ftp ftp.eg.bucknell.edu
# log in anonymously with e-mail as password
cd pub/jgallimo
get extractCASAscript.py
</source>

Latest revision as of 17:17, 3 January 2024

The series of commands shown in each tutorial can be written to a single casapy script using the CASA Guides script extractor. The script extractor is described here.

Introduction

The script extractor will produce a Python script that can be invoked inside casapy. The extractor ignores all CASA Guide source code that is not Python. Special UNIX commands (such as 'ls' and 'less') supported by CASA but not by Python are commented out, and interactive pauses are inserted when GUIs are invoked. (The interactive pause is necessary to avoid table lock errors that are produced when multiple tasks are run simultaneously.)

If you are using OSX, you must have Python 2.7.13 or greater. Due to OSX security updates, the script extractor will not work with earlier versions of Python.

How to Get the Script Extractor

For most uses, the single python script script extractor is all you will need. This Python module is maintained in a github repository as part of a simple, automated benchmark testing system. If you like, you can browse the whole repository also.

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 or 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. This script can be run in CASA:

# in CASA
execfile('CalibratingaVLA5GHzcontinuumsurvey.py')

Support

Questions and bug reports should be submitted to either the NRAO or ALMA helpdesks.