\documentstyle[12pt]{article}
\begin{document}
\begin{center}
{\huge Data Reduction Using the HEASARC Archive and Ftools}
\end{center}
{\large
\begin{itemize}
\item
Open Netscape
\item
Go to HEASARC web page by typing $\ $
{\tt http://heasarc.gsfc.nasa.gov}
\item 
W3Browse

On the bottom of the page there are two rows of six locations within
HEASARC to which you can go.  The top left option is the {\it
W3Browse} location where you can search for observations of various
objects.

\begin {itemize}
\item
Click on it.
\item
Select the {\it Basic} option.
\end{itemize}

\item 
Search for a specific object

\begin {itemize}
\item
From the {\it Active Mission Archives} section select {\it ROSAT} by
clicking on the gray button to its left.
\item
In the box at the top labeled {\it Object Name or Coordinates} enter
{\tt GK PER}.
\item
Click on {\it Submit Query}.
\end{itemize}

\item
Selecting an observation

\begin{itemize}
\item
Select the second observation whose instrument is the PSPCB.

\item
Slightly below the table of observations there is a box, entitled 
{\it Categories of data products}, containing different types of data
collected in each observation.  Click on the gray {\it Submit} button below.
You may receive a security warning message from Netscape, to continue
just click on {\it Continue Submission}.

\item
This page shows all the possible data that can be examined from the
observation you chose.  At the end of each line the filename of the
data you wish to retrieve is printed in the form of {\it file.Z}.
Select the {\it Basic Science Events}
file by clicking on the gray button on its left.  
\item
Scroll down the page and click on {\it Retrieve Data Products}
\end{itemize}

\item
Downloading TAR files

\begin{itemize}
\item
The screen that appears should list the file you chose.  Click on
{\it Download TAR file} which appears right below.

\item
The window that appears contains four sections: {\it Filter,
Directories, Files, Selection}.  Make sure that {\bf your} directory apears
in the {\it Selection} box.  If it does not then you must enter the
{\tt /temp} directory you created to store your files.  

If you had to re-enter your directory then when you finished typing
click on {\it Cancel}, then Click on {\it Download TAR file} again.
This time the correct directory should appear in the {\it Selection} box. 

\item
Click on {\it OK}

Netscape will copy the files you have selected into your directory in
the form of a {\it w3browse-$\#$.tar} file.  It is a compressed file
and cannot be used until it is opened up properly.

\item
Un-tar your {\it w3browse-$\#$.tar} by typing:

{\tt tar -vxf} {\it w3browse-$\#$.tar}

This command produced a subdirectory chain in your directory called
{\it rp300217n00/} where youre files are
located.
\end{itemize}

\item
Organizing and uncompressing the files in your directory

\begin{itemize}
\item
You will find the files you downloaded from HEASARC in their new 
subdirectory by typing:

{\tt cd} {\it rp300217n00/}

\item
Then type {\tt ls} to list the files. 

{\it rp300217n00$\_$bas.fits.Z} should appear.

Notice the file ends with {\it .Z}$\ $.  This means it is comrpessed
further and still cannot be used.  

\item
Uncompress the files by typing:

{\tt uncompress *.Z} 

The * is a wildcard character so that your command above says
``uncompress {\bf anything} in this directory that ends with {\it .Z}''.

Then type {\tt ls}.  The {\it .Z} should have disappeared from the
filename making the file usable.

\item
Remove the {\it w3browse-$\#$.tar} file now that you have what you
need.  Type:

{\tt rm ../{\it w3browse-$\#$.tar}}
\end{itemize}

\item
To see the important information about this observation open up one of
the files in the emacs editor.  Type:

{\tt emacs rp300217n00$\_$bas.fits $\&$ }

The file that comes up contains information such as the date and time
of this observation, the telescope and instrument that collected the
data, the location of the object as well as its name.  

Close emacs.

\item
Reading the data into Xselect

\begin{itemize}
\item
The program you are using to process and analyze the data from
HEASARC, {\it ftools} contains a package (i.e. subprogram) named {\it
xselect} which contains all the commands you will need to look at the
images from your data, and examine lightcurves and power spectra.

\item
To use {\it xselect} you must execute its commands.  At the prompt
type:

{\tt xselect}

\item
You will be asked to enter a session (so that when you are done you
can save all your work into that session or continue where you left
off).  

Call your session {\tt session1}.

\item 
Notice the information that appears on the screen is specific for {\it
ASCA} - a different satellite.  We want to analyze {\it ROSAT} data and
we need to tell {\it xselect} to do so.  Type:

{\tt read events}

\item
You will be asked in which directory do the event files exist.  If you
called up {\it xselect} from the directory where youre {\it ROSAT} files
exist then enter {\tt ./} (which means {\it this} directory).

\item 
Then enter the name of your file: {\tt rp300217n00$\_$bas.fits}
 
\item
Type {\tt yes} to reset the mission.

Now {\it xselect} is configured.  Notice the important notes that
follow on your screen.  

\begin{tabbing}
Keywords for time and pha areXX\=TIMExxxxx\=PI\kill
Notes: XSELECT set up for\> ROSAT\\
Keywords for time and pha are\>TIME\>PI\\
Units of time are\>s\\
Default timing binsize =\>16.000
\end{tabbing}

This data and that which follows describes how the program is now
configured to handle your data.  For example, it tells that the units
of time in any process will be in seconds.  It also prints the
directory where your data is located.  Finally,
the programs outputs the information about your object, {\it GK PER},
its position in the sky, the livetime (how long the detector was
taking data on this object), and the date of observation. 
\end{itemize}

\item 
A few Commands

{\it xselect} has some general commands that you will be using to
create images, light curves, and power spectra.  Here are some of the
commands (and their descriptions) that you will be using the most.   
\begin{itemize}

\item
{\it Read event}, which you have already used in the previous
section, enters data into the program.  If you wish to enter a new set
of data, you can do it with this command

\item
{\it Filter} commands do no work.  They merely enter filters selecting
a particular region or time interval that will be applied to the next
run of the {\it extract} command. 

\item
{\it Extract} command produces a product file such as an image, a
pectrum, or a lightcurve.  

\item
{\it Clear} command is used to clear any changes you have made to
data and restores it to the way it was originally.

\item 
Another useful command is {\it show data} which you can type at any
time and you will receive an output of your working directory and the
names of the files you are using.

\item
Similar to the {\it ls} command, to list all the files in your current
directory you can type {\tt list workdirectory} or {\tt list
datadirectory}.

\end{itemize}

\item
Image analysis

\begin{itemize}
\item
To look at {\it GK PER} you need to command {\it xselect} to show it
to you. At the prompt type:

{\tt extract image < Enter >}

Once again {\it xselect} prints out information on the screen.  The
important facts are the {\it seconds} and the {\it counts} that
provide a countrate for the image.  This is important because a high
countrate means the object was giving off photons at a high rate and
will be bright.  A very low countrate implies a faint or no image
(just noise).  

\item
The image has been extracted from the data and you must now use an
imaging tool to look at it.  Type {\tt saoimage} to call up the
imaging tool.  A new window should pop up with your data displayed
upon it.
\pagebreak

\centerline{SAOIMAGE}

You should take some time to familiarize yourself with this tool.
You can change the features of your display by selecting a ``button''
from the top row.  If you click on {\it Scale}, for example, you have
a choice, on the seconds row, of viewing your image in a variety of
brightness scales.  Notice the grayscale legend at the bottom.  A linear
scaling would let the brightest thing in your image be the color of
the extreme right, the least bright thing in your image be the color
of the extreme left, and the values in between would be evenly spaced along
the grayscale legend.  A square root display would let the square root
of the maximum and minimum brightness values be displayed as the
leftmost and rightmost grayscale values.  Try the logarithmic scaling
to see what it does.

You can also change the color schemes by clicking on {\it Color}.  The
button {\it cmap} will add more choices to your display options.  You
can invert the grayscale legend by clicking on {\it invert}.  To
return to the color options click on {\it cmap} again.  

You can mark your object of choice with a {\it cursor} and define a
region to later observe.

\begin{itemize}
\item
The object we are examining is GK PER.  It is located at the bottom
left of the display. 
If you want to center your object click on {\it Pan} and then click on
the object.  It should move to the center.  Then click on {\it
Cursor}.

\item
Select a circle shaped cursor.  With your mouse button choose a circle
size that places your object comfortably inside.  The left mouse
button puts the center of your shape in place, and clicking down on
both mouse buttons allows you to drag out the radius of the shape to
any size you wish.  Make your circle just big enough to enclose the
star. Then type {\tt s} on the keyboard to ``save'' the region.

\item 
Click on the button labeled {\it region} (the rest of the buttons
should change) and select {\it write}.  On the line that appears type
{\tt src.reg} which saves the region surrounding your object for later
use.
\end{itemize}
Continue to play with SAOimage until you feel comfotable using it.

\item
To look at the data inside your selected region only, return to the
window where {\it xselect} is running and type:

{\tt filter region src.reg < Enter >}

When you apply the filter command to an image it is as if you are
placing an opaque screen with a hole in it over the data.  The hole
int he screen is the region you selected.

\item
Next you must type {\tt extract events} to select only the data
contained in your region. In other words you are choosing only the
points that show through the hole in the screen.  The rest are
ignored.  The output of this command should show a {\it Grand Total}
of 112910 counts with a much smaller number (around 3 or 4 thousand)
of {\it Good} counts and the rest are {\it Bad: Region} counts.  This
tells you you have excluded all the points not in your selected
region.  

\item
Now type {\tt clear region}

This removes the filter from your image since you pulled out the
events you wanted and no longer need the filter.  

\item
Now you must extract the image from those points you selected by
typing:

{\tt extract image}

\item
Call up SAOimage again to display your new image.  (You may close
your old SAOimage window by clicking on {\it etc} and then on {\it
QUIT} or leave it up for comparison with your new display.)

\item
Getting a Filtered Image

The following is a list of the commands you just used with no comment
so that you may refer to it quickly beginning after {\tt read events}:

{\tt extract image}

{\tt saoimage} (select a region with the cursor)

{\tt filter region src.reg}

{\tt extract events}

{\tt clear region}

{\tt extract image}

{\tt saoimage} (To see the final image)

You may now proceed to manipulate the image of {\it GK PER}

\item
Binning up pixels.

The image you originally displayed (before the filtering) is made up
of 1024 $\times$ 1024 pixels.  When you chose the region you simply
selected a particular set of pixels to be displayed.  Sometimes,
however, it is helpful to group pixels together into one block to get a
smoother appearence of the data.  This technique is called
block-averaging.  If you tell {\it xselect} to take every 8 pixels and
replace them with 1 pixel whose grayscale value is the average of
those eight, you have binned up your image into 128 $\times$ 128
pixels.  To see this type:

{\tt set xybinsize < Enter >}

\item
You will be asked for a rebinning factor (this would be the value 8
mentioned above) select {\tt 8} to see a 128 $\times$ 128 pixel image.

Then continue to process the image by commanding:

{\tt extract image < Return >} and {\tt saoimage < Return >}

You should see your region selected image in a binned up fashion.  The
pixels should now be larger sized squares.  
\item
Try to rebin with different values such as 32.To do this you simply
need to type:

{\tt set xybinsize} and input the binning you desire.

{\tt extract image}

{\tt saoimage}

The default xybinsize is 15; this means the first image you looked at
had an xybinsize of 15.  When you are done exploring this function,
set it back to 15.  

\item
Smoothing images.

Smoothing images often allows you to concentrate on the general
features of the image and not worry about individual pixels. 

Type: {\tt smooth image}

You will be asked for a smoothing method.  Your options are {\it
Boxcar, Gaussian,} or {\it Lorentzian}.  Choose the {\tt Gaussian}
method by typing it at the prompt.  You will be asked for a sigma for
image smoothing. The default is 1.5 you may accept that value to see
what happens. 

Again display your result with {\tt saoimage}.

\item
Notice your object is now smoothed.  Try different color schemes on
the smoothed data and pan in on it so you can see it clearer.  Notice
the top left part of the image is now bright and there is a dark
``hole'' in the middle.  The value 1.5 is the $\sigma$ in a gaussian
curve which you are applying to the image, a larger $\sigma$ means a
smoother image.   

\item
An image will be smoothed differently depending on the binning factor
of the image.  You can explore different possibilities by following
these steps:

{\tt set xybinsize} and input the binning you desire.

{\tt extract image}

{\tt smooth image < Enter >} then choose {\tt Gaussian} with a
$\sigma$ of 2 or any value you wish to explore.

Then view it with {\tt saoimage < Enter >}.

Try a $\sigma$ of 3 or 4 to see what happens when you smooth too much!

\end{itemize}

\item
Examining lightcurves

\begin{itemize}
\item
You will now use the {\it extract} command to make a lightcurve of your
observation.  

{\tt extract curve}

\item
Next you must set a program device upon which your lightcurve can be
plotted.  

{\tt set device /XW}

and now plot it {\tt plot curve}

\item
You will notice that all of your data is in the center of the plot and
a curve or spectrum is hard to make out.  Also, notice that at the top
of your plot you are told that the binsize is 16.000s.  This means
that the total livetime has been divided by 16s and plotted
accordingly.  

Notice on your {\it Xselect} screen that the prompt has changed from
{\it session1:ROSAT-PSPC}{\tt >} to {\it PLT}{\tt >}.  This means you are in an
{\it interactive} mode with the plot window and commands you give the
screen will be received by the plot window.

The most important command is {\it exit}; type it if things get really crazy.
In this case you can clear events and start the lightcurve extraction
all over.  

\item
One useful thing you can do is reset the x and y axes to zoom into
some interesting part of the lightcurve.  

{\tt rescale x 4e5 6e5}

This displays the datapoints across the entire screen. You can zoom in
even more by typing {\tt rescale x 4.8e5 5.5e5}

Type {\tt exit} to return to {\it xselect} now.

\item
It is useful to define a region of interest from your image and
extract the events from that region.  Since you already extracted the
lightcurve you can define a time interval through which you can filter
the data.  

Type: {\tt filter time cursor < Enter >}

Again you will be in the {\it PLT}{\tt >} mode.  The first thing to do
is to enter {\tt quit} as you are told to do on the screen.  Then in
the plot itself click to the right of the curve (around x=5.5e5) and
to the left (around x=4.8e5).  A horizontal line should have connected
your clicks.  

Then type {\tt x} {\it in} the plot window to exit this mode.  
NOTE: You can get tangled up very quickly while in this mode.  Do not
attempt to try the other commands that appear unless you have plenty
of time and motivation!  The instructions above will be sufficient for
your purposes.

\item
Type  {\tt  show status < Enter >} to see that file of the time
selections was added to the filters.  It also shows what you have done
so far under {\it PRODUCTS}.  

\item
Type {\tt extract curve < Enter >} since now there has been a filter
applied to it.

And {\tt plot curve < Enter >}.

\item
You now have a light curve.  You can rescale this curve as you did
before.  Typing {\tt rescale} with no argument will return the
original curve.  

\item
Finally, you might want to make a hardcopy (printout) of your
lightcurve.  to create a postscript file that can be printed, type at
the {\it PLT}{\tt >} prompt:

{\tt  Hardcopy /PS}.  this will make a ps file in your main directory
that you can later print out.
\end{itemize}

\item
Extracting an Energy Spectrum from the Lightcurve

\begin{itemize}
\item
To further analyze the light curve you extracted, it is useful to make
a energy spectrum, which tells you the intensity of the radiation as a
function of energy.  By looking at the shape of this energy spectrum,
we can tell a lot about the nature of the processes that give rise
to the x-rays that we see.

Type {\tt extract spectrum < Enter >}

Followed by {\tt plot spetrum < Enter >}.

You will get a plot of COUNTS vs. CHANNEL 
\end{itemize}

\item
When you are done using Xselect you may type {\tt exit} at the prompt
and save the session so that all the images, curves and spectra remain
in your directory as independant files.  You are now able to take
these data and manupilate them to produce power spectra, as well as
fit the spectral data to learn more about the properties of this star!

\end{itemize}
\end{document}
