def _maxima_indices(self, a): """ Return the indicies of all local maxima in `a`. """ a = utils.smooth(a) maxima = np.where(np.r_[True, a[1:] > a[:-1]] & np.r_[a[:-1] > a[1:], True] == True)[0] if maxima[-1] == len(a)-1: maxima = maxima[:-1] return maxima
def _maxima_indices(self, a): """ Return the indicies of all local maxima in `a`. """ a = utils.smooth(a) maxima = np.where(np.r_[True, a[1:] > a[:-1]] & np.r_[a[:-1] > a[1:], True] == True)[0] if maxima[-1] == len(a) - 1: maxima = maxima[:-1] return maxima
def _load_calibration_sample(self, filename, distance): """ Loads a calibration file, measures the peak positions of rings in that file, and stores that data in the internal structure self.samples """ img = read.load_raw_image(filename) bin_centers, a = self.cspad.intensity_profile(img, n_bins=800) #sa = a sa = utils.smooth(a, beta=10.0, window_size=20) # finds all local maxima, i.e. all points that has both adjacent points with lower values after smoothing max_inds = np.where(np.r_[True, sa[1:] > sa[:-1]] & np.r_[sa[:-1] > sa[1:], True] == True)[0] real_peak_locations = bin_centers[max_inds] self.sample_peak_locs.append( np.array(real_peak_locations) ) self.sample_peak_heights.append( a[max_inds] ) self.sample_distances.append(float(distance)) print " found: %d peaks" % len(real_peak_locations) return
def _load_calibration_sample(self, filename, distance): """ Loads a calibration file, measures the peak positions of rings in that file, and stores that data in the internal structure self.samples """ img = read.load_raw_image(filename) bin_centers, a = self.cspad.intensity_profile(img, n_bins=800) #sa = a sa = utils.smooth(a, beta=10.0, window_size=20) # finds all local maxima, i.e. all points that has both adjacent points with lower values after smoothing max_inds = np.where(np.r_[True, sa[1:] > sa[:-1]] & np.r_[sa[:-1] > sa[1:], True] == True)[0] real_peak_locations = bin_centers[max_inds] self.sample_peak_locs.append(np.array(real_peak_locations)) self.sample_peak_heights.append(a[max_inds]) self.sample_distances.append(float(distance)) print " found: %d peaks" % len(real_peak_locations) return