コード例 #1
0
ファイル: areadetector.py プロジェクト: Tubbz-alt/lcls2
    def image(self, evt, nda=None, **kwa):
        logger.debug('in AreaDretector.image')
        if any(v is None for v in self.pix_rc):
            self.cached_pixel_coord_indexes(evt, **kwa)
            if any(v is None for v in self.pix_rc): return None

        vbase = kwa.get('vbase', 0)
        mapmode = kwa.get('mapmode', 2)
        fillholes = kwa.get('fillholes', True)

        if mapmode == 0: return self.img_entries

        data = self.calib(evt) if nda is None else nda
        if data is None:
            logger.warning('AreaDetector.image calib returns None')
            return None

        #logger.debug(info_ndarr(data, 'data ', last=3))

        rows, cols = self.pix_rc
        img = img_from_pixel_arrays(rows, cols, weight=data,
                                    vbase=vbase)  # mapmode==1
        if mapmode == 2:
            img_multipixel_max(img, data, self.dmulti_pix_to_img_idx)
        elif mapmode == 3:
            img_multipixel_mean(img, data, self.dmulti_pix_to_img_idx,
                                self.dmulti_imgidx_numentries)

        if mapmode < 4 and fillholes:
            fill_holes(img, self.hole_rows, self.hole_cols)

        return img if mapmode<4 else\
               img_interpolated(data, self.interpol_pars) if mapmode==4 else\
               self.img_entries
コード例 #2
0
ファイル: test_mask_algos.py プロジェクト: slac-lcls/lcls2
def test_mask_algos(tname):
    """
    """
    dcc = dict_calib_constants()
    mo = mask_algos(dcc)
    cc = calib_constants(dcc)
    #logging.info(info_ndarr(cc.pedestals(), 'pedestals'))
    #logging.info(info_ndarr(mo.mask_from_status(), 'pedestals'))

    mask = test_mask_select(tname, mo)
    arr = mask + 1
    logger.info(info_ndarr(arr, 'test_mask arr for image'))

    rows, cols = cc.pixel_coord_indexes()
    #cc.cached_pixel_coord_indexes()
    #rows, cols = cc.pix_rc()

    from psana.detector.UtilsAreaDetector import img_from_pixel_arrays
    img = img_from_pixel_arrays(rows, cols, weight=arr, vbase=0)
    logger.info(info_ndarr(img, 'img'))

    flimg = ug.fleximagespec(img, arr=arr, amin=0, amax=2)
    flimg.axtitle(title='test_mask %s' % tname)
    #   ug.gr.show(mode='NO HOLD')
    ug.gr.show()
コード例 #3
0
    def image(self, evt, nda=None, **kwa) -> Array2d:
        """
        Create 2-d image.

        Parameters
        ----------
        evt: event
            psana event object, ex. run.events().next().

        mapmode: int, optional, default: 2
            control on overlapping pixels on image map.
            0/1/2/3/4: statistics of entries / last / max / mean pixel intensity / interpolated (TBD) - ascending data index.

        fillholes: bool, optional, default: True
            control on map bins inside the panel with 0 entries from data.
            True/False: fill empty bin with minimal intensity of four neares neighbors/ do not fill.

        vbase: float, optional, default: 0
            value substituted for all image map bins without entry from data.

        Returns
        -------
        image: np.array, ndim=2
        """
        logger.debug('in AreaDretector.image')
        if any(v is None for v in self._pix_rc_):
            self._cached_pixel_coord_indexes(evt, **kwa)
            if any(v is None for v in self._pix_rc_): return None

        vbase = kwa.get('vbase', 0)
        mapmode = kwa.get('mapmode', 2)
        fillholes = kwa.get('fillholes', True)

        if mapmode == 0: return self.img_entries

        data = self.calib(evt) if nda is None else nda

        if is_none(data, 'AreaDetector.image calib returns None'): return None

        #logger.debug(info_ndarr(data, 'data ', last=3))

        rows, cols = self._pix_rc_
        img = img_from_pixel_arrays(rows, cols, weight=data,
                                    vbase=vbase)  # mapmode==1
        if mapmode == 2:
            img_multipixel_max(img, data, self.dmulti_pix_to_img_idx)
        elif mapmode == 3:
            img_multipixel_mean(img, data, self.dmulti_pix_to_img_idx,
                                self.dmulti_imgidx_numentries)

        if mapmode < 4 and fillholes:
            fill_holes(img, self.hole_rows, self.hole_cols)

        return img if mapmode<4 else\
               img_interpolated(data, self._interpol_pars_) if mapmode==4 else\
               self.img_entries
コード例 #4
0
ファイル: calibconstants.py プロジェクト: slac-lcls/lcls2
    def image(self, nda, segnums=None, **kwa):
        """
        Create 2-d image.

        Parameters
        ----------
        nda: np.array, ndim=3
            array shaped as daq raw data.

        segnums: list/tuple of segment (uint) indexes

        mapmode: int, optional, default: 2
            control on overlapping pixels on image map.
            0/1/2/3/4: statistics of entries / last / max / mean pixel intensity / interpolated (TBD) - ascending data index.

        fillholes: bool, optional, default: True
            control on map bins inside the panel with 0 entries from data.
            True/False: fill empty bin with minimal intensity of four neares neighbors/ do not fill.

        vbase: float, optional, default: 0
            value substituted for all image map bins without entry from data.

        Returns
        -------
        image: np.array, ndim=2
        """
        logger.debug('in CalibConstants.image')

        if any(v is None for v in self._pix_rc):
            self.cached_pixel_coord_indexes(segnums, **kwa)
            if any(v is None for v in self._pix_rc): return None

        vbase     = kwa.get('vbase',0)
        mapmode   = kwa.get('mapmode',2)
        fillholes = kwa.get('fillholes',True)

        if mapmode==0: return self.img_entries

        if ut.is_none(nda, 'CalibConstants.image calib returns None'): return None

        logger.debug(info_ndarr(nda, 'nda ', last=3))
        rows, cols = self._pix_rc
        logger.debug(info_ndarr(rows, 'rows ', last=3))
        logger.debug(info_ndarr(cols, 'cols ', last=3))

        img = img_from_pixel_arrays(rows, cols, weight=nda, vbase=vbase) # mapmode==1
        if   mapmode==2: img_multipixel_max(img, nda, self.dmulti_pix_to_img_idx)
        elif mapmode==3: img_multipixel_mean(img, nda, self.dmulti_pix_to_img_idx, self.dmulti_imgidx_numentries)

        if mapmode<4 and fillholes: fill_holes(img, self.hole_rows, self.hole_cols)

        return img if mapmode<4 else\
               img_interpolated(nda, self._cached_interpol_pars()) if mapmode==4 else\
               self.img_entries