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.
DS9 searches for an analysis file named ds9.ans or ds9.analysis in the current directory and $HOME to be loaded at startup. In addition, DS9 will search the following directories for any analysis files to be loaded at startup in the form of *.ds9: the current directory, $HOME/bin, /usr/local/bin, /opt/local/bin, and /soft/saord/bin. Finally, the user may specify analysis files to be loaded at startup in the preferences analysis panel. 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
Sample 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 programTask 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 '---'.
Example:# this will insert a menu separator
---The third line indicates the type of command.
menu
A menu command creates an menu option under the Analysis menu option, and can be invoked by the user via the GUI or XPA.
Example:# Menu command example
My Analysis Task
*.fits
menu
$data | doit | $textbind
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>Example:# Bind command example
Print coordinates
*.fits
bind x
echo "$x $y" | $textweb
A web command allows the user to invoke the internal web browser from the analysis menu.
Example:# web command example
HTTP based
*
web
http://hea-www.harvard.edu/RD/ds9/ref/index.html
File based
*
web
file:/home/joye/index.htmlThe 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"
$width
$height
$depthSubstitute the width, height, or depth of the data file in the command line.
Syntax:
$width
$height
Example:
echo "$width $height $depth" | $text
$bitpix
Substitute the bitpix of the data file in the command line.
Syntax:
$bitpix
Example:
echo "$bitpix" | $text$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$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$env
Substitute the value of a shell environment variable.
Syntax:
$env(<shell variable>)
Example:
echo "$env(PATH)" | $text$filedialog
Display the standard file dialog. Substitutes the returned pathname. Argument specifies if an open file or save file dialog is invoked.
Syntax:
$filedialog([open|save])
Example:
echo "$filedialog(open)" | $text
$filename
Substitute the filename of the data file in the command line. A full filename includes any absolute or relative path. A root filename contains no path. A (2D) subsection defines a subimage from xmin,ymin to xmax,ymax. For Frame3D, a 2D subsection will also include the current slice (PLANE=) parameter if not 1. A 3D subsection defines a subimage from xmin,ymin,zmin to xmax,ymax,zmax and no PLANE parameter.
Syntax:
$filename # filename with extname, (2d) subsections, filters
$filename(root|root,base) # root filename with with extname, no subsections, no filters)
$filename(full|full,base) # full filename with extname, no subsections, no filters)
Example:
dosomething $filename | $text
dosomething $filename(root) | $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$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
$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 and what type of frame is created for the new data. The macro is removed from the command line before execution.
Syntax:
$image
$image([new|rgb|3d|current])
Example:
doit | $image(new)$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$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:
$null
Example:
echo "Hello, world" > foo | $null$pan
Substitute current pan location of the particular data file are returned. The default coordinate system is physical.
Syntax:
$pan
$pan(<coordinate system>,<format>)
where:
coordinate system = [image|physical|detector|amplifier|wcs|wcsa...wcsz]
sky frame = [fk4|fk5|icrs|galactic|ecliptic]
sky format = [hms|sexagesimal|degrees]
Example:
echo $pan(fk5,sexagesimal) | $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, xyex, xyey, xyexey) 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 occurred and a text dialog window is displayed only.
Syntax:
$plot
$plot(,,,)
$plot(<title>,<x axis label>,<y axis label>,[xy|xyex|xyey|xyexey])
$plot(stdin)
Example:
doit | $plot(This is aTitle,X Axis,Y Axis)
doit | $plot(stdin)$regions
Substitute region definition in specified region format, coordinate system, and coordinate format. The default coordinate 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_hms
Example:
dosomething $regions | $text
dosomething $regions(pros) | $text
dosomething $regions(source,wcs,fk5) | $text
dosomething $regions(saotng,background,exclude,ecliptic,sexagesimal) | $text$text
Display text in a text dialog window. This macro should be the last macro of a command line. To display text from only STDOUT use '|' as the pipe command. To display text from both STDOUT and STDERR, use '|&' as the pipe command. No parameters are required. The macro is removed from the command line before execution.
Syntax:
$text
Example:
doit | $text # stdout
doit |& $text # stdout and stderr
$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
$vo_method
Returns the vo method.
Syntax:
$vo_method
Example:
echo '$vo_method' | $text
$value
Substitute the value at the location of the cursor of an bind event.
Syntax:
$value
Example:
echo "$value" | $text
$x
$y
$zSubstitute 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. For datacubes, the z coordinate is returned based on the current slice selected.
Syntax:
$x
$x(<coordinate system>,<format>)
$y
$y(<coordinate system>,<format>)
$z
$z(<coordinate system>)
where:
coordinate system = [image|physical|detector|amplifier|wcs|wcsa...wcsz]
sky frame = [fk4|fk5|icrs|galactic|ecliptic]
sky format = [hms|sexagesimal|degrees]
Example:
echo "$x $y" | $text
echo "$x $y $z" | $text
echo "$x(fk5,sexagesimal) $y(fk5,sexagesimal)" | $text
echo "$x(wcs) $y(wcs) $z(wcs)" | $text
$xpa
Returns the xpa access point name.
Syntax:
$xpa
Example:
echo '$xpa' | $text$xpa_method
Returns the xpa method.
Syntax:
$xpa_method
Example:
echo '$xpa_method' | $textThe 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
endhelpThe 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 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}
endparamTo use parameters, specify the param name at the beginning of your command line:
Parameter Test
*
menu
$param(foobar); echo "$var1 $var2 $var3" | $textWhen 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.
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 implemented.
Example:
hmenu Stuff
hello
*
menu
echo "Hello" | $textworld
*
menu
echo "World" | $texthmenu More Stuff
hello world
*
menu
echo "Hello World" | $text
endhmenu
endhmenuWill create an hierarchical menu with two members, hello and world.
#
# Analysis command descriptions:
# menu label
# file templates
# menu/bind
# analysis command line
param foo
var1 entry entry 40 {this is a entry}
var2 checkbox checkbox 1 {this is a checkbox}
var3 menu menu AAA|BBB|CCC {this is a menu}
endparam
param bar
@analysis.par
endparam
param foobar
@tvdisply.par
endparam
param ltc
bins entry "Enter number of [t1:t2:]bins" 0 "('0' for default number of bins)"
endparam
# Help Main Help
help Main Help
These menus contain a test for each possible feature
supported by the ds9 (blank line above)
endhelp
---
hmenu Test Web
help Web Help
Help for web features
endhelp
Web Test url
*
web
http://hea-www.harvard.edu/RD/ds9/
Web Test file
*
web
file:/home/joye/saods9/ds9/tests/hv.html
endhmenu
hmenu Test Basics
help Basic Help
Help for basic features
endhelp
---
Test escape char # this is a comment
*
menu
echo "this is not a macro $$xpa" | $text
Test pass thru # this is a comment
*
menu
echo "this is not a macro $foo" | $text
Test $xpa # this is a comment
*
menu
echo $xpa | $text
Test $xpa_method
*
menu
echo $xpa_method | $text
Test $vo_method
*
menu
echo $vo_method | $text
Test $filename
*.fits
menu
echo $filename | $text
Test $filename(root)
*.fits
menu
echo $filename(root) | $text
Test $xdim $ydim $bitpix
*.fits
menu
echo "$xdim $ydim $bitpix" | $text
Test $xcen $ycen
*.fits
menu
echo "$xcen $ycen" | $text
Test $env
*
menu
echo $env(PATH) | $text
endhmenu
hmenu Test Regions
help Regions Help
Help for regions features
endhelp
---
Test $regions
*.fits
menu
echo "$regions ds9_s:$regions(ds9,source,image) ciao_b:$regions(ciao,background) saotng_i:$regions(saotng,include,wcs,fk5) pros_e:$regions(pros,exclude,wcs,fk5,sexagesimal) xy_be:$regions(xy,background,exclude,wcs,fk4,hms)" | $text
Test $regions wcs
*.fits
menu
echo "$regions(ds9,wcs) $regions(ds9,wcs,fk5,sexagesimal) $regions(ds9,wcsa) " | $text
Test $include_regions_pixels
*.fits
menu
echo "ds9_s: $source_regions ds9_b: $background_regions_pixels ds9_i: $include_regions_degrees ds9_e: $exclude_regions_hms" | $text
Test $filename $regions
*.fits
menu
echo "$filename[$regions]" | $text
Test $filename $regions()
*.fits
menu
echo "$filename[$regions()]" | $text
endhmenu
hmenu Test Output
help Output Help
Help for output features
endhelp
---
Test $null
*
menu
echo "This is Text" > /dev/null | $null
Test $text
*
menu
echo "This is Text" | $text
Test $text stderr
*
menu
ls foofoofoo | $text
Test $plot
*
menu
cat xy.dat | $plot
Test $plot(title,x,y,xyey)
*
menu
cat xye.dat | $plot(Title,X Axis,Y Axis,xyey)
Test $plot(title,x,y,xyexey)
*
menu
cat xyee.dat | $plot(Title,X Axis,Y Axis,xyexey)
Test $plot(title,x,y,4)
*
menu
cat xyey.dat | $plot(Title,X Axis,Y Axis,4)
Test $plot(title,x,y,5)
*
menu
cat xyeye.dat | $plot(Title,X Axis,Y Axis,5)
Test $plot(stdin)
*
menu
cat xye.stdin.dat | $plot(stdin)
Test $plot(stdin) text
*
menu
cat xye.stdin.text.dat | $plot(stdin)
Test $plot(stdin) error
*
menu
cat xy.stdin.error.dat | $plot(stdin)
Test $data
*.fits
menu
$data | $image(new)
Test $image
*
menu
cat img16.fits | $image
endhmenu
hmenu Test Dialogs
help Dialogs Help
Help for dialog features
endhelp
---
Test $message(message)
*
menu
$message(ok,This is a Message) | echo "hello" | $text
Test $message(ok,message)
*
menu
$message(ok,This is a Message) | echo "World" | $text
Test $entry(message)
*
menu
echo "$entry(Enter Something)" | $text
endhmenu
hmenu Test Params
help Param Help
Help for param features
endhelp
---
Test $param
*
menu
$param(foo); echo "$var1 $var2 $var3" | $text
Test $param @file
*
menu
$param(bar); echo "$var1 $var2 $var3" | $text
endhmenu
hmenu Test Network
help Network Help
Help for network features
endhelp
---
Test $url(http://)
*
menu
$url(http://legacy.gsfc.nasa.gov/FTP/rosat/data/cdrom/vol1/IMAGES/00h/p000s26b.img.Z) | gunzip | $image
Test $url(ftp://)
*
menu
$url(ftp://legacy.gsfc.nasa.gov/rosat/data/hri/images/fits/rh100193_img.fits) | $image
Test $geturl $text
*
menu
$geturl(http://hea-www.harvard.edu/RD/saord-cgi/funtools?funcnts+$filename+$regions(source,,)+$regions(background,,))|$text
Test $geturl $plotstd
*
menu
$param(ltc); $geturl(http://hea-www.harvard.edu/RD/saord-cgi/funtools?funhist_plot+$filename[$regions]+time+$bins)|$plot(stdin)
endhmenu
hmenu Test Other
help Other Help
Help for other features
endhelp
---
Test $param @tvdisply
*
menu
$param(foobar); echo "$frame $erase" | $text
hmenu Test MultiLevel
test
*
menu
echo "Hello World" | $text
endhmenu
endhmenu
$x $y
*.fits
bind x
echo "$x $y" | $text
$x(fk5,hms) $y(fk5,hms)
*.fits
bind y
echo "$x(fk5,hms) $y(fk5,hms)" | $text
$x(wcs,fk5,hms) $y(wcs,fk5,hms)
*.fits
bind z
echo "$x(wcs,fk5,hms) $y(wcs,fk5,hms)" | $text