Beispiel #1
0
    def calculate_bin_size_in_all_units(self):
        current_value = np.float(
            self.parent.ui.selection_bin_size_value.text())
        o_get = Get(parent=self.parent)
        current_axis_name = o_get.x_axis_name_checked()

        tof_array_s = self.parent.tof_array_s
        lambda_array = self.parent.lambda_array

        if current_axis_name == 'index':
            current_value = np.int(current_value)
            bin_index = current_value
            bin_tof = tof_array_s[current_value]
            bin_lambda = lambda_array[current_value]
        elif current_axis_name == 'tof':
            bin_index = find_nearest_index(array=tof_array_s,
                                           value=current_value * 1e-6)
            bin_tof = current_value
            bin_lambda = lambda_array[bin_index]
        elif current_axis_name == 'lambda':
            bin_index = find_nearest_index(array=lambda_array,
                                           value=current_value)
            bin_tof = tof_array_s[bin_index]
            bin_lambda = current_value

        self.parent.bin_size_value = {
            'index': bin_index,
            'tof': bin_tof,
            'lambda': bin_lambda
        }
Beispiel #2
0
    def update_selection_plot(self):
        self.parent.ui.profile.clear()
        o_get = Get(parent=self.parent)
        x_axis, x_axis_label = o_get.x_axis()
        max_value = self.parent.ui.profile_of_bin_size_slider.maximum()
        roi_selected = max_value - self.parent.ui.profile_of_bin_size_slider.value(
        )

        y_axis = self.parent.fitting_input_dictionary['rois'][roi_selected][
            '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')

        # full region
        y_axis = self.parent.fitting_input_dictionary['rois'][0]['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]))
Beispiel #3
0
    def bragg_edge_range_changed(self):
        [left_range, right_range] = list(self.bragg_edge_range_ui.getRegion())
        o_get = Get(parent=self)
        x_axis, _ = o_get.x_axis()

        left_index = find_nearest_index(array=x_axis, value=left_range)
        right_index = find_nearest_index(array=x_axis, value=right_range)

        self.bragg_edge_range = [left_index, right_index]
Beispiel #4
0
    def profile_selection_range_changed(self):
        """this method converts the ROI left and right position in current x-axis units to index units """
        [left_range, right_range] = list(self.profile_selection_range_ui.getRegion())
        o_get = Get(parent=self)
        x_axis, _ = o_get.x_axis()

        left_index = find_nearest_index(array=x_axis, value=left_range)
        right_index = find_nearest_index(array=x_axis, value=right_range)

        self.profile_selection_range = [left_index, right_index]
Beispiel #5
0
 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
Beispiel #6
0
    def update_bin_size_widgets(self):
        o_get = Get(parent=self.parent)
        x_axis_units = o_get.x_axis_units()
        current_axis_name = o_get.x_axis_name_checked()

        # update units
        self.parent.ui.selection_bin_size_units.setText(x_axis_units)

        bin_size_value = self.parent.bin_size_value[current_axis_name]
        if current_axis_name == 'tof':
            bin_size_value *= 1e6
        elif current_axis_name == 'lambda':
            bin_size_value = "{:2f}".format(bin_size_value)
        self.parent.ui.selection_bin_size_value.setText(str(bin_size_value))
Beispiel #7
0
    def update_vertical_line_in_profile_plot(self):
        o_get = Get(parent=self)
        x_axis, x_axis_label = o_get.x_axis()

        bragg_edge_range = [x_axis[self.bragg_edge_range[0]],
                            x_axis[self.bragg_edge_range[1]]]

        if self.bragg_edge_range_ui:
            self.ui.profile.removeItem(self.bragg_edge_range_ui)
        self.bragg_edge_range_ui = pg.LinearRegionItem(values=bragg_edge_range,
                                                       orientation=None,
                                                       brush=None,
                                                       movable=True,
                                                       bounds=None)
        self.bragg_edge_range_ui.sigRegionChanged.connect(self.bragg_edge_range_changed)
        self.bragg_edge_range_ui.setZValue(-10)
        self.ui.profile.addItem(self.bragg_edge_range_ui)
Beispiel #8
0
    def update_selection_profile_plot(self):
        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)
        self.parent.roi_selection_dict = {
            'x0': x0,
            'y0': y0,
            'x1': x1,
            'y1': 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]))

        self.parent.ui.profile.setLabel("bottom", x_axis_label)
        self.parent.ui.profile.setLabel("left", 'Mean transmission')

        # vertical line showing peak to fit
        profile_selection_range = [
            x_axis[self.parent.profile_selection_range[0]],
            x_axis[self.parent.profile_selection_range[1]]
        ]

        self.parent.profile_selection_range_ui = pg.LinearRegionItem(
            values=profile_selection_range,
            orientation=None,
            brush=None,
            movable=True,
            bounds=None)
        self.parent.profile_selection_range_ui.sigRegionChanged.connect(
            self.parent.profile_selection_range_changed)
        self.parent.profile_selection_range_ui.sigRegionChangeFinished.connect(
            self.parent.roi_moved)
        self.parent.profile_selection_range_ui.setZValue(-10)
        self.parent.ui.profile.addItem(self.parent.profile_selection_range_ui)

        _pen = QtGui.QPen()
        _pen.setColor(self.parent.bin_line_settings['color'])
        _pen.setWidth(self.parent.bin_line_settings['width'])

        if self.parent.list_bin_ui:
            for _bin_ui in self.parent.list_bin_ui:
                self.parent.ui.profile.removeItem(_bin_ui)
            self.parent.list_bin_ui = []

        if self.parent.list_bin_positions:
            current_axis_name = o_get.x_axis_name_checked()
            for bin in self.parent.list_bin_positions[current_axis_name]:
                if current_axis_name == 'tof':
                    bin *= 1e6
                _bin_ui = pg.InfiniteLine(bin, movable=False, pen=_pen)
                self.parent.ui.profile.addItem(_bin_ui)
                self.parent.list_bin_ui.append(bin)