Notes on installation of TiRiFiC on MacOS

Here is a small note on installing the package TiRiFiC on MacOS 10.12.6. 

Here is a short introduction from its official webpage:

Tilted Ring Fitting Code (TiRiFiC) is a computer program to construct simulated (high-resolution) astronomical spectroscopic 3d-observations (data cubes) of simple kinematical- and morphological models of rotating (galactic) disks. It is possible to automatically optimise the parametrisations of constructed model disks to fit spectroscopic (3d-) observations via a χ2 minimisation. TiRiFiC depends on several free non-standard libraries, but is a standalone routine (after compilation). In former development stages, TiRiFiC has been implemented as a task in the Groningen Image Processing System (GIPSY) software package. From version 2.2.0 on, the GIPSY implementation is not longer supported and will not be installed. The source code of TiRiFiC can be downloaded from this web page.

The original installation guide can be found here: Installation_Guide. However, I notice that this guide was written for Linux specifically. On Ubuntu, things are quite easy. But under MacOS/MacOSX, the situation can be a bit different. Because the official website does not provide a detailed guide for Mac users. I put a small note here for general (to be honest, mostly my personal note) interests.

As said on their installation guide page, some dependencies are needed before installation: fftw-3, wcs, gsl, gcc, libreadline, pgplot, openmp, doxygen. For Mac users, the aforementioned packages can be easily installed using MacPorts. Since I am using MacPorts, I will just show the cases for that below. Taking fftw-3 for example, what you need to do is just to use 

sudo port search fftw-3

And the results will pop-up, just copy the names of the packages, and then use

sudo port install fftw-3

to install the package. It’s the same for all the rest packages.

After installation of all the dependencies, one will need to download the latest version of the package TiRiFiC from the GitHub page Then unzip the file if you downloaded the zip from GitHub. On the official installation guide page of TiRiFiC, it’s said you need to compile qfits first, but that seems only valid for older versions. So the proper step now is to edit the settings file. This file is the core for a successful compilation of the entire package.
Unfortunately, the template is not MacOS/MacOSX friendly. After several times experiment, I found the right way of editing it. If you are using Macports, the file should be like this:

# This part has to be edited by the user. tirific depends on the
# existence of several external libraries, which have to be provided
# by the user. Those libraries are non-standard, but quite common,
# such that you can easily install them. We leave it to you to install
# the libraries in a convenient form.
# Default number of disks, can be changed at runtime by the user
# Compile with possibility to do a primary beam correction (YES/NO)
# CC is the compiler to use
CC = gcc
# CFLAGS is the flags to use the compiler with
CFLAGS = -Wall -pedantic -O4 -I/opt/local/include/malloc
# The operating system (At the moment chose between MAC_OS_X and LINUX
# Compile with open mp (YES/NO)? Note that this means that fftw is optimally compiled with the --enable-openmp option (personally I used the Ubuntu synaptic version, which seems to work)
# Opem MP compiler options
OPENMPCOMP = -fopenmp
# Open MP linker options
OPENMPLIB = -fopenmp
# external directories containing include files
# This is the standard include 
STDDIR = /opt/local/include/
# This is the math library include file and most probably at this location
MATHDIR = /usr/include/
# This is the fftw include directory. It should contain the file fftw3.h
FFTWDIR = /opt/local/include/
# This is the position of the parent directory of the gsl directory
GSLDIR = /opt/local/include/gsl/
# This is the directory in which the wcs include files reside
WCSDIR = /opt/local/include/wcslib
# Pgplot directory
PGPDIR = /opt/local/include/
# X11 Lib
X11LIB = /opt/local/lib/
# external libraries
# The math library
# The fftw3f library, alternatively
# -Ldirectory_in_which_the_file_libfftw3f.a_is -lfftw3f
FFTWLIB = -L/opt/local/lib/ -lfftw3f -lfftw3
# laquaterm
AQUATERMLIB = -L/opt/local/lib/ -lfftw3f -lfftw3
# The gsl library linker flags-, alternatively
GSLLIB = -L$(GSLDIR) -lgsl -lgslcblas
# The wcs library
WCSLIB = -L$(WCSDIR) -lwcs
# Pgplot linker flags, for Mac OS, maybe -L$(PGPDIR) -lcpgplot -lpgplot $(X11LIB) -lpng -laquaterm -Wl,-framework -Wl,Foundation  -W1,-AppKit 
PGPLIB = -L$(PGPDIR) -lcpgplot -lpgplot -L$(X11LIB) -lpng -Wl,-framework -Wl,Foundation  
# Readline library
READLINELIB= -lreadline

After editing this file, you can now type “make” to compile the packages. It will first compile qfits and then the tirific packages. In the end, you will see a binary file named “tirific” under the bin directory. Now you can use this binary to run the modelling. See an example here:

Now you would like to make your binary executable everywhere. This can be done simply by putting the binary path in your ~/.profile file, namely adding

export PATH=$PATH:/Users/your_path_of_the_binray/tirific-master/bin

That’s it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.