def findPeaks(self, calib, evt): if self.streakMask_on: # make new streak mask self.streakMask = self.StreakMask.getStreakMaskCalib(evt) # Apply background correction if self.medianFilterOn: calib -= median_filter_ndarr(calib, self.medianRank) if self.radialFilterOn: self.pf.shape = calib.shape # FIXME: shape is 1d calib = self.rb.subtract_bkgd(calib * self.pf) calib.shape = self.userPsanaMask.shape # FIXME: shape is 1d if self.streakMask is not None: self.combinedMask = self.userPsanaMask * self.streakMask else: self.combinedMask = self.userPsanaMask # set new mask #self.alg = PyAlgos(windows=self.windows, mask=self.combinedMask, pbits=0) # set peak-selector parameters: #self.alg.set_peak_selection_pars(npix_min=self.npix_min, npix_max=self.npix_max, \ # amax_thr=self.amax_thr, atot_thr=self.atot_thr, \ # son_min=self.son_min) self.alg.set_mask(self.combinedMask) # This doesn't work reliably # set algorithm specific parameters if self.algorithm == 1: # v1 - aka Droplet Finder - two-threshold peak-finding algorithm in restricted region # around pixel with maximal intensity. self.peaks = self.alg.peak_finder_v4r2(calib, thr_low=self.hitParam_alg1_thr_low, thr_high=self.hitParam_alg1_thr_high, rank=self.hitParam_alg1_rank, r0=self.hitParam_alg1_radius, dr=self.hitParam_alg1_dr) elif self.algorithm == 3: self.peaks = self.alg.peak_finder_v3(calib, rank=self.hitParam_alg3_rank, r0=self.hitParam_alg3_r0, dr=self.hitParam_alg3_dr) elif self.algorithm == 4: # v4 - aka iDroplet Finder - two-threshold peak-finding algorithm in restricted region # around pixel with maximal intensity. self.peaks = self.alg.peak_finder_v4(calib, thr_low=self.hitParam_alg4_thr_low, thr_high=self.hitParam_alg4_thr_high, \ rank=self.hitParam_alg4_rank, r0=self.hitParam_alg4_r0, dr=self.hitParam_alg4_dr) self.numPeaksFound = self.peaks.shape[0] if self.numPeaksFound > 0: cenX = self.iX[np.array(self.peaks[:, 0], dtype=np.int64), np.array(self.peaks[:, 1], dtype=np.int64), np.array( self.peaks[:, 2], dtype=np.int64)] + 0.5 cenY = self.iY[np.array(self.peaks[:, 0], dtype=np.int64), np.array(self.peaks[:, 1], dtype=np.int64), np.array( self.peaks[:, 2], dtype=np.int64)] + 0.5 self.maxRes = getMaxRes(cenX, cenY, self.cx, self.cy) else: self.maxRes = 0 if self.numPeaksFound >= 15: self.powderHits = np.maximum(self.powderHits, calib) else: self.powderMisses = np.maximum(self.powderMisses, calib)
def prepoces(eventNumber): evt = run.event(times[eventNumber]) calib = det.calib(evt) * det.mask(evt, calib=True, status=True, edges=True, central=True, unbond=True, unbondnbrs=True) # background suppression medianFilterRank = 5 calib -= median_filter_ndarr(calib, medianFilterRank) # crop img = det.image(evt, calib)[cropT:cropB, cropL:cropR] # crop inside water ring return img
def prepoces(eventNumber): evt = run.event(times[eventNumber]) calib = det.calib(evt) * det.mask(evt, calib=True, status=True, edges=True, central=True, unbond=True, unbondnbrs=True) # background suppression medianFilterRank = 5 calib -= median_filter_ndarr(calib, medianFilterRank) # crop img = det.image(evt, calib)[cropT:cropB, cropL:cropR] # crop inside water ring # normalization sig = np.std(img) mu = np.mean(img) img = img - mu if sig > 0.000000001: img = img / sig return img
def getDetImage(self, evtNumber, calib=None): if calib is None: if self.parent.exp.image_property == self.parent.exp.disp_medianCorrection: # median subtraction calib = self.getCalib(evtNumber) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') calib -= median_filter_ndarr(calib, self.parent.exp.medianFilterRank) elif self.parent.exp.image_property == self.parent.exp.disp_radialCorrection: # radial subtraction + polarization corrected calib = self.getCalib(evtNumber) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') self.pf.shape = calib.shape # FIXME: shape is 1d calib = self.rb.subtract_bkgd(calib * self.pf) calib.shape = self.parent.calib.shape # FIXME: shape is 1d elif self.parent.exp.image_property == self.parent.exp.disp_adu: # gain and hybrid gain corrected calib = self.getCalib(evtNumber) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') elif self.parent.exp.image_property == self.parent.exp.disp_commonModeCorrected: # common mode corrected calib = self.getCommonModeCorrected(evtNumber) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') elif self.parent.exp.image_property == self.parent.exp.disp_pedestalCorrected: # pedestal corrected calib = self.parent.det.raw(self.parent.evt).astype('float32') if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') else: calib -= self.parent.det.pedestals(self.parent.evt) elif self.parent.exp.image_property == self.parent.exp.disp_raw: # raw calib = self.parent.det.raw(self.parent.evt) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_photons: # photon counts calib = self.parent.det.photons(self.parent.evt, mask=self.parent.mk.userMask, adu_per_photon=self.parent.exp.aduPerPhoton) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='int32') self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_pedestal: # pedestal calib = self.parent.det.pedestals(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_status: # status calib = self.parent.det.status(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_rms: # rms calib = self.parent.det.rms(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_commonMode: # common mode calib = self.getCommonMode(evtNumber) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_gain: # gain calib = self.parent.det.gain(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_gainMask: # gain_mask calib = self.parent.det.gain_mask(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_coordx: # coords_x calib = self.parent.det.coords_x(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_coordy: # coords_y calib = self.parent.det.coords_y(self.parent.evt) self.parent.firstUpdate = True shape = self.parent.det.shape(self.parent.evt) if len(shape) == 3: if self.parent.exp.image_property == self.parent.exp.disp_quad: # quad ind calib = np.zeros(shape) for i in range(shape[0]): # TODO: handle detectors properly if shape[0] == 32: # cspad calib[i,:,:] = int(i)%8 elif shape[0] == 2: # cspad2x2 calib[i,:,:] = int(i)%2 elif shape[0] == 4: # pnccd calib[i,:,:] = int(i)%4 self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_seg: # seg ind calib = np.zeros(shape) if shape[0] == 32: # cspad for i in range(32): calib[i,:,:] = int(i)/8 elif shape[0] == 2: # cspad2x2 for i in range(2): calib[i,:,:] = int(i) elif shape[0] == 4: # pnccd for i in range(4): calib[i,:,:] = int(i) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_row: # row ind calib = np.zeros(shape) if shape[0] == 32: # cspad for i in range(185): calib[:,i,:] = i elif shape[0] == 2: # cspad2x2 for i in range(185): calib[:,i,:] = i elif shape[0] == 4: # pnccd for i in range(512): calib[:,i,:] = i self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_col: # col ind calib = np.zeros(shape) if shape[0] == 32: # cspad for i in range(388): calib[:,:,i] = i elif shape[0] == 2: # cspad2x2 for i in range(388): calib[:,:,i] = i elif shape[0] == 4: # pnccd for i in range(512): calib[:,:,i] = i self.parent.firstUpdate = True # Update photon energy self.parent.exp.updatePhotonEnergy('lcls') # Update clen self.parent.geom.updateClen('lcls') # Write a temporary geom file self.parent.geom.deployCrystfelGeometry('lcls') self.parent.geom.writeCrystfelGeom('lcls') # Hack to override coffset # Get assembled image if calib is not None: data = self.getAssembledImage('lcls', calib) else: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') data = self.getAssembledImage('lcls', calib) # Update detector centre self.updateDetectorCentre('lcls') # Update ROI histogram if self.parent.roi.roiCurrent == 'rect': self.parent.roi.updateRoi(self.parent.roi.roi) elif self.parent.roi.roiCurrent == 'poly': self.parent.roi.updateRoi(self.parent.roi.roiPoly) elif self.parent.roi.roiCurrent == 'circ': self.parent.roi.updateRoi(self.parent.roi.roiCircle) return calib, data
def findPeaks(self, calib, evt, thr_high=None, thr_low=None): if facility == 'LCLS': if self.streakMask_on: # make new streak mask self.streakMask = self.StreakMask.getStreakMaskCalib(evt) # Apply background correction if self.medianFilterOn: calib -= median_filter_ndarr(calib, self.medianRank) if self.radialFilterOn: self.pf.shape = calib.shape # FIXME: shape is 1d calib = self.rb.subtract_bkgd(calib * self.pf) calib.shape = self.userPsanaMask.shape # FIXME: shape is 1d if self.streakMask is not None: self.combinedMask = self.userPsanaMask * self.streakMask else: self.combinedMask = self.userPsanaMask # set new mask #self.alg.set_mask(self.combinedMask) # This doesn't work reliably elif facility == 'PAL': self.combinedMask = self.userMask # set algorithm specific parameters if self.algorithm == 1: if facility == 'LCLS': #print "param: ", self.npix_min, self.npix_max, self.atot_thr, self.son_min, thr_low, thr_high, np.sum(self.combinedMask) # v1 - aka Droplet Finder - two-threshold peak-finding algorithm in restricted region # around pixel with maximal intensity. if thr_high is None: # use gui input self.peakRadius = int(self.hitParam_alg1_radius) self.peaks = self.alg.peak_finder_v4r3( calib, thr_low=self.hitParam_alg1_thr_low, thr_high=self.hitParam_alg1_thr_high, rank=self.hitParam_alg1_rank, r0=self.hitParam_alg1_radius, dr=self.hitParam_alg1_dr, mask=self.combinedMask.astype(np.uint16)) # self.peaks = self.alg.peak_finder_v4r2(calib, # thr_low=self.hitParam_alg1_thr_low, # thr_high=self.hitParam_alg1_thr_high, # rank=self.hitParam_alg1_rank, # r0=self.hitParam_alg1_radius, # dr=self.hitParam_alg1_dr) else: self.peaks = self.alg.findPeaks(calib, npix_min=self.npix_min, npix_max=self.npix_max, atot_thr=self.atot_thr, son_min=self.son_min, thr_low=thr_low, thr_high=thr_high, mask=self.combinedMask) # self.peaks = self.alg.peak_finder_v4r2(calib, # thr_low=thr_low, # thr_high=thr_high, # rank=self.hitParam_alg1_rank, # r0=self.hitParam_alg1_radius, # dr=self.hitParam_alg1_dr) elif facility == 'PAL': self.peakRadius = int(self.hitParam_alg1_radius) _calib = np.zeros((1, calib.shape[0], calib.shape[1])) _calib[0, :, :] = calib if self.combinedMask is None: _mask = None else: _mask = self.combinedMask.astype(np.uint16) self.peaks = self.alg.findPeaks( _calib, npix_min=self.npix_min, npix_max=self.npix_max, son_min=self.son_min, thr_low=self.hitParam_alg1_thr_low, thr_high=self.hitParam_alg1_thr_high, atot_thr=self.atot_thr, r0=self.peakRadius, dr=int(self.hitParam_alg1_dr), mask=_mask) elif self.algorithm == 2: if facility == 'LCLS': #print "param: ", self.npix_min, self.npix_max, self.atot_thr, self.son_min, thr_low, thr_high, np.sum(self.combinedMask) # v1 - aka Droplet Finder - two-threshold peak-finding algorithm in restricted region # around pixel with maximal intensity. self.peakRadius = int(self.hitParam_alg1_radius) self.peaks = self.alg.peak_finder_v3r3( calib, rank=int(self.hitParam_alg1_rank), r0=self.peakRadius, dr=self.hitParam_alg1_dr, nsigm=self.son_min, mask=self.combinedMask.astype(np.uint16)) elif self.algorithm == 3: self.peaks = self.alg.peak_finder_v3(calib, rank=self.hitParam_alg3_rank, r0=self.hitParam_alg3_r0, dr=self.hitParam_alg3_dr) elif self.algorithm == 4: # v4 - aka iDroplet Finder - two-threshold peak-finding algorithm in restricted region # around pixel with maximal intensity. self.peaks = self.alg.peak_finder_v4(calib, thr_low=self.hitParam_alg4_thr_low, thr_high=self.hitParam_alg4_thr_high, \ rank=self.hitParam_alg4_rank, r0=self.hitParam_alg4_r0, dr=self.hitParam_alg4_dr) self.numPeaksFound = self.peaks.shape[0] if self.numPeaksFound > 0: if facility == 'LCLS': cenX = self.iX[np.array(self.peaks[:, 0], dtype=np.int64), np.array(self.peaks[:, 1], dtype=np.int64), np.array(self.peaks[:, 2], dtype=np.int64)] + 0.5 cenY = self.iY[np.array(self.peaks[:, 0], dtype=np.int64), np.array(self.peaks[:, 1], dtype=np.int64), np.array(self.peaks[:, 2], dtype=np.int64)] + 0.5 elif facility == 'PAL': cenX = self.iX[np.array(self.peaks[:, 1], dtype=np.int64), np.array(self.peaks[:, 2], dtype=np.int64)] + 0.5 cenY = self.iY[np.array(self.peaks[:, 1], dtype=np.int64), np.array(self.peaks[:, 2], dtype=np.int64)] + 0.5 self.maxRes = getMaxRes(cenX, cenY, self.cx, self.cy) else: self.maxRes = 0 if self.numPeaksFound >= 15: if self.powderHits is None: self.powderHits = calib else: self.powderHits = np.maximum(self.powderHits, calib) else: if self.powderMisses is None: self.powderMisses = calib else: self.powderMisses = np.maximum(self.powderMisses, calib) if self.powderHits is None: self.powderHits = np.zeros_like(calib) if self.powderMisses is None: self.powderMisses = np.zeros_like(calib)
def getDetImage(self, evtNumber, calib=None): if calib is None: if self.parent.exp.image_property == self.parent.exp.disp_medianCorrection: # median subtraction calib = self.getCalib(evtNumber) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') calib -= median_filter_ndarr(calib, self.parent.exp.medianFilterRank) elif self.parent.exp.image_property == self.parent.exp.disp_radialCorrection: # radial subtraction + polarization corrected calib = self.getCalib(evtNumber) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') self.pf.shape = calib.shape # FIXME: shape is 1d calib = self.rb.subtract_bkgd(calib * self.pf) calib.shape = self.parent.calib.shape # FIXME: shape is 1d elif self.parent.exp.image_property == self.parent.exp.disp_adu: # gain and hybrid gain corrected calib = self.getCalib(evtNumber) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') elif self.parent.exp.image_property == self.parent.exp.disp_commonModeCorrected: # common mode corrected calib = self.getCommonModeCorrected(evtNumber) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') elif self.parent.exp.image_property == self.parent.exp.disp_pedestalCorrected: # pedestal corrected calib = self.parent.det.raw(self.parent.evt).astype('float32') if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') else: calib -= self.parent.det.pedestals(self.parent.evt) elif self.parent.exp.image_property == self.parent.exp.disp_raw: # raw calib = self.parent.det.raw(self.parent.evt) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_photons: # photon counts calib = self.parent.det.photons( self.parent.evt, mask=self.parent.mk.userMask, adu_per_photon=self.parent.exp.aduPerPhoton) if calib is None: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='int32') self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_pedestal: # pedestal calib = self.parent.det.pedestals(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_status: # status calib = self.parent.det.status(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_rms: # rms calib = self.parent.det.rms(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_commonMode: # common mode calib = self.getCommonMode(evtNumber) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_gain: # gain calib = self.parent.det.gain(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_gainMask: # gain_mask calib = self.parent.det.gain_mask(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_coordx: # coords_x calib = self.parent.det.coords_x(self.parent.evt) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_coordy: # coords_y calib = self.parent.det.coords_y(self.parent.evt) self.parent.firstUpdate = True shape = self.parent.det.shape(self.parent.evt) if len(shape) == 3: if self.parent.exp.image_property == self.parent.exp.disp_quad: # quad ind calib = np.zeros(shape) for i in range(shape[0]): # TODO: handle detectors properly if shape[0] == 32: # cspad calib[i, :, :] = int(i) % 8 elif shape[0] == 2: # cspad2x2 calib[i, :, :] = int(i) % 2 elif shape[0] == 4: # pnccd calib[i, :, :] = int(i) % 4 self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_seg: # seg ind calib = np.zeros(shape) if shape[0] == 32: # cspad for i in range(32): calib[i, :, :] = int(i) / 8 elif shape[0] == 2: # cspad2x2 for i in range(2): calib[i, :, :] = int(i) elif shape[0] == 4: # pnccd for i in range(4): calib[i, :, :] = int(i) self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_row: # row ind calib = np.zeros(shape) if shape[0] == 32: # cspad for i in range(185): calib[:, i, :] = i elif shape[0] == 2: # cspad2x2 for i in range(185): calib[:, i, :] = i elif shape[0] == 4: # pnccd for i in range(512): calib[:, i, :] = i self.parent.firstUpdate = True elif self.parent.exp.image_property == self.parent.exp.disp_col: # col ind calib = np.zeros(shape) if shape[0] == 32: # cspad for i in range(388): calib[:, :, i] = i elif shape[0] == 2: # cspad2x2 for i in range(388): calib[:, :, i] = i elif shape[0] == 4: # pnccd for i in range(512): calib[:, :, i] = i self.parent.firstUpdate = True # Update photon energy self.parent.exp.updatePhotonEnergy('lcls') # Update clen self.parent.geom.updateClen('lcls') # Write a temporary geom file self.parent.geom.deployCrystfelGeometry('lcls') self.parent.geom.writeCrystfelGeom('lcls') # Hack to override coffset # Get assembled image if calib is not None: data = self.getAssembledImage('lcls', calib) else: calib = np.zeros_like(self.parent.exp.detGuaranteed, dtype='float32') data = self.getAssembledImage('lcls', calib) # Update detector centre self.updateDetectorCentre('lcls') # Update ROI histogram if self.parent.roi.roiCurrent == 'rect': self.parent.roi.updateRoi(self.parent.roi.roi) elif self.parent.roi.roiCurrent == 'poly': self.parent.roi.updateRoi(self.parent.roi.roiPoly) elif self.parent.roi.roiCurrent == 'circ': self.parent.roi.updateRoi(self.parent.roi.roiCircle) return calib, data
def findPeaks(self, calib, evt, minPeaks=15, thr_high=None, thr_low=None): #t0 = time.time() if facility == 'LCLS': if self.streakMask_on: # make new streak mask self.streakMask = self.StreakMask.getStreakMaskCalib(evt) # Apply background correction if self.medianFilterOn: calib -= median_filter_ndarr(calib, self.medianRank) if self.radialFilterOn: self.pf.shape = calib.shape # FIXME: shape is 1d calib = self.rb.subtract_bkgd(calib * self.pf) calib.shape = self.userPsanaMask.shape # FIXME: shape is 1d self.calib = calib # save background subtracted calib as an attribute if self.streakMask is not None: self.combinedMask = self.userPsanaMask * self.streakMask else: self.combinedMask = self.userPsanaMask #t1 = time.time() # set algorithm specific parameters if self.algorithm == 1: if facility == 'LCLS': # v1 - aka Droplet Finder - two-threshold peak-finding algorithm in restricted region # around pixel with maximal intensity. if thr_high is None: # use gui input self.peakRadius = int(self.hitParam_alg1_radius) self.peaks = self.alg.peak_finder_v4r3( calib, thr_low=self.hitParam_alg1_thr_low, thr_high=self.hitParam_alg1_thr_high, rank=self.hitParam_alg1_rank, r0=self.hitParam_alg1_radius, dr=self.hitParam_alg1_dr, mask=self.combinedMask.astype(np.uint16)) else: self.peaks = self.alg.findPeaks(calib, npix_min=self.npix_min, npix_max=self.npix_max, atot_thr=self.atot_thr, son_min=self.son_min, thr_low=thr_low, thr_high=thr_high, mask=self.combinedMask) elif self.algorithm == 2: if facility == 'LCLS': # Adaptive peak finder v3r3 self.peakRadius = int(self.hitParam_alg1_radius) self.peaks = self.alg.peak_finder_v3r3( calib, rank=int(self.hitParam_alg1_rank), r0=self.peakRadius, dr=self.hitParam_alg1_dr, nsigm=self.son_min, mask=self.combinedMask.astype(np.uint16)) elif self.algorithm == 3: if facility == 'LCLS': # perform binning here binr = 2 binc = 2 downCalib = sm.block_reduce(calib, block_size=(1, binr, binc), func=np.sum) downWeight = sm.block_reduce(self.combinedMask, block_size=(1, binr, binc), func=np.sum) warr = np.zeros_like(downCalib, dtype='float32') ind = np.where(downWeight > 0) warr[ind] = downCalib[ind] / downWeight[ind] upCalib = utils.upsample(warr, calib.shape, binr, binc) self.peakRadius = int(self.hitParam_alg1_radius) self.peaks = self.alg.peak_finder_v3r3( upCalib, rank=int(self.hitParam_alg1_rank), r0=self.peakRadius, dr=self.hitParam_alg1_dr, nsigm=self.son_min, mask=self.combinedMask.astype(np.uint16)) #t2 = time.time() self.numPeaksFound = self.peaks.shape[0] if self.numPeaksFound >= minPeaks: if facility == 'LCLS': cenX = self.iX[np.array(self.peaks[:, 0], dtype=np.int64), np.array(self.peaks[:, 1], dtype=np.int64), np.array(self.peaks[:, 2], dtype=np.int64)] + 0.5 cenY = self.iY[np.array(self.peaks[:, 0], dtype=np.int64), np.array(self.peaks[:, 1], dtype=np.int64), np.array(self.peaks[:, 2], dtype=np.int64)] + 0.5 self.maxRes = getMaxRes(cenX, cenY, self.cx, self.cy) else: self.maxRes = 0 #t3 = time.time() if self.numPeaksFound >= minPeaks: if self.powderHits is None: self.powderHits = calib else: self.powderHits = np.maximum(self.powderHits, calib) else: if self.powderMisses is None: self.powderMisses = calib else: self.powderMisses = np.maximum(self.powderMisses, calib) if self.powderHits is None: self.powderHits = np.zeros_like(calib) if self.powderMisses is None: self.powderMisses = np.zeros_like(calib)