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.
Syntax
Command Type
Macros
Help
Parameters
Hierarchical Menus
SampleSyntax
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 usedExample:
A space separated list of file templates
Command type [menu | bind <event>]
The command line for the analysis program# this is a commentTask names may contain space characters. All lines may be indented. Also, the '#' character is a comment character. A separator can be inserted in the menu by specifying the following sequence '---'.
My Analysis Task # this is a comment
*.fits
menu
$data | doit | $text
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 menu option, 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 interfere with other internal DS9 events.
To bind to a key stroke, use the following command type:
bind <keystroke>
examples:bind t
bind GMacros
The following macros are macro-expanded to fill in user-defined arguments before the command is executed. Strings that contain $<macroname> that user does not want to be expanded may be escaped by using $$<macroname>. All strings that contain $<string> that are not a macro name will not be affected. For example:
echo "$$data $foo" | $textwill display a text dialog that contains "$data $foo"
$data
Data from the current frame becomes the input data to the command string. This data is in the form of a FITS image. This macro can only used at the beginning of the command string.
Syntax:
$data
Example:
$data | dosomething | $text$filename
Substitute the filename of the data file in the command line. $filename(root) will return only the root filename.
Syntax:
$filename
$filename(root)
Example:
dosomething $filename | $text
dosomething $filename(root) | $text$xdim
Substitute the width, height, or bitpix of the data file in the command line.
$ydim
$bitpix
Syntax:
$xdim
$ydim
$bitpix
Example:
echo "$xdim $ydim $bitpix" | $text$regions
Substitute region definition in specified region format, coordinate system, and coordinate format. The default coord system is physical, default coordinate format degrees, and default region format DS9. Arguments may appear in any order, as long as they are separated by ',' and no spaces. If one or more properties are specified, only regions with all of the specified properties will be substituted.Syntax:
$regions
$regions(<options>)where options are one of the following:
regions format = [ds9|ciao|saotng|saoimage|pros|xy]
property = [include|exclude|source|background]
coordinate system = [image|physical|detector|amplifier|wcs]
sky frame = [fk4|fk5|icrs|galactic|ecliptic]
sky format = [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_hmsExample:
dosomething $regions | $text
dosomething $regions(pros) | $text
dosomething $regions(source,wcs,fk5) | $text
dosomething $regions(saotng,background,exclude,ecliptic,sexagesimal) | $text$filename[$regions]
Combination of $filename and $regions macros. Generates a series of filenames, each with a region.
Syntax:
$filename[$regions]
$filename[$regions(<options>)]
Example:
dosomething $filename[$regions] | $text$x
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.
$y
Syntax:
$x
$x(<coordinate system>,<format>)
$y
$y(<coordinate system>,<format>)
where:
coordinate system = [image|physical|detector|amplifier|wcs]
sky frame = [fk4|fk5|icrs|galactic|ecliptic]
sky 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$entry
Display an entry modal dialog. The returned string is substituted. If cancel is selected, the command line is not executed.
Syntax
$entry(<message>)Example:
echo "$entry(Enter something here)" | $text$null
Expect no output or results from analysis task. Note: no error message will be returned if the analysis task fails to execute correctly.
Syntax
$nullExample:
echo "Hello, world" > foo | $null$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
Display 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 values. (xy, xye, xyee) Default dimension is xy. The macro is removed from the command line before execution.For $plot(stdin) only:
The title, x axis label, and y axis label are assumed to be on the first line of input, delimited with a new-line. However, if the data starts with $BEGINTEXT, all text between $BEGINTEXT and $ENDTEXT will be removed from the data and displayed in a separate text dialog window, with the remaining data, including the title, x axis label, and y axis label, will be displayed in a plot window. Furthermore, if the data contains the string $ERROR, an error is assumed to have occured and a text dialog window is displayed only.Syntax
$plot
$plot(,,,)
$plot(<title>,<x axis label>,<y axis label>,[xy|xye|xyee])
$plot(stdin)
Example:
doit | $plot(This is aTitle,X Axis,Y Axis)
doit | $plot(stdin)$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)$url
URLs are processed and stored in a temporary file. Only HTTP and anonymous FTP are supported.
Syntax:
$url(http://<hostname>:<port>/<query>)
$url(ftp://<hostname>/<filename>)
Example:
$url(http://legacy.gsfc.nasa.gov/rosat/data/p000s26b.img.Z) | uncompress | $image
$url(ftp://legacy.gsfc.nasa.gov/rosat/data/hri/images/rh100193_img.fits) | $image$geturl
This macro differs from all other macros, including $url, in that no subprocess pipe is created. Only HTTP is supported. The contents of the url are retrieved and sent to $text, $plot, or $image. No other processing is allowed. The primary purpose of this macro is to support external analysis for the Windows platform, which has no subprocess support.
Syntax:
$geturl(http://<hostname>:<port>/<query>)
Example:
$geturl(http://foo.bar.edu/foo.html) | $text$xpa
Returns the xpa access point name.
Syntax:
$xpa
Example:
echo '$xpa' | $text$xpamethod
Returns the xpa method.
Syntax:
$xpamethod
Example:
echo '$xpamethod' | $textHelp
The user may define his own HELP message. This message will be available to the user as a menu item. An optional label maybe specified. The default label is Help. When invoked, an text dialog window will appear, containing the message. Multiple HELP items maybe defined within a menu or across hierarchical menus.
Example:help Main Help
A help message may contain
multiple lines of description of the tasks
in the menu or menus
endhelpParameters
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}>
...
endparamor
param <name>
@<iraf param filename>
endThe definition 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>Example:
$UPARM/<filename>
$HOME/iraf/<filename>param foobarTo use parameters, specify the param name at the beginning of your command line:
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}
endparamParameter TestWhen 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.
*
menu
$param(foobar); echo "$var1 $var2 $var3" | $textHierarchical Menus
The user may define hierarchical menus. Use this to organized crowded menus. To do this, frame menu entries with hmenu <label> and endhmenu. Hierarchical menu labels may contain spaces. Multiple levels maybe implimented.
Example:hmenu StuffWill create an hierarchical menu with two members, hello and world.
hello
*
menu
echo "Hello" | $textworld
*
menu
echo "World" | $texthmenu More Stuff
hello world
*
menu
echo "Hello World" | $text
endhmenu
endhmenuSample
#
# Analysis command descriptions:
# menu label
# file templates
# command type [menu | bind <event>]
# analysis command lineparam foo
var1 entry {File Name} foobar.fits {Enter a filename}
var2 checkbox Verbose 1 {Verbose Output}
var3 menu {Mode} Fast|Better|Cheaper {Select Mode}
endparam bar
@tvdisply.par
endDoit
*
menu
$param(foo); echo "$var1 $var2 $var3" | $textTV Display
*
menu
$param(bar); echo "$var1 $var2 $var3" | $textCounts
*.fits
menu
funcnts -r $filename $regions(source,,) $regions(background,,) | $textRadial 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,xye)Spectrum
*.fits
menu
funhist "$filename[$regions]" pi | sed "1,/---- .*/d" | awk "{print $3,$2}" | $plot(Spectrum,Bin,Counts,xy)Light Curve
*.fits
menu
funhist "$filename[$regions]" time ":1024" | sed "1,/---- .*/d" | awk "{print $3,$2}" | $plot(Light Curve,Time,Counts,xy)Copy Image
*.fits
menu
$data | $image(new)Interactive
*.fits
bind t
echo "$x $y" | $textInteractive 2
*.fits
bind y
echo "$x(fk5,hms) $y(fk5,hms)" | $text