Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/~mperrin/software/sources/ircal_deghost.pro
Дата изменения: Sat Aug 11 03:00:42 2007
Дата индексирования: Sat Mar 1 16:57:16 2014
Кодировка:

Поисковые слова: http www.badastronomy.com bad tv foxapollo.html

;+
; NAME: ircal_deghost
; PURPOSE:
; remove annoying negative ghosts caused by channel crosstalk.
;
; USAGE:
; **** NOTE: This is mostly a cosmetic improvement ****
; If you're trying to do science on faint objects inside the
; crosstalk region, you're on your own!
;
; This seems to work sort of OK. It could probably improved in
; various ways, but I'm not entirely sure how useful this will be,
; so for now I'm not going to worry about it.
;
;
;
; INPUTS:
; KEYWORDS:
; OUTPUTS:
;
; HISTORY:
; Began 2004-10-21 21:45:07 by Marshall Perrin
; 2006-06-12 code cleanup for unused option ,m=m to imcut.
;-

PRO ircal_deghost,image,imout,height=height,center=center,header=header

if ~(keyword_set(height)) then height=32
sz = size(image)

if ~(keyword_set(center)) then begin
findmaxstar,image,mx,my
endif else begin
mx = center[0]
my = center[1]
endelse

message,/info," Deghosting using center "+printcoo(mx,my)
if keyword_set(header) then begin
sxaddhist,"IRCAL_DEGHOST: Now removing readout channel crosstalk",header
sxaddhist,"IRCAL_DEGHOST: Using offsets of +- 128 px from "+printcoo(mx,my),header
endif
; 7 6 5
; 0 4
; 1 2 3


; ims = fltarr(128,128,8)
; ims[*,*,0] = image[mx-64-128:mx-65,my-64:my+63]
; ims[*,*,1] = image[mx-64-128:mx-65,my-64-128:my-65]
; ims[*,*,2] = image[mx-64:mx+63,my-64-128:my-65]
; ims[*,*,3] = image[mx+63:mx+63+127,my-64-128:my-65]
; ims[*,*,4] = image[mx+63:mx+63+127,my-64:my+63]
; ims[*,*,5] = image[mx+63:mx+63+127,my+63:my+63+127]
; ims[*,*,6] = image[mx-64:mx+63,my+63:my+63+127]
; ims[*,*,7] = image[mx-64-128:mx-65,my+63:my+63+127]
;

ims2 = fltarr(128,128,8)
masks = intarr(128,128,8)
mx+=30
ims2[*,*,0] = imcut(image,128,mx-128,my,/pad,mask=m,/silent) & masks[*,*,0]=m
ims2[*,*,1] = imcut(image,128,mx-128,my-128,/pad,mask=m,/silent) & masks[*,*,1]=m
ims2[*,*,2] = imcut(image,128,mx,my-128,/pad,mask=m,/silent) & masks[*,*,2]=m
ims2[*,*,3] = imcut(image,128,mx+128,my-128,/pad,mask=m,/silent) & masks[*,*,3]=m
ims2[*,*,4] = imcut(image,128,mx+128,my,/pad,mask=m,/silent) & masks[*,*,4]=m
ims2[*,*,5] = imcut(image,128,mx+128,my+128,/pad,mask=m,/silent) & masks[*,*,5]=m
ims2[*,*,6] = imcut(image,128,mx,my+128,/pad,mask=m,/silent) & masks[*,*,6]=m
ims2[*,*,7] = imcut(image,128,mx-128,my+128,/pad,mask=m,/silent) & masks[*,*,7]=m

masks[*,0:height,*] = 0
masks[*,128-height:*,*] = 0


;medarr,ims,ghost
medarr,ims2,ghost2,masks

; enforce zero-mean at edges
offset = median( [ghost2[*,height+1:height+4],ghost2[*,128-height-4:128-height-1]])
ghost2[*,height+1:128-height-1] -= offset

; fade out the edges
for i=1,9 do ghost2[*,[height+i,128-height-i]] *= i/10.
for i=1,9 do ghost2[[i,128-i],*] *= i/10.
ghost2[*,0:height,*] = 0
ghost2[*,128-height:*,*] = 0


;
; imout = image
; imout[mx-64-128:mx-65,my-64:my+63] -= ghost
; imout[mx-64-128:mx-65,my-64-128:my-65] -= ghost
; imout[mx-64:mx+63,my-64-128:my-65] -= ghost
; imout[mx+63:mx+63+127,my-64-128:my-65] -= ghost
; imout[mx+63:mx+63+127,my-64:my+63] -= ghost
; imout[mx+63:mx+63+127,my+63:my+63+127] -= ghost
; imout[mx-64:mx+63,my+63:my+63+127] -= ghost
; imout[mx-64-128:mx-65,my+63:my+63+127] -= ghost

mx += 64+128
my += 64+128

imout2 = image;,mask

subtract = fltarr(sz[1]+400,sz[2]+400)

subtract[mx-64-128:mx-65,my-64:my+63] -= ghost2
subtract[mx-64-128:mx-65,my-64-128:my-65] -= ghost2
subtract[mx-64:mx+63,my-64-128:my-65] -= ghost2
subtract[mx+63:mx+63+127,my-64-128:my-65] -= ghost2
subtract[mx+63:mx+63+127,my-64:my+63] -= ghost2
subtract[mx+63:mx+63+127,my+63:my+63+127] -= ghost2
subtract[mx-64:mx+63,my+63:my+63+127] -= ghost2
subtract[mx-64-128:mx-65,my+63:my+63+127] -= ghost2
subtract2 = imcut(subtract,[sz[1],sz[2]],sz[1]/2+64+128,sz[2]/2+64+128,/fix)
subtract2 = subtract[64+128:64+128+sz[1]-1, 64+128:64+128+sz[2]-1]

imout2 = image+subtract2

atv,[[[image]],[[imout2]]],/bl,/log,min=-2,max=200
imout = temporary(imout2)

;return,imout2




end