#!/bin/csh -f # # Use: scriptname [ndf_file_name] # source /star/etc/login >& /dev/null source /star/etc/cshrc >& /dev/null kappa >& /dev/null convert >& /dev/null if (`alias kappa` == "") then echo "" echo "Fatal: Initialization error of kappa environment" echo "" exit endif # Get the input NDF and strip .sdf extension if ($# == 0) then set def = `parget data_array GLOBAL` echo -n "Input MAKECUBE cube /$def/ > " set file = $< if ("$file" == "") then set file = $def else if ("$file" == "\!" || "$file" == "\!\!") then echo "" exit endif else set file = "$argv[1]" shift endif set file = `echo $file | cut -d\. -f1` # Find dimensions of the NDF file ndftrace ${file} >& /dev/null set dims = `parget dims ndftrace | head -1` set lbnds = `parget lbound ndftrace | head -1` set ubnds = `parget ubound ndftrace | head -1` set xsize = $dims[1] set ysize = $dims[2] set xmin = $lbnds[1] set xmax = $ubnds[1] set ymin = $lbnds[2] set ymax = $ubnds[2] echo "Map size read in : $xsize x $ysize " echo "Xrange read in : $xmin to $xmax " echo "yrange read in : $ymin to $ymax " # Extract individual spectra from the NDF and convert to FITS @ nr = 0 @ i = $xmin while ($i <= $xmax) @ j = $ymin while ($j <= $ymax) ndfcopy in="${file}(${i},${j},)" out=${file}_${i}_${j} exten ./cubecopy ${file}_${i}_${j} ${file}_cc_${i}_${j} ndf2fits ${file}_cc_${i}_${j} ${file}_${i}_${j}.fits encoding="fits-class" echo "Finished ${file}_${i}_${j}.fits" @ nr ++ @ j ++ end @ i ++ end stats "${file}(,,~1)" >& /dev/null set nrpix = `parget numpix stats | head -1` echo "-----------------------------------------" echo "$file has $nrpix spectra." echo "Routine created $nr fits files." echo "-----------------------------------------"