#!/bin/csh
alias echo "echo > /dev/null"
kappa
unalias echo
echo " "
echo " ***************************** "
echo " * Calc % Pol and Angle * "
echo " * From I, Q, U aperture * "
echo " * photometry measurements * "
echo " ***************************** "
echo " "
echo " Notes... "
echo " - Display I, Q and U images in Gaia "
echo " - Use aperture photom (result in counts) "
echo " with option - 'keep apertures same' and "
echo " parameters - 'centroid' switched off "
echo " - Enter values below..."
loop1:
echo " "
echo -n " >>> I in counts: "
set I="$<"
echo -n " >>> Q in counts: "
set Q="$<"
echo -n " >>> U in counts: "
set U="$<"
set a = `calc exp="'( ($Q)*($Q)+($U)*($U) )/( ($I)*($I) )'"`
set P = `calc exp="'(sqrt($a))*100'"`
# IF (and indeed all cshell commands) only work on integers
set QIN = `calc exp=$Q prec=_integer`
set UIN = `calc exp=$U prec=_integer`
set b = `calc exp="'atand(($U)/($Q))'"`
if ($QIN < 0) then
set TH = `calc exp="'(($b) + 180)/2.0'"`
else if ($QIN > 0 && $UIN < 0) then
set TH = `calc exp="'(($b) + 360)/2.0'"`
else
set TH = `calc exp="'($b)/2.0'"`
endif
echo " "
echo " some math..."
echo " a = " $a
echo " b = " $b
echo " q - integ = " $QIN
echo " u - integ = " $UIN
echo " "
echo " "
echo " Results: "
echo " -------- "
echo " *** I = ${I} "
echo " *** Q = ${Q} "
echo " *** U = ${U} "
echo " *** P = ${P} % "
echo " *** Theta = ${TH} degrees"
echo " "
echo " "
echo -n " Calculate for another target...(y/n)? "
set answr="$<"
if ($answr == "Y" || $answr == "y") then
goto loop1
endif
echo " "