In this post, i wanted to take some notes about a few useful CFITSIO tools’ commands for myself.
First of all you need to install cfitsio library into your OS.
- For OS X;
$ brew install cfitsio
- For Debian Based GNU/Linux distributions;
$ sudo apt-get update $ sudo apt-get install libcfitsio-dev
- For RPM-based GNU/Linux distributions;
$ sudo dnf install cfitsio-devel
I often have to deal with public astronomical catalogues and I have to fetch a certain part of the sky. In particular, I would prefer the FITS tables not images :). For this reason, I need a quick manipulation tool: CFITSIO – A FITS File Subroutine Library. Especially; tablist, fitscopy, listhead…
listhead:
It is very simple. List FITS file’s header&keywords…
- For whole header information:
$ listhead 'file_name.fits[0]'
- For a specific keyword:
$ listhead 'file_name.fits[0]'| grep -i "keyword"
- Example:
$ listhead 'astronomia_0012_R.fits[0]'| grep -i "OBJCTRA" OBJCTRA = '10:36:41.8' / Nominal Right Ascension of center of image
- Bring the catalogue’s column names:
$ listhead 'tyc2_sample.fits[0]' Header listing for HDU #1: SIMPLE = T / Standard FITS Format BITPIX = 8 / Character data NAXIS = 0 / No Image --- just extension(s) EXTEND = T / There are standard extensions ORIGIN = 'xml2fits_v1.95' / Converted from XML-Astrores to FITS ... ********************************************************** EXCERPT from catalogues stored in VizieR (CDS) with the following conditions: ********************************************************** VizieR Astronomical Server vizier.u-strasbg.fr Date: 2017-02-04T08:24:44 [V1.99+ (14-Oct-2013)] In case of problem, please report to: cds-question@unistra.fr ... -out=TYC1 -out=TYC2 -out=TYC3 -out=pmRA -out=pmDE -out=BTmag -out=VTmag -out=HIP -out=RA(ICRS) -out=DE(ICRS) # INFO = '-c=150.418448+17.409087,rd=2.' END
tablist:
Please note that, in the last example “-out=” indicates column names. We can just extract the column(s) we’re interested in with;
- Usage:
tablist 'intab.fit[1][RA;DEC; X; Y][PHA > 24]' - print rows with PHA < 24
- Example:
$ tablist "tyc2_sample.fits[1][col TYC1;RA_ICRS_;DE_ICRS_;pmRA;pmDE;][pmRA<=1 && pmDE<=1]" TYC1 pmRA pmDE RA_ICRS_ DE_ICRS_ 1 1411 -42.4 -18.6 148.84569528 17.33590806 2 1411 -20.2 -8.0 149.18173167 17.25955361 3 1411 -9.6 -3.3 148.34490528 17.40581389 4 1411 -4.7 -53.4 148.87273306 17.48238361 5 1411 -12.7 -12.9 148.99339639 16.43346194 6 1411 -17.2 -14.4 148.85315028 17.16688167 7 1411 148.82302972 16.59136000 8 1411 -17.6 -8.3 148.49574417 17.10538167 9 1411 -1.9 -7.3 148.60960694 16.49546000 10 1411 -96.7 -38.5 148.82500167 16.42460056 11 1411 0.7 -35.9 148.94166750 16.46986167
fitscopy:
Sometimes I have to deal with very large catalog files. I’m reducing their size (by extracting only selected columns) for the rapid reduction process. This process is very similar to the tablist.
- Usage:
$ fitscopy 'in.fit[2][bin X,Y]' out.fit
- Example:
$ fitscopy tyc2_sample.fits"[1][col TYC1;RA_ICRS_;DE_ICRS_;pmRA;pmDE;][pmRA<=1 && pmDE<=1]" out_cat.fits
I wrote a script file that can do this very easily. You may wish to take a look at them from here.
Reference: