| 1 |
! @(#)pisco.prg 19.1 (ES0-DMD) 02/25/03 14:28:08 |
| 2 |
!********************************************************************* |
| 3 |
!* |
| 4 |
!* |
| 5 |
!* PISCO |
| 6 |
!* ----- |
| 7 |
!* |
| 8 |
!* Purpose: reduces polarimetric data obtained with PISCO |
| 9 |
!* |
| 10 |
!* author: Otmar Stahl March 1986 |
| 11 |
!* updated to portable MIDAS by |
| 12 |
!* Martin Schloetelburg June 1990 |
| 13 |
!* |
| 14 |
!* use: @@ PISCO catalog result sky calibration mode |
| 15 |
!* |
| 16 |
!* catalog = catalog containing data files to be reduced |
| 17 |
!* result = output table |
| 18 |
!* sky = sky measurement file |
| 19 |
!* calibration = sky measurement file |
| 20 |
!* mode = 1 : x and y channel are reduced seperately |
| 21 |
!* 2 : '' '' together |
| 22 |
!* 3 : '' '' both (1+2) |
| 23 |
!* |
| 24 |
!* exampel: @@ PISCO CATALOG TABLE SKY CALIB 3 |
| 25 |
!* |
| 26 |
!* This would reduce all the files listed in catalog CATALOG |
| 27 |
!* taking the file SKY as sky measurement and CALIB for calibration |
| 28 |
!* with x and y channel both separately and together. The result |
| 29 |
!* is stored in the table file TABLE. |
| 30 |
!* |
| 31 |
!* defaults: catalog = ? , result = ? , sky = ? , calibration = ? , mode = 3 |
| 32 |
!* |
| 33 |
!* note: The error is estimated from the noise level in the |
| 34 |
!* Fourier-transform. The angle is still arbitrary and has |
| 35 |
!* to be transformed to a standard system by observations of |
| 36 |
!* standard stars. |
| 37 |
!* |
| 38 |
!* All commands are explained in the MIDAS manual. |
| 39 |
!* Scratch files are called XX* and are deleted afterwards. |
| 40 |
!* |
| 41 |
!* |
| 42 |
!********************************************************************* |
| 43 |
! |
| 44 |
DEFINE/PARA P1 ? ? "catalog of input data files" |
| 45 |
DEFINE/PARA P2 ? ? "output table holding results" |
| 46 |
DEFINE/PARA P3 ? ? "input sky file" |
| 47 |
DEFINE/PARA P4 ? ? "input calibration file" |
| 48 |
DEFINE/PARA P5 3 ? "data reduction mode" |
| 49 |
!---------------------------------- |
| 50 |
! |
| 51 |
! get number of data files and prevent |
| 52 |
! further entries in image catalog |
| 53 |
! |
| 54 |
!---------------------------------- |
| 55 |
SHOW/ICAT P1 NODISPLAY |
| 56 |
CLEAR/ICAT |
| 57 |
!---------------------------------- |
| 58 |
! |
| 59 |
! create output table |
| 60 |
! |
| 61 |
!---------------------------------- |
| 62 |
COMP/KEYW OUT_A(1:20) = M$TIME() |
| 63 |
WRITE/OUT {OUT_A(13:20)} creating output table {P2} |
| 64 |
WRITE/OUT |
| 65 |
! |
| 66 |
CREA/TABLE {P2} 17 {OUTPUTI(1)} NULL |
| 67 |
CREA/COLUMN {P2} :IDENT "A" A16 C*16 |
| 68 |
CREA/COLUMN {P2} :UT "A" E12.5 |
| 69 |
CREA/COLUMN {P2} :X_intensity "A" E12.5 |
| 70 |
CREA/COLUMN {P2} :Y_intensity "A" E12.5 |
| 71 |
CREA/COLUMN {P2} :polxy "A" E12.5 |
| 72 |
CREA/COLUMN {P2} :errorxy "A" E12.5 |
| 73 |
CREA/COLUMN {P2} :anglexy "A" E12.5 |
| 74 |
CREA/COLUMN {P2} :polx "A" E12.5 |
| 75 |
CREA/COLUMN {P2} :errorx "A" E12.5 |
| 76 |
CREA/COLUMN {P2} :anglex "A" E12.5 |
| 77 |
CREA/COLUMN {P2} :poly "A" E12.5 |
| 78 |
CREA/COLUMN {P2} :errory "A" E12.5 |
| 79 |
CREA/COLUMN {P2} :angley "A" E12.5 |
| 80 |
!------------------------------------------------- |
| 81 |
! |
| 82 |
! extract useful part of sky |
| 83 |
! |
| 84 |
!------------------------------------------------- |
| 85 |
EXTRA/LIN XXS1 = {P3}[1,1:32,1] |
| 86 |
EXTRA/LIN XXS2 = {P3}[1,2:32,2] |
| 87 |
!------------------------------------------------- |
| 88 |
! |
| 89 |
! extract normalized calibration |
| 90 |
! |
| 91 |
!------------------------------------------------- |
| 92 |
EXTRA/LIN XXSC = {P4}[1,8:32,8] |
| 93 |
!------------------------------------------------- |
| 94 |
! |
| 95 |
! divide sky by integration time |
| 96 |
! |
| 97 |
!------------------------------------------------- |
| 98 |
COMP/IMAG XXS1 = XXS1/{{P3},O_TIME(7)} |
| 99 |
COMP/IMAG XXS2 = XXS2/{{P3},O_TIME(7)} |
| 100 |
!------------------------------------------------- |
| 101 |
! |
| 102 |
! do-loop for object files |
| 103 |
! |
| 104 |
!------------------------------------------------- |
| 105 |
DEFINE/LOCAL CATAL/I/1/1 0 |
| 106 |
CAT_LOOP: |
| 107 |
! |
| 108 |
! get name of data files from catalog |
| 109 |
! |
| 110 |
STORE/FRAME IN_A {P1}.cat 1 FINITO |
| 111 |
! |
| 112 |
COMP/KEYW OUT_A(1:20) = M$TIME() |
| 113 |
WRITE/OUT {OUT_A(13:20)} processing file {IN_A} |
| 114 |
! |
| 115 |
! store file identifier in table column :IDENT |
| 116 |
! |
| 117 |
{P2},:IDENT,@{CATAL} = "{{IN_A},IDENT(1:16)}" |
| 118 |
! |
| 119 |
! store UT in table |
| 120 |
! |
| 121 |
{P2},:UT,@{CATAL} = {{IN_A},O_TIME(5)} |
| 122 |
! |
| 123 |
! extract useful part |
| 124 |
! |
| 125 |
EXTRA/LIN XXI1 = {IN_A}[1,1:32,1] |
| 126 |
EXTRA/LIN XXI2 = {IN_A}[1,2:32,2] |
| 127 |
! |
| 128 |
! divide by integration time, subtract sky and calibrate |
| 129 |
! |
| 130 |
COMP/IMAG XXI1 = (XXI1/{XXI1,O_TIME(7)}-XXS1)/XXSC |
| 131 |
COMP/IMAG XXI2 = (XXI2/{XXI1,O_TIME(7)}-XXS2)/XXSC |
| 132 |
! |
| 133 |
! normalize and store mean value |
| 134 |
! |
| 135 |
STAT/IMAG XXI1 ? ? ? RN |
| 136 |
COMP/IMAG XXI1 = XXI1/{OUTPUTR(3)}-1. |
| 137 |
{P2},:X_intensity,@{CATAL} = {OUTPUTR(3)} |
| 138 |
! |
| 139 |
STAT/IMAG XXI2 ? ? ? RN |
| 140 |
COMP/IMAG XXI2 = XXI2/{OUTPUTR(3)}-1. |
| 141 |
{P2},:Y_intensity,@{CATAL} = {OUTPUTR(3)} |
| 142 |
! |
| 143 |
! branch to modes |
| 144 |
! |
| 145 |
IF P5 .EQ. 2 THEN |
| 146 |
GOTO XANDY |
| 147 |
ENDIF |
| 148 |
! |
| 149 |
! reduce X channel data |
| 150 |
! |
| 151 |
FFT/FPOW XXI1 |
| 152 |
COMP/KEYW OUTPUTR(1) = 205.234*{POWER[@13]} |
| 153 |
{P2},:polx,@{CATAL} = {OUTPUTR(1)} |
| 154 |
! |
| 155 |
! compute error |
| 156 |
! |
| 157 |
COMP/IMAG XXIE = POWER*POWER |
| 158 |
STAT/IMAG XXIE ? ? ? RN |
| 159 |
COMP/KEYW OUTPUTR(1) = M$SQRT({OUTPUTR(3)})*232.2 |
| 160 |
{P2},:errorx,@{CATAL} = {OUTPUTR(1)} |
| 161 |
! |
| 162 |
! compute angle |
| 163 |
! |
| 164 |
IF FFTR[@13] .GT. 0. THEN |
| 165 |
COMP/KEYW OUTPUTR(1) = 45.-0.5*M$ATAN({FFTI[@13]}/{FFTR[@13]}) |
| 166 |
{P2},:anglex,@{CATAL} = {OUTPUTR(1)} |
| 167 |
ELSE |
| 168 |
COMP/KEYW OUTPUTR(1) = 135.-0.5*M$ATAN({FFTI[@13]}/{FFTR[@13]}) |
| 169 |
{P2},:anglex,@{CATAL} = {OUTPUTR(1)} |
| 170 |
ENDIF |
| 171 |
! |
| 172 |
! reduce Y channel data |
| 173 |
! |
| 174 |
FFT/FPOW XXI2 |
| 175 |
COMP/KEYW OUTPUTR(1) = 205.234*{POWER[@13]} |
| 176 |
{P2},:poly,@{CATAL} = {OUTPUTR(1)} |
| 177 |
! |
| 178 |
! compute error |
| 179 |
! |
| 180 |
COMP/IMAG XXIE = POWER*POWER |
| 181 |
STAT/IMAG XXIE ? ? ? RN |
| 182 |
COMP/KEYW OUTPUTR(1) = M$SQRT({OUTPUTR(3)})*232.2 |
| 183 |
{P2},:errory,@{CATAL} = {OUTPUTR(1)} |
| 184 |
! |
| 185 |
! compute angle |
| 186 |
! |
| 187 |
IF FFTR[@13] .LT. 0. THEN |
| 188 |
COMP/KEYW OUTPUTR(1) = 45.-0.5*M$ATAN({FFTI[@13]}/{FFTR[@13]}) |
| 189 |
{P2},:angley,@{CATAL} = {OUTPUTR(1)} |
| 190 |
ELSE |
| 191 |
COMP/KEYW OUTPUTR(1) = 135.-0.5*M$ATAN({FFTI[@13]}/{FFTR[@13]}) |
| 192 |
{P2},:angley,@{CATAL} = {OUTPUTR(1)} |
| 193 |
ENDIF |
| 194 |
! |
| 195 |
! now use differential method |
| 196 |
! |
| 197 |
IF P5 .EQ. 1 THEN |
| 198 |
GOTO NEXT |
| 199 |
ENDIF |
| 200 |
XANDY: |
| 201 |
! |
| 202 |
COMP/IMAG XXI3 = (XXI1-XXI2)/(XXI1+XXI2+2) |
| 203 |
! |
| 204 |
! Fourier-transform of two-channel data |
| 205 |
! |
| 206 |
FFT/FPOW XXI3 |
| 207 |
COMP/KEYW OUTPUTR(1) = 205.234*{POWER[@13]} |
| 208 |
{P2},:polxy,@{CATAL} = {OUTPUTR(1)} |
| 209 |
! |
| 210 |
! compute error |
| 211 |
! |
| 212 |
COMP/IMAG XXIE = POWER*POWER |
| 213 |
STAT/IMAG XXIE ? ? ? RN |
| 214 |
COMP/KEYW OUTPUTR(1) = M$SQRT({OUTPUTR(3)})*232.2 |
| 215 |
{P2},:errorxy,@{CATAL} = {OUTPUTR(1)} |
| 216 |
! |
| 217 |
! compute angle |
| 218 |
! |
| 219 |
IF FFTR[@13] .GT. 0. THEN |
| 220 |
COMP/KEYW OUTPUTR(1) = 45.-0.5*M$ATAN({FFTI[@13]}/{FFTR[@13]}) |
| 221 |
{P2},:anglexy,@{CATAL} = {OUTPUTR(1)} |
| 222 |
ELSE |
| 223 |
COMP/KEYW OUTPUTR(1) = 135.-0.5*M$ATAN({FFTI[@13]}/{FFTR[@13]}) |
| 224 |
{P2},:anglexy,@{CATAL} = {OUTPUTR(1)} |
| 225 |
ENDIF |
| 226 |
! |
| 227 |
NEXT: |
| 228 |
! |
| 229 |
DELETE XXI% NO |
| 230 |
DELETE FFTI NO |
| 231 |
DELETE FFTR NO |
| 232 |
DELETE POWER NO |
| 233 |
! |
| 234 |
GOTO CAT_LOOP |
| 235 |
FINITO: |
| 236 |
DELETE XXS% NO |
| 237 |
RETURN |