OS X for Astronomers:   Setting up your Apple computer for professional astronomy

by Jane Rigby (Carnegie Observatories)

If you're a scientist who bought an Apple computer as a scientific workhorse, read on.  I assume you want to write scripts, reduce data, view FITS images, plot results, work with latex, pdf, and postscript, and give presentations.  I also assume that you're using the "OS X" operating system (true for post-2001 Apples), and that you are comfortable using unix/linux.

I wrote these instructions for G4 apples running OS X 10.3, and overhauled them to work on OS X 10.4, 10.5, and Intel processers.

(There are several apples-for-scientists sites, so if my page doesn't answer your questions, try these links.)

A brief preface:

Your Mac's operating system is called "OS X". It is a version of BSD Unix with a fancy graphical interface. Because Unix is the engine under the hood, you can use all your favorite linux tools, plus prettier programs written for Apples.  These instructions show you how.

Apple's graphical interface has you click & drag, graphically, in Finder menus ("Drag folder Crapdir to the trashcan.")   At first you may resent the GUI interface. If so, remember that you can do everything from a terminal shell instead ("rm -rf Crapdir/").   You'll need to experiment to determine when it's easier to use a terminal or a menu.

I've re-organized these instructions into the following categories:

Absolute Essentials:

First things first:  get yourself X11

X11 is the standard linux graphical window environment.  You must install X11 before you can use any of the standard graphical programs written for li/unix, including most astronomical software.

Before you do anything, which version of OS X do you have? Click the little apple in the upper lefthand corner of your screen, and choose "About This Mac".

If you have OS X 10.5 ("Leopard") or 10.6 ("Snow Leopard"), then X11 is already pre-installed. Yay!   Skip ahead to "Once X11 is installed".

If you have version 10.4 ("Tiger") or earlier, you can get X11 in one of two ways:

Once X11 is installed, drag the X11 icon or the Terminal icon from /Applications/Utilities to your Dock.   Now, anytime you want a terminal session, just click that icon in the Dock. A terminal will open, and you'll get a real linux-style terminal.   Type "df", "ls", "emacs", and prove to yourself that you've got unix under the hood!

Try these great tricks: Type "open -a preview foo.pdf" in a terminal.   The computer will open the file foo.pdf in the Apple PDF viewer named "Preview".   Even better, type "open foo.pdf".   OS X will open foo.pdf using its best-guess application, just as if you'd double-clicked it.   These two tricks let you use OS X-native programs from the X11 command line.   Read more here.

Second step: get yourself a C compiler (and optionally, a fortran compiler).

Gcc is the standard gnu C compiler. You need it to build programs from source, and to compile your own C programs. OS X was built using gcc, so they play well together.   Unfortunately, gcc isn't installed by default; you must install it.   Here's how to install Apple's binary version of gcc: Some users prefer sourceforge's version of gcc. (One advantage for some: the modern fortran compiler g95 comes with sourceforge's version but not Apple's.) High Performance Computing provides gcc binaries compiled from CVS source code (powerPC or Intel).

If you code in Fortran and/or use pgplot, you also need the g77 fortran compiler, which is available in several ways:

Where the hell's the root account?

'Nix users are used to logging in as the all-powerful root user ("/bin/su").   By default, OS X has no root user!   Insteads there's an "administrator" account: a regular user who, upon request, can issue commands with root permission by prefacing the command with "sudo".   (sudo = do as root).   So to run "make install" with root permission, you would type "sudo make install".   [Or you can create a root acct.]

Incidentally, this is why fink frequently asks for your password -- it's doing "sudo make install." If you're not sure who the administrator is, go to System Preferences, Accounts.

Unix Programs You Will Need:

Fink: an easy way to manage unix packages

Since the heart of Mac OS X is BSD Unix, most of your familiar unix/linux commands are available from an X11 terminal:  perl, which, top, emacs, gzip, pine.  But you may want to install other linux programs  (gv, xemacs, tetex, etc.)  The management tool "Fink" helps you do this -- it explains what packages are available, installs them for you, updates them, and un-installs them.  

Most people also use Fink Commander, which is a graphical interface to Fink.  Search the web for Fink and Fink Commander, and you'll find several good websites that explain how to install them.

Four tips for running Fink and Fink Commander:

Tex & Latex ("Hbox badness 10000!")

You'll need a Tex distribution, which provides the executables "tex", "latex", "dvi", etc. There are various ways to do this.   Kelle at AstroBetter has written step-by-step instructionsfor setting up latex by installing several packages including the MacTeX package. This package gives you tetex, the graphical Tex front-end TeXShop, ghostscript, and "convert".   Go follow Kelle's instructions and you should be texing in no time.

Because I am old-fashioned, I run latex on the command line in one step, using this .cshrc alias:

alias texerpdf 'latex "\!*".tex; latex "\!*".tex ; dvips -t letter -o "\!*".ps -P pdf "\!*".dvi; ps2pdf13 "\!*".ps "\!*".pdf'

Plotting programs

  • Super Mongo works well on OS X.   If you or your institution owns a license, download the one-click SuperMongo install w Aquaterm support, or the older FTP download.
  • Gnuplot:   works well, with either "set term X11" or "set term aquaterm". If you've installed scisoft, you should have gnuplot; alternatively, you can install gnuplot using fink.
  • Pgplot: it comes with scisoft, or you can custom compile if needed.
  • The Perl module for pgplot, called pgplot.pm:  (This module lets you call Pgplot subroutines from Perl -- it's how I make plots.) I've gotten this working on both PowerPC and MacIntel machines.

    Update! The inventor of pgperl has an experimental new package called SciKarl, which installs pgplot and the PDL & pgplot perl modules all at once. It's supposed to be an easier way to install the pgplot perl module.   Please try it and let me (& Karl Glazebrook) know how it works!

    Alternatively, here's the other method of installing pgperl, which is a pain, but I know it works:

    Astro Software You'll Need:

    "Scisoft": essential astro-software, nicely bundled.

    ESO has packaged many astronomical tools into one easy-to-install lump call Scisoft.   Scisoft includes iraf (!), pyraf, gnuplot, pgplot, csfitsio, wcstools, xephem, etc.  By far, this is the easiest way to get Iraf & Pyraf. You need this package.

    Here's how to download it.   Go to Scisoft. The "Download" tab shows the last stable releases for PowerPC and Intel computers and OS X 10.5.   The latest scisoft does NOT work on 10.4; you'll need to select the "News" tab and download the old version from Feb 2008.

    Installation is easy; just follow the instructions. Executables will be stored to /scisoft/*/bin/ . The scisoft Readme tells you to add that directory to your path through your .cshrc or .bashrc file, and add a line like: alias scisoft "source /scisoft/all/bin/Setup.csh".

    One tip that's missing:  when you initialize iraf's preferences with "mkiraf", and it asks what terminal -- PICK "xgterm"!  To start iraf, just type "xgterm &" in an X11 terminal, then type "ds9&; cl" in the new xgterm window. That's it.

    Scisoft installs many handy packages at once, easily, but often they're not the latest versions. When you need the newer versions, try using fink commander, or check a particular program's website for an OS X version.

    Again, Fink executables are installed in /sw/bin, and scisoft packages are installed in /scisoft. Got it?

    Fits viewers: ds9 and fv

    I recommend you download the latest version of ds9 (the image display tool) directly from the CfA.  (You'll want to rename or move the older versions that came with scisoft and ciao.)   I have had problems with stale versions of ds9 that came bundled with other programs.

    Heasarc's "fv" fits viewer is extremely handy for visualizing and manipulating fits images and fits tables.


    Starlink is a collection of useful astro packages. Dowload here, with errata here.

    Astronomy visualization and "what's up?" software

    There are several great astronomy visualization programs for OS X:
  • Kstars is a "What's up in the night sky?" program, similar to "Starry Night". Get it by installing the "kdeedu" packages in Fink Commander.
  • Celestia is a beautiful "zoom around the universe" program, with a free OS X version.
  • Skycalc, by John Thorstensen, provides almanac, ephemeris, and airmass information, invaluable for planning observing runs. The new version is in Java, is graphical, and runs on all major platforms.   Here's a walk-through from AstroBetter.   Alternatively, you can download the "classic" shell version.

    Other Useful Programs

    Firefox: a better web browser

    Apple's "Safari" browser is the default, but you may prefer Mozilla's open-source Firefox for OS X.

    If you want to screen out annoying ads and flash animations, open Firefox, and under the menu "Tools>Extensions", install "Adblock" and "Flashblock".

    Spreadsheets, Databases, and Word Processing

    For a free OS X implementation of Open Office, try NeoOffice.

    Alternatively, buy "iWork" at your local Apple store (remember the educational discount!), which includes Keynote (presentation), Numbers (spreadsheets), and Pages (word processing.)

    Or you could pay Microsoft for Office.   But I can't condone that sort of thing.

    Desktop Pagers

    How can you work without multiple desktops, especially if you have a small screen?  You need an organizing "pager". This is built into 10.5, in a program named "Spaces".

    If you have an earlier version of OSX, or like me you hate Spaces, you can add a pager.   I like You Control: Desktops, which costs $30, and works great for 10.5 and earlier, but is not compatable with 10.6.

    For old apples with PowerPC (non-Intel) chips, try the free tool called Desktop Manager, also available (here.) A more fully-featured alternative, for $40, is Code Tek's Virtual Desktop Pro.  Unfortunately, neither program works properly with Mac Intel machines yet, (though an older version of Desktop Manager, v0.5.0 works decently.) Once you've selected a Pager and saved it to /Applications, you may want it to auto-start when you log in. To do this, got to System Preferences, Accounts, Login Items, and add drag the Pager icon from /Applications onto your login list.

    If you're paranoid, quit the pager before connecting to an LCD projector to deliver a presentation (select Quit from the pager menu.) 

    Fetchers for the Astronomy Picture of the Day

    Several tools will download the APOD for you, and set it as your backdrop. Try Auto APOD (power-pc only), APOD Grabber, or write a simple script to fetch and resize it.

    GIMP, the poor man's photoshop

    Fink's version of Gimp does work, but I recommend the OS X--friendlier version Gimp.app.   Other ports are here.

  • The venerable XV image viewer

    A fast way to crop, invert, and browse images. Binary here.

    How to install IDL

    Download IDL 7 from www.ittvis.com.

    Add the following two lines to your .bashrc (or the equivalent if you use a different shell):

    source /Applications/itt/idl/bin/idl_setup.bash

    export IDL_PATH="+/User/me/idl/:<IDL_DEFAULT>"

    (This assumes that /Applications/itt/ is the likely default installation path, and that "User/me/idl" is your private scripts directory. The + is required (for a recursion), and IDL_DEFAULT ensures idl can find the standard idl libraries.)

    Then run the License Wizard. If it fails with a write permission error, cd to /Applications/itt/idl70/bin and run 'sudo lmgrd'.

    IDL may have trouble under leopard recognizing mouse events in plot windows. If so, try setting 'Click-through Inactive Windows' under X11 preferences.

    Backup your data!

    There are many ways to back up your precious data.   If you have 10.5, you can use the built-in apple program Time Machine for incremental backups.

    If you don't have 10.5, or don't trust Time Machine, you have several options.   I'm a fan of Carbon Copy Cloner, a freeware program that schedules incremental rsync backups.   CCC can also backup automatically whenever a specified external drive is plugged in.

    Key Tips

    Working remotely

    You'll want to log into remote computers and display windows on your apple.   To do this, in an X11 term, start a secure ssh shell like this: "ssh -Y hmilk@camera.castro.edu".  

    (The "-Y" flag means "allow and trust X11 forwarding", so it will remotely display windows and graphics.   Some linux flavors have -Y or -X by default, but in OS X you need to specify -Y.)

    Set applications to auto-start when you log in

    Certain applications (e.g. Desktop Manager, X11) are so handy that you may want OS X to start them automatically when you log in. To set this up, go to System Preferences, Accounts, Login Items, and add applications.

    Multi-button mouse functionality

    OS X is easier to use if you have a 3-button mouse (right- and center-clicking brings up options menus, just like you'd expect.)   Also, most X11 programs assume 3 buttons. For desktops, just add a 3-button USB or Bluetooth mouse, or use the now-standard Mighty Mouse, then do the following: select "Emulate 3 buttom mouse" from the X11 Preferences menu; go to System Preferences>Keyboard \& Mouse and fuss with the button choices.

    Laptop users -- sorry, but Apple laptops only have single-button trackpads (Why, Apple, why?)   Work-arounds to get 3-button functionality:

    Improve your Dock

    Unlink dippy applications:   Everything in the Dock is a link, not an actual program.   So feel free to remove seldom-used programs from the Dock by dragging them off the Dock. You can always find those programs later with Finder.

    Link useful applications:   Add to the Dock new programs like X11, Firefox, Fink Commander, and OpenOffice. To do this, drag their icons from the Finder to the Dock. Also, you may want to add "Applications/Utilities/Activity Monitor" to your dock; it's a graphical version of the unix command "top".

    X11 and account setup tips

    Connect your laptop to an LCD projector

    Follow this sequence in order:
  • Those little white cord adapters that came with your apple laptop? Bring them!
  • On your laptop, go to "System Preferences > Displays".
  • Connect the little adapter to the projector cord.
  • THEN, plug the adapter into your computer. (The order of operations matters.)
  • If the projector doesn't automatically show the image, hit the "Detect Displays" button in the "Displays" menu. When new windows pop up, be SURE to check the box that says "Mirror Displays"! This makes sure projector and laptop show the same information.
  • If the Dock disappears, just click on the Apple symbol at the upper-left, and get to System Prefs > Displays from there.
  • Experienced presenters often turn "mirror displays" off, and use "Presenter Notes" in Keynote or Powerpoint.   In this mode, your laptop screen can display a timer, clock, and notes, while the projecter shows only the slide.   This is a great way to avoid reading slides to your audience, but ensure you'll remember what you wanted to say.

    Get protective sleeve for your laptop.

    I like Shinza.com's "Zeroshock" protective sleeves.    They use a high-grade foam that compresses slowly, reducing the acceleration imparted to your computer when you bang it around.

    Other references:

    If you can't find what you need here, try these resources:

    High Performance Computing for OS X.   Compilers and optimization, including a working binary of g77 (fortran compiler) for MacIntels.
    Edmondson's Mac OS X for Astrophysicists (includes lots of X11 customization tips.)
    Ridge's Professional Astronomy Software for Mac OSX.
    Mandavi's OS X page for Astronomy. Includes advice on sExtractor, skycalc, and mozilla.
    Mac Singularity website, with IRAF and IDL advice. Includes the "IRAF button" and the Mac Astronomers Wiki.
    Kelle Cruz's tips and tricks.
    IRAF.net, which includes bug reports on macs.
    The book "Mac OS X Tiger Edition: The Missing Manual" is a great introduction to OS X.

    Or try a Yahoo web search.

    Last Words:

    This page was written by Dr. Jane Rigby, an astronomer at the Carnegie Observatories.   Please email Jane at if you: a) found this page useful, b) found an error in this page, or c) have a tip to add.   If you have technical problems, please don't email Jane -- ask the interwebs, your friends, your sysadmin, Apple's tech support, or pray to Lord Zorkon.

    Copyright Jane Rigby.
    Page created 14 January 2005.  Last updated July 2010.
    "Apple", "OS X", and "Powerbook" are trademarks of Apple Computers.
    This page is not endorsed by Apple, OCIW, or Lord Zorkon.

    Astronomers Emeric Le Floc'h, Casey Papovich, Richard Cool, Eric Mamajek, Wayne Schlingman, Karen Knierman, Martin Elvis, and Phil Massey have certified that this page is not entirely useless.

    Astronomers Richard Cool, Colin Snodgrass, Phil Massey, Christopher Willmer, Ivo Labbe, Adam Ginsburg, Sara Ellison, and George Becker have suggested useful tips & corrections.   Please send yours!