Space Telescope Science Institute
DrizzlePac 2012 Handbook
help@stsci.edu
Table of Contents Previous Next Index Print


The DrizzlePac Handbook > Chapter 5: Introduction to the drizzlepac Interface > 5.4 Using the PyRAF/Python Command-line

5.4
Some users prefer command-line interaction with software, rather than a GUI interface. This can be done from the PyRAF or Python environment using Python commands. For the convenience of users who are familiar with IRAF, a few IRAF commands have been implemented such that the “IRAF” command is translated to Python syntax. The equivalent Python syntax can be viewed in Table 5.2.
epar: launches the TEAL GUI
unlearn: resets all the parameters in a task to their default values
help: shows the help files for a task
When drizzlepac is imported, it displays these messages on the screen:
DrizzlePac tasks are executed using Python syntax. This syntax is analogous to running a command in a Unix shell in that a “path” needs to be provided to the task. Options for the task are entered as “keyword-value pairs,” all wrapped in a parenthesis. The first parameter in that parenthesis is always the files to be operated on, followed by the rest of the keyword-value pairs which may be optional. A typical command has the following syntax:
package.module.task(files,keyword1=value1, keyword2=value2.....)
For example, here is tweakreg as a Python command:
Table 5.1 lists the full Python command syntax for each of the tasks available in drizzlepac.
Table 5.1: Python Syntax for DrizzlePac Tasks
See the help file for each task to see the full list of options available.
There is no need to import an entire module if only one task will be used.  The individual task can be imported in the following manner:
From that point forward, the package name does not have to be specified whenever that task is run during the Python session. A slightly shorter version of the command can be used:
Commands for running drizzlepac from a Python command line are identical to the PyRAF commands, with the exception of the “IRAF-like” commands mentioned earlier and summarized in Table 5.2. Those “IRAF-like” commands require the TEAL module from the stsci package to mimic IRAF functionality. To import the TEAL package:
Table 5.2: “IRAF-like” Commands that Call Python Syntax to Execute a Task
IRAF Command
These commands are only available in PyRAF.
As previously mentioned, Python commands can be executed with optional keyword parameters. These are passed to the task as keyword-value pairs (i.e., searchrad=2.0). The keywords specified in Python are the same as those seen in the TEAL GUI.
As shown in Figure 5.1, the TEAL GUI has several types of keyword value types: string; float; integer; boolean “Yes” or “No” buttons; pull-down menus. Each of these requires a different format when they’re entered in the Python command-line.
The following command illustrates how these value types are specified; here, the back-slash simply continues the command on the next line. The input “flc.fits” files specification is not a typo–this is a new CTE-corrected calibrated ACS data product from the pipeline that can be used instead of flt.fits files.
In this command, the first parameter value is for the input files, written as a string wrapped in quotes: flc.fits’. Next, the updatewcs parameter value is a boolean set to True–note that it does not require quotes and that it is case-sensitive. (In the TEAL GUI, updatewcs has a yes/no button). The third parameter, minobj, requires an integer value. Whenever a float or integer value is needed, simply enter the number without quotes. Finally, in this command, is the searchunits parameter that has a choice of values which are documented in the help files. One of them, used in this example, is ‘pixels’–a quote is required but it is not case sensitive. (In the TEAL GUI, this parameter has a pull-down menu that allows the user to select a value from several settings.)
Table 5.3: Summary of Python Syntax Requirements for Types of Parameter Values
Parameter Value Type
Quotes Needed?
The real power of having drizzlepac written in Python is that it can be called and used from within a Python script. For instance, if a user wishes to run updatenpol and tweakreg on ACS/WFC images in a directory, a Python script can be written to run it as follows:
Not only does this script keep a record of how images were processed, changes can be easily implemented by editing the script and re-running the commands.

Table of Contents Previous Next Index Print