Mac OS 10.6 (Snow Leopard) for astronomers

This is an update of my surprisingly popular Leopard page (which at one point accounted for >80% of the traffic to my website). This version probably won't be as pretty, but hopefully it should be useful. As before you should note that several other astronomers have Mac pages, most of which are better than this one. Of particular interest is the AstroBetter blog, which contains many useful tips.
Disclaimer: my new Mac is a MacBook Pro, running OS X 10.6.4 (which came pre-installed). I make no guarantees regarding cross-version compatibility.
Update: After a catastrophic disk failure (and re-install of everything) I now have 10.6.5, and also updated versions of some of the things listed below.
Update 2: As of January 2011, I'm now running 10.6.6. Major change is the addition of the OS X App Store. I haven't used it much yet, but the fact that you can now buy the components of iLife and iWork separately looks very useful. (Also, a lot of Apple software is much cheaper from the App Store than it is from anywhere else.)

Basics

If you're new to Macs, just fire it up and follow the instructions. Once you're logged in you should be able to follow most of the instructions below.

If you're upgrading to a new Mac from an older one, you will be prompted to copy data from the old computer during the intial start-up phase (assuming you can find a suitable FireWire cable, which is not trivial - they changed the standard ports on the newest Macs from FW400 to FW800). I did this last time, but gave it a miss this time. Pros of doing it are that it's very simple and imports everything; cons are that you'll probably have to spend some time deleting stuff you didn't need/want (like the SSH cache, lots of dead aliases, etc.). Pros of not doing it are that you get a ``clean'' new account, and only need to copy what you want; cons are that some very useful stuff (like your Mail history, saved passwords, bookmarks, etc.) isn't imported this way. I'm honestly not sure which I prefer.

Firewall

This is turned off by default: go to Applications -> Security to switch it on.

Time Machine & backups

Time Machine is Apple's automated backup utility, first implemented in 10.5. It's much more than a standard backup utility though - it keeps a record of all your file changes, so you can recover any old revision of any file. It's designed to allow easy recovery of accidentally deleted files, and seems to do its job well (and the interface looks cool). I'm a bit equivocal about it, mostly because the historical backup tends to swallow up vast amounts of space on an external drive, but these days I use it anyway. However, if you want more control I can also recommend the excellent iBackup. It's essentially an rsync client, but it allows you to set up multiple backup profiles - for example, I have a one that backs up my current work to my iPod when I'm travelling.

Unix environment: X11/Xquartz

The big advantage of Macs for astronomers is the fact that they're a Unix(ish) system at heart. To get to the Unix base you need to run an X11 application: the official Apple one installed by default in /Applications/Utilities/, but I prefer the semi-official XQuartz version (which is maintained & updated slightly more frequently). If you go with XQuartz be sure to download the correct version: the Leopard version won't work under Snow Leopard, and vice versa. I currently have v2.6.0.

The basic X11 environment is fine, but if you actually want to do anything you'll need to install some Unix software, as the default installation is very limited. The OS X install CDs contain an optional package known as XCode (you can also download it) - installing this gives you a C compiler (Apple's version of gcc) and a number of other important things. Other things, such as Fortran compilers, need to be installed separately (see below).

Unix basics

An admistrator account on the Mac gives you administrator privileges in Unix (sudo), but not true root access (su) - the root user is disabled by default. If you want to enable root access (you probably don't) open the Directory Utility, which has now moved to /System/Library/CoreServices/. Click the padlock to unlock it, then go to Edit -> Enable root user. Pick a secure password...

The default shell is bash. If, like me, you prefer tcsh, go to System Preferences -> Accounts. Click the padlock to make changes, then Control-Click on the user whose shell you want to change. Select "Advanced Options", and change the login shell as desired. You have to log out and log back in again in order for the change to take effect.

Printers

Getting printers to work properly in my office requires telling the Mac where to look for the local print server, which in turns involves creating the file /etc/cups/client.conf. Unfortunately, doing that means that you won't be able to see other printers (at home, for example), so I have an alias set up to create/delete the file as needed. (Editing anything in /etc/cups requires root or administrator access, so you need to sudo the commands.)

TeX

My preferred way to run (La)TeX is the excellent MacTeX. Trivial to install, and comes with all the bells and whistles (including the TeXShop front-end and the Keynote-compatible LaTeXIT utility).

Emacs

Several options exist here, all simple to install. I used to use this one, but it seems to be a bit unstable under Snow Leopard. I now use this; others prefer Aquamacs. Personal preference, really.

iWork

Apple's iWork is invaluable. It's not expensive (especially when compared to MS Office): under £100, and significantly cheaper if you can get an educational discount. The current version comes with Keynote, Pages and Numbers, and it's worth the price for Keynote alone. (Pages can read & write MS Word files too, if you're so inclined, but the Word compatibility can be a bit hit-and-miss.)

