f2n - fits to net
Ocotber 2009 : f2n.py released !
f2n is now ported to python ! Read on here, and forget about the rest of this page.
December 2008 : deprecation warning ...
I played with f2n to experiment with my own grayscale mappings for special tasks. This simplified release of f2n works fine and I still use it in a pipeline, but do not expect further development. All this can/should/will be done directly from within python in future !
Note that you might now also consider STIFF from Emmanual Bertin, or some tools from imcat to perform similar tasks.
f2n is a tiny standalone program to "convert" fits images into png, with options about the grayscale (or colour) scaling.
It's particularly useful to call f2n from a script, applying it to a set of images, and then generate html pages using the png files, or combine/resize/annotate them with ImageMagick, or make MPEG movies or gif animations, or all this at the same time. Actually I'm using f2n a lot !
[maltembp:~/Desktop] mtewes% f2n ------------------------------------------------------------------------- f2n - fits to net I convert images from fits to png version 0.9.1, December 2008 malte.tewes at ... Usage : f2n p/n ztrans in.fits out.png [z1 z2] Example : f2n p f in.fits out.png -10 2000 p/n = p: positive output n: negative (inverse video) output ztrans = l: lin scale (lc : same but with coloured cutoffs) e: log centered on 0.0 f: log scale as in IRAF's display (fc : coloured cutoffs) p: lin from z1 to -z1, then log up to z2 (my fav for dec.fits) c: log with color countours around 1.0 (my fav for sm residuals) r: pseudocolour log hsv s: somewhere over the rainbow (exprimental) z1 z2 = the lower and upper cutoffs to use. Give either none or both. (not given) : min and max cutoffs (same as m m, see below) -1.2e-5 : hard cutoff (for example) m : extremal (min or max) cutoff a : super intelligent auto cutoff (experimental but not that bad) You can also mix them. Examples : "-10.0 a", "a m", "a a", "0 1" You can use file.fits[a:b,c:d] to select a region of the input file. (In case of trouble use quotes : "file.fits[a:b,c:d]") ------------------------------------------------------------------------- [maltembp:~/Desktop] mtewes% f2n p f "wfpc2.fits[20:319,50:349]" out.png m a +++ region of wfpc2.fits[20:319,50:349] : 300 x 300 pixels +++ calculating auto cutoffs ... +++ z1 = min = 23.000000 +++ z2 = auto = 125.000000 +++ (max value is 3400.000000) +++ positive output image +++ using IRAF log scale +++ f2n : done [maltembp:~/Desktop] mtewes%
If you are working at the Observatoire de Sauverny (hey, chances are not that bad if you are reading this), I suggest to directly alias my binaries : /home/epfl/tewes/bin/f2n_linux for "obsds20"-like servers, and just f2n for the Sun computers like "obssf8" etc.
If not, or if you want to run it on your laptop, you will have to go the hard way and compile it.
Code & Compilation
f2n is plain procedural C code, written as I couldn't find anything similar at that time ([sic] - something like this for sure already exists out there; all those survey websites can generate pngs or jpgs on demand but they probably use functions of larger packages and not tiny apps...), but I also wanted to tweak the grayscale mapping by myself. In principle there would be ImageMagick, as convert can handle FITS files, but it didn't suit my needs.
Using C for this task is a product of ignorance. I would now use python, which would be much easier. And as I love playing with pixels, I might rewrite something similar in python one day. Anyway, for now it works in C.
In the box : the source and a small fits file to play with.
The usual warning first : the code is quick, dirty, and certainly not optimal, don't blame me please :-) You'll need the libraries libpng and cfitsio. BTW both are part of ESO's scisoft distribution.
I've currently installed :
but older versions will work as well.
So, tweak the includes at the top of the source, (i.e. give the absolute path to fitsio.h and png.h in the source if you need), and compile using a call to gcc like
> gcc f2n_091.c -o f2n -lm /scisoft/i386/lib/libcfitsio.a /scisoft/i386/lib/libpng.aJust to give some inspiration about options, here are the lines I used on the workstations at work :
> cc f2n_091.c ../cfitsiolinux/libcfitsio.a -lpng -lm -lnsl -o f2n_linux > cc f2n_091.c ../cfitsio2420/libcfitsio.a -lpng -lm -lnsl -lsocket -o f2n
0.9.1 : December 2008 : no-brainer change to allow for larger filenames.
0.9.0 : first "release".
And don't hesitate to ask me if you have questions or trouble running/installing it.