def calc_median_profile(self, roll_offset=0): """Calculate the median profile of the Line Pair region. Parameters ---------- roll_offset : int, float The offset to apply to the start of the profile, in radians. E.g. if set to pi/2, profile extraction will begin at 12 o clock (90 degrees). Returns ------- median profile : core.profile.Profile A 1D Profile of the Line Pair regions. """ # extract the profile for each ROI (5 adjacent profiles) for roi in self.ROIs.values(): roi.get_profile(self.image.array, size=2*np.pi*1000, start=np.pi+roll_offset) # average profiles together prof = np.zeros(len(roi.y_values)) for idx, roi in enumerate(self.ROIs.values()): prof += roi.y_values prof /= len(self.ROIs) new_prof = Profile(prof) new_prof.filter(0.001) # new_prof.ground() return new_prof
def _threshold(self): """Threshold the image by subtracting the minimum value. Allows for more accurate image orientation determination. """ col_prof = np.mean(self.image.array, 0) col_prof = Profile(col_prof) col_prof.filter(3) row_prof = np.mean(self.image.array, 1) row_prof = Profile(row_prof) row_prof.filter(3) _, r_peak_idx = row_prof.find_peaks(min_peak_distance=0.01, exclude_lt_edge=0.05, exclude_rt_edge=0.05) _, c_peak_idx = col_prof.find_peaks(min_peak_distance=0.01, exclude_lt_edge=0.05, exclude_rt_edge=0.05) min_val = self.image.array[r_peak_idx[0]:r_peak_idx[-1], c_peak_idx[0]:c_peak_idx[-1]].min() self._analysis_array = self.image.array.copy() self._analysis_array[self._analysis_array < min_val] = min_val self._analysis_array -= min_val