bfclean.c - standalone C program implementing the CLEAN algorithm. author: j. blakeslee I started by translating Keel's Fortran code, but made it more general and (perhaps) streamlined, made it read and write FITS images, and added a number of options, listed below. Executing without any arguments gives you the options: ===================================================== acs% bfclean Usage: bfclean [options] -d name of input data image -p name of input psf image -e name of noise (rms) image [def: work in count, not S/N, space] -i number of iterations (int) (def: 1000000) -n print info every iters (int) (def: 1000) -w also write images on every iters (def: don't) -g "loop gain" for cleaning iterations (float) (def: 0.01) -s Cutoff to stop cleaning, in sigma [cnts] (def: 3.0 [0.0]) -c name of output cleaned file (def: cleaned.fits) -r name of output residual file (def: resid.fits) -k smooth clean map with gauss_1.5_3x3 kernel *at end* (def: don't) -m smooth clean map with gauss_2.0_5x5 kernel (More smooth) at end -a add the clean map to the resid file *at end* (def: don't) -q|-v be quiet|verbose about it (def verbose) Flags without defaults are required. ===================================================== The program runs on one FITS image (postage stamp) at a time, but can use it in batch mode with scripts like 'Nclean.csh' in this directory. That example script creates an output directory, runs bfclean for an arbitrary number of FITS images in the working directory, finds peaks in either image or S/N space, for an arbitrary number of iterations on each image. But it uses some specific gain and other command-line parameter settings, e.g.: bfclean -d i0027.fits -p psfi081.fits -e rms_i0027.fits -n 1e4 -i 1e6 -s 2.5 -c ../Cleaned_LGsm_1e6_s2.5/cmap_i0027.fits -r ../Cleaned_LGsm_1e6_s2.5/rcln_i0027.fits -a -g 0.002 -k Much more general batch scripts could obviously be made. Compilation ----------- This directory contains object (*.o) and executuable (bfclean) from an Intel (Dell) Linux system. If you want to remake the executable: make clean make bfclean should work, in principle. See the Makefile for dependencies. Some helpful hints: ------------------ For best results, understand and optimize all the options! This version of bfclean only finds positive peaks (at Marijn's recommendation), so it won't repair oversubtraction, but it also doesn't expend endless iterations trying to remove sharp-edge features (e.g., bleeding or saturation). You definitely want to use either the "-k" or "-m" option (-k should probably be made the default). Also, I had envisioned generalizing it to use more (or arbitary) kernels. The GIF images clean_smoocmp.gif and clean_smoocmp0600.gif compare results with and without "-k" option. Of course, you can omit this step and just smooth the resulting cleaned imaged afterwards, using any kernel or method you like. The default 'loopgain' of 0.01 should be thought of as an upper limit, unless you're just working on star fields maybe. A value near 0.001 is better, but of course requires about 10x as many iterations; 0.002 seems to be ok, too. Make that the default?