next up previous contents index
Next: 5.4 Potential Up: 5.3 Tables Previous: 5.3 Tables   Contents   Index

5.3.1 Making an image from a table

Any scatterdiagram can now easily be turned into an image by using the snapshot interface! This would be temporary solution until the need for this would turn into a program tabccd(1NEMO). The example below also demonstrates how existing tools can be effectively combined to create a new tool!

#! /bin/csh -f
#         - transform table into image - 
#       DEMO version: no bells and whistles
set in=$1               # infile (table)
set out=$2              # outfile (image)
set xcol=$3             # columns from table to use
set ycol=$4
set xrange=$5           # gridding area
set yrange=$6
set nx=$7               # number of pixels to use
set ny=$8
set sx=$9               # some smoothing 
set sy=$10

set tmp=tmp$$           # temp name for intermediate results

#     convert table to ASCII "205" snapshot (see atos(1NEMO))
awk  "END {print NR}"                $in     > $tmp.1
echo "3"                                    >> $tmp.1
echo "0.0"                                  >> $tmp.1
awk '{print 1.0}'                    $in    >> $tmp.1
awk '{print $'$xcol',$'$ycol',0.0}'  $in    >> $tmp.1
awk '{print 0.0,0.0,0.0}'            $in    >> $tmp.1
#                       convert to snapshot
atos $tmp.1 $tmp.2
#                       convert to image
snapgrid $tmp.2 $tmp.3 xrange=$xrange yrange=$yrange nx=$nx ny=$ny zvar=vz
#                       smooth image a bit
ccdsmooth $tmp.3 $tmp.4 gauss=$sx dir=x
ccdsmooth $tmp.4 $out  gauss=$sy dir=y
#                       write a FITS file
ccdfits $out $out.fits
#                       clean up mess
rm -f $tmp.*



(c) Peter Teuben