Skip to content
Snippets Groups Projects
Commit 624b8c9d authored by Egor Sobolev's avatar Egor Sobolev
Browse files

Add total intensity computation, fix names

parent 9c79f65a
No related branches found
No related tags found
1 merge request!986[AGIPD] Feat: lit-pixel counter
...@@ -113,9 +113,12 @@ class LitPixelCounter(AnalysisAddon): ...@@ -113,9 +113,12 @@ class LitPixelCounter(AnalysisAddon):
channel = "litpx" channel = "litpx"
output_fields = [ output_fields = [
"cellId", "pulseId", "trainId", "litPixels", "goodPixels"] "cellId", "pulseId", "trainId",
"litPixels", "unmaskedPixels", "totalIntensity"
]
required_data = [ required_data = [
"data", "mask", "cellId", "pulseId", "trainId"] "data", "mask", "cellId", "pulseId", "trainId"
]
def __init__(self, data, threshold=0.8): def __init__(self, data, threshold=0.8):
"""Initialize the instance of lit-pixel analysis addon. """Initialize the instance of lit-pixel analysis addon.
...@@ -135,19 +138,23 @@ class LitPixelCounter(AnalysisAddon): ...@@ -135,19 +138,23 @@ class LitPixelCounter(AnalysisAddon):
self.mask = data["mask"] self.mask = data["mask"]
self.threshold = threshold self.threshold = threshold
self.num_good_px = sharedmem.full(self.max_images, 0, int) self.num_unmasked_px = sharedmem.full(self.max_images, 0, int)
self.num_lit_px = sharedmem.full(self.max_images, 0, int) self.num_lit_px = sharedmem.full(self.max_images, 0, int)
self.total_intensity = sharedmem.full(self.max_images, 0, int)
self.data["litPixels"] = self.num_lit_px self.data["litPixels"] = self.num_lit_px
self.data["goodPixels"] = self.num_good_px self.data["unmaskedPixels"] = self.num_unmasked_px
self.data["totalIntensity"] = self.total_intensity
def process(self, chunk): def process(self, chunk):
ix = range(*chunk.indices(self.num_images)) ix = range(*chunk.indices(self.num_images))
for i in ix: for i in ix:
mask = self.mask[i] == 0 mask = self.mask[i] == 0
self.total_intensity[i] = np.sum(
self.image[i], initial=0, where=mask)
self.num_lit_px[i] = np.sum( self.num_lit_px[i] = np.sum(
self.image[i] > self.threshold, initial=0, where=mask) self.image[i] > self.threshold, initial=0, where=mask)
self.num_good_px[i] = np.sum(mask) self.num_unmasked_px[i] = np.sum(mask)
def source_name(self, karabo_id, channel): def source_name(self, karabo_id, channel):
return f"{karabo_id}/LITPX/{channel}" return f"{karabo_id}/LITPX/{channel}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment