Ejemplo n.º 1
0
 def cons_and_meta_for_ctype(self, ctype='pedestals'):
     logger.debug('cons_and_meta_for_ctype(ctype="%s")'%ctype)
     cc = self.calibconst()
     if cc is None: return None
     cons_and_meta = cc.get(ctype, None)
     if ut.is_none(cons_and_meta, 'calibconst["%s"] is None'%ctype): return None, None
     return cons_and_meta
Ejemplo n.º 2
0
 def geotxt_and_meta(self):
     logger.debug('geotxt_and_meta')
     cc = self.calibconst()
     if cc is None: return None
     geotxt_and_meta = cc.get('geometry', None)
     if ut.is_none(geotxt_and_meta, 'calibconst[geometry] is None'): return None, None
     return geotxt_and_meta
Ejemplo n.º 3
0
 def segment_numbers_total(self):
     """returns total list list of segment numbers."""
     nsegs = self.number_of_segments_total()
     segnums = None if ut.is_none(nsegs, 'number_of_segments_total is None') else\
               list(range(nsegs))
               #tuple(np.arange(nsegs, dtype=np.uint16))
     logger.debug('segnums: %s' % str(segnums))
     return segnums
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
    def pixel_coords(self, **kwa):
        """ returns x, y, z - three np.ndarray
        """
        logger.debug('pixel_coords')
        geo = self.geo()
        if ut.is_none(geo, 'geo is None'): return None

        #return geo.get_pixel_xy_at_z(self, zplane=None, oname=None, oindex=0, do_tilt=True, cframe=0)
        return geo.get_pixel_coords(\
            do_tilt            = kwa.get('do_tilt',True),\
            cframe             = kwa.get('cframe',0))
Ejemplo n.º 6
0
 def geo(self):
     """ return GeometryAccess() object
     """
     if self._geo is None:
         geotxt, meta = self.geotxt_and_meta()
         if geotxt is None:
             geotxt = self.geotxt_default()
             if ut.is_none(geotxt, 'geo geotxt is None'): return None
         self._geo = GeometryAccess()
         self._geo.load_pars_from_str(geotxt)
     return self._geo
Ejemplo n.º 7
0
    def pixel_coord_indexes(self, **kwa):
        """ returns ix, iy - two np.ndarray
        """
        logger.debug('pixel_coord_indexes')
        geo = self.geo()
        if ut.is_none(geo, 'geo is None'): return None

        return geo.get_pixel_coord_indexes(\
            pix_scale_size_um  = kwa.get('pix_scale_size_um',None),\
            xy0_off_pix        = kwa.get('xy0_off_pix',None),\
            do_tilt            = kwa.get('do_tilt',True),\
            cframe             = kwa.get('cframe',0))
Ejemplo n.º 8
0
 def calibconst(self):
     logger.debug('calibconst')
     cc = self._calibconst
     if ut.is_none(cc, 'self._calibconst is None'): return None
     return cc
Ejemplo n.º 9
0
 def seg_geo(self):
     logger.debug('pixel_coords')
     geo = self.geo()
     if ut.is_none(geo, 'geo is None'): return None
     return None if ut.is_none(geo, 'geo is None') else\
            geo.get_seg_geo().algo
Ejemplo n.º 10
0
 def shape_as_daq(self):
     peds = self.pedestals()
     if ut.is_none(peds, 'shape_as_daq - pedestals is None, can not define daq data shape - returns None'): return None
     return peds.shape if peds.ndim<4 else peds.shape[-3:]