Update: As of January 2011, you can now buy the individual components of iWork separately though the App Store (if you've upgraded to OS X 10.6.6). Keynote is only £8.99!

MacPorts

MacPorts is by far the easiest way to maintain a standard library of Unix software on a Mac. (Fink used to be very similar, but it seems to be lacking in support now. You can install it, but most of the packages aren't available under 10.6.) Follow the instructions and it should be fairly straightforward - the major things I have installed are the GNU compiler collection (the gcc package, which includes gcc, g++, gfortran and others), ghostscript & gv. (To make sure I use the right versions, I've aliased "gcc" and "gfortran" to "gcc-mp-4.4" and "gfortran-mp-4.4" respectively.) Note that this isn't a quick process though - allow at least an hour, if not two.

Plotting packages, etc.

By all accounts, the preferred option for observers is simply to install ESO's Scisoft package, which includes IRAF, MIDAS, Python, SuperMongo, PGPlot and lots more. However, I didn't really need or want all of that, so instead I just went for a pick-and-choose appoach for the packages I need.

PGPlot

I'm enough of a dinosaur that I still use PGPlot for virtually all my plotting. It used to be avaialble under Fink, but there's no working Fink version for 10.6 so now you have to download and install it manually. Following the installation instructions on the website gets you almost all of the way there, but I found a few variations to be necessary.
  • When you run makemake to create the Makefile, choose the "bsd" and "g77_gcc" options.
  • Once it has created the Makefile, open it up and manually change the compiler from g77 to gfortran. You also need to remove (comment out) a driver dependency line - the line starting "pndriv.o: ..." isn't needed, and causes the build to crash on most modern systems. (It's line 874 in my Makefile.)
  • Compile the code by typing make in the PGPlot directory, and install the optional C binding if you want to. It's also a good idea to delete the grfont.dat file and create a new one by typing make grfont.dat. (The default file can cause problems on 64-bit machines.) If it has worked, the various demo programs will run properly.

    Once you've got here, there are a few things that still need to be done in order to run the code:

  • Set the PGPLOT_DIR environment variable. I have
    setenv PGPLOT_DIR /(PGPlot directory path)/pgplot/
    in my .tcshrc file. (You may want the bash equivalent.)
  • Work out what set of flags and links is needed to compile PGPlot scripts. The easiest way to do this is copy-and-paste from the Makefile (which compiles the demo scripts). I find that this works for me:
    gfortran prog.f90 -o prog.e -L$PGPLOT_DIR/ -lpgplot -lpng -lz -L/usr/X11R6/lib -lX11 -lm
  • Depending on your set-up, you may need to add the PGPlot source directory to the LD_LIBRARY_PATH environment variable.

    That works for Fortran code. If (like me) you use C, there are a couple of extra steps. You need to include the PGPlot header file at the top of your code (#include "/(PGPlot directory path)/pgplot/cpgplot.h"), and you also have to do a two-step compiltion process. First, compile the C code:
    gcc -c prog.c
    then compile the executable (as above, but with the -lcpgplot link added):
    gfortran prog.o -o prog.e -L$PGPLOT_DIR/ -lpgplot -lcpgplot -lpng -lz -L/usr/X11R6/lib -lX11 -lm
    I have a short script in my home directory that executes the latter two commands, and then cleans up by removing the prog.o file. An alias in my .tcshrc file then allows me to compile using a single command. You may also want to change the default graphics device by setting the PGPLOT_DEV environment variable to the device of your choice (/xs, /ps, etc. - the default is /null).

    Fugu

    Fugu is a GUI front end for SCP, SSH and SFTP - very useful when working remotely.

    Gimp

    Gimp can be installed through MacPorts (for command-line access), but I prefer the native OS X version, available here.

    Papers

    Papers, from Mekentosj, is a really nice tool for organising a PDF library. It's linked into ADS and arXiv (and lots of other non-astromomy databases), and markets itself as "iTunes for your PDF files". It's shareware, but well worth the money. (Incidentally, "Mekentosj" is a much funnier name if you speak a little Dutch.)

    Splash

    As a regular SPH user I can't speak highly enough of Dan Price's Splash package, which makes rendering SPH data wonderfully simple. (Among other things, I used Splash to make the beautiful image of a fragmenting disc that adorns my homepage.) It's pretty smooth to set up these days too: I used the SYSTEM=gfortran_macosx option in the Makefile. The only modifications I had to make were to make sure that the fortran compiler was correctly identified, and to change the PGPLOT library variable to that given above. After that it compiled and worked without any problems.

    IDL

    Installing IDL is trivial, but getting the license manager to work properly is a bit of a fiddle. (I've got a node-locked, single-user license for IDL v7.1.) Two speficic problems arise. First, when the installer program runs the license wizard it returns a permissions error - it is unable to put the license manager daemon in /Library/StartupItems/. The way around this is to re-run the license manager as root (note that sudo isn't good enough). Enable the root user if you haven't already done so (see above), then log in on the command line as root. Run the license wizard again - it's /bin/ittlicense in the IDL directory (usually /Applications/itt/idlxx/, where xx is the version number). This should create a directory /Library/StartupItems/IDL_LMGRD/, which contains an AppleScript (.plist) and the license daemon executable. The license manager should now run automatically on start-up.

    The second problem I came across is that the license manager sometimes crashes because of a host-name mismatch. My machine allocates the Unix host name ($HOST in tcsh) dynamically from the DHCP connection, and if the host name doesn't match the one in in the IDL license file the license manager fails. The license file is found in /Applications/itt/license/license.dat; the host name is the first entry on the line that begins SERVER. The solution is to modify the host name in the license file: I found that changing it to 127.0.0.1 (the loopback IP address) works; apparently you can also change it to this_host if you want it to pick up the dynamically-allocated host name.

    One minor bug I still haven't found a way around is an apparent clash between the IDL license manager and the new Snow Leopard firewall. Whenever I start up my machine I get prompted to either "Deny" or "Allow" the idl_lmgrd process to breach the firewall, despite a) it already being listed as a firewall exemption in my Security settings, and b) the license manager not needing to breach the firewall anyway (it works fine even when off-line). IDL works whichever option I click, but it's a bit weird. Any news of a fix would be welcome.




    More to be added in due course. Maybe.
  • Return to homepage.


    © Richard Alexander. Last updated January 2011. Site Meter