I happened to know a code called High Order Transform of Psf ANd Template Subtraction, which has a sexy short name called HOTPANTS, when reading a paper. The code, developed by Andy Becker,  is said to be a supersession of another optimal subtraction package ISIS, which unfortunately has a name in common with a terrorist organisation in Middle East. I clearly remember the pain when tweaking parameters so as for ISIS to work and output satisfactory results for me. So I was tempted to try HOTPANTS and see if I can benefit from its name. So I did.

I downloaded the zipped file from Github to my local directory and untarred it. I edited the paths CFITSIOINCDIR in Makefile.macosx and linked them to my CFITSIO that came with Ureka. Also deleted was -ansi in the line of COPTS =.... Then simply type

$ make

Only two warnings popped out. The rest looked good. Then I decided to try with two images taken by NEXT, Xingming Observatory C42, about 2018 C2:

$ ./hotpants -inim reg_A2018C2-S001-R001-C001-V.fts -tmplim reg_A2018C2-S014-R001-C001-V.fts -outim result.fts -tu 60000 -c t -n i -ng 3 6 0.7 4 1.5 2 3.0 -tg 2.2 -tr 7.0 -iu 60000 -ig 2.2 -tr 7.0 -hki -gd 40 2048 0 2010

Meanings about the parameters (copied from the output without any inputs):

   [-inim fitsfile]  : comparison image to be differenced
   [-tmplim fitsfile]: template image
   [-outim fitsfile] : output difference image
   [-tu tuthresh]    : upper valid data count, template (25000)
   [-tg tgain]       : gain in template (1)
   [-tr trdnoise]    : e- readnoise in template (0)
   [-iu iuthresh]    : upper valid data count, image (25000)
   [-ig igain]       : gain in image (1)
   [-ir irdnoise]    : e- readnoise in image (0)
   [-gd xmin xmax ymin ymax]
                     : only use subsection of full image (full image)
   [-c  toconvolve]  : force convolution on (t)emplate or (i)mage (undef)
   [-n  normalize]   : normalize to (t)emplate, (i)mage, or (u)nconvolved (t)
   [-hki]            : print extensive kernel info to output image header (0)
   [-ng  ngauss degree0 sigma0 .. degreeN sigmaN]
                     : ngauss = number of gaussians which compose kernel (3)
                     : degree = degree of polynomial associated with gaussian #
                                (6 4 2)
                     : sigma  = width of gaussian #
                                (0.70 1.50 3.00)
                     : N = 0 .. ngauss - 1
                     : (3 6 0.70 4 1.50 2 3.00

But then I immediately had the following error:

ERROR: Mismatch in the CFITSIO_SONAME value in the fitsio.h include file
that was used to build the CFITSIO library, and the value in the include file
that was used when compiling the application program:
   Version used to build the CFITSIO library   = 2
   Version included by the application program = 1393625872

Fix this by recompiling and then relinking this application program
with the CFITSIO library.
Segmentation fault: 11

So I reinstalled the latest version of CFITSIO, and changed the two paths accordingly. Reinstalling went smoothly but not quite for reinstalling HOTPANTS:

Undefined symbols for architecture x86_64:
  "_curl_easy_cleanup", referenced from:
      _https_open_network in libcfitsio.a(drvrnet.o)
  "_curl_easy_init", referenced from:
      _https_open_network in libcfitsio.a(drvrnet.o)
  "_curl_easy_perform", referenced from:
      _https_open_network in libcfitsio.a(drvrnet.o)
  "_curl_easy_setopt", referenced from:
      _https_open_network in libcfitsio.a(drvrnet.o)
  "_curl_global_cleanup", referenced from:
      _ffchtps in libcfitsio.a(cfileio.o)
  "_curl_global_init", referenced from:
      _ffihtps in libcfitsio.a(cfileio.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [hotpants] Error 1

I suspected this was due to incompatibility between CFITSIO and HOTPANTS, which was written five years ago. As a test, I downloaded an older version of CFITSIO, and repeated all the steps. Annoyingly, now I instead had these at the end when executing make:

/Applications/ for architecture: i386 file: libcfitsio.a(drvrgsiftp.o) has no symbols
/Applications/ for architecture: x86_64 file: libcfitsio.a(drvrgsiftp.o) has no symbols

But the above warnings do not seem to interrupt with HOTPANTS. My guess is that this has something to do with the structure in which drvrgsiftp.c is written. Anyway, I could successfully reinstall it and obtain a difference image. So it seems working anyway, at least giving me a result rather satisfying, and saving me plenty of time. I will definitely have more tests in the future. Now I start favouring HOTPANTS.

The bright spot is object 2018 C2, a weakly active long-period comet from the Oort cloud. Click to enlarge.



Memo for WCSTools

Recently I have been more dissatisfied with, because no matter how I tweak the parameters, some portions in an image can never have catalogue stars’ positions overlaid with the corresponding actual stars. I also have learnt that only provides crude solutions to plate constants of images, and therefore, if one needs high-quality astrometry, WCS by is not accurate enough yet, and other better astrometric software should be used. This is the reason why I need to use WCSTools.

The following is simply a memo to record my steps to install the software. My reference is basically from this webpage.

(1) Download the latest version of WCSTools (3.9.4).

(2) Go to the directory where the file is downloaded, and type in the following commands to install it:

$ tar xvfz wcstools-3.9.4.tar.gz
$ cd wcstools-3.9.4
$ make all

(3) Now the environment needs to be set:

$ sudo cp wcstools /usr/local/bin/
$ sudo cp ./bin/* /usr/local/bin/
$ sudo cp libwcs/*.h /usr/local/include/
$ sudo cp libwcs/libwcs.a /usr/local/lib/

(4) Test the installation:

$ wcstools

(5) You should see a very lengthy message including the version of the software, as well as a number of programme names. The following is what I can get (truncated):

WCSTools 3.9.4 Programs

addpix:    Add a constant value(s) to specified pixel(s)
bincat:    Bin a catalog into a FITS image in flux or number
char2sp:   Replace this character with spaces in output (default=_)
conpix:    Operate on all of the pixels of an image
cphead:    Copy keyword values between FITS or IRAF images
crlf:      Change CR's to newlines in text file (for imwcs, imstar logs)
delhead:   Delete specified keywords from FITS or IRAF image file headers

Since I am using an online servers to visit star catalogues, the environment variables such as the following ones have been set:

setenv UB1_PATH
setenv SAO_PATH
setenv UCAC3_PATH

Note that I haven’t yet figured out how to connect to catalogue UCAC4. Apparently WCSTools cannot cope with the newly released Gaia either.

As still being in a process of learning the software, I may update this post infrequently in the future.

Memo for WCSTools

Install OrbFit on My Mac

So far I have not yet fully successful with the software. But the problem may well be intrinsic in the codes, rather than mistakes during my installation. I have reported a bug to the OrbFit consortium. But anyway I think I need to record my steps of installing it, which may benefit me in the future if I want to reinstall the software.

Step 1: Download the software from the website and unzip it.

Step 2: Change the terminal to tcsh.

Step 3: Type config -O gfortran, Since I’m using gfortran. Other modes will flag -static which leads to errors of ld: library not found for -lcrt0.o.

Step 4: Type make. It should take seconds to finish.

Step 5: Download ASCII formatted of JPL DExxx to directory src/jpleph. I downloaded DE431. Edit makefile if necessary.

Step 6: Type make ephemerides. It is then converting the DExxx from ASCII to binary, which takes about 20 sec on my computer. After it completes a file called jpleph will appear.

Step 7: Copy that file to lib under the main directory of OrbFit, or goto that directory by cd ../../lib, and then type ln -s ../src/jpleph/jpleph jpleph to create an alias.

Step 8: Goto the main directory and test the installation:
make tests
where I am confronted with errors about segmentation, with the latest version OrbFit5.0.

Install OrbFit on My Mac

Weird Function TRIANGULATE in IDL

Time to update my blog again. It’s been more than a year since my last update after all. Today I encountered with a weird error in IDL when trying to improve computation precision of own polar transform image routines. The source was traced back to function TRIANGULATE. So far I really have no idea about why it occurs. The example is as follows:

IDL> theta=dindgen(360L)
IDL> rad=dindgen(500L)
IDL> xpol=rad#cos(theta/1.8d2*!dpi)
IDL> ypol=rad#sin(theta/1.8d2*!dpi)
IDL> triangulate,xpol,ypol,tri
% TRIANGULATE: Points are co-linear, no solution.
% Execution halted at: $MAIN$

However, if I type the following TRIANGULATE works flawlessly:

IDL> xpol=rad#cos(float(theta/1.8d2*!dpi))
IDL> ypol=rad#sin(float(theta/1.8d2*!dpi))
IDL> triangulate,xpol,ypol,tri
IDL> help,tri
TRI             LONG      = Array[3, 358920]

This is really annoying, as I can’t figure out how come co-linearity can be related to float or double precision whatsoever. Not sure if anyone could help this for me, but I just throw this problem here and see if there’s anyone else faced with the same encounter so that we can potentially sigh together…

Weird Function TRIANGULATE in IDL

My Record of Installing IDL, SSW and SSWDB on My New Mac OS X

I got a new laptop Mac OS X from Dave and needed to install IDL, SSW and SSWDB on it. The following are the main steps how I installed it successfully.


Basic Steps of installation of IDL 8.3 on my Mac OS X

1. Download the installation package from the EXELIS.

2. Click on the icon and follow the instructions of the installation wizard.

3. Put the license into the following directory: Applications/exelis/license.

4. The license wizard pops out automatically after the installation completes. Now select the license file in the panel.

5. Now IDL should be successfully launched by double clicking on the workbench icon, however, if you type idl in the terminal, you will be informed that idl: Command not found. Environment has to be set.

6. Type the following commands in the terminal:

vi .tcshrc

7. See if there is the following lines within the file, insert them otherwise.

setenv IDL_DIR /Applications/exelis/idl83
setenv OS darwin.

In Tshell command line, typing idl will now successfully run IDL.


Steps of installation of SSW

1. Fill out and submit the form at

2. Follow the instructions in that website and the links therein.

3. Type sswidl in the terminal, but fails, so insert the following lines into the .tcshrc file:

set path=(/usr/local/bin /sw/bin /sw/sbin /usr/local /usr/local/ssw/gen/mirror /usr/X11R6/bin /Applications/exelis/idl83/bin $path .)
setenv SSW_INSTR "lasco secchi"
setenv SSW ssw
setenv SSWDB sswdb
setenv ssw_quiet 1
source $SSW/gen/setup/setup.ssw
source $SSW/soho/lasco/setup/setup.lasco_envsetenv SSWDB /usr/local/ssw/sswdb

Installation of SSWDB

1. Anyway I am not able to generate a configuration file from, but there is a file called setup.sswdb_upgrade_template in directory of ssw/site/setup. Add lines indicating the packages in need, or, if there are packages already listed in the template, remove the corresponding “#” at the beginning. Root is required:

sudo vi setup.sswdb_upgrade

2. Follow the steps listed at

3. If Perl is installed in a non-default directory, type
ln -s /usr/bin/perl /usr/local/bin/perl
in the terminal.

4.IDL> sswdb_upgrade, /spawn, /passive_ftp

5. Be patient about Step 4, and it took me rather long.

6. Done!

My Record of Installing IDL, SSW and SSWDB on My New Mac OS X

Further to My Previous Blog, rgd RVSF

I got in touch with Dr. Nalin Samarasinha at PSI, who wrote the codes for all of the special cometary processing filters at PSI website. He has beeing patiently answering every of my questions so I now can understand what his RVSF code is basically doing, though I know very little of FORTRAN. The discrepancy I spot between the source code and the explanation file is indeed a typo.

I added a new keyword to my IDL routine so that the user could have the option whether they like to switch on or off the function of sub-pixel sampling of the image prior to the function of the filter or not. Through some simple tests I realized that the differences between sub-pixelization and non-sub-pixelization of the image would not be very obvious in terms of visual inspection. However, the speed matters considerably, especially when the input image size or the part of regions selected is quite large — the processing time, in this case, could be quite consuming. So it’s a good idea to preview the enhanced image without sub-pixel sampling, not only would you save a great amount of time, but also this would give you a basic knowledge about if your kernel parameters are appropriate, and finally, to process the image by sub-pixelization with reasonable kernel parameters.

I couldn’t discern any difference in the enhanced images with or without sub-pixelization, however, a subtraction between the two clearly reveals what is previously hidden behind. See the following image.

The difference between non-sub-pixelization and sub-pixelization sampling. Linear stretch.
The difference between non-sub-pixelization and sub-pixelization sampling. Linear stretch.

Additionally, I’m very delighted to find that the resulting enhanced image processed by means of sub-pixelization shares great similarity with the one processed through Nalin’s code or PSI’s online tool. So I think my routine is quite successful.

At last, before the end of this update, I need to confess that I had mistakenly regarded the author of the source codes to be Padma Yanamandra-Fisher. I had been confused by their names, all look rather long for me… ><

Further to My Previous Blog, rgd RVSF

Testing My Radially Variable Spatial Filter Code

I think I need to update my blog; it has been so long since my last update… Also should I prove that I’m still alive here.

I saw a message in the comets-ml posted by Martino Nicolini that the PSI website has released a web tool for processing cometary images, including azimuthal median/average/renormalization filters, 1/rho coma model division, and, quite unfamiliar to me, radially variable spatial filter ( I attempted to process an image taken by HST regarding comet C/2012 S1 (ISON) in May 2013 with the online tool, however, I had difficulty in retrieving the enhanced or processed data. Weirdly the size of the to-be-downloaded file was always 0 KB, obviously problematic. With consideration that the network is not permanently available for me, it sounds absurd and waste-of-time for me to wait for accessible network before performing specially processed cometary images, and therefore I decided to write codes for my own purpose.

So I did by taking reference to the explanation file of the enhancement techniques, understanding the global idea of how the radially variable spatial filter works. Realizing the algorithm of the filter was proved easy, and it didn’t take me long to accomplish the IDL routine.

I did some tests with the image CometCIEF_test.fits provided in this page. The following was generated with kernel A = 4.0, B = 4.0, N = 0.4. It looks correct anyway, quite similar to the appearance in the tutorial file.

RVSF test imageHowever, I found my result would look somewhat different from those presented in the tutorial file if the kernel size was smaller — probably the scaling plays a role there, yet anyway my outcome would look less detailed. The corresponding FORTRAN source code of the filter in the PSI page seems to has a typo, which I have already reported to Padma Yanamandra-Fisher. I’m still comparing my codes against the PSI’s…

Testing My Radially Variable Spatial Filter Code