A Guide to using Cygwin, DS9, and IRAF at Mount Holyoke

advertisement
ASTR 330/FC 30 – Spring 2006
A Guide to using Cygwin, DS9, and IRAF – PART I
I. Introduction
This document has been designed to introduce you to the basics of logging into cecilia, the MHC
astronomy department server, using Cygwin, an X-terminal emulator. Once you have
successfully logged in, we will learn some of the basics of the software package IRAF (Image
Reduction and Analysis Facility) in preparation for your project involving spectroscopic data
reductions.
II. Logging Into Cecilia using Cygwin
At many of the PCs available in the Library and Dwight Hall at Mount Holyoke College, one
will find the X-terminal emulator, Cygwin, located on the C: drive under “My Computer”.
Cygwin is a Linux-like envirnment for Windows. A convenient guide for using Cygwin is
located at http://cygwin.com/cygwin-ug-net/cygwin-ug-net.html.
Procedure
1.
2.
3.
4.
5.
Double-click on the computer icon on the desktop. This will open up a folder.
Double-click on the Local Disk (C:).
Locate and double-click on the folder entitled “cygwin”.
Locate and double-click on the file “cygwin.bat”. This will open a terminal window.
In this terminal window, at the prompt, type:
$ startx
and then wait…
a) If you see a firewall message, click on “UNBLOCK” to allow communication
between cecilia and your PC.
b) You will be greeted with 3 screens. To keep your screen relatively free of
clutter, you will want to get rid of the 2 screens on the right. Simply type
“exit” at the prompts.
c) Place the left mouse button in the upper right hand corner of the remaining
window. Resize the window by dragging your cursor in such a fashion as to
make the window smaller.
6. Now that you have your cygwin terminal up and running, you need to tell it to accept
displays from cecilia. At the prompt, type:
$ xhost + cecilia.mtholyoke.edu
It will tell you that cecilia is being added to the control list.
7. Now you are ready to log onto cecilia. We do this using a secure shell environment.
In your cygwin window, type the following:
$ ssh cecilia.mtholyoke.edu –l username –X
It should ask you if you want to continue connecting. Type in “yes” at the prompt. Then
it will prompt you for your password. Enter the password that was given to you by the
Help Desk.
8. You should now be logged on and in your home directory on cecilia. Cecilia is a
Linux (Unix)-based environment and therefore requires the use of special commands
to navigate the directories and examine files. At the prompt type:
$ ls
This command will display a list of files in the current directory. You should have a
directory called iraf/.
9. In order to do anything with IRAF, you need to be in the directory called iraf/. To
get there, type the following command at your prompt:
$ cd iraf
This will allow you to “change directories” from /home/username to
/home/username/iraf.
10. At the prompt, type:
$ pwd
This will show you the “path of working directory”. Basically, this will tell you where
you are in the directory structure. It should say “/home/username/iraf” at the prompt.
11. Next, we need to create IRAF. To do this, type:
$ mkiraf
It will then ask you which terminal type we wish to work with. Type xgterm and hit
return.
12. Next, type: $ ls. This time, you should see that your iraf/ directory contains 2 items:
one file called “login.cl”, and another directory called, uparm/. The uparm directory
is the depository for the “user’s parameters”. Within the IRAF environment, there are
a number of different tasks that can be used to manipulate the raw data obtained at the
telescope (more on this later…). Each task has a list of parameters that may be edited
to correspond to your particular data. When these parameters are edited, they are
saved in the uparm directory.
13. Now we need to edit your login.cl file. The login.cl file tells IRAF which packages to
load upon startup, as well as how big to set the display for your images. In this
particular case, you can use a couple of different editors to accomplish this task. vi
and emacs are two different kinds of available editors.
At any rate, lets work with vi. I have placed a useful cheat sheet of vi commands
on the course homepage. At the prompt, type:
$ vi login.cl
IRAF will have automatically set your username, home directory, image directory,
and parameter file directory in the login.cl file, but you should check that it looks
right. The pertinent lines in the login.cl file should look something like this:
home = "/home/username/iraf/"
imdir = "/bak/imdirs/username/"
uparm = "home/username/iraf/uparm/"
userid = "username"
The commented-out set commands in the login.cl can be uncommented to indicate
some preferences to IRAF. For instance, what editor do you want to use when editing
within IRAF? Just delete the # symbol at the beginning of the first set command, and
enter the name of the editor you like.
To do this in vi, move your cursor with the arrow keys down to the line that starts:
# set
stdimage
= imt512
Typing an ‘x’ will delete a single character. Try getting rid of the # symbol at the
beginning of this line.
Next, we will need to change the stdimage setting to "imt2048". This will set the
image display appropriately for the 1200x800 Loral CCD chip used with the B&C
spectrograph at the 2.3-m Steward Observatory Bok Telescope.
To do this, move your cursor with the arrow keys until it is at the “5”.
Next, hit the “x” key 3 times. This will delete the 5, then the 1, then the 2.
Next, you want to input “2048”. To do this, type the letter “i”, move your cursor over
one space with the arrow key, and then type in “2048”. When you are finished, you
must be sure to hit the “esc” key to exit the “input” mode.
Check to make sure that your imtype and imextn are set to fits.
When you are finished, type: “:wq” to write, and quit the editor. This will over-write
the file with your fresh edits. If you decide that you do not want to keep the changes
you have made, type: “:q!” instead. This will allow you to quit the file without
saving any changes.
14. Now that your login.cl file has been edited, you are almost ready to begin using
IRAF. But first we need to get you some data! I would like you to create a directory
for your class work, within the iraf/ directory. To do this, type:
$ mkdir Spectra
mkdir is the Unix command to make a new directory. Type “ls” to make sure that it is
there.
15. Now we will transfer the data provided on the CD to the appropriate directory on
cecilia.
a) Place the CD into the drive on your PC.
b) From the Start menu, go to Programs and locate WinSCP or WinSCP2.
Click on the executable file.
c) This will bring up a new window that will prompt you for the host you wish to
connect to. Where it says “Host name”, enter: cecilia.mtholyoke.edu. Enter
your username and password in the appropriate boxes and then click on
“Login”. You will be prompted to accept the host key. Click on Yes.
d) You are now connected to cecilia. In the right hand side of the window, you
will see your directory iraf. Open it by double-clicking on the folder. Inside
of that, you should see 2 more folders representing your Spectra directory,
and the uparm directory. Double-click on your Spectra directory.
e) Next, change the current directory displayed on the left hand side of the screen
to D: by clicking on the drive selector.
f) Click on the first file on your CD (a0006.fits). Then, from the top tool bar,
select Mark, and choose Select All.
g) Then, under Command, select Copy. This will bring up another window,
asking you if the directory shown is the correct directory to which you wish to
copy your files. If so, click on Copy and wait for the operation to finish.
h) When it has finished (it took me 1:15 minutes to transfer the data), close out
the session by clicking the red-X in the upper right hand corner of the screen.
Confirm the termination of your session by clicking on Yes.
16. Now we can start looking at some data and familiarizing ourselves with IRAF.
Learning How to Start IRAF and Display Images
We left off logged into cecilia, in our iraf/ directory. Now we need to find out how to start our
IRAF session and how to display our images. We will be using the astronomical imaging and
data visualization application called SAOImage DS9 or DS9 for short. DS9 may be used in
conjunction with IRAF or in stand-alone mode.
To start DS9: At your prompt, type:
$ ds9 &
The ampersand is important because it ensures that DS9 will be run as a background job, leaving
your xterm window free for other tasks. Once DS9 opens, you will want to re-size it by using
the left mouse button and the upper right corner of the window.
The images acquired at the telescope are recorded in fits (Flexible Image Transport System)
format. This is currently the standard format for recording astronomical data, developed by D.
Wells of Kitt Peak National Observatory (Astronomy and Astrophysics Supplement, 1981, 44,
363). Any data file in fits format will start with a header record, describing the name of the file,
the structure and coordinate system of the data array, plus additional information about the data
this is written either at the telescope as the data is collected or during later data processing steps.
Followoing the header record will be the data array record, consisting of 8, 16, or 32 bit integers
representing the intensity value recorded in each pixel of the detector. All major optical and
infrared observatories record data in fits format, and IRAF is designed to work with images in
this format.
To start IRAF: At your prompt, type:
$ cl &
This will open up a new xterm from which you will operate IRAF. Again, it is very important to
remember to include the ampersand.
About IRAF
IRAF is made up of four parts:
- the Command Language (CL) - the user interface to the system;
- the applications packages - the routines and algorithms that do the data analysis;
- the Virtual Operating System (VOS) - the foundation of higher level functions;
- the Host Interface System - the interface between IRAF's VOS and the host machine.
Only the first two are directly apparent to the user in most cases. When you start IRAF with the
command “cl &”, you are invoking the command language in an xterm or xgterm window which
thereafter serves as your command interface to IRAF. The CL gives the user direct control over
the data and the parameters involved in data analysis through an assortment of tasks that are
logically organized into packages. Depending on the explicit instructions in your login.cl and
loginuser.cl files, when you invoke IRAF you'll see a listing of loaded packages:
dataio.
dbms.
images. lists.
language. noao.
obsolete. proto.
system.
plot.
softools. utilities.
cl >
The tasks associated with each package are accessible from the cl > prompt if you've loaded that
package already. Access to any package, loaded or not, is accomplished by typing it's name at
the cl > prompt:
cl > noao
artdata.
astcat.
astrometry.
astutil.
digiphot.
focas.
imred.
mtlocal.
nobsolete.
nproto.
observatory
obsutil.
onedspec.
rv.
surfphot.
twodspec.
no >
The new listings are the tasks within the noao package, invoked simply by typing the task name
at the no > prompt.
Type onedspec at the cl> prompt. List the packages available within onedspec.
Return to the no> prompt by typing bye at the current prompt. Type bye again to return to the
cl> prompt.
Basic Image Commands
The simplest package in IRAF for investigating image data is known simply as images and can
be invoked by typing:
cl> images
The menu which appears contains another host of routines for simple image processing,
including arithmetic and display tasks.
imcoords.
imfilter.
imfit.
imgeom.
immatch.
imutil.
tv.
im>
Load the imutil package to see a list of simple functions you can perform on your image.
Getting Help
There is lots of help within IRAF ... just type help followed by a package or task name. For
example: at the im> prompt, type:
im> help imutil
You will see a listing of all the tasks under that package with a short description of each. Next,
type:
im> help imheader
This displays the help that is available for this particular task. You will see the various
parameters that can be set within the imheader task. The values of these parameters will be save
in your uparm/ directory.
Where is your uparm directory located?
EXAMPLE
Let’s look at the header information for one of your files. In order to access the files you just
uploaded from the CD, you need to change directories to where your images are located. To do
this, at the prompt in your IRAF window, type:
im> cd Spectra
since this is where you placed your files.
Type “ls” at the prompt to make sure that your files are there.
There are 2 modes to display the header information. If the parameter file for imheader is set to
select a “short header”, then you will simply get the name and size of the image.
Try it! At your prompt, type: im> imheader filename
In order to see the full image header, you will need to edit the parameter file for imheader. To
do this, type:
im> epar imheader
Once inside the parameter file, use the arrow keys to navigate through each setting. Change the
parameter “longhea” to yes. To exit a parameter file editing session, use either “cntl-d” or “:go”.
Now try reading the image header again. (What do you have to type?)
Virtually all the tasks in IRAF have a parameter file, which you can look at with the lpar
taskname command, and edit with the epar taskname command. These parameters control
how the task operations will be accomplished. There are both hidden (parenthesized) and
positional/query (unparenthesized) parameters. The query parameters will be confirmed each
time a task is run (via command line prompt) unless they are explicitly stated on the command
line. The hidden parameter values currently entered in the parameter file are used in executing
the task unless specified on the command line by the user. It's important to understand the
parameters for the tasks you use ... otherwise what you think is being done to your data may not
be what's really being done.
Displaying Images
In order to interact with an image display by pointing the cursor with a mouse, you must first
open the image from INSIDE of IRAF with the display command. You should have already
started DS9 and positioned the image window in a convenient location on your screen. Now
return your attention to your IRAF window.
The IRAF task display is in the tv package. Let’s try the display with the default scale first.
Type:
im> display C.41015.0001.I.fits
It will ask you for the frame buffer, identified simply by 1, 2, 3, or 4, and then will load the
image. Dragging the right mouse button on the image allows you to play with the contrast in the
image. The COLOR menu on the SAOImage window allows you to manipulate the "look-up
table" into the different greyscale or color tones.
Logging out of IRAF
Typing “lo” at any prompt will exit IRAF.
Download