clatlan / cdiutils

A python package to help Coherent Diffraction Imaging (CDI) practitioners in their analysis.
MIT License
12 stars 7 forks source link

Add merlin detector mask #61

Open Abd-zak opened 3 months ago

Abd-zak commented 3 months ago

The merlin detector of SixS is not in the list.

https://github.com/clatlan/cdiutils/blob/8f573d2d47cbbb508c4f228afcece7caa4d494ef/cdiutils/load/loader.py#L232C1-L232C72

clatlan commented 3 months ago

Sure, I have no idea what merlin detector mask looks like. Can you provide me with the associated mask?

Abd-zak commented 3 months ago

i just added it as following (the gap are eliminated automatically in my data)

    elif detector_name in ("merlin"):
        mask = np.zeros(shape=(512, 512))
DSimonne commented 3 months ago

Hi, do you mean that when you give the path to your mask that you made during the experiment, it does not work ?

DSimonne commented 3 months ago
class MerlinSixS(Detector):
    """Implementation of the Merlin detector for SixS."""

    def __init__(self, name, **kwargs):
        super().__init__(name=name, **kwargs)
        self.saturation_threshold = 1e6

    def _mask_gaps(self, data, mask):
        """
        Mask the gaps between sensors in the detector.

        :param data: a 2D numpy array
        :param mask: a 2D numpy array of the same shape as data
        :return:

         - the masked data
         - the updated mask

        """
        valid.valid_ndarray(
            (data, mask), ndim=2, shape=self.unbinned_pixel_number, fix_shape=True
        )

        data[:, 254:257] = 0
        data[254:257, :] = 0

        mask[:, 254:257] = 1
        mask[254:257, :] = 1
        return data, mask

    @property
    def unbinned_pixel_number(self):
        """
        Define the number of pixels of the unbinned detector.

        Convention: (vertical, horizontal)
        """
        return 512, 512

    @property
    def unbinned_pixel_size(self):
        """Pixel size (vertical, horizontal) of the unbinned detector in meters."""
        return 55e-06, 55e-06

see this code for used for the bcdi package, it's a specific Merlin configuration

Abd-zak commented 3 months ago

In both case if the mask given ior not it do get_mask function where the mask is defined list of detectors.

The snipped code must do the job.

clatlan commented 2 months ago

Done. The current merlin mask is np.zeros(shape=(512, 512)), ie no masked pixels. Tell me if you want to add the masked pixels as given above.