How to install and initiate IRAF in Ubuntu/Mac OS

0. Introduction to IRAF

IRAF (Image Reduction and Analysis Facility) is a general purpose software system for the reduction and analysis of astronomical data. IRAF is licensed under a MIT style license. The software was written by the National Optical Astronomy Observatories (NOAO) in Tucson, Arizona.

1. Install IRAF and PyRAF from AstroConda

1.1 General brief instructions

If you are already (or going to be) familiar with Conda, which is an open source package management system, then you may prefer to install IRAF/PyRAF from AstroConda channel. AstroConda provides a simple way to plan and extract packages into your environment. You can refer to the documentation of AstroConda for instructions on how to install Legacy Software Stack with IRAF. In short, the installation can be done with:

conda config --add channels http://ssb.stsci.edu/astroconda
conda create -n iraf27 python=2.7 iraf-all pyraf-all stsci

Note that every time you want to use IRAF/PyRAF (and any other packages in iraf27 environment), you need to activate the env ‘iraf27’ that you have created:

source activate iraf27
### or conda activate iraf27

And to deactivate, run:

source deactivate
### or conda deactivate

1.2 Initiate IRAF/PyRAF

First activate iraf27 environment:

source activate iraf27
### or conda activate iraf27 #(for newer versions)

Make sure you’re under your working dirctory (not the installation directory of IRAF), and initiate IRAF/PyRAF with mkiraf command, which is necessary when you’re going to use IRAF/PyRAF for the first time in YourWorkingDirectory:

cd YourWorkingDirectory

mkiraf

###Enter 'xgterm' in the terminal type
>>>-- creating a new uparm directory
>>>Terminal types: xgterm,xterm,gterm,vt640,vt100,etc.
>>>Enter terminal type [default xterm-256color]: xgterm

Now you have a login.cl file (which stores basic settings for current dir) and a uparm directory (which keeps parameter files produced during data reduction) in YourWorkingDirectory. At this point, logging in to the IRAF/PyRAF environment is considered legal.

1.2.1 Log in to IRAF

The command for logging in to IRAF is cl or ecl (you can try both in your system). However, we’re not supposed to type the command directly in the system default terminal, but rather do that in xgterm. This is because only xgterm can play well in terms of interactive operations when using IRAF. Also, we often need to keep a ds9 window active when learning data reduction. So the steps here are:

  • Open xgterm
  • Log in with cl (or ecl) in xgterm
  • Open ds9

If you’re satisfied with all the windows that pop up, then you can stop reading this article. But you may find ths fonts in xgterm too small, and the whole process not so smooth. You may even get errors because iraf27 environment needs to be activated again in xgterm in some computers! Then I have some tips for you. You can link all the commands of the whole 3 steps together, and also set font size for xgterm with:

xgterm -fn 10*20 -e cl & ds9 &

where argument -fn 10*20 tells xgterm to use font with size ‘10*20’, -e cl (or -e ecl) tells xgterm to log in to IRAF immediately after it’s started. The & put the process into background of the terminal, so that we can excute new commands without waiting for the former process to be finished.

If you want xgterm to display a scroll bar, simply add another -sbr argument:

xgterm -fn 10*20 -sbr -e cl & ds9 &

You may wish to type less, and there’s a good way for sure: edit your ~/.bashrc (for Ubuntu) or ~/.bash_profile (for Mac OS) file to add this line to the file:

alias iraf='xgterm -fn 10*20 -sbr -e cl & ds9 &'
###(You're free to edit the quoted as you like)

Save the file and use source to make it take effect in your current open terminal:

###For Ubuntu
source ~/.bashrc
source activate iraf27 #or conda activate iraf27

###For Mac OS
source ~/.bash_profile
source activate iraf27 #or conda activate iraf27

Now and next time you launch a new terminal window, just activate iraf27 environment and you can use iraf command to log in.

Always check if there are login.cl and uparm in your (new) working directory! If not, remember to mkiraf before logging in.

1.2.1 Log in to PyRAF

After mkiraf, just type:

pyraf

and then you can use PyRAF just in your current terminal. (You will not need xgterm!)

You can either open ds9 before pyraf using:

ds9 & pyraf

or open ds9 in PyRAF environment with !ds9 &:

PyRAF 2.1.15 Copyright (c) 2002 AURA
Python 2.7.16 Copyright (c) 2001-2019 Python Software Foundation.
Python/CL command line wrapper
  .help describes executive commands
--> !ds9 &

To give you a hint, ! can be used in many cases when you want to excute external (shell) commands in a specific programming environment.

1.3 Trouble shooting

1.3.1. xgterm not working in Ubuntu

If xgterm does not execute with error ‘File not found’, although the file is clearly there, make sure you have installed 32 bit dependencies:

sudo dpkg --add-architecture i386 #Add 32-bit architecture
sudo apt-get update #Update package source list
sudo apt-get install libc6:i386 zlib1g:i386 libncurses5:i386 libbz2-1.0:i386 libuuid1:i386 libxcb1:i386 libxmu6:i386

If ds9 does not execute with error ‘File not found’, although the file is clearly there, please download the latest version of SAODS9 from its offical website, and extract the executable file ds9 into the original location.

Suppose you have Ubuntu 18, go to http://ds9.si.edu/site/Download.html and you’ll find the latest package for your system: Linux Ubuntu 18. And if you have download it to your user’s Downloads folder, with its filename being ds9.ubuntu18.8.0.1.tar.gz:

cd ~/Downloads
tar -zxvf ds9.ubuntu18.8.0.1.tar.gz #Decompress the .tar.gz file

Now you have ds9 in Downloads folder. Please record your path to conda-version ds9, which is the output of the following commands:

source activate iraf27
### or conda activate iraf27
which ds9
#e.g.>>>/home/yourname/anaconda3/envs/iraf27/bin/ds9

With this output, we know that the conda-version ds9 is under /home/yourname/anaconda3/envs/iraf27/bin/ds9, just backup and replace:

cp /home/yourname/anaconda3/envs/iraf27/bin/ds9 /home/yourname/anaconda3/envs/iraf27/bin/ds9.bak #Create a backup file for ds9
mv ~/Downloads/ds9 /home/yourname/anaconda3/envs/iraf27/bin/ds9 #Replace

2. Install IRAF Community Distribution

2.1 Install binary packages (under Ubuntu 18.04 LTS and later)

For Ubuntu 18.04 LTS and later, IRAF Community Distribution are available via system package manager “APT”. Although there some major differences between the Community Distribution and the conda version.

Try to install those packages with command:

sudo apt install xterm iraf iraf-dev iraf-noao iraf-noao-dev iraf-wcstools iraf-rvsao

IMPORTANT NOTE

For this IRAF Community Distribution, the mkiraf command is no longer needed when initiating iraf in the working directory. And to start (log in to) iraf from xterm (unfortunately xgterm is not included in the packages), use:

irafcl -x

If you also want to change font size for xterm like what we do for xgterm, excute:

xterm -fn 10*20 -e irafcl &

or

xterm -fn 10*20 -e irafcl & ds9 &

if you want to open ds9 in the mean time. You can use alias as you wish to simplify your commands.

2.2 Build from sources

The steps for this method can be found at IRAF Community Distribution website. Please refer to “Compile the Sources” in the installation page.