; ---------------------------------------------------------------------- ; Create a sigma image for a subsection of an image. ; Set siglim high (99999.) for first pass, then low (5.) for second pass. ; ;> valimg gets set with | image - median | (aka residual) ;> sigimg get set with residual / error (aka scaled deviation) pro nsx_sigma_subsection, nc, nr, image, sigimg, valimg, c1, c2, r1, r2, iipix, jjpix, siglim mp = (1+c2-c1) * (1+r2-r1) arr = fltarr(mp) ; Median and RMS from median. ;> Not sure why ((ii ne iipix)&&(jj ne jjpix)) -- ;> this cuts out the center row and center column ;> rather than just the center pixel narr=0 for ii=c1,c2 do begin for jj=r1,r2 do begin if ((ii ne iipix)&&(jj ne jjpix)) then begin pixno = ii + (jj * long(nc)) if ( (*sigimg)[pixno] lt siglim) then begin arr[narr] = (*image)[pixno] ++narr endif endif endfor endfor median = cfind_median(narr,arr) ; rms=0. for kk=0L,narr-1 do begin rms = rms + ((arr[kk] - median) * (arr[kk] - median)) endfor rms = sqrt(( rms / double(narr) )) ; ; Load sigmas image. */ pixno = iipix + (jjpix * long(nc)) (*valimg)[pixno] = (*image)[pixno] - median (*sigimg)[pixno] = ABS(( (*valimg)[pixno])) / rms end