|
sample IDL program fred5.pro to reduce pdat:
dat1={pdat0,xc:0.,yc:0.,sm:0.,flx:0.,mag:0.,merr:0.,im:""}
fx0=fltarr(5)
qme0=fltarr(5)
fx90=fltarr(5)
qme90=fltarr(5)
fx45=fltarr(5)
ume45=fltarr(5)
fx135=fltarr(5)
ume135=fltarr(5)
q=fltarr(5)
qme=fltarr(5)
u=fltarr(5)
ume=fltarr(5)
openr,runit,"pdat",/get_lun
for i=0,4 do begin
readf,runit,dat1
fx0[i]=dat1.flx
qme0[i]=dat1.merr
readf,runit,dat1
fx90[i]=dat1.flx
qme90[i]=dat1.merr
endfor
for i=0,4 do begin
readf,runit,dat1
fx135[i]=dat1.flx
ume135[i]=dat1.merr
readf,runit,dat1
fx45[i]=dat1.flx
ume45[i]=dat1.merr
endfor
free_lun,runit
for i=0,4 do begin
q[i]=(fx0[i]-fx90[i])/(fx0[i]+fx90[i])
qme[i]=(qme0[i]+qme90[i])/2.
endfor
for i=0,4 do begin
u[i]=(fx45[i]-fx135[i])/(fx45[i]+fx135[i])
ume[i]=(ume45[i]+ume135[i])/2.
endfor
nq=size(q,/n_elements)
nu=size(u,/n_elements)
q=q(sort(q))
u=u(sort(u))
qm=mean(q)
um=mean(u)
dq=stddev(q)
du=stddev(u)
qem=mean(qme)
uem=mean(ume)
pme=(qem+uem)/2.
print
print,format='("q vals =",4(" ",f8.5,",")," ",f8.5)',q
print,format='("u vals =",4(" ",f8.5,",")," ",f8.5)',u
print
print,format='("q = ",f8.5," +/- ",f7.5)',qm,dq
print,format='("u = ",f8.5," +/- ",f7.5)',um,du
print,format='("qmerr = ",f7.5)',qem
print,format='("umerr = ",f7.5)',uem
print
;instrumental corrections
qi=0.
ui=0.
pacorr=0.
;correct q and u
qm=qm-qi
um=um-ui
;find the polarization
p=sqrt(qm^2.+um^2.)
dp=(dq+du)/2.
;find the position angle
if ((qm eq 0.) and (um ge 0.)) then th=!dpi/4 else $
if ((qm eq 0.) and (um lt 0.)) then th=3*!dpi/4 else $
th=0.5*atan(um/qm)
if (qm lt 0.) then th=th+!dpi/2
if (th lt 0.) then th=th+!dpi
th=th*!radeg
if (p eq 0.) then dth=180.d else dth=!radeg/2*dp/p
if (dth gt 180.) then dth=180.d
;correct position angle
th=th+pacorr
if (th ge 180.) then th=th-180
if (th lt 0.) then th=th+180
;reconstruct q and u after position angle correction
qm=p*cos(2*th/!radeg)
um=p*sin(2*th/!radeg)
print,format='("q(%) = ",f6.2," +/- ",f5.2," (",i1,")")',100.*qm,100.*dq,nq
print,format='("u(%) = ",f6.2," +/- ",f5.2," (",i1,")")',100.*um,100.*du,nu
print,format='("p(%) = ",f5.2," +/- ",f5.2)',100.*p,100.*dp
print,format='("pmerr(%) = ",f5.2)',100.*pme
print,format='("th(deg) = ",f5.1," +/- ",f5.1)',th,dth
print
end
output from IDL program fred5.pro and photometry data file
pdat above:
q vals = -0.03335, -0.03077, -0.03061, -0.02965, -0.02877
u vals = -0.00346, -0.00302, -0.00224, -0.00213, -0.00087
q = -0.03063 +/- 0.00172
u = -0.00234 +/- 0.00099
qmerr = 0.00110
umerr = 0.00100
q(%) = -3.06 +/- 0.17 (5)
u(%) = -0.23 +/- 0.10 (5)
p(%) = 3.07 +/- 0.14
pmerr(%) = 0.11
th(deg) = 92.2 +/- 1.3
|