#!/bin/csh
#
# CGS4 version:
# CJD - June 2000
# Tweeked for UIST, file suffix may still be wrong!!
# CJD - August 2002
# Tweeked further for UIST, file suffix should be right now...
# CJD - November 2002
# Changed to process _wce frames from pipeline
# CJD - July 2005
#
echo " "
echo " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * "
echo " * * "
echo " * IRPOL QUICK-LOOK FOR UIST SPEC-POL * "
echo " * * "
echo " * Assumes frame naming convention is * "
echo " * * "
echo " * u<DATE>_<NNNNN>_wce * "
echo " * * "
echo " * (i.e. uses flat-fielded "wce" output files from * "
echo " * the pipeline; can edit to reduce QUICK_LOOK raw * "
echo " * data!) * "
echo " * * "
echo " * Note: Processes only sequential list of 8 spec-pol * "
echo " * frames. Assumes one obj-sky pair at each WP * "
echo " * angle. Order of frames MUST be * "
echo " * obj-sky-sky-obj-obj-sky-sky-obj * "
echo " * * "
echo " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * "
echo " "
echo "Listing data directory..."
echo " "
pwd
ls
echo " "
###
# Start the FIGARO, KAPPA & TSP routines (quietly)
#
alias echo 'echo > /dev/null'
figaro
kappa
tsp
unalias echo
###
# Enter UT Date and number of first frame
#
echo -n "UT data of the observations: "
set date="$<"
echo -n "Number of first frame: "
set first="$<"
###
# Read in data frames, setting number to 5 digits
# n - increment to first frame number
# m - counter (1 to 8)
#
set n = $first
set m = 1
while ($m <= 8)
set num=000${n}
if ($n < 10) set num=0000${n}
if ($n > 99) set num=00${n}
if ($n > 999) set num=0${n}
set polframe${m}=u${date}_${num}_wce
echo "Copied " u${date}_${num}_wce " to " polframe${m}...
@ n = $n + 1
@ m = $m + 1
end
###
# Echo comment
#
echo " "
echo "--->>> Result will be written to file rgp${date}_${first}"
echo " "
echo "--->>> First subtract OBJECT frames from SKY frames"
echo " Displaying the four resulting spectral images in GAIA"
echo " "
###
# Subtract skies from obj frames first; display each result
#
sub $polframe1 $polframe2 polframe_0d
gaiadisp polframe_0d; sleep 1
sub $polframe4 $polframe3 polframe_45d
gaiadisp polframe_45d; sleep 1
sub $polframe5 $polframe6 polframe_22d
gaiadisp polframe_22d; sleep 1
sub $polframe8 $polframe7 polframe_67d
gaiadisp polframe_67d; sleep 1
###
# Rotate images 90 degress clockwise
# so that dispersion access is vertical (necessary with
# TSP!) irevy is a Figaro command that flips the image about
# a hortizontal axis (so that top becomes bottom).
# Displays last rotated image.
#
echo " "
echo "--->>> Must then ROTATE differenced frames for TSP"
sleep 1
rotate angle=-90 in=polframe_0d out=polframe_0dr
irevy image=polframe_0dr output=polframe_0rev
rotate angle=-90 in=polframe_45d out=polframe_45dr
irevy image=polframe_45dr output=polframe_45rev
rotate angle=-90 in=polframe_22d out=polframe_22dr
irevy image=polframe_22dr output=polframe_22rev
rotate angle=-90 in=polframe_67d out=polframe_67dr
irevy image=polframe_67dr output=polframe_67rev
echo " "
echo "--->>> Displaying one of the rotated obj-sky frames "
echo " (this one is for the 67 deg. WP angle) "
echo " "
gaiadisp polframe_67rev; sleep 1
###
# Now use TSP routine "ccd2pol" to extract spectrum from each sky-subtracted
# specpol image. ccd2pol assumes 4 specpol images, and 4 spectra (2 positive
# and 2 negative) within each image. Y-axis is assumed to be the dispersion
# axis.
#
echo " "
echo "--->>> Now use this displayed/rotated image to measure: "
echo " "
echo " ASTART = start column for left-hand "OBJECT" aperture"
echo " BSTART = start column for left-hand "SKY" aperture"
echo " OESEP = number columns between two positive spectra"
echo " WIDTH = width of spectrum (in pixels) "
echo " "
echo " EXAMPLE - First, left-hand +ve spectrum is centred on "
echo " column 148, left-hand -ve spectrum is on column 248, and "
echo " separation between two positive spectra is 165 pixels, then: "
echo " "
echo " ASTART = 143 "
echo " BSTART = 243 "
echo " OESEP = 165 "
echo " WIDTH = 10 "
echo " "
ccd2pol pos1=polframe_0rev pos2=polframe_45rev pos3=polframe_22rev pos4=polframe_67rev aperture=a bias=0 readnoise=1 photadu=1 algorithm=ratio output=temp
echo " "
echo " *** NO CORRECTION FOR CURVATURE/DISTORTIONS *** "
echo " i.e. assumes spectra are along columns... "
echo " "
###
# Result of ccd2pol written to TSP-format polarisation file, rgp${date}_${n}.
# Use "pplot" to display polarisation results on a kapview window.
#
echo " "
echo "--->>> Finally, plot Polarisation spectrum "
mv temp.sdf rgp${date}_${n}.sdf
pplot rgp${date}_${n} device=xw label=rgb${date}_${n}
###
# Calculate percent pol and polarisation angle over a selected
# wavelength range
#
loop1:
echo " "
echo "--->>> Calculate Pol.(%) and P.A. over selected wavelength region "
echo " (read the wavelength range off the displayed spectrum) "
echo " "
ptheta INPUT=rgp${date}_${n}
echo " "
echo -n " Measure pol values over another wavelength range (y/n)? "
set answr="$<"
if ($answr == "Y" || $answr == "y") then
goto loop1
endif
###
# Tidy up and done...
#
rm polframe*
echo " "
exit