Skip to content

Commit

Permalink
Apply panel buffers to raw view image data too
Browse files Browse the repository at this point in the history
Now, any pixels in the panel buffers are displayed as `np.nan` in
the raw view as well.

Signed-off-by: Patrick Avery <[email protected]>
  • Loading branch information
psavery committed Oct 11, 2023
1 parent 58a0111 commit 5bba70f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion hexrd/ui/hexrd_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,12 +896,25 @@ def masked_images_dict(self):

def create_masked_images_dict(self, fill_value=0):
"""Get an images dict where masks have been applied"""
from hexrd.ui.create_hedm_instrument import create_hedm_instrument

images_dict = self.images_dict
if not self.visible_masks:
instr = create_hedm_instrument()

has_masks = bool(self.visible_masks)
has_panel_buffers = any(panel.panel_buffer is not None
for panel in instr.detectors.values())

if not has_masks and not has_panel_buffers:
# Force a fill_value of 0 if there are no visible masks
# and no panel buffers.
fill_value = 0

for det, mask in self.raw_masks_dict.items():
if has_panel_buffers:
panel = instr.detectors[det]
utils.convert_panel_buffer_to_2d_array(panel)

for name, img in images_dict.items():
if (np.issubdtype(type(fill_value), np.floating) and
not np.issubdtype(img.dtype, np.floating)):
Expand All @@ -910,6 +923,9 @@ def create_masked_images_dict(self, fill_value=0):
if det == name:
img[~mask] = fill_value

if has_panel_buffers:
img[~panel.panel_buffer] = fill_value

return images_dict

def save_imageseries(self, ims, name, write_file, selected_format,
Expand Down

0 comments on commit 5bba70f

Please sign in to comment.