About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: 1 Dec 2006
Hardcopy (PDF): A4 | Letter

Introduction to Plotting Using ChIPS

[CIAO 3.4 Science Threads]



Overview

Last Update: 1 Dec 2006 - updated for CIAO 3.4: ChIPS version

Synopsis:

The Chandra Imaging and Plotting System (ChIPS) is the visualization interface which can receive commands from any application within CIAO. ChIPS is designed so that plots can be built up interactively in small steps and can easily be refined, saved, printed, and restored. It is particularly flexible at creating plots from tables, but also allows users to generate plots of selected columns from an image or event file.

Related Links:

Proceed to the HTML or hardcopy (PDF: A4 | letter) version of the thread.




Contents



Getting Started

If you haven't obtained it yet, the data used in this thread is available as chips.tar.gz (SHIFT-click to download the file). Use the tar xvf chips.tar command to unpack the unzipped file.

Move to that directory and start a ChIPS session:

unix% chips

Welcome to ChIPS, version CIAO 3.4
Copyright (C) 1999-2003, Smithsonian Astrophysical Observatory

chips> ls
data1.pha       data2b.dat      data4.tab       plot.chp
data2a.dat      data3.tab       data5.dat       

Within ChIPS, Unix commands must be preceded by a dollar sign ($), except for cd, pwd, and ls. For example, to view the contents of the ASCII data data2a.dat:

chips> $more data2a.dat
40535    31.24   0.69  
40872    29.67   0.36  
41006    30.18   1.33  
41285    30.5   0.3    
41713    29.5   0.4    
43556    26.2   0.1    
.
. (etc.)
.

Also, ChIPS commands are case insensitive; they may be used in either upper or lower case.



Creating Simple Plots

To begin, we create a plot from the file data1.pha:

chips> plot data1.pha
The inferred file type is PHA type I.

As seen in Figure 1 [Link to Image 1: Plotting the first 2 columns of a PHA file], x is plotted from the first column of the file, y from the second.

This can also be specified explicitly, e.g. for an ASCII file:

chips> clear
chips> plot data2a.dat x 1 y 2

This selects column 1 as x and column 2 as y; see Figure 2 [Link to Image 2: Plotting the first 2 columns of an ASCII file]. The clear command is used to remove all previous plotting objects and create a new blank drawing area.

If the file contains error data, they can be included:

chips> clear
chips> plot data2a.dat 1 2 3

This command plots x and y from columns 1 and 2, respectively, as shown in Figure 3 [Link to Image 3: Including error bars]. Data from column 3 is used to plot symmetrical error bars in y.

If the file contains data for nonsymmetrical error bars:

chips> clear
chips> plot data3.tab x 1 y 2 yup 3 ydown 9

This command plots x and y from columns 1 and 2 respectively, as shown in Figure 4 [Link to Image 4: Including asymmetric error bars]; data from column 3 is used to plot the positive error bars in y and data from column 9 is used to plot the negative error bars in y.



Customizing the Plot

Labels and titles may be added to a plot:

chips> clear
chips> plot data1.pha
chips> title "Test Plot"
chips> ylabel "Count Rate"
chips> xlabel "Channel"

In addition, the characteristics of the labels and title may be modified:

chips> xlabel blue
chips> xlabel size 1.5
chips> ylabel blue
chips> ylabel size 1.5
chips> title red

The plot now appears as shown in Figure 5 [Link to Image 5: Customizing a plot].

See the appropriate ahelp files for other commands that may be used to customize the appearance of the plot:

  • axes: specify the bounding box surrounding a drawing area.
  • curve: change curve attributes.
  • errs: specify the appearance of errorbars.
  • grids: add grid lines or change grid attributes.
  • limits: set the ranges to be displayed in the axes.
  • line: add a line or change line attributes.
  • symbol: change or remove symbols from a curve.
  • ticks: specify the spacing of tick marks.
  • tickvals: control the numerical tick mark labels.


Plotting Two Datasets Together

