def kropff_fitting_range_changed(self): [global_left_range, global_right_range] = self.bragg_edge_range if not self.fitting_peak_ui: return [left_range, right_range] = list(self.fitting_peak_ui.getRegion()) xaxis_dict = self.fitting_input_dictionary['xaxis'] o_get = Get(parent=self) x_axis_selected = o_get.x_axis_checked() xaxis_index, _ = xaxis_dict[x_axis_selected] [left_xaxis_index, right_xaxis_index] = self.bragg_edge_range xaxis = xaxis_index[left_xaxis_index: right_xaxis_index] left_index = find_nearest_index(array=xaxis, value=left_range) right_index = find_nearest_index(array=xaxis, value=right_range) global_left_index = find_nearest_index(array=xaxis, value=global_left_range) global_right_index = find_nearest_index(array=xaxis, value=global_right_range) self.kropff_fitting_range['high'] = [right_index, global_right_index] self.kropff_fitting_range['low'] = [global_left_index, left_index] self.kropff_fitting_range['bragg_peak'] = [left_index, right_index] self.bragg_peak_selection_range = [left_index, right_index] o_kropff = Kropff(parent=self) o_kropff.update_roi_labels()
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 }
def update_roi_labels(self): [global_left_range, global_right_range] = self.parent.bragg_edge_range [left_range, right_range] = list(self.parent.fitting_peak_ui.getRegion()) o_get = Get(parent=self.parent) x_axis_selected = o_get.x_axis_checked() xaxis_dict = self.parent.fitting_input_dictionary['xaxis'] xaxis_index, _ = xaxis_dict[x_axis_selected] [left_xaxis_index, right_xaxis_index] = [global_left_range, global_right_range] xaxis = xaxis_index[left_xaxis_index: right_xaxis_index] left_index = find_nearest_index(array=xaxis, value=left_range) right_index = find_nearest_index(array=xaxis, value=right_range) xaxis_in_selected_axis = self.parent.fitting_input_dictionary['xaxis'][x_axis_selected][0][ global_left_range: global_right_range] real_left_value = xaxis_in_selected_axis[left_index] real_right_value = xaxis_in_selected_axis[right_index] if x_axis_selected == 'lambda': str_format = "{:02f}" elif x_axis_selected == 'tof': str_format = "{:04.2f}" else: str_format = "{}" real_left_value = str_format.format(real_left_value) real_right_value = str_format.format(real_right_value) units = Get.units(name=x_axis_selected) self.parent.ui.bragg_peak_range_from_value.setText(str(real_left_value)) self.parent.ui.bragg_peak_range_to_value.setText(str(real_right_value)) self.parent.ui.from_bragg_peak_range_units.setText(units) self.parent.ui.to_bragg_peak_range_units.setText(units)
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]
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]
def initialize_default_peak_regions(self): [left_range, right_range] = self.bragg_edge_range xaxis_dict = self.fitting_input_dictionary['xaxis'] xaxis_index, _ = xaxis_dict['index'] [left_xaxis_index, right_xaxis_index] = self.bragg_edge_range xaxis = xaxis_index[left_xaxis_index: right_xaxis_index] left_index = find_nearest_index(array=xaxis, value=left_range) right_index = find_nearest_index(array=xaxis, value=right_range) # kropff tab for _key in self.kropff_fitting_range.keys(): self.kropff_fitting_range[_key] = [left_index, right_index] # TBD tab pass