def update_selection_profile_plot(self): if self.parent.is_file_imported: self.update_selection_plot() self.parent.update_vertical_line_in_profile_plot() else: o_get = Get(parent=self.parent) x_axis, x_axis_label = o_get.x_axis() self.parent.ui.profile.clear() # large selection region [x0, y0, x1, y1, _, _] = o_get.selection_roi_dimension() profile = o_get.profile_of_roi(x0, y0, x1, y1) x_axis, y_axis = check_size(x_axis=x_axis, y_axis=profile) self.parent.ui.profile.plot(x_axis, y_axis, pen=(self.parent.selection_roi_rgb[0], self.parent.selection_roi_rgb[1], self.parent.selection_roi_rgb[2])) # shrinkable region shrinking_roi = self.get_coordinates_of_new_inside_selection_box() x0 = shrinking_roi['x0'] y0 = shrinking_roi['y0'] x1 = shrinking_roi['x1'] y1 = shrinking_roi['y1'] profile = o_get.profile_of_roi(x0, y0, x1, y1) x_axis, y_axis = check_size(x_axis=x_axis, y_axis=profile) self.parent.ui.profile.plot(x_axis, y_axis, pen=(self.parent.shrinking_roi_rgb[0], self.parent.shrinking_roi_rgb[1], self.parent.shrinking_roi_rgb[2])) self.parent.ui.profile.setLabel("bottom", x_axis_label) self.parent.ui.profile.setLabel("left", 'Mean transmission') # vertical line showing peak to fit bragg_edge_range = [ x_axis[self.parent.bragg_edge_range[0]], x_axis[self.parent.bragg_edge_range[1]] ] self.parent.bragg_edge_range_ui = pg.LinearRegionItem( values=bragg_edge_range, orientation=None, brush=None, movable=True, bounds=None) self.parent.bragg_edge_range_ui.sigRegionChanged.connect( self.parent.bragg_edge_range_changed) self.parent.bragg_edge_range_ui.setZValue(-10) self.parent.ui.profile.addItem(self.parent.bragg_edge_range_ui)
def update_dict_profile_to_fit(self): [left_range, right_range] = self.bragg_edge_range o_selection = BraggEdgeSelectionTab(parent=self) [x0, y0, x1, y1] = o_selection.get_shrinking_roi_dimension() o_get = Get(parent=self) profile = o_get.profile_of_roi(x0=x0, y0=y0, x1=x1, y1=y1) yaxis = profile[left_range: right_range] all_x_axis = o_get.all_x_axis() index_array = all_x_axis['index'][0] tof_array = all_x_axis['tof'][0] lambda_array = all_x_axis['lambda'][0] index_selected = index_array[left_range: right_range] tof_selected = tof_array[left_range: right_range] lambda_selected = lambda_array[left_range: right_range] profile_to_fit = {'yaxis': yaxis, 'xaxis': {'index': index_selected, 'tof': tof_selected, 'lambda': lambda_selected}, } self.dict_profile_to_fit = profile_to_fit
def add_profile_to_dict_of_all_regions(self, dict_regions=None): for _key in dict_regions.keys(): current_region = dict_regions[_key] x0 = current_region['x0'] y0 = current_region['y0'] width = current_region['width'] height = current_region['height'] o_get = Get(parent=self) profile = o_get.profile_of_roi(x0=x0, y0=y0, x1=x0 + width, y1=y0 + height) current_region['profile'] = profile