Issue

Issue reported by Sabine, Valerio, Philip
Mariani, Valerio
Mon 2/7/2022 4:31 PM
Dear Phil, Mikhail and Chris,

   Sabine provided me with the mask they are using. You can find it at:
~valmarpsana-extra-extreme-sabine2.h5

Like the name suggests, it goes to the extreme in masking stuff. It looks more or less like the attached screenshot.
Sabine says she is working on another mask, which I will pass to you as soon as I get.
Thank you!
Valerio

-----

From: Hart, Philip Adam <philiph@slac.stanford.edu>
Sent: Wednesday, November 10, 2021 3:01 PM
To: lcls-det-support <lcls-det-support@slac.stanford.edu>
Subject: JF4M status
 
Hi, I'm looking a bit at the report of damaged JF4M pixels following an ice (?) event.  I see we've gone from ~261 official bad pixels to ~1931 and now have ~520 more pixels stuck in low when autoranging (id est, in 'Normal').  A simple script to capture this information and look at pixels stuck in the wrong state for a pedestal run is
~philiph/psana/jungfrau/2021/badSwitchStatus.py.

E.g.,

psanagpu103:~/psana/jungfrau/2021$ python badSwitchStatus.py cxilu7619 168
mode is Normal
found 4194254 pixels in Normal
found 20 pixels in Med
found 30 pixels in Low
mode is Med
found 29 pixels in Normal
found 4194273 pixels in Med
found 2 pixels in Low
mode is Low
found 23 pixels in Normal
found 3 pixels in Med
found 4194272 pixels in Low
number of bad pixels overall: 261

psanagpu103:~/psana/jungfrau/2021$ python badSwitchStatus.py cxilv1019 142
mode is Normal
found 4193737 pixels in Normal
found 17 pixels in Med
found 550 pixels in Low
mode is Med
found 28 pixels in Normal
found 4194274 pixels in Med
found 2 pixels in Low
mode is Low
found 22 pixels in Normal
found 3 pixels in Med
found 4194273 pixels in Low
number of bad pixels overall: 1931

- Philip

Implementation

	    igm - is a gain mode index 0,1,2 for Normal-00, Med-01, Low-11
        gbits = raw>>14 # 00/01/11 - gain bits for mode 0,1,2
        fg0, fg1, fg2 = gbits==0, gbits==1, gbits==3
        bad = (np.logical_not(fg0),\
               np.logical_not(fg1),\
               np.logical_not(fg2))[igm]

Images of mask versions

User's mask

Mask from ~valmar/psana-extra-extreme-sabine2.h5 - very agressive masking - radial=9 pix around bad!

Bad pixel status as mask

Images of generated from status_as_mask arrays (3, 8, 512, 1024) merged for 3 gain ranges to the shape=(8, 512, 1024)

  1. mask = det.status_as_mask(par, mode=3, mstcode=63) - mask all status codes but bad gain switch
  2. mstcode=64 - mask of the new bad gain switch status
  3. mstcode=127 - mask all bad status codes

cxic00120 run 42

cxic00120 run 24

cxic00120 run 42 NEIGHBOURS MASKED AS +/-1pixel around each bad

  • mstcode=64 strongly overlaps with 63 
  • mstcode=63 and 127 shows about the same mask, difference is minor as shown in pixel status statistics.

pixel status statistics

Merged for 3 gain modes status
cxic00120 run:24 status.shape:(8, 512, 1024) size: 4194304
bad pixels w/o sw: number of pixels containing bits   63(dec)  077(oct): 3739 of total bad 3768 of total 4194304
bad pixels switch: number of pixels containing bits   64(dec) 0100(oct): 1117 of total bad 3768 of total 4194304
bad pixels total : number of pixels containing bits  127(dec) 0177(oct): 3768 of total bad 3768 of total 4194304

Bad status code 64 adds 3768-3739=29 bad pixel.


Non-merged for 3 gain modes status

cxic00120 run:24 status.shape:(3, 8, 512, 1024) size: 12582912
bad pixels w/o sw: number of pixels containing bits   63(dec)  077(oct): 6217 of total bad 6280 of total 12582912
bad pixels switch: number of pixels containing bits   64(dec) 0100(oct): 1150 of total bad 6280 of total 12582912
bad pixels total : number of pixels containing bits  127(dec) 0177(oct): 6280 of total bad 6280 of total 12582912

Bad status code 64 adds 6280-6217=63 bad pixel.


Non-merged for 3 gain modes status

cxic00120 run:42 status.shape:(3, 8, 512, 1024) size: 12582912
bad pixels w/o sw: number of pixels containing bits   63(dec)  077(oct): 7673 of total bad 7734 of total 12582912
bad pixels switch: number of pixels containing bits   64(dec) 0100(oct): 1850 of total bad 7734 of total 12582912
bad pixels total : number of pixels containing bits  127(dec) 0177(oct): 7734 of total bad 7734 of total 12582912

Bad status code 64 adds 7734-7673=61 bad pixel.

Combined mask

det.mask(evt, calib=False, status=True, edges=True, central=True, unbond=False, unbondnbrs=False, mode=0o377, width=5, wcentral=5, mstcode=0xffff)

Custom mask

import PSCalib.GlobalUtils as gu

mask = det.status_as_mask(evt, mstcode=0o377) # mode=0 - by default do not mask neighbors

mask = gu.mask_neighbors_in_radius(mask, rad=6, ptrn='r')

mask = gu.merge_masks(mask, det.mask_geo(evt, width=10, wcentral=5)) # mbits=0o377, where 1-edges, 2-central, 4-non-bonded for cspad2x1, ... non-bonded neighbors

#mask = gu.merge_masks(mask, gu.mask_edges(mask, mrows=2, mcols=4)) # masks each segment edges only

mask = gu.merge_masks(mask, det.mask_calib(evt))

Summary

  • New bad pixel status code is added for bad gain mode switch:
[I] L0703 bad pixel status:
  status  1:     1240 pixel rms       > 19.414
  status  2:     1875 pixel rms       < 0.611
  status  4:     1755 pixel intensity > 16000 in more than 0.1 fraction of events
  status  8:      111 pixel intensity < 1 in more than 0.1 fraction of events
  status 16:      340 pixel average   > 3761.95
  status 32:     1940 pixel average   < 1226.6
  status 64:     1790 pixel with bad gain mode switch
  • However this new status bit 64 strongly overlaps with other bad pixel status.
  • User's mask contains more bad pixels in peripheral rings ...

References


  • No labels