Read a FITS file


After installation of a binary kit, you start gopaw with:

    UNIX> <install_path>/gopaw/<version>/bin/gopaw  # UNIX here is for Linux and macOS.
 on Windows:
     DOS> <install_path>\gopaw\<version>\bin\gopaw.exe

Note that on Windows you must run from a DOS prompt (CMD.exe), it does not work from a cygwin prompt.

A distribution comes with examples to play with under the res/gopaw/examples directory. The below instructions are based on data files (for example data_m51.fits or data_ntuple.fits) found under this directory. The best is to have a local copy of this directory and work on that.

    UNIX> cp -R <install_path>/gopaw/<version>/res/gopaw/examples .
    UNIX> cd examples/gopaw  # in this directory there is are data_*.fits files.
    UNIX> <start gopaw> 
 on Windows:
     DOS> xcopy /s /q /i <install_path>\gopaw\<version>\res\gopaw\examples examples
     DOS> cd examples\gopaw
     DOS> <start gopaw> 

In the same way than for HDF5, you can read and plot images (IMAGE_HDU) and ntuples (TBL) in fits files.

Read and plot an IMAGE_HDU

For example, you can look at the hst.kumac script that works on the data_hst-img-2010x1890.fits Hubble space telescope fits file :

MACRO hst
  SET * ; OPT *       | Reset the defaults
  session/delete *    | delete all objects.
  SET XTIC 0.0001
  SET YVAL 100.
  SET YTIC 0.0001
  SET XVAL 100.
  CLR
  * width = 2010, height = 1890, mean = 0.052, rms = 0.7
  ZONE 1 1
  NULL 0 2 0 2
  h/file 1 data_hst-img-2010x1890.fits
  ldir  | to see available objects in the file.
  * in the below IMAGE_HDU command :
  *  - hdu = 1, slice = 0
  *  - lut(min,max) = -0.04 0.4, color map = colbr32
  *  - pos = 1 0.5, size = 1 0.9 (in axes coordinates)
  *  - angles(theta,phi) = 0 0
  IMAGE_HDU 1 0 -0.04 0.4 colbr32 1 0.5 1 0.9 0 0
  IMAGE_HDU 1 1 -0.04 0.4 colrj32 1 1.5 1 0.9 0 0   | slice = 1, pos = 1 1.5
  close 1
RETURN

If executing this script with:

   GOPAW> exec hst

you should see in the graphics window:

out_gopaw_hst.png

You can look at the m51.kumac script that works on the data_m51.fits file containing a picture of the M51 galaxy :

MACRO sdss
  SET * ; OPT *       | Reset the defaults
  session/delete *    | delete all objects.
  SET XTIC 0.0001
  SET YVAL 100.
  SET YTIC 0.0001
  SET XVAL 100.
  OPT NBGR            | remove background so that a tilt image is not cut.
  /VIEWER/BACKGROUND_COLOR 0.8 0.8 0.8 1   | set the window background color.
  CLR
  NULL 0 2 0 2
  h/file 1 data_m51.fits  | width = 512, height = 512, mean = 43.8, rms = 37.7, cmap.size = 256
  IMAGE_HDU 1 0 0 200 colbr32 1 1 1 1.2 30 30
  close 1
RETURN

If executing this script with:

   GOPAW> exec m51

you should see in the graphics window:

out_gopaw_m51.png

Here we played with the (THETA,PHI) angles of the IMAGE_HDU command to have some 3D rendering.

Work on a TBL (a fits ntuple)

You can look at the ntuple_fits.kumac script that works on the data_ntuple.fits file containing a TBL:

macro ntuple_fits
* Copyright (C) 2018, Guy Barrand. All rights reserved.
* See the file gopaw.license for terms.
exec alldef
zone 1 3
opt stat
*////////////////////////////////////////
*/// ntuple : ///////////////////////////
*////////////////////////////////////////
h/file 1 data_ntuple.fits   | file produced with exlib/examples/cpp/cfitsio_write_ntuple.cpp.
ldir
n/print 2
n/plot 2.fgauss
n/plot 2.dbw
n/plot 2.fgauss%dbw
close 1
*////////////////////////////////////////
*////////////////////////////////////////
*////////////////////////////////////////
return

If executing this script with:

   GOPAW> exec ntuple_fits

you should see in the graphics window:

out_gopaw_ntuple_fits.png