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.

Astronomy · Note

Notes on PdBI/IRAM data reduction – I. Get Data Ready

This is a personal note about PdBI/IRAM spectral data reduction. The steps will start from transferring the raw data to the local hard-drive, organising raw data, calibration with \tt{CLIC/GILDAS} to the further data reduction with \tt{MAPPING/GILDAS} procedure. The final stage will be mapping and acquire the spectra. If you have any questions or comments, please feeling free to contact me.

PART I: Get Data Ready (Get proj, etc.)

Now, let’s take a high-z observation project for example. Assuming we have observed a molecular line of a high-z galaxy in 2012. So our project name (starting from 2014, a new proposal system called PMS took over the old one, the project naming system has also been changed) would be:


W is 2012, V is for 2011 and X is for 2013, etc. I guess there’s a loop of the letters starts from a certain date; 0 is for the target index in this proposal, it could be WAB4, WBB4 and WCB4, …; B4 is the project index, 16th, hexadecimal.
And also we have an observation project name containing the data information, and it could be:


Just as the proposed project code X represents the year “2013”, C stands for December, the hexadecimal form of the month; 12: the date 12th.
Thus the raw data file of one observation will be like this:


for the source, WAB4 observed on Dec 12th, 2013. IPB file contains the data scan by scan, and OBS & RDI files store the observation parameters.

Now we need to download the data from IRAM data centre to the computers that we perform data reduction (usually at IRAM-HQ) by using:

getproj -p w0b4 -s wab4

The data (subproject wab4 from project w0b4) will be downloaded to the “~/tmp/DATA” directory (actually, it’s a link to the “/scratch/DATA” directory).
You will need to create several directories for data calibration. Usually, they will be generated automatically after getting the project, the calibration directory is under ~/calib, such as


And also there is a ~/reports directory containing some very useful notes from DoA for performing better calibration, and a ~/map for storing the results from your further data analysis.
After all, these get ready, you can now move on to the data calibration.

Astronomy · computer · Linux · Note


有时候你想在一个目录的所有子目录下批量建立文件夹,并且批量的运行这些子目录内新建立好的文件夹内的 IDL 程序,以下是一种可能的解决途径,如果你有更好的方法,欢迎告诉我

Here are the things I want to do:

  1.  I have a data folder containing many sources, like Arp220, NGC981, etc.. Each of them possesses a folder under the whole data folder (./source/Arp220, ./source/NGC891, …). I want to create a subfolder named “plot” under each sources folder, e.g., ./source/Arp220/plot.
  2. And then I want to copy the IDL routine to each “plot” folder I just created and run all the PRO routines at one time.

Here is a bash script being able to do such things:

for i in $(ls -d */); do mkdir -p $i/'plot'; done
for i in $(ls -d */); do cp ./ $i/'plot'/; done
for i in $(ls -d */); do cd $PWD/$i/'plot';idl -e ".r ./"; cd ../.. ; done

The first line means creating a “plot” folder under all the subfolders under you present folder. And the next line is to copy the IDL routine ( to each “plot” folder you created. The last line runs all the IDL routines.


find ./* -type f|grep X|while read file; do rm "$file"; done

比如你要删除“./you suck/arXiv.pdf“这种文件。上面那句话中 -type f|grep X|while read file 是为了保证有空格的目录也可以被写入到一个变量里面


find ./* -type f -name "*X*" -exec rm {} \;
Astronomy · computer · Internet · Linux · Note

Obfuscated ssh Client under Linux

SSH is a powerful tool not only for astronomers. We often use it to download observation data from the observatory’s server or run some complicated programs on remote (overseas) servers. But for the reason as we all know, the SSH tunnels are always being obstructed. So we need some technique to get over such obstruction. Therefore, the obfuscated SSH turns out to be a sufficient method.

I will describe how to use obfuscated SSH_TUNNEL under Linux as below:
(Original Code: Here)


cd ./brl-obfuscated*
./configure  --prefix=/usr/local/newssh --sysconfdir=/etc/newssh
make install

Then you need to configure the ssh server following the guide here.

Then use this to run the ssh client:

/usr/local/newssh/bin/ssh -N -v -Z ObfuscateKeyWord -p ***** username@hostname -D

There are 4 parameters you need to specify: “ObfuscateKeyWord” is the obfuscated keyword you set in the configuration file (sshd_config) of the server, “*****” is the ssh server port number, “username” and “hostname” are as the name described.