Analysis Commands

Do you find yourself doing the same sequence of commands repeatedly in ds9 ?

You can script your interactions with ds9 and invoke them using the Analysis menu.


This demo uses data for SDSSJ1030+0524, combined from multiple observations

find_chandra_obsid SDSSJ1030+0524 download=all
reproject_obs "*/primary/*evt2.fits.gz" outroot=SDSSJ1030+0524
In [1]:
cd Analysis

ds9 SDSSJ1030+0524_merged_evt.fits -scale log -bin factor 2 &
[1] 22726
In [2]:
import -window "SAOImage ds9" ds9_11_analysis_01.png 
display < ds9_11_analysis_01.png

Analysis Commands

The Reference Manual contains a chapter on the Analysis command. Below is a very simple example:

In [3]:
cat kjg.ans
# Custom Commands
Maximize Image
bind m

Each command is a block of 4 lines in the analysis command file. The hash lines are comments.

  1. The Maximize Image is the name of the command I created.

  2. The * is a filter for which file-types, in this case all file types.

  3. bind m says that this command will be executed whenever I press the lowercase m key.

  4. The last line says run the executable script.

Now what does look like?

In [4]:
/bin/ls -l | sed -e s,$USER,user, -e s,$GROUP,group,
-rwxrwxr-x 1 user group 170 Jan  2 08:08
In [5]:

xpaset -p ds9 view colorbar no
xpaset -p ds9 view info no
xpaset -p ds9 view panner no
xpaset -p ds9 view magnifier no
xpaset -p ds9 view buttons no
exit 0

So we see that the script has execute permissions. It is a bash shell script, that simply run a set of xpa commands to hide various parts of the UI: colorbar, info, panner, magnifier, and buttons.

In [6]:
xpaset -p ds9 analysis load kjg.ans
In [7]:
# Press 'm'
sleep 5

import -window "SAOImage ds9" ds9_11_analysis_02.png 
display < ds9_11_analysis_02.png

In [8]:
xpaset -p ds9 quit
[1]+  Done                    ds9 SDSSJ1030+0524_merged_evt.fits -scale log -bin factor 2
In [ ]: