Loading...
 
(Cached)

Setup a New Mac for Astronomy

Getting Started

If you're a scientist with a new Apple computer, read on. This page assumes you want to write scripts, reduce data, plot results, work with LaTeX, and give presentations, among other handy things. This is not a tutorial.

As a brief introduction: Mac's operating system is called "OS X" or now "macOS". It is a version of BSD Unix with a fancy graphical interface. Because unix is the engine, you can use your favorite linux tools, plus prettier programs written for Macs.

Many of these apps are large files and will take a while to download. You should be on a good internet connection and allow at least a couple hours to complete the entire setup.

Find out which version of OS X you have. Click the apple in the upper lefthand corner of your screen, and choose "About This Mac."

Change Shell - bash or tsch

Default is bash and is recommended.

To change your default shell, look under "System Preferences" and open the "Users & Groups" panel. If the padlock icon in the lower left corner is locked, click on it and authenticate. Then right click (or Ctrl-click, or two-finger tap) on your user account in the account list on the left hand side. Select the "Advanced Options" option when it appears. Change your "Login Shell" setting by selecting or typing "/bin/tcsh". Don't change anything else in here, these are dangerous settings. 

Testing:  Start up the "Terminal" application, and type "echo $SHELL". A full logout / login or system reboot may be needed for the shell change to register in Xquartz / X11. Speaking of which...

XQuartz & X11

X11 is the standard linux graphical window environment and most astronomical software (and anything written for li/unix) requires X11. Terminal is built-in and will work for basic commands, but X11 is required for graphics. The XQuartz project is an open-source effort to develop a version of the X.Org X Window System that runs on OS X.

OS 10.8, 10.9, 10.12: Download XQuartz  (~70 MB)

OS 10.7 and earlier: X11 is already pre-installed. You may wish to install Xquartz anyway (link above). 

To initiate an X11 session: Launch XQuartz from Applications/Utilities. You will then be able to launch xterm instances from the "Applications" menu. 

 

XCode: Command Line Tools + Compilers

XCode includes the standard C compiler (gcc) and command line tools (e.g., make, tar, gzip, vi) that are necessary so that you can use the terminal's full suite of commands as you would in a linux enivornment.

OS X 10.7, 10.8, 10.9, 10.12:

  • Install XCode (1.5 GB) from the App Store. (The App Store should be available as an icon in your Dock.)
  • Install Command Line Tools
    • 10.9: Command Line > xcode-select --install
    • 10.8:
      • Launch XCode from Applications
      • Go to XCode "Preferences > Downloads > Components" and install the "Command Line Tools."  
      • Restart your Mac.
    • 10.12
      • xcode-select --install
  • Agree to Xcode license in Terminal:  sudo xcodebuild -license
  • Additional help with XCode installation and its many uses is here: XCode Support
  • (Optional) Install a standard Fortran compiler, gfortran (38 MB). Download and move to /usr/local/bin

OS X 10.6 and Earlier:

  • Install Apple's binary version of gcc:  Insert the DVD/CD that came with your computer into the drive. Use Finder to search the disk for "XcodeTools.mpkg". Double-click to install. This gives you gcc, Java, and many other developer tools. To learn more, read "About Xcode Tools.pdf" on your install disc.
An alternative to a full XCode install (for those that have an Apple Developer Account) is to only install the command line compilers, without the additional bulk of XCode - look for Apple's own "Command Line Tools for XCode package." You might wish to uninstall XCode first, by typing "sudo /Developer/Library/uninstall-devtools --mode=all" in the Terminal.
 

Test the install by checking the gcc install via the command line.

> which gcc
/usr/bin/gcc
> gcc
i686-apple-darwin11-llvm-gcc-4.2: no input files 

MacPorts

Now would be a good time to install MacPorts (via package) and start downloading and compiling your favorite MacPorts packages. Check out the MacPorts 101 page for an introduction, overview, and usage pointers. Each package gets installed (along with its dependencies) via "sudo port install ", and you can list available packages by search string via "port search ". Here is a list of likely packages: 

  • emacs +x11 (assuming you want the X11-savvy version)
  • aspell and aspell-dict-en
  • texlive
  • R
  • wget and gv and xv and/or gimp
  • xfig and GraphicsMagick

Python

macOS 10.12: We recommend installing Anaconda and AstroConda (optionally with IRAF support).

OS 10.8, 10.9: See the page Installing Scientific Python via the Python4Astronomers group for discussion - they recommend Anaconda. With a little more work and a lot more time (everything compiled from source), you can install Python using MacPorts. Finally, you may want to consider a Ureka install, which includes Python 2.7, the most popular scientific Python tools, pyraf, and IRAF. 

Under the default Ureka setup, you will only have access to the Python tools in a given login session after running the "ur_setup" script. If you want these tools to be available by default, you should call the script from within your .cshrc or equivalent startup file. 

Test your Ureka installation:

> ur_setup
> which python
/Applications/Ureka/variants/common/bin/python
>ipython

In 1: import astropy

