KRIS LOWE example script

KRIS LOWE example script

#!/bin/csh

#This script takes apart the scrunched image
#then puts it all together into a cube
#This script has been 'made' by Krispian Lowe

#Calls the Kappa commands.
alias echo "echo > /dev/null"
kappa
unalias echo

echo
echo "***************************************************"
echo
echo "  CONVERT IFU SCRUNCHED 2-D IMAGE TO 3-D CUBE   "
echo "      (Courtesy of Kris Lowe, U. Herts)         "
echo 
echo " This script makes a cube out of a scrunched IFU "
echo " image. "
echo 
echo " The offsets are taken from ORACDR, therefore"
echo " thanks go to Brad C."
echo
echo " Listing Available ndfs:"
echo 

ls *.sdf

echo
echo -n " Please enter name of INPUT ndf (but without the .sdf): "
set ndf = $< 

#This section assigns the slit physical offsets.

echo 
echo " The y offsets of each slice in the scrunched image are: "
echo " -0.1 0.71 -0.39 -0.13 -0.14 4.41 2.88 4.19 4.58 4.13 5.59 3.16 4.90 3.53"
echo " This offsets should not change, since the mirror slices"
echo " in UIST are fixed.  However, check the output from a "
echo " standard star to be sure..."
echo 

set yoffsets = (-0.1 0.71 -0.39 -0.13 -0.14 4.41 2.88 4.19 4.58 4.13 5.59 3.16 4.90 3.53)

rm temp*.sdf

@ sliceoffsets = 1

set i = 1

while ( $i <= 14 )

@ sliceoffsetmax = $sliceoffsets + 46

#Extracting every slice into it own little bit 

ndfcopy "in=${ndf}(,${sliceoffsets}:${sliceoffsetmax}) out=temp${i} title=\! trim=no trimwcs=no"

#Extending the slice into the 3rd dimension.
setbound << EOF 
temp${i}(,,1:1)
EOF

setorigin ndf=temp${i} << EOF
1,1,$i
EOF

#Sliding the slice into position.

slide "in=temp${i} out=temp${i}slid" << EOF
0,$yoffsets[$i],0
EOF

@ sliceoffsets = $sliceoffsetmax + 1 

@ i = $i + 1

end

#Pasting all the slices together.

paste in=temp1slid p1=temp2slid p2=temp3slid p3=temp4slid p4=temp5slid p5=temp6slid p6=temp7slid p7=temp8slid p8=temp9slid p9=temp10slid p10=temp11slid p11=temp12slid p12=temp13slid p13=temp14slid out=temp_cube

#The ORACDR output frames are different for a STD and an OBJ frame!
echo 
echo -n " Is this a STANDARD scrunched image? [y/n]:  "
set stdorobj = $<


if ( $stdorobj == "y" || $stdorobj == "Y" || $stdorobj == "yes" || $stdorobj == "Yes" || $stdorobj == "YES" ) then 

permaxes in=temp_cube out=temp_cube2 perm="[3,2,1]"

else 

permaxes in=temp_cube out=temp_cube2 perm="[3,2,1]"

echo  
echo  "*************************************************************************"
echo  " The object cube WCSFRAME information has to be COPIED from the ORACDR "
echo  " pipeline cube to complete the process. "
echo  " Here is a list of possible cubes: "
ls gu*cub*.sdf
echo 
echo -n " Please enter the name for the ORACDR PIPELINE cube ndf (but without the .sdf): " 
set oracdrcube = $<

wcscopy "ndf=temp_cube2 like=${oracdrcube} confirm=yes ok=yes tr=\!"

endif



echo 
echo -n " Please Enter name of the output cube (without the .sdf): "
set outndf = $<
echo 

mv temp_cube2.sdf ${outndf}.sdf

#Having a bit of a clean up. If you have any files called temp*.sdf - sorry.
rm temp*.sdf

exit