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.


有时候你想在一个目录的所有子目录下批量建立文件夹,并且批量的运行这些子目录内新建立好的文件夹内的 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 {} \;

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.



Set wshobj=WScript.CreateObject("WScript.Shell")
app=wshobj.Run("FoxitReader.exe Ping.pdf")
wshobj.AppActivate app
WScript.Sleep 1000
wshobj.SendKeys "%vf"

这段代码是我根据FoxitReader的执行办法改写的,可以看到第二行是用阅读器打开pdf文档,你可以对应改成任意你要用的程序打开对应任意的文件(注意相对路径和绝对路径)。然后第四行让你的当前窗口sleep…… 意思是说你下面的操作将对新打开的窗口有效,即你启动的程序界面。于是倒数第二行是快捷键的输入,就像是vbs脚本自动替你从键盘输入命令。%代表Alt 键,vf代表V和F的字母键。然后退出脚本。因为foxitreader里面的全屏播放按钮时Alt+v+f,于是当我双击vbs脚本之后,我就可以直接全屏显示pdf文件了,就和ppt一样……