Erik Tollerud, Oct 2013
As part of some upcoming work reducing pODI data, I needed to (re)install a number of different photometry tools. It turns out this is non-trivial on a recent Mac, so I’m posting here what I found to work, in the hopes that others may find it useful.
The specific tools I needed are:
The first three are all freely avaiable from their web sites, but DAOPHOT is a bit different. You have to e-mail the author (Peter Stetson) and ask him for a copy (and sign an agreement that you won’t re-distribute the code). I find this form of licensing a bit curious given the wealth of open source astronomy software already out there, but presumably there’s some reason for it.
While the first three have library dependencies needed before they will compile, they’re all open source libraries. I’ve found macports to be one of the best tools for managing such libraries, as it’s kept very up-to-date and is the easiest to use. Others may prefer alternatives like fink or homebrew, but I’m not sure whether all the dependencies are available on them. So these instructions will assume you are using macports. See the macports web site for instructions on how to get macports working. Note that it will require C compilers, which you can get most easily via the Xcode command line tools. (You can get the command line tools either by getting Xcode and installing them via the prompts, or going directly to apple’s developer download site.)
SExtrator, SWarp, and SCAMP
It turns out that sextractor, swarp, and scamp are all available on macports, but scamp doesn’t actually compile correctly. So start by doing this in a terminal:
sudo port install sextractor swarp
You may not have to add “sudo” at the beginning of those commands, depending on how your permissions are set up, but the default way requires it. Macports will now install the “fftw-3” and “atlas” libraries (ATLAS can take a verty long time to build so be patient), and then install sextractor and swarp. At least on OS X 10.8 with my 2011 Macbook Pro, this just worked without any problems or modifications needed, and you can now use sextractor or swarp by just running “sex” or “swarp” anywhere.
One important caveat with extractor: the macports version installs the code, but does *not* include some of the files necessary to actually run SExtractor, like the convolution filters or default parameter files. An easy way to get these is to just download the source code and look in the “config” directory.
SCAMP may be a bit trickier, though. Start off by trying
sudo port install scamp
This will install all of scamp’s dependencies, and then try to compile and install scamp. The last time I tried it, all the dependencies were fine, but scamp’s compilation failed. It’s possible that in the future this will get straightened out (especially if I get around to figuring out how to fixing the scamp port file…), but in the meantime you’ll need to compile by hand. Instructions for that are below.
It turns out the latest released version of scamp (from 2010…) isn’t compatible with recent versions of one of the libraries it depends on. Fortunately, the latest developer version of scamp does work. You can get it by accessing the scamp subversion repository, or if you don’t know how to do that (or don’t want to), this link gets you a tarball of the latest version – just untar it into its own directory. Once you’ve got that, cd into the SCAMP source code directory and run this command:
./configure --with-fftw-incdir=/opt/local/include --with-fftw-libdir=/opt/local/lib --with-atlas-libdir=/opt/local/lib --with-atlas-incdir=/opt/local/include --enable-threads
That will configure SCAMP to use all the dependencies that macports installed – for some reason SCAMP’s configuration system isn’t smart enough to find it on its own. After this, just do:
sudo make install
This should compile SCAMP and then install it in your /usr/local/ directory. After that, you should be able to run it at the command line by typing “scamp”.
So at this point, all three of the S-something utilities should be working. That leaves only DAOPHOT.
To compile DAOPHOT, you’ll need a fortran 77 compiler. This is harder than you might hope, because Apple does not provide such a compiler. The easiest bet is probably to use macports. It’s not obvious until you install them, but any of the macports GCC compilers include gfortran – I got it to work with gcc48, but others may well also work. An alternative is to install a compiler made by the HPC Mac OS X group, and a nice guide to installing these compilers can be found at this web site.
You also need the “cfitsio” library. It’s on macports, so you can install it by typing
sudo port install cfitsio
As I mentioned above, you get DAOPHOT’s source code by e-mailing Peter Stetson, and he’ll send you the info to get the tarball. Untar it into a directory, and cd into that directory. You’ll see there’s a “Makefile.mac” file there… It doesn’t work out-of-the-box, but with some modification it will. So first do
cp Makefile.mac Makefile
and open “Makefile” in your favorite text editor. You’ll need to change the “F77” line at the top to point your fortran compiler, add “-arch x86_64” in the front of the “FFLAGS” and “LFLAGS” variables, and add “-L/opt/local/lib” to “HOSTLIBS” (or wherever you put cfitsio, if you didn’t use macports). Alternatively, you can just copy the “Makefile” section at the bottom of this post, which has all these modifications already in.
Now try doing
that should run without errors, and you should now see a binary called “daophot.” Try running it my typing “./daophot” – if it executes without complaint, then it compiled successfully.
One possible snag: you might also need to remove the “-Wsurprising,–defsys,mem_=0” part from “LFLAGS” in the makefile, depending on exactly which fortran compiler you have. You’ll know right away because the compiler will fail complaining about that option. Just delete it from the makefile, try compiling again, and you should be set.
At this point you can copy the “daophot” file to somewhere on your path – “/usr/local/bin” is the conventional place, or the other convention is to use “~/bin” (where “~” is your home directory) if you add it to your PATH environment variable. Just repeat the process with any other daophot sub-commands you need. Alternatively, if you use the makefile below, you can slightly speed things up by doing “make all” – that will build all of the daophot subcommands. Then “make install” will put them in “~/bin” (or you can change the destination by changing the “INSTALL_TO” variable in the Makefile).
Alright, that should do it! You are now ready to start reducing data on your mac.
F77 = gfortran FFLAGS = -arch x86_64 -c -O2 LFLAGS = -arch x86_64 -O2 -Wall -Wsurprising,--defsym,mem_=0 -fbounds-check HOSTLIBS = -L/opt/local/lib -L/usr/local/lib -L/usr/lib -lm -lgcc FITLIB = -lcfitsio INSTALL_TO = $(HOME)/bin EXECUTABLES = daophot allstar daomaster daomatch montage2 allframe daogrow # RULES: .SUFFIXES: .o .f .f.o: $(F77) $(FFLAGS) $< all: $(EXECUTABLES) install: all cp $(EXECUTABLES) $(INSTALL_TO) .PHONY : clean clean: rm -f $(EXECUTABLES) rm -f *.o daophot: daophot.o pckpsf.o find.o fotometry.o psf.o peak.o nstar.o fudge.o addstar.o substar.o group.o sort.o lnxsubs.o fitsubs.o iosubs.o mathsubs.o $(F77) $(LFLAGS) -o daophot daophot.o pckpsf.o find.o fotometry.o psf.o peak.o nstar.o fudge.o addstar.o substar.o group.o sort.o lnxsubs.o fitsubs.o iosubs.o mathsubs.o $(HOSTLIBS) $(FITLIB) allstar: allstar.o allstsubs.o lnxsubs.o iosubs.o mathsubs.o fitsubs.o $(F77) $(LFLAGS) -o allstar allstar.o allstsubs.o lnxsubs.o iosubs.o mathsubs.o fitsubs.o $(HOSTLIBS) $(FITLIB) daomaster: daomaster.o iosubs.o mathsubs.o lnxsubs.o dummysm.o $(F77) $(LFLAGS) -o daomaster daomaster.o iosubs.o mathsubs.o lnxsubs.o dummysm.o daomatch: daomatch.o iosubs.o mathsubs.o lnxsubs.o $(F77) $(LFLAGS) -o daomatch daomatch.o iosubs.o mathsubs.o lnxsubs.o montage2: montage2.o mathsubs.o iosubs.o lnxsubs.o fitsubs.o $(F77) $(LFLAGS) -o montage2 montage2.o mathsubs.o iosubs.o lnxsubs.o fitsubs.o $(HOSTLIBS) $(FITLIB) allframe: allframe.o fitsubs.o lnxsubs.o iosubs.o mathsubs.o $(F77) $(LFLAGS) -o allframe allframe.o fitsubs.o lnxsubs.o iosubs.o mathsubs.o $(HOSTLIBS) $(FITLIB) daogrow: daogrow.o iosubs.o mathsubs.o lnxsubs.o $(F77) $(LFLAGS) -o daogrow daogrow.o iosubs.o mathsubs.o lnxsubs.o