DS9 Users Manual
Table of Contents

Analysis

Each file type known to DS9 can have user-defined analysis commands associated with it. These analysis commands are defined at start-up time , or loaded by the user, by means of an ASCII analysis description file. The analysis commands are available for execution, either via the Analysis Menu or the XPA point Analysis. In addition, commands may be bound to events, such as keystrokes or mouse clicks. This type of command is called a bind command.

At startup, DS9 first searches for the analysis file, named .ds9.ans,in the local directory, then in the users home directory. A second analysis file to load at startup may be specified in the preferences (Preferences : Analysis : Analysis File). The user may also load or clear current analysis commands via command line options or the Analysis menu.

When activated, either from the menu, xpa, or bound event, an analysis command first is macro-expanded to fill in user-defined arguments and then is executed externally. Results may be displayed in a separate text window, plot window, or in a image frame.

The analysis file that defines the known analysis commands consists of one or more file descriptors, each of which has the following format:

Menu label to be used
A space-separated list of file templates
Command type [menu | bind <event>]
The command line for the analysis program
Example:
My Analysis Task
*.fits
menu
$data | doit | $text
Note that blank lines separate the file descriptions and should not be used as part of a description. Also, the '#' character is a comment character. A separtator can be inserted in the menu by specifying the following sequence '---'.

Example:

# this will insert a menu separator
---

Command Type

The third line indicates the type of command. A menu command creates an menu option under the Analysis menuoption, and can be invoked by the user via the GUI or XPA.

A bind command is a command that is bound to an event. When the event occurs, the command is executed. Types of events available include all TK events, including all keystrokes and mouse clicks. If a command is bound to an event other that a keystroke, care must be taken to not to interfer with other interal DS9 events.

To bind to a key stroke, use the following command type:

bind <keystroke>
examples:

bind t
bind G

Macros

The following macros are macro-expanded to fill in user-defined arguments before the command is executed.

$data

Data from the current frame becomes the input data to the command string. This macro can only used at the begining of the command string.
Syntax:
    $data
Example:
    $data | dosomething | $text

$filename

Substitute the filename of the data file in the command line.
Syntax:
    $filename
Example:
    dosomething $filename | $text

$regions

Substitute region definition in specified coordinate system and format. The default coordsystem is physical, and default format degrees.
Syntax:
    $regions
    $regions(,,)
    $regions(<property>,<coordinate system>,<format>)
where:
    propery = [include|exclude|source|background]
    coordinate system = [image|physical|detector|amplifier]
                      = [fk4|fk5|icrs|galactic|ecliptic]
    format = [hms|sexagesimal|degrees]

also, the old saotng formats are also supported:

    $regions_pixels
    $regions_degrees
    $regions_hms
    $include_regions
    $include_regions_pixels
    $include_regions_degrees
    $include_regions_hms
    $exclude_regions
    $exclude_regions_pixels
    $exclude_regions_degrees
    $exclude_regions_hms

Example:
    dosomething $regions(source,fk5,sexagesimal) | $text

$x | $y

Substitute coordinates of an bind event. When a bind event is triggered, the x,y coordinates of the mouse of the particular data file are returned. The default coordinate system is physical. This macro is only available for bind commands.
Syntax:
    $x
    $x(<coordinate system>,<format>)
    $y
    $y(<coordinate system>,<format>)
where:
    coordinate system = [image|physical|detector|amplifier]
                      = [fk4|fk5|icrs|galactic|ecliptic]
    format = [hms|sexagesimal|degrees]

Example:
    echo $x(fk5,sexagesimal) $y(fk5,sexagesimal) | $text

$message

Display a message dialog box, with option buttons.  After displaying the message, the macro is removed from the command line before execution. If cancel or no is selected, the command line is not executed.
Syntax
    $message(<message>)
    $message([ok|okcancel|yesno],<message>)

Example:
    $message(okcancel,This is a Message)| doit | $text

$text

Display text in a text dialog window. This macro should be the last macro of a command line. The text is read via stdin. No parameters are required. The macro is removed from the command line before execution.
Syntax
    $text
Example:
    doit | $text

$plot

Diplay data in plot window. This macro should be the last macro of a command line.The data is read via stdin and consist of a pair of coordinates, with option error value. Default dimension is 2. The macro is removed from the command line before execution.
Syntax
    $plot
    $plot(,,,)
    $plot(<title>,<x axis label>,<y axis label>,[2|3])
Example:
    doit | $plot(This is aTitle,X Axis,Y Axis)

$image

The resulting image data is display in a DS9 frame. This macro should be the last macro of a command line. Optional parameter indicates if a new frame is created for the new data. The macro is removed from the command line before execution.
Syntax
    $image
    $image([new|current])
Example:
    doit | $image(new)

Parameters

The user may define his own macros or parameters to be evaluated before the command line is executed. To do this, the user defines a param segment that is referenced in the command line. The param definition has the follow format:

param <name>
<variable> <entry | checkbox | menu> <title> <default> <{comment}>
...
end

or

param <name>
@<iraf param filename>
end

The definiton either consisted of a number of variables, one per row, or the name of a IRAF style parameter file. DS9 will look for the IRAF parameter file in:

./<filename>
$UPARM/<filename>
$HOME/iraf/<filename>


Example:

param foobar
var1 entry {Variable 1} default {this is a entry}
var2 checkbox {Variable 2} 1 {this is a checkbox}
var3 menu {Variable 3} AAA|BBB|CCC {this is a menu}
end
To use parameters, specify the param name at the begining of your command line:
Parameter Test
*
menu
$param(foobar); echo "$var1 $var2 $var3" | $text
When the menu item is selected, the user will be presented with a dialog box that contains entry, checkbox, or menu choices for each variable specified. If the user clicks ok, the values are substituted in the command line before execution.

Sample

#
# Analysis command descriptions:
#    menu label
#    file templates
#    command type [menu | bind <event>]
#    analysis command line

param foo
var1 entry {File Name} foobar.fits {Enter a filename}
var2 checkbox Verbose 1 {Verbose Output}
var3 menu {Mode} Fast|Better|Cheaper {Select Mode}
end

param bar
@tvdisply.par
end

Doit
*
menu
$param(foo); echo "$var1 $var2 $var3" | $text

TV Display
*
menu
$param(bar); echo "$var1 $var2 $var3" | $text

Counts
*.fits
menu
funcnts -r $filename $regions(source,,) $regions(background,,) | $text

Radial Profile
*.fits
menu
$message(okcancel,This routine requires an annulus) | funcnts -r $filename $regions(source,,) $regions(background,,) | sed "1,/---- .*/d; /^$/,$d" | awk "{print ($10-$9)/2.+$9, $7, $8}" | $plot(Radial Profile,Physical Coordinates,Counts/Pixel,3)

Spectrum
*.fits
menu
funhist "$filename[$regions]" pi | sed "1,/---- .*/d" | awk "{print $3,$2}" | $plot(Spectrum,Bin,Counts,2)

Light Curve
*.fits
menu
funhist "$filename[$regions]" time ":1024" | sed "1,/---- .*/d" | awk "{print $3,$2}" | $plot(Light Curve,Time,Counts,2)

Copy Image
*.fits
menu
$data | $image(new)

Interactive
*.fits
bind t
echo "$x $y" | $text

Interactive 2
*.fits
bind y
echo "$x(fk5,hms) $y(fk5,hms)" | $text