IRAF/PyRAF

  • The recommended way to get Python + IRAF + PyRAF (stsci_python) is to install Ureka (see above), an easy-to-install binary distribution from STScI and Gemini.  You can find more information and installation instructions here:  http://ssb.stsci.edu/ureka/.  Click on the link for the latest version (not the development version).
  • IRAF 2.16 is included with Ureka.  Not Recommended (because it's not trivial): install IRAF  from NOAO
  • 10.12: IRAF can be optionally install with AstroConda (only python 2.7).

Other Astronomical Software 

IDL

See the IDL install and setup page.

LaTeX

Via MacPorts: "sudo port install texlive" is the command you're looking for. Further discussion at the LaTex install and setup page

App Store for Astronomy

See the dedicated Mac Apps page for suggestions

DS9 X11 Hints

  • Many, many, many thanks to Jonathan Foster for the leg up on this!
  • Mac native version is updated now (as of June 2015), but if it falls off again the below can give you easier integration with Finder and the like via an Automator app you create yourself after installing DS9 via MacPorts (or whatever).  These instructions assume you installed via MacPorts, so change the first line of the bash snippet to whatever you need. Tested in 10.7.5 and again in 10.9.5.
  1. Launch Automator
  2. Choose a document type as "Application"
  3. Choose an action: Library -> Utilities -> Run Shell Script
  4. At the top, change the "Pass Inputs" type to "as arguments"
  5. Paste the following into the code box (removing whatever's in that box to begin with)
  6. # Change this line to whatever you need to get ds9 (and libs) in the path.
    # This should work for MacPorts. PATH changes you make elsewhere aren't
    #  applied, Automator starts from a blank profile.
    #
    # NOTE: It should just be single square brackets, not doubles.
    Sometimes Wiki formatting things single square brackets are links, so doubles are a defense
     
    export PATH=/opt/local/bin:/opt/local/sbin:$PATH
     
    if [[ $# == 0 ]]; then
        ds9 -cd "~/" &
    else
        ds9 "$@" -cd $(dirname "$1") &
    fi
  7. Save it (File -> Save) somewhere with a nice name (such as DS9) in /Applications (or you can save it somewhere in your home dir and drag it in).
  8. Find a FITS file and open the "Get Info" pane.  Choose to Open with Other... and select the DS9 thing you've saved from step #7, click "Add", then "Change All..." to associate all .FITS files with ds9.
  9. Rejoice!

Additional hint: If you're adapting this to work with some other X11 app, you might need to set other environment variables; Spyder required LANG to be set, otherwise some things (e.g. astropy.io.fits) would fail with a locale error.

Selecting multiple FITS files to open opens them as seperate frames, and launching it via the Applications menu (such as in your dock) opens ds9 by itself. Yay!

Setup printers

  • Configure CUPS for printing from the command line with lpr. (Following commands modify ~/.cups/lpoptions)

    Set default printer:

    lpoptions -d

    Make duplex printing default:

    lpoptions -p -o sides=two-sided-long-edge

Tweaks to Taste

  • Show hidden files
    • 10.9 - in Terminal, execute this command then restart (ref):
      				defaults write com.apple.finder AppleShowAllFiles 1 
    • 10.8 and earlier
      				defaults write com.apple.finder AppleShowAllFiles TRUE
      killall Finder
  • If you're converting to a Mac from a Linux system, the behavior of home, end, pg up, and pg down are probably driving you absolutely insane in a terminal. This blog post fixed it for me, in the terminal at least. (tested in OS X 10.7.x)
  • Swap Control and Caps Lock Key: Easier on the fingers for emacs/unix users.
    • System Preferences -> Keyboard and Mouse -> Keyboard -> Modifier Keys
    • Just switch the two with a drop down box.
  • Still needed in 10.8? Enable X11 Click Through: more info. In a terminal, do the following:
    • >10.5.5 or later:
      				defaults write org.x.X11 wm_click_through -bool true
    • earlier than 10.5.5:
      				defaults write.com.apple.x11 wm_click_through -bool true

Old Stuff (Only relevant for 10.4 or earlier)

  • Install DesktopManager (10.4 Tiger Only) In Tiger, and on PPC macs, this gives you a multiple desktop option. Spaces will replace this in Leopard and I don't think Desktop Manager is Universal. Note : Most of the non-Apple virtual desktop programs are going away, due to Spaces (such as VirtueDesktops).
  • X11 on Leopard 10.5 is very different than on Tiger 10.4 and may cause some issues. Options include installing Tiger's X11 or installing some patches. The latest X11 patches from XDarwin appear to fix the majority of the issues with the possible exception of X11 full screen mode.
  • Setup a 3-button Mouse: This sets up right click and paste with middle mouse button in Terminal/X11.
    • System Preferences -> Keyboard and Mouse -> Mouse
    • Set left button to Primary Button
    • Set middle (scroller) button to Button 3
    • Set right button to Secondary Button
  • Install X11:  If you have OS X 10.4 or earlier, you can install X11 from the DVD or CDs that came with your computer. To do this, insert the install disk and user Finder to search for "X11User.pkg". (Finder is the blue happy face in the Dock.)   Double-click on X11User.pkg, and X11 should install. 
Page last modified on Tuesday 27 of September, 2016 13:53:32 EDT