XMM-Newton SAS Home Page
XMM-Newton Science Analysis System


embadpixfind (embadpixfind-2.6.1) [xmmsas_20230412_1735-21.0.0]


Algorithm

    Read the parameters

    Define goodPixel array, set to True

    if incremental then
       Read the bad pixels already in file
       goodPixel(bad pixels) = False
    endif

    if usecal then
       Read the bad pixels in CAL
       goodPixel(uplinked and dead pixels) = False
       if not ignoreccfbright then goodPixel(bright pixels) = False
       if includedeadpixels then Write dead pixels to output list
    endif

    Read map = projected image

    Iterate
       call findAllBad(map, goodPixel, bad)
    until nothing new is found or niter is reached

    Write bad pixels file


subroutine findAllBad(map, goodPixel, bad)

! Get local average around each pixel and estimated significance
    call avMedFilter(map, goodPixel, medsmooth, badtest)
! Look for bright pixels
    call findBadPix(map, goodPixel, medsmooth, badtest, False, bad)
    if findbadsegments then
! Look for bright/dark columns
       profil = sum(map,2)
       call findBad1D(profil, bad)
! Look for bright/dark rows
       profil = sum(map,1)
       call findBad1D(profil, bad)
       Update goodPixel and medsmooth/badtest around bad columns/rows
    endif
! Look for dark pixels
    call findBadPix(map, goodPixel, medsmooth, badtest, True, bad)

end subroutine findAllBad

subroutine avMedFilter(map, goodPixel, medsmooth, badtest)

    Loop over current pixel
       Consider all good pixels in window around current pixel
       Extract average (or median+1 if smaller) into medsmooth
       Estimate dispersion from average absolute deviation divided by 0.8
       Estimate significance S1 of excess using Gaussian law
       If larger than 3, estimate significance S2 of excess using Li and Ma
       badtest = min(S1,S2)
    endloop

end subroutine avMedFilter

subroutine findBadPix(map, goodPixel, medsmooth, badtest, negative, bad)

    Loop over current bad pixel
       Find maximum in badtest (minimum if negative) down to probathreshold
       Get probability of excess using binomial law
       if probability < probathreshold  then
          add bad pixel to list
          Update goodPixel and  medsmooth/badtest around maximum
       endif
    endloop

end subroutine findBadPix

subroutine findBad1D(profil, psf1D, bad)

    Find bad columns in profil (same as findBadPix)
    Loop over bad columns
       Get expected distribution along column from its neighbours
       width = 1/(expected count rate per pixel)
       Get running integral over bins of width pixels
       While total(rest of column) larger (lower if negative) than expected
          Find maximum integral (minimum if negative)
          Remove segment of width pixels around it
       endwhile
    endloop

end subroutine findBad1D



XMM-Newton SOC -- 2023-04-16