An important ChIPS concept is the "plotting object". Plotting objects are curves, labels, lines, titles, etc. When multiple plotting objects of the same type exist in a single plot, each is assigned a unique reference number.

To plot two datasets in the same drawing area, the first curve is plotted:

chips> clear
chips> plot data3.tab 1 2 3
chips> symbol circle
chips> limits 1982.0 1999.0 0.0 3.0

then the second curve is added:

chips> plot data4.tab 1 2 3
chips> c 2 symbol square

When the symbol type for the second curve is changed, "c 2" specifies the curve on which you wish to operate.

Labels are then added to the drawing area:

chips> xlabel "Time (years)"
chips> ylabel "Flux (2-10keV)"
chips> xlabel size 1.5
chips> ylabel size 1.5

Figure 6 [Link to Image 6: Combining two datasets] shows the resulting plot.

It may also be useful to overlay one dataset on another; here we plot a dataset overlayed by the fit:

chips> clear
chips> plot data2a.dat 1 2 3
chips> plot data2b.dat
chips> c 2 simpleline
chips> c 2 symbol none
chips> c 2 red

chips> xlabel "Time (JD-2,400,000)"
chips> ylabel Velocity

Figure 7 [Link to Image 7: Plotting a dataset as a curve] shows the resulting plot.



Plotting Two Datasets Separately

Similar to curves, multiple drawing areas may be created and referenced by a number.

Two drawing areas are created and a gap between them is defined:

chips> clear
chips> split 2
chips> split gap 0.05

A curve is added to each drawing area:

chips> d 1 plot data3.tab 1 2 3
chips> d 2 plot data3.tab x 1 y 4 yup 5 ydown 6

Note that the "d #" portion of these commands specifies the drawing area.

Various modifications are made to the two drawing areas and their curves:

chips> d 1,2 symbol circle
chips> d 1 tickvals x off
chips> d 1 ylabel "Flux (2-10keV)"
chips> d 2 xlabel "Time (years)"
chips> d 2 ylabel "N_H (/10^{23} cm)"
chips> d 2 xlabel size 1.5 
chips> d all ylabel size 1.5

Both drawing areas are changed at the same time by using the "d 1,2" or "d all" syntax. Figure 8 [Link to Image 8: Plotting using multiple drawing areas] shows the resulting plot.

Add another curve to each of the drawing areas:

chips> d 1 plot data4.tab 1 2 3 
chips> d 1 c 2 symbol square
chips> d 2 plot data4.tab X 1 Y 4 yup 5 ydown 6
chips> d 2 c 2 symbol square
chips> d 1 limits 1982.0 1999.0 0.5 3.5
chips> d 2 limits 1982.0 1999.0 0.0 4.5

Now it is necessary to give both the drawing area number (d #) and the curve number (c #) to change a curve attribute. Figure 9 [Link to Image 9: Combining multiple plots and drawing areas] shows the resulting plot.



Saving and Printing a Plot

The print command may be used to save a plot in postscript format or send it directly to the system printer:

chips> print postfile plot.ps
chips> ls *ps 
plot.ps

chips> print

The commands pagesize and colorsys are used to control the appearance of the hardcopy.

The store command may be used to save a plot for future use in another ChIPS session:

chips> store plot.chp
chips> exit

unix% chips

Welcome to ChIPS, version CIAO 3.4
Copyright (C) 1999-2003, Smithsonian Astrophysical Observatory

chips> restore plot.chp
chips> exit


Getting More Help

There are several ways to get help on ChIPS:

  • A complete discussion of each command can be brought up by typing ahelp from within ChIPS (e.g. "ahelp curve"). Use "q" to exit from the help page.
  • This information is also available from the ChIPS Reference Manual.
  • The chips help page contains information on how to use S-Lang within ChIPS.


History

14 Dec 2004 reviewed for CIAO 3.2: no changes
01 Dec 2005 updated for CIAO 3.3: ChIPS version number
01 Dec 2006 updated for CIAO 3.4: ChIPS version

Return to Threads Page: Top | All | Intro
Hardcopy (PDF): A4 | Letter
Last modified: 1 Dec 2006


The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.