Example #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
        }
Example #2
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)
Example #3
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))