def plot_result(self): """ Plot the scaled data sets """ low_xmin = util._check_and_get_float_line_edit(self._content.low_min_edit) low_xmax = util._check_and_get_float_line_edit(self._content.low_max_edit) med_xmin = util._check_and_get_float_line_edit(self._content.medium_min_edit) med_xmax = util._check_and_get_float_line_edit(self._content.medium_max_edit) ws_list = [] if self._low_q_data is not None: xmin,_ = self._low_q_data.get_skipped_range() self._low_q_data.apply_scale(xmin, low_xmax) ws_list.append(self._low_q_data.get_scaled_ws()) if self._medium_q_data is not None: _,xmax = self._medium_q_data.get_skipped_range() if self._high_q_data is not None: xmax = med_xmax self._medium_q_data.apply_scale(low_xmin, xmax) ws_list.append(self._medium_q_data.get_scaled_ws()) if self._high_q_data is not None: _,xmax = self._high_q_data.get_skipped_range() self._high_q_data.apply_scale(med_xmin, xmax) ws_list.append(self._high_q_data.get_scaled_ws()) if len(ws_list)>0: g = mantidplot.graph(self._graph) if g is None or not self._plotted: g = mantidplot.plotSpectrum(ws_list, [0], True) g.setName(self._graph) self._plotted = True
def get_data_info(self): """ Retrieve information from the data file and update the display """ if self._data_proxy is None: return data_files = self._get_data_files() if len(data_files)<1: return fname = data_files[0] if len(str(fname).strip())>0: dataproxy = self._data_proxy(fname) if len(dataproxy.errors)>0: #QtGui.QMessageBox.warning(self, "Error", dataproxy.errors[0]) return self._settings.last_data_ws = dataproxy.data_ws if dataproxy.sample_detector_distance is not None: self._content.sample_dist_edit.setText(str(dataproxy.sample_detector_distance)) util._check_and_get_float_line_edit(self._content.sample_dist_edit, min=0.0) if dataproxy.wavelength is not None: self._content.wavelength_edit.setText(str(dataproxy.wavelength)) util._check_and_get_float_line_edit(self._content.wavelength_edit, min=0.0) if dataproxy.wavelength_spread is not None: self._content.wavelength_spread_edit.setText(str(dataproxy.wavelength_spread)) # This will be enabled once the meta data contains the sample thickness - will be turned into check box #if dataproxy.sample_thickness is not None: # self._content.thickness_edit.setText(QtCore.QString(str(dataproxy.sample_thickness))) if dataproxy.beam_diameter is not None: self._settings.emit_key_value("beam_diameter", str(dataproxy.beam_diameter)) self._emit_experiment_parameters()
def _emit_experiment_parameters(self): sdd = util._check_and_get_float_line_edit(self._content.sample_dist_edit, min=0.0) self._settings.emit_key_value("sample_detector_distance", str(sdd)) wavelength = util._check_and_get_float_line_edit(self._content.wavelength_edit, min=0.0) self._settings.emit_key_value("wavelength", str(wavelength)) spread = self._content.wavelength_spread_edit.text() self._settings.emit_key_value("wavelength_spread", spread)
def _update_total_distance(self, text): distance = 0 distance += float(self._summary.sample_dist_edit.text()) distance += float(self._summary.detector_offset_edit.text()) distance += float(self._summary.sample_si_dist_edit.text()) self._summary.total_detector_distance_edit.setText(str(distance)) util._check_and_get_float_line_edit(self._summary.total_detector_distance_edit, min=0.0)
def get_data_info(self): """ Retrieve information from the data file and update the display """ if self._data_proxy is None: return fname = str(self._content.background_edit.text()) if len(str(fname).strip())>0: api = 2 if self._settings.api2 else 1 dataproxy = self._data_proxy(fname, "__background_raw") if len(dataproxy.errors)>0: #QtGui.QMessageBox.warning(self, "Error", dataproxy.errors[0]) return self._settings.last_data_ws = dataproxy.data_ws if dataproxy.sample_detector_distance is not None: self._content.sample_dist_edit.setText(QtCore.QString(str(dataproxy.sample_detector_distance))) util._check_and_get_float_line_edit(self._content.sample_dist_edit, min=0.0) if dataproxy.wavelength is not None: self._content.wavelength_edit.setText(QtCore.QString(str(dataproxy.wavelength))) util._check_and_get_float_line_edit(self._content.wavelength_edit, min=0.0) if dataproxy.wavelength_spread is not None: self._content.wavelength_spread_edit.setText(QtCore.QString(str(dataproxy.wavelength_spread)))
def get_editing_state(self): m = REFMDataSets() #Peak from/to pixels m.DataPeakPixels = [int(self._summary.data_peak_from_pixel.text()), int(self._summary.data_peak_to_pixel.text())] m.data_x_range = [int(self._summary.x_min_edit.text()),\ int(self._summary.x_max_edit.text())] m.data_x_range_flag = self._summary.data_low_res_range_switch.isChecked() m.norm_x_range = [int(self._summary.norm_x_min_edit.text()), int(self._summary.norm_x_max_edit.text())] m.norm_x_range_flag = self._summary.norm_low_res_range_switch.isChecked() #Background flag m.DataBackgroundFlag = self._summary.data_background_switch.isChecked() #Background from/to pixels roi1_from = int(self._summary.data_background_from_pixel1.text()) roi1_to = int(self._summary.data_background_to_pixel1.text()) m.DataBackgroundRoi = [roi1_from, roi1_to, 0, 0] #from TOF and to TOF from_tof = float(self._summary.data_from_tof.text()) to_tof = float(self._summary.data_to_tof.text()) m.DataTofRange = [from_tof, to_tof] m.TOFstep = float(self._summary.tof_bin_width_edit.text()) datafiles = str(self._summary.data_run_number_edit.text()).split(',') m.data_files = [str(i) for i in datafiles] # Normalization flag m.NormFlag = self._summary.norm_switch.isChecked() # Normalization options m.norm_file = int(self._summary.norm_run_number_edit.text()) m.NormPeakPixels = [int(self._summary.norm_peak_from_pixel.text()), int(self._summary.norm_peak_to_pixel.text())] #Background flag m.NormBackgroundFlag = self._summary.norm_background_switch.isChecked() #Background from/to pixels roi1_from = int(self._summary.norm_background_from_pixel1.text()) roi1_to = int(self._summary.norm_background_to_pixel1.text()) m.NormBackgroundRoi = [roi1_from, roi1_to] if hasattr(m, "set_detector_angle"): m.set_detector_angle = self._summary.det_angle_check.isChecked() m.detector_angle = util._check_and_get_float_line_edit(self._summary.det_angle_edit) m.set_detector_angle_offset = self._summary.det_angle_offset_check.isChecked() m.detector_angle_offset = util._check_and_get_float_line_edit(self._summary.det_angle_offset_edit) m.set_direct_pixel = self._summary.direct_pixel_check.isChecked() m.direct_pixel = util._check_and_get_float_line_edit(self._summary.direct_pixel_edit) return m
def _beamstop_clicked(self, is_checked): self._summary.scale_beam_radius_edit.setEnabled(is_checked and self._summary.scale_chk.isChecked()) # Keep track of current value so we can restore it if the check box is clicked again if self._beam_diameter_supplied != is_checked: current_value = util._check_and_get_float_line_edit(self._summary.scale_beam_radius_edit) self._summary.scale_beam_radius_edit.setText(str(self._beam_diameter)) util._check_and_get_float_line_edit(self._summary.scale_beam_radius_edit, min=0.0) self._beam_diameter = current_value self._beam_diameter_supplied = is_checked
def get_state(self): """ Returns an object with the state of the interface """ m = SampleData.BeamSpreader() m.spreader_trans = util._check_and_get_float_line_edit(self._content.spreader_trans_edit) m.spreader_trans_spread = util._check_and_get_float_line_edit(self._content.spreader_trans_spread_edit) m.sample_scatt = unicode(self._content.sample_scatt_edit.text()) m.direct_scatt = unicode(self._content.direct_scatt_edit.text()) m.sample_spreader = unicode(self._content.sample_spread_edit.text()) m.direct_spreader = unicode(self._content.direct_spread_edit.text()) return m
def _update_scattering_angle(self): dangle = util._check_and_get_float_line_edit(self._summary.det_angle_edit) dangle0 = util._check_and_get_float_line_edit(self._summary.det_angle_offset_edit) direct_beam_pix = util._check_and_get_float_line_edit(self._summary.direct_pixel_edit) ref_pix = util._check_and_get_float_line_edit(self._summary.center_pix_edit) PIXEL_SIZE = 0.0007 # m delta = (dangle-dangle0)*math.pi/180.0/2.0\ + ((direct_beam_pix-ref_pix)*PIXEL_SIZE)/ (2.0*self._detector_distance) scattering_angle = delta*180.0/math.pi scattering_angle_str = "%4.3g" % scattering_angle self._summary.angle_edit.setText(scattering_angle_str.strip())
def get_state(self): """ Returns an object with the state of the interface """ m = Detector() # Mask m.x_position = util._check_and_get_float_line_edit(self._content.x_pos_edit) m.y_position = util._check_and_get_float_line_edit(self._content.y_pos_edit) m.beam_radius = util._check_and_get_float_line_edit(self._content.beam_radius_edit) m.use_finder = self._content.use_beam_finder_checkbox.isChecked() m.beam_file = unicode(self._content.beam_data_file_edit.text()) m.use_direct_beam = self._content.direct_beam.isChecked() # Sensitivity m.sensitivity_corr = self._content.sensitivity_chk.isChecked() m.sensitivity_data = unicode(self._content.sensitivity_file_edit.text()) m.min_sensitivity = util._check_and_get_float_line_edit(self._content.min_sensitivity_edit) m.max_sensitivity = util._check_and_get_float_line_edit(self._content.max_sensitivity_edit) if not self._use_sample_dc: m.sensitivity_dark = unicode(self._content.sensitivity_dark_file_edit.text()) m.use_sample_dark = self._use_sample_dc m.use_sample_beam_center = self._content.use_sample_center_checkbox.isChecked() m.flood_x_position = util._check_and_get_float_line_edit(self._content.x_pos_edit_2) m.flood_y_position = util._check_and_get_float_line_edit(self._content.y_pos_edit_2) m.flood_beam_radius = util._check_and_get_float_line_edit(self._content.beam_radius_edit_2) m.flood_use_finder = self._content.use_beam_finder_checkbox_2.isChecked() m.flood_beam_file = unicode(self._content.beam_data_file_edit_2.text()) m.flood_use_direct_beam = self._content.direct_beam_2.isChecked() self._settings.emit_key_value("FLOOD_FIELD", str(self._content.sensitivity_file_edit.text())) return m
def _sample_dist_clicked(self, is_checked): self._summary.sample_dist_edit.setEnabled(is_checked) if is_checked: self._summary.detector_offset_chk.setChecked(not is_checked) self._summary.detector_offset_edit.setEnabled(not is_checked) # Keep track of current value so we can restore it if the check box is clicked again if self._sample_detector_distance_supplied != is_checked: current_value = util._check_and_get_float_line_edit(self._summary.sample_dist_edit) self._summary.sample_dist_edit.setText(str(self._sample_detector_distance)) util._check_and_get_float_line_edit(self._summary.sample_dist_edit, min=0) self._sample_detector_distance = current_value self._sample_detector_distance_supplied = is_checked
def get_state(self): """ Returns an object with the state of the interface """ s = SampleSetupScript(self._instrument_name) s.sample_file = self._content.sample_edit.text() if IS_IN_MANTIDPLOT: s.live_button = self._content.sample_edit.liveButtonIsChecked() s.output_wsname = self._content.output_ws_edit.text() s.detcal_file = self._content.detcal_edit.text() s.incident_energy_guess = self._content.ei_guess_edit.text() s.use_ei_guess = self._content.use_ei_guess_chkbox.isChecked() s.tzero_guess = util._check_and_get_float_line_edit(self._content.tzero_guess_edit) s.monitor1_specid = int(self._content.monitor1_specid_edit.text()) s.monitor2_specid = int(self._content.monitor2_specid_edit.text()) s.rebin_et = self._content.et_range_box.isChecked() s.et_range_low = self._content.etr_low_edit.text() s.et_range_width = self._content.etr_width_edit.text() s.et_range_high = self._content.etr_high_edit.text() s.et_is_distribution = self._content.et_is_distribution_cb.isChecked() s.hardmask_file = self._content.hardmask_edit.text() s.grouping_file = self._content.grouping_edit.text() s.show_workspaces = self._content.show_workspaces_cb.isChecked() s.savedir = self._content.savedir_edit.text() return s
def _data_updated(self, key, value): """ Respond to application-level key/value pair updates. @param key: key string @param value: value string """ if key == "sample_detector_distance": self._sample_detector_distance = value if not self._summary.sample_dist_chk.isChecked(): self._summary.sample_dist_edit.setText(str(value)) util._check_and_get_float_line_edit(self._summary.sample_dist_edit, min=0.0) elif key == "beam_diameter": value_float = float(value) self._beam_diameter = "%-6.1f" % value_float if not self._summary.beamstop_chk.isChecked(): self._summary.scale_beam_radius_edit.setText(str(self._beam_diameter)) util._check_and_get_float_line_edit(self._summary.scale_beam_radius_edit, min=0.0)
def _emit_experiment_parameters(self): ''' This will send the pair key,values below to other tabs. ''' sdd = util._check_and_get_float_line_edit(self._content.sample_dist_edit, min=0.0) self._settings.emit_key_value("sample_detector_distance", str(sdd)) value = util._check_and_get_float_line_edit(self._content.sample_dist_offset_edit, min=0.0) self._settings.emit_key_value("sample_detector_distance_offset", str(value)) value = util._check_and_get_float_line_edit(self._content.sample_si_window_dist_edit, min=0.0) self._settings.emit_key_value("sample_si_window_distance", str(value)) wavelength = util._check_and_get_float_line_edit(self._content.wavelength_edit, min=0.0) self._settings.emit_key_value("wavelength", str(wavelength)) spread = self._content.wavelength_spread_edit.text() self._settings.emit_key_value("wavelength_spread", spread)
def get_state(self): """ Returns an object with the state of the interface """ m = SampleData.DirectBeam() m.beam_radius = util._check_and_get_float_line_edit(self._content.beam_radius_edit) m.sample_file = unicode(self._content.sample_edit.text()) m.direct_beam = unicode(self._content.direct_edit.text()) return m
def get_state(self): """ Returns an object with the state of the interface """ m = Background() m.background_corr = self._content.background_chk.isChecked() m.background_file = str(self._content.background_edit.text()) m.bck_transmission_enabled = self.show_transmission if self.show_transmission: #m.sample_thickness = util._check_and_get_float_line_edit(self._content.thickness_edit) m.bck_transmission = util._check_and_get_float_line_edit(self._content.transmission_edit) m.bck_transmission_spread = util._check_and_get_float_line_edit(self._content.dtransmission_edit) m.calculate_transmission = self._content.calculate_trans_chk.isChecked() m.theta_dependent = self._content.theta_dep_chk.isChecked() m.trans_dark_current = self._content.trans_dark_current_edit.text() if self._method_box is not None: m.trans_calculation_method=self._method_box.get_state() return m
def get_state(self): """ Returns an object with the state of the interface """ m = SampleData() m.transmission = util._check_and_get_float_line_edit(self._content.transmission_edit) m.transmission_spread = util._check_and_get_float_line_edit(self._content.dtransmission_edit) m.sample_thickness = util._check_and_get_float_line_edit(self._content.thickness_edit) m.calculate_transmission = self._content.calculate_chk.isChecked() m.theta_dependent = self._content.theta_dep_chk.isChecked() m.dark_current = self._content.dark_current_edit.text() m.calculation_method=self._method_box.get_state() # Data file m.data_files = self._get_data_files() return m
def get_state(self): """ Returns an object with the state of the interface """ m = SampleData.DirectBeam() m.beam_radius = util._check_and_get_float_line_edit(self._content.beam_radius_edit) m.sample_file = unicode(self._content.sample_edit.text()) m.direct_beam = unicode(self._content.direct_edit.text()) self._settings.emit_key_value("TRANS_SAMPLE", str(self._content.sample_edit.text())) self._settings.emit_key_value("TRANS_DIRECT", str(self._content.direct_edit.text())) return m
def get_state(self): """ Returns an object with the state of the interface """ a = AbsoluteUnitsScript(self._instrument_name) a.do_absolute_units = self._content.absunits_gb.isChecked() a.absunits_vanadium = self._content.absunits_van_edit.text() a.grouping_file = self._content.grouping_file_edit.text() a.absunits_detector_vanadium = self._content.absunits_detvan_edit.text() a.incident_energy = self._content.ei_edit.text() a.emin = util._check_and_get_float_line_edit(self._content.emin_edit) a.emax = util._check_and_get_float_line_edit(self._content.emax_edit) a.vanadium_mass = util._check_and_get_float_line_edit(self._content.van_mass_edit) a.sample_mass = util._check_and_get_float_line_edit(self._content.sample_mass_edit) a.sample_rmm = util._check_and_get_float_line_edit(self._content.sample_rmm_edit) a.absunits_median_test_high = util._check_and_get_float_line_edit(self._content.median_test_high_edit) a.absunits_median_test_low = util._check_and_get_float_line_edit(self._content.median_test_low_edit) a.absunits_median_test_out_high = util._check_and_get_float_line_edit(self._content.median_test_out_high_edit) a.absunits_median_test_out_low = util._check_and_get_float_line_edit(self._content.median_test_out_low_edit) a.absunits_errorbar_criterion = util._check_and_get_float_line_edit(self._content.errorbar_crit_edit) return a
def _apply(self): """ Perform auto-scaling """ # Update data sets, in case the user typed in a file name without using the browse button if self._low_q_modified: self._update_low_q() if self._medium_q_modified: self._update_medium_q() if self._high_q_modified: self._update_high_q() s = Stitcher() if self._low_q_data is not None: xmin = util._check_and_get_float_line_edit(self._content.low_min_edit) xmax = util._check_and_get_float_line_edit(self._content.low_max_edit) self._low_q_data.set_range(xmin,xmax) s.append(self._low_q_data) if self._referenceID==0: scale = util._check_and_get_float_line_edit(self._content.low_scale_edit) self._low_q_data.set_scale(scale) if self._medium_q_data is not None: s.append(self._medium_q_data) if self._referenceID==1: scale = util._check_and_get_float_line_edit(self._content.medium_scale_edit) self._medium_q_data.set_scale(scale) if self._high_q_data is not None: xmin = util._check_and_get_float_line_edit(self._content.medium_min_edit) xmax = util._check_and_get_float_line_edit(self._content.medium_max_edit) self._high_q_data.set_range(xmin,xmax) s.append(self._high_q_data) if self._referenceID==2: scale = util._check_and_get_float_line_edit(self._content.high_scale_edit) self._high_q_data.set_scale(scale) if s.size()==0: return s.set_reference(self._referenceID) s.compute() # Update scaling factor if self._low_q_data is not None: self._content.low_scale_edit.setText(str(self._low_q_data.get_scale())) if self._medium_q_data is not None: self._content.medium_scale_edit.setText(str(self._medium_q_data.get_scale())) if self._high_q_data is not None: self._content.high_scale_edit.setText(str(self._high_q_data.get_scale())) self._stitcher = s self.plot_result()
def update_data(self, dataset_control, min_control, max_control, scale_control): """ Update a data set @param dataset_control: combo box with the file path or workspace name @param min_control: text widget containing the minimum Q of the overlap region @param max_control: text widget containing the maximum Q of the overlap region @param scale_control: text widget containing the scale (can be input or output) """ data_object = None file_in = str(dataset_control.lineEdit().text()) if len(file_in.strip()) == 0: data_object = None elif os.path.isfile(file_in) or AnalysisDataService.doesExist(file_in): data_object = DataSet(file_in) try: data_object.load(True) except (StandardError, Warning): data_object = None util.set_valid(dataset_control.lineEdit(), False) QtGui.QMessageBox.warning(self, "Error loading file", "Could not load %s.\nMake sure you pick the XML output from the reduction." % file_in) return if min_control is not None and max_control is not None \ and (len(min_control.text()) == 0 or len(max_control.text()) == 0): minx, maxx = data_object.get_range() min_control.setText("%-6.3g" % minx) max_control.setText("%-6.3g" % maxx) # Set the reference scale, unless we just loaded the data if len(scale_control.text()) == 0: scale_control.setText("1.0") else: scale = util._check_and_get_float_line_edit(scale_control) data_object.set_scale(scale) _npts = data_object.get_number_of_points() util.set_valid(dataset_control.lineEdit(), True) else: data_object = None util.set_valid(dataset_control.lineEdit(), False) self._plotted = False return data_object
def get_state(self): """ Returns an object with the state of the interface """ m = DataSets() m.transmission = util._check_and_get_float_line_edit(self._content.transmission_edit) m.transmission_spread = util._check_and_get_float_line_edit(self._content.dtransmission_edit) m.sample_thickness = util._check_and_get_float_line_edit(self._content.sample_thickness_edit) m.calculate_transmission = self._content.calculate_radio.isChecked() m.theta_dependent = self._content.theta_dep_chk.isChecked() m.combine_transmission_frames = self._content.fit_together_check.isChecked() d = m.calculation_method d.beam_radius = util._check_and_get_float_line_edit(self._content.beam_radius_edit) d.sample_file = unicode(self._content.sample_edit.text()) d.direct_beam = unicode(self._content.empty_edit.text()) # Data file m.data_files = self._get_data_files() m.separate_jobs = self._content.separate_jobs_check.isChecked() # Background b = m.background b.background_corr = self._content.background_chk.isChecked() b.background_file = str(self._content.background_edit.text()) b.bck_transmission_enabled = True b.bck_transmission = util._check_and_get_float_line_edit(self._content.bck_transmission_edit) b.bck_transmission_spread = util._check_and_get_float_line_edit(self._content.bck_dtransmission_edit) #b.sample_thickness = util._check_and_get_float_line_edit(self._content.bck_thickness_edit) b.calculate_transmission = self._content.bck_calculate_radio.isChecked() b.theta_dependent = self._content.bck_theta_dep_chk.isChecked() b.combine_transmission_frames = self._content.bck_fit_together_check.isChecked() d = b.trans_calculation_method d.beam_radius = util._check_and_get_float_line_edit(self._content.bck_beam_radius_edit) d.sample_file = unicode(self._content.bck_sample_edit.text()) d.direct_beam = unicode(self._content.bck_empty_edit.text()) self._settings.emit_key_value("TRANS_SAMPLE", str(self._content.sample_edit.text())) self._settings.emit_key_value("TRANS_DIRECT", str(self._content.empty_edit.text())) self._settings.emit_key_value("TRANS_BCK", str(self._content.bck_sample_edit.text())) self._settings.emit_key_value("TRANS_DIRECT", str(self._content.bck_empty_edit.text())) return m
def _wavelength_clicked(self, is_checked): self._summary.wavelength_edit.setEnabled(is_checked) self._summary.wavelength_spread_edit.setEnabled(is_checked) # Keep track of current value so we can restore it if the check box is clicked again if self._wavelength_supplied != is_checked: current_value = util._check_and_get_float_line_edit(self._summary.wavelength_edit) self._summary.wavelength_edit.setText(str(self._wavelength)) util._check_and_get_float_line_edit(self._summary.wavelength_edit, min=0) self._wavelength = current_value current_value = util._check_and_get_float_line_edit(self._summary.wavelength_spread_edit) self._summary.wavelength_spread_edit.setText(str(self._wavelength_spread)) util._check_and_get_float_line_edit(self._summary.wavelength_spread_edit) self._wavelength_spread = current_value self._wavelength_supplied = is_checked
def get_state(self): """ Returns an object with the state of the interface """ d = DataCorrectionsScript(self._instrument_name) d.filter_bad_pulses = self._content.filter_bad_pulses_chkbox.isChecked() d.incident_beam_norm = DataCorrectionsScript.INCIDENT_BEAM_NORM_TYPES[self.incident_beam_norm_grp.checkedId()] d.monitor_int_low = util._check_and_get_float_line_edit(self._content.monint_low_edit) d.monitor_int_high = util._check_and_get_float_line_edit(self._content.monint_high_edit) d.tib_subtraction = self._content.background_sub_gb.isChecked() d.tib_tof_start = util._check_and_get_float_line_edit(self._content.tof_start_edit) d.tib_tof_end = util._check_and_get_float_line_edit(self._content.tof_end_edit) d.correct_kikf = self._content.correct_kikf_cb.isChecked() d.detector_vanadium = self._content.van_input_edit.text() d.detvan_integration = self._content.van_int_cb.isChecked() d.detvan_int_range_low = util._check_and_get_float_line_edit(self._content.van_int_range_low_edit) d.detvan_int_range_high = util._check_and_get_float_line_edit(self._content.van_int_range_high_edit) d.detvan_int_range_units = self._content.van_int_range_units_cb.currentText() d.save_proc_detvan = self._content.save_procdetvan_cb.isChecked() d.save_proc_detvan_file = self._content.save_procdetvan_edit.text() d.use_proc_detvan = self._content.use_procdetvan_cb.isChecked() return d
def get_state(self): """ Returns an object with the state of the interface """ m = ReductionOptions() m.instrument_name = self._summary.instr_name_label.text() # Absolute scaling m.scaling_factor = util._check_and_get_float_line_edit( self._summary.scale_edit) m.calculate_scale = self._summary.scale_chk.isChecked() m.scaling_direct_file = unicode(self._summary.scale_data_edit.text()) m.scaling_att_trans = util._check_and_get_float_line_edit( self._summary.scale_att_trans_edit) m.scaling_beam_diam = util._check_and_get_float_line_edit( self._summary.scale_beam_radius_edit, min=0.0) m.manual_beam_diam = self._summary.beamstop_chk.isChecked() # ## If total detector distance is checked, ignore the other 3 distances: # if self._summary.total_detector_distance_chk.isChecked(): # m.sample_total_distance = util._check_and_get_float_line_edit(self._summary.total_detector_distance_edit) # else: # # Detector offset input # if self._summary.detector_offset_chk.isChecked(): # m.detector_offset = util._check_and_get_float_line_edit(self._summary.detector_offset_edit) # # Sample-detector distance # if self._summary.sample_dist_chk.isChecked(): # m.sample_detector_distance = util._check_and_get_float_line_edit(self._summary.sample_dist_edit) # # Sample-Si-window # if self._summary.sample_si_dist_chk.isChecked(): # m.sample_si_window_distance = util._check_and_get_float_line_edit(self._summary.sample_si_dist_edit) # Workaround: # Offset is not used # The detector_distanc will be used as sample_total_distance m.sample_detector_distance = util._check_and_get_float_line_edit( self._summary.total_detector_distance_edit) m.detector_offset = 0 # Wavelength value wavelength = util._check_and_get_float_line_edit( self._summary.wavelength_edit, min=0.0) if self._summary.wavelength_chk.isChecked(): m.wavelength = wavelength m.wavelength_spread = util._check_and_get_float_line_edit( self._summary.wavelength_spread_edit) # Solid angle correction m.solid_angle_corr = self._summary.solid_angle_chk.isChecked() # Dark current m.dark_current_corr = self._summary.dark_current_check.isChecked() m.dark_current_data = unicode(self._summary.dark_file_edit.text()) # Normalization if self._summary.normalization_none_radio.isChecked(): m.normalization = m.NORMALIZATION_NONE elif self._summary.normalization_time_radio.isChecked(): m.normalization = m.NORMALIZATION_TIME elif self._summary.normalization_monitor_radio.isChecked(): m.normalization = m.NORMALIZATION_MONITOR # Q range m.n_q_bins = util._check_and_get_int_line_edit( self._summary.n_q_bins_edit) m.n_sub_pix = util._check_and_get_int_line_edit( self._summary.n_sub_pix_edit) m.log_binning = self._summary.log_binning_radio.isChecked() m.align_log_with_decades = self._summary.align_check.isChecked() m.error_weighting = self._summary.error_weighting_check.isChecked() m.n_wedges = util._check_and_get_int_line_edit( self._summary.n_wedges_edit) m.wedge_angle = util._check_and_get_float_line_edit( self._summary.wedge_angle_edit) m.wedge_offset = util._check_and_get_float_line_edit( self._summary.wedge_offset_edit) # Detector side masking if self._summary.mask_side_front_radio.isChecked(): m.masked_side = 'Front' elif self._summary.mask_side_back_radio.isChecked(): m.masked_side = 'Back' else: m.masked_side = None # Mask detector IDs m.use_mask_file = self._summary.mask_check.isChecked() m.mask_file = unicode(self._summary.mask_edit.text()) m.detector_ids = self._masked_detectors if self._in_mantidplot: from mantid.api import AnalysisDataService import mantid.simpleapi as api if AnalysisDataService.doesExist(self.mask_ws): _, masked_detectors = api.ExtractMask( InputWorkspace=self.mask_ws, OutputWorkspace="__edited_mask") m.detector_ids = [int(i) for i in masked_detectors] self._settings.emit_key_value("DARK_CURRENT", str(self._summary.dark_file_edit.text())) return m
def _apply(self): """ Perform auto-scaling """ # Update data sets, in case the user typed in a file name without using the browse button if self._low_q_modified: self._update_low_q() if self._medium_q_modified: self._update_medium_q() if self._high_q_modified: self._update_high_q() s = Stitcher() if self._low_q_data is not None: xmin = util._check_and_get_float_line_edit( self._content.low_min_edit) xmax = util._check_and_get_float_line_edit( self._content.low_max_edit) self._low_q_data.set_range(xmin, xmax) s.append(self._low_q_data) if self._referenceID == 0: scale = util._check_and_get_float_line_edit( self._content.low_scale_edit) self._low_q_data.set_scale(scale) if self._medium_q_data is not None: s.append(self._medium_q_data) if self._referenceID == 1: scale = util._check_and_get_float_line_edit( self._content.medium_scale_edit) self._medium_q_data.set_scale(scale) if self._high_q_data is not None: xmin = util._check_and_get_float_line_edit( self._content.medium_min_edit) xmax = util._check_and_get_float_line_edit( self._content.medium_max_edit) self._high_q_data.set_range(xmin, xmax) s.append(self._high_q_data) if self._referenceID == 2: scale = util._check_and_get_float_line_edit( self._content.high_scale_edit) self._high_q_data.set_scale(scale) if s.size() == 0: return s.set_reference(self._referenceID) s.compute() # Update scaling factor if self._low_q_data is not None: self._content.low_scale_edit.setText( str(self._low_q_data.get_scale())) if self._medium_q_data is not None: self._content.medium_scale_edit.setText( str(self._medium_q_data.get_scale())) if self._high_q_data is not None: self._content.high_scale_edit.setText( str(self._high_q_data.get_scale())) self._stitcher = s self.plot_result()
def get_state(self): """ Returns an object with the state of the interface """ d = DiagnoseDetectorsScript(self._instrument_name) d.high_counts = util._check_and_get_float_line_edit( self._content.high_counts_edit) d.low_counts = util._check_and_get_float_line_edit( self._content.low_counts_edit) d.median_test_high = util._check_and_get_float_line_edit( self._content.median_test_high_edit) d.median_test_low = util._check_and_get_float_line_edit( self._content.median_test_low_edit) d.median_test_out_high = util._check_and_get_float_line_edit( self._content.median_test_out_high_edit) d.median_test_out_low = util._check_and_get_float_line_edit( self._content.median_test_out_low_edit) d.errorbar_criterion = util._check_and_get_float_line_edit( self._content.errorbar_crit_edit) d.det_van2 = self._content.det_van2_edit.text() d.detvan_ratio_var = util._check_and_get_float_line_edit( self._content.ratio_var_crit_edit) d.background_check = self._content.background_check_gb.isChecked() d.sambkg_median_test_high = util._check_and_get_float_line_edit( self._content.sambkg_median_test_high_edit) d.sambkg_median_test_low = util._check_and_get_float_line_edit( self._content.sambkg_median_test_low_edit) d.sambkg_errorbar_criterion = util._check_and_get_float_line_edit( self._content.sambkg_errorbar_crit_edit) d.tof_start = util._check_and_get_float_line_edit( self._content.tof_start_edit) d.tof_end = util._check_and_get_float_line_edit( self._content.tof_end_edit) d.reject_zero_bkg = self._content.reject_zero_bg_cb.isChecked() d.psd_bleed = self._content.psd_bleed_gb.isChecked() d.max_framerate = util._check_and_get_float_line_edit( self._content.max_framerate_edit) d.ignored_pixels = util._check_and_get_float_line_edit( self._content.ignored_pixels_edit) return d
def get_state(self): """ Returns an object with the state of the interface """ m = ReductionOptions() m.instrument_name = self._summary.instr_name_label.text() # Absolute scaling m.scaling_factor = util._check_and_get_float_line_edit(self._summary.scale_edit) m.calculate_scale = self._summary.scale_chk.isChecked() m.scaling_direct_file = unicode(self._summary.scale_data_edit.text()) m.scaling_att_trans = util._check_and_get_float_line_edit(self._summary.scale_att_trans_edit) m.scaling_beam_diam = util._check_and_get_float_line_edit(self._summary.scale_beam_radius_edit, min=0.0) m.manual_beam_diam = self._summary.beamstop_chk.isChecked() # ## If total detector distance is checked, ignore the other 3 distances: # if self._summary.total_detector_distance_chk.isChecked(): # m.sample_total_distance = util._check_and_get_float_line_edit(self._summary.total_detector_distance_edit) # else: # # Detector offset input # if self._summary.detector_offset_chk.isChecked(): # m.detector_offset = util._check_and_get_float_line_edit(self._summary.detector_offset_edit) # # Sample-detector distance # if self._summary.sample_dist_chk.isChecked(): # m.sample_detector_distance = util._check_and_get_float_line_edit(self._summary.sample_dist_edit) # # Sample-Si-window # if self._summary.sample_si_dist_chk.isChecked(): # m.sample_si_window_distance = util._check_and_get_float_line_edit(self._summary.sample_si_dist_edit) # Workaround: # Offset is not used # The detector_distanc will be used as sample_total_distance m.sample_detector_distance = util._check_and_get_float_line_edit(self._summary.total_detector_distance_edit) m.detector_offset = 0 # Wavelength value wavelength = util._check_and_get_float_line_edit(self._summary.wavelength_edit, min=0.0) if self._summary.wavelength_chk.isChecked(): m.wavelength = wavelength m.wavelength_spread = util._check_and_get_float_line_edit(self._summary.wavelength_spread_edit) # Solid angle correction m.solid_angle_corr = self._summary.solid_angle_chk.isChecked() # Dark current m.dark_current_corr = self._summary.dark_current_check.isChecked() m.dark_current_data = unicode(self._summary.dark_file_edit.text()) # Normalization if self._summary.normalization_none_radio.isChecked(): m.normalization = m.NORMALIZATION_NONE elif self._summary.normalization_time_radio.isChecked(): m.normalization = m.NORMALIZATION_TIME elif self._summary.normalization_monitor_radio.isChecked(): m.normalization = m.NORMALIZATION_MONITOR # Q range m.n_q_bins = util._check_and_get_int_line_edit(self._summary.n_q_bins_edit) m.n_sub_pix = util._check_and_get_int_line_edit(self._summary.n_sub_pix_edit) m.log_binning = self._summary.log_binning_radio.isChecked() m.align_log_with_decades = self._summary.align_check.isChecked() m.error_weighting = self._summary.error_weighting_check.isChecked() m.n_wedges = util._check_and_get_int_line_edit(self._summary.n_wedges_edit) m.wedge_angle = util._check_and_get_float_line_edit(self._summary.wedge_angle_edit) m.wedge_offset = util._check_and_get_float_line_edit(self._summary.wedge_offset_edit) # Detector side masking if self._summary.mask_side_front_radio.isChecked(): m.masked_side = 'Front' elif self._summary.mask_side_back_radio.isChecked(): m.masked_side = 'Back' else: m.masked_side = None # Mask detector IDs m.use_mask_file = self._summary.mask_check.isChecked() m.mask_file = unicode(self._summary.mask_edit.text()) m.detector_ids = self._masked_detectors if self._in_mantidplot: from mantid.api import AnalysisDataService import mantid.simpleapi as api if AnalysisDataService.doesExist(self.mask_ws): _, masked_detectors = api.ExtractMask(InputWorkspace=self.mask_ws, OutputWorkspace="__edited_mask") m.detector_ids = [int(i) for i in masked_detectors] self._settings.emit_key_value("DARK_CURRENT", str(self._summary.dark_file_edit.text())) return m
def set_state(self, state): """ Populate the UI elements with the data from the given state. @param state: InstrumentDescription object """ self._summary.instr_name_label.setText(state.instrument_name) # npixels = "%d x %d" % (state.nx_pixels, state.ny_pixels) # self._summary.n_pixel_label.setText(QtCore.QString(npixels)) # self._summary.pixel_size_label.setText(QtCore.QString(str(state.pixel_size))) # Absolute scaling self._summary.scale_chk.setChecked(state.calculate_scale) self._summary.scale_edit.setText(str(state.scaling_factor)) self._summary.scale_data_edit.setText(state.scaling_direct_file) self._summary.scale_att_trans_edit.setText(str(state.scaling_att_trans)) self._summary.scale_beam_radius_edit.setText(str("%-6.1f" % state.scaling_beam_diam)) if self._beam_diameter is None: self._beam_diameter = state.scaling_beam_diam self._beam_diameter_supplied = state.manual_beam_diam self._summary.beamstop_chk.setChecked(state.manual_beam_diam) util._check_and_get_float_line_edit(self._summary.scale_beam_radius_edit, min=0.0) self._scale_clicked(self._summary.scale_chk.isChecked()) # Detector offset input # is_enabled, stored_value, chk_widget, edit_widget, suppl_value=None, suppl_edit=None # self._prepare_field(state.detector_offset != 0, # state.detector_offset, # self._summary.detector_offset_chk, # self._summary.detector_offset_edit) # # # Sample-detector distance # self._prepare_field(state.sample_detector_distance != 0, # state.sample_detector_distance, # self._summary.sample_dist_chk, # self._summary.sample_dist_edit) # util._check_and_get_float_line_edit(self._summary.sample_dist_edit, min=0) util._check_and_get_float_line_edit(self._summary.sample_si_dist_edit, min=-0.0001) util._check_and_get_float_line_edit(self._summary.detector_offset_edit, min=-0.0001) util._check_and_get_float_line_edit(self._summary.total_detector_distance_edit, min=0) # if self._sample_detector_distance is None: # self._sample_detector_distance = state.sample_detector_distance # self._sample_detector_distance_supplied = self._summary.sample_dist_chk.isChecked() # # # Sample-detector distance takes precedence over offset if both are non-zero # self._sample_dist_clicked(self._summary.sample_dist_chk.isChecked()) # Wavelength value self._prepare_field(state.wavelength != 0, state.wavelength, self._summary.wavelength_chk, self._summary.wavelength_edit, state.wavelength_spread, self._summary.wavelength_spread_edit) if self._wavelength is None: self._wavelength = state.wavelength if self._wavelength_spread is None: self._wavelength_spread = state.wavelength_spread self._wavelength_supplied = self._summary.wavelength_chk.isChecked() # Solid angle correction flag self._summary.solid_angle_chk.setChecked(state.solid_angle_corr) # Dark current self._summary.dark_current_check.setChecked(state.dark_current_corr) self._summary.dark_file_edit.setText(state.dark_current_data) self._dark_clicked(self._summary.dark_current_check.isChecked()) # Normalization if state.normalization == state.NORMALIZATION_NONE: self._summary.normalization_none_radio.setChecked(True) elif state.normalization == state.NORMALIZATION_TIME: self._summary.normalization_time_radio.setChecked(True) elif state.normalization == state.NORMALIZATION_MONITOR: self._summary.normalization_monitor_radio.setChecked(True) # Q range self._summary.n_q_bins_edit.setText(str(state.n_q_bins)) self._summary.n_sub_pix_edit.setText(str(state.n_sub_pix)) self._summary.log_binning_radio.setChecked(state.log_binning) self._summary.align_check.setEnabled(state.log_binning) self._summary.align_check.setChecked(state.align_log_with_decades) self._summary.error_weighting_check.setChecked(state.error_weighting) self._summary.n_wedges_edit.setText(str(state.n_wedges)) self._summary.wedge_angle_edit.setText(str(state.wedge_angle)) self._summary.wedge_offset_edit.setText(str(state.wedge_offset)) # Mask self._summary.mask_edit.setText(str(state.mask_file)) self._summary.mask_check.setChecked(state.use_mask_file) self._mask_checked(state.use_mask_file) self._masked_detectors = state.detector_ids self.mask_reload = True if state.masked_side == 'Front': self._summary.mask_side_front_radio.setChecked(True) elif state.masked_side == 'Back': self._summary.mask_side_back_radio.setChecked(True) else: self._summary.mask_side_none_radio.setChecked(True)
def get_state(self): """ Returns an object with the state of the interface """ m = ReductionOptions() m.instrument_name = self._summary.instr_name_label.text() # Absolute scaling m.scaling_factor = util._check_and_get_float_line_edit(self._summary.scale_edit) m.calculate_scale = self._summary.scale_chk.isChecked() m.scaling_direct_file = unicode(self._summary.scale_data_edit.text()) m.scaling_att_trans = util._check_and_get_float_line_edit(self._summary.scale_att_trans_edit) m.scaling_beam_diam = util._check_and_get_float_line_edit(self._summary.scale_beam_radius_edit, min=0.0) m.manual_beam_diam = self._summary.beamstop_chk.isChecked() # Detector offset input if self._summary.detector_offset_chk.isChecked(): m.detector_offset = util._check_and_get_float_line_edit(self._summary.detector_offset_edit) # Sample-detector distance if self._summary.sample_dist_chk.isChecked(): m.sample_detector_distance = util._check_and_get_float_line_edit(self._summary.sample_dist_edit) # Wavelength value wavelength = util._check_and_get_float_line_edit(self._summary.wavelength_edit, min=0.0) if self._summary.wavelength_chk.isChecked(): m.wavelength = wavelength m.wavelength_spread = util._check_and_get_float_line_edit(self._summary.wavelength_spread_edit) # Solid angle correction m.solid_angle_corr = self._summary.solid_angle_chk.isChecked() # Dark current m.dark_current_corr = self._summary.dark_current_check.isChecked() m.dark_current_data = unicode(self._summary.dark_file_edit.text()) # Normalization if self._summary.normalization_none_radio.isChecked(): m.normalization = m.NORMALIZATION_NONE elif self._summary.normalization_time_radio.isChecked(): m.normalization = m.NORMALIZATION_TIME elif self._summary.normalization_monitor_radio.isChecked(): m.normalization = m.NORMALIZATION_MONITOR # Q range m.n_q_bins = util._check_and_get_int_line_edit(self._summary.n_q_bins_edit) m.n_sub_pix = util._check_and_get_int_line_edit(self._summary.n_sub_pix_edit) m.log_binning = self._summary.log_binning_radio.isChecked() # Mask detector IDs m.use_mask_file = self._summary.mask_check.isChecked() m.mask_file = unicode(self._summary.mask_edit.text()) m.detector_ids = self._masked_detectors if self._in_mantidplot: from mantid.api import AnalysisDataService import mantid.simpleapi as api if AnalysisDataService.doesExist(self.mask_ws): ws, masked_detectors = api.ExtractMask(InputWorkspace=self.mask_ws, OutputWorkspace="__edited_mask") m.detector_ids = [int(i) for i in masked_detectors] self._settings.emit_key_value("DARK_CURRENT", str(self._summary.dark_file_edit.text())) return m
def set_state(self, state): """ Populate the UI elements with the data from the given state. @param state: InstrumentDescription object """ self._summary.instr_name_label.setText(state.instrument_name) #npixels = "%d x %d" % (state.nx_pixels, state.ny_pixels) #self._summary.n_pixel_label.setText(str(npixels)) #self._summary.pixel_size_label.setText(str(state.pixel_size)) # Absolute scaling self._summary.scale_chk.setChecked(state.calculate_scale) self._summary.scale_edit.setText(str("%-6.3g" % state.scaling_factor)) self._summary.scale_data_edit.setText(state.scaling_direct_file) self._summary.scale_att_trans_edit.setText(str(state.scaling_att_trans)) self._summary.scale_beam_radius_edit.setText(str("%-6.3g" % state.scaling_beam_diam)) if self._beam_diameter is None: self._beam_diameter = state.scaling_beam_diam self._beam_diameter_supplied = state.manual_beam_diam self._summary.beamstop_chk.setChecked(state.manual_beam_diam) util._check_and_get_float_line_edit(self._summary.scale_beam_radius_edit, min=0.0) self._scale_clicked(self._summary.scale_chk.isChecked()) # Detector offset input self._prepare_field(state.detector_offset != 0, state.detector_offset, self._summary.detector_offset_chk, self._summary.detector_offset_edit) # Sample-detector distance self._prepare_field(state.sample_detector_distance != 0, state.sample_detector_distance, self._summary.sample_dist_chk, self._summary.sample_dist_edit) util._check_and_get_float_line_edit(self._summary.sample_dist_edit, min=0) if self._sample_detector_distance is None: self._sample_detector_distance = state.sample_detector_distance self._sample_detector_distance_supplied = self._summary.sample_dist_chk.isChecked() # Sample-detector distance takes precedence over offset if both are non-zero self._sample_dist_clicked(self._summary.sample_dist_chk.isChecked()) # Solid angle correction flag self._summary.solid_angle_chk.setChecked(state.solid_angle_corr) # Dark current self._summary.dark_current_check.setChecked(state.dark_current_corr) self._summary.dark_file_edit.setText(state.dark_current_data) self._dark_clicked(self._summary.dark_current_check.isChecked()) # Q range self._summary.n_q_bins_edit.setText(str(state.n_q_bins)) self._summary.log_binning_radio.setChecked(state.log_binning) self._summary.lin_binning_radio.setChecked(not state.log_binning) # TOF cuts self._summary.tof_cut_chk.setChecked(state.use_config_cutoff) self._tof_clicked(self._summary.tof_cut_chk.isChecked()) self._summary.low_tof_edit.setText(str(state.low_TOF_cut)) self._summary.high_tof_edit.setText(str(state.high_TOF_cut)) # Config Mask self._summary.config_mask_chk.setChecked(state.use_config_mask) # Mask self._summary.mask_edit.setText(str(state.mask_file)) self._summary.mask_check.setChecked(state.use_mask_file) self._mask_checked(state.use_mask_file) self._masked_detectors = state.detector_ids self.mask_reload = True # Resolution parameters self._summary.resolution_chk.setChecked(state.compute_resolution) self._summary.sample_apert_edit.setText(str(state.sample_aperture_diameter)) self._resolution_clicked(self._summary.resolution_chk.isChecked()) self._summary.tof_correction_chk.setChecked(state.perform_TOF_correction) self._summary.beam_monitor_chk.setChecked(state.use_beam_monitor) self._summary.beam_monitor_edit.setText(str(state.beam_monitor_reference)) self._beam_monitor_clicked(self._summary.beam_monitor_chk.isChecked()) # Output directory self._summary.select_output_dir_radio.setChecked(not state.use_data_directory) self._summary.use_data_dir_radio.setChecked(state.use_data_directory) if len(state.output_directory.strip())>0: self._summary.output_dir_edit.setText(str(state.output_directory)) else: self._summary.output_dir_edit.setText(str(os.path.expanduser('~'))) self._output_dir_clicked()
def get_state(self): """ Returns an object with the state of the interface """ d = DiagnoseDetectorsScript(self._instrument_name) d.high_counts = util._check_and_get_float_line_edit(self._content.high_counts_edit) d.low_counts = util._check_and_get_float_line_edit(self._content.low_counts_edit) d.median_test_high = util._check_and_get_float_line_edit(self._content.median_test_high_edit) d.median_test_low = util._check_and_get_float_line_edit(self._content.median_test_low_edit) d.median_test_out_high = util._check_and_get_float_line_edit(self._content.median_test_out_high_edit) d.median_test_out_low = util._check_and_get_float_line_edit(self._content.median_test_out_low_edit) d.errorbar_criterion = util._check_and_get_float_line_edit(self._content.errorbar_crit_edit) d.det_van2 = self._content.det_van2_edit.text() d.detvan_ratio_var = util._check_and_get_float_line_edit(self._content.ratio_var_crit_edit) d.background_check = self._content.background_check_gb.isChecked() d.sambkg_median_test_high = util._check_and_get_float_line_edit(self._content.sambkg_median_test_high_edit) d.sambkg_median_test_low = util._check_and_get_float_line_edit(self._content.sambkg_median_test_low_edit) d.sambkg_errorbar_criterion = util._check_and_get_float_line_edit(self._content.sambkg_errorbar_crit_edit) d.tof_start = util._check_and_get_float_line_edit(self._content.tof_start_edit) d.tof_end = util._check_and_get_float_line_edit(self._content.tof_end_edit) d.reject_zero_bkg = self._content.reject_zero_bg_cb.isChecked() d.psd_bleed = self._content.psd_bleed_gb.isChecked() d.max_framerate = util._check_and_get_float_line_edit(self._content.max_framerate_edit) d.ignored_pixels = util._check_and_get_float_line_edit(self._content.ignored_pixels_edit) return d
def get_state(self): """ Returns an object with the state of the interface """ m = ReductionOptions() m.instrument_name = self._summary.instr_name_label.text() # Absolute scaling m.scaling_factor = util._check_and_get_float_line_edit(self._summary.scale_edit) m.calculate_scale = self._summary.scale_chk.isChecked() m.scaling_direct_file = unicode(self._summary.scale_data_edit.text()) m.scaling_att_trans = util._check_and_get_float_line_edit(self._summary.scale_att_trans_edit) m.scaling_beam_diam = util._check_and_get_float_line_edit(self._summary.scale_beam_radius_edit, min=0.0) m.manual_beam_diam = self._summary.beamstop_chk.isChecked() # Detector offset input if self._summary.detector_offset_chk.isChecked(): m.detector_offset = util._check_and_get_float_line_edit(self._summary.detector_offset_edit) # Sample-detector distance if self._summary.sample_dist_chk.isChecked(): m.sample_detector_distance = util._check_and_get_float_line_edit(self._summary.sample_dist_edit) # Solid angle correction m.solid_angle_corr = self._summary.solid_angle_chk.isChecked() # Dark current m.dark_current_corr = self._summary.dark_current_check.isChecked() m.dark_current_data = unicode(self._summary.dark_file_edit.text()) # Q range m.n_q_bins = util._check_and_get_int_line_edit(self._summary.n_q_bins_edit) m.log_binning = self._summary.log_binning_radio.isChecked() # TOF cuts m.use_config_cutoff = self._summary.tof_cut_chk.isChecked() m.low_TOF_cut = util._check_and_get_float_line_edit(self._summary.low_tof_edit) m.high_TOF_cut = util._check_and_get_float_line_edit(self._summary.high_tof_edit) # Config Mask m.use_config_mask = self._summary.config_mask_chk.isChecked() # Mask detector IDs m.use_mask_file = self._summary.mask_check.isChecked() m.mask_file = unicode(self._summary.mask_edit.text()) m.detector_ids = self._masked_detectors if AnalysisDataService.doesExist(self.mask_ws): ws, masked_detectors = ExtractMask(InputWorkspace=self.mask_ws, OutputWorkspace="__edited_mask") m.detector_ids = [int(i) for i in masked_detectors] # Resolution parameters m.compute_resolution = self._summary.resolution_chk.isChecked() m.sample_aperture_diameter = util._check_and_get_float_line_edit(self._summary.sample_apert_edit) m.perform_TOF_correction = self._summary.tof_correction_chk.isChecked() m.use_beam_monitor = self._summary.beam_monitor_chk.isChecked() m.beam_monitor_reference = unicode(self._summary.beam_monitor_edit.text()) # Output directory m.use_data_directory = self._summary.use_data_dir_radio.isChecked() m.output_directory = str(self._summary.output_dir_edit.text()) self._settings.data_output_dir = m.output_directory self._settings.emit_key_value("DARK_CURRENT", str(self._summary.dark_file_edit.text())) self._settings.emit_key_value("OUTPUT_DIR", m.output_directory) return m
def set_state(self, state): """ Populate the UI elements with the data from the given state. @param state: InstrumentDescription object """ self._summary.instr_name_label.setText(state.instrument_name) #npixels = "%d x %d" % (state.nx_pixels, state.ny_pixels) #self._summary.n_pixel_label.setText(QtCore.QString(npixels)) #self._summary.pixel_size_label.setText(QtCore.QString(str(state.pixel_size))) # Absolute scaling self._summary.scale_chk.setChecked(state.calculate_scale) self._summary.scale_edit.setText(str("%-6.3g" % state.scaling_factor)) self._summary.scale_data_edit.setText(state.scaling_direct_file) self._summary.scale_att_trans_edit.setText(str( state.scaling_att_trans)) self._summary.scale_beam_radius_edit.setText( str("%-6.3g" % state.scaling_beam_diam)) if self._beam_diameter is None: self._beam_diameter = state.scaling_beam_diam self._beam_diameter_supplied = state.manual_beam_diam self._summary.beamstop_chk.setChecked(state.manual_beam_diam) util._check_and_get_float_line_edit( self._summary.scale_beam_radius_edit, min=0.0) self._scale_clicked(self._summary.scale_chk.isChecked()) # Detector offset input self._prepare_field(state.detector_offset != 0, state.detector_offset, self._summary.detector_offset_chk, self._summary.detector_offset_edit) # Sample-detector distance self._prepare_field(state.sample_detector_distance != 0, state.sample_detector_distance, self._summary.sample_dist_chk, self._summary.sample_dist_edit) util._check_and_get_float_line_edit(self._summary.sample_dist_edit, min=0) if self._sample_detector_distance is None: self._sample_detector_distance = state.sample_detector_distance self._sample_detector_distance_supplied = self._summary.sample_dist_chk.isChecked( ) # Sample-detector distance takes precedence over offset if both are non-zero self._sample_dist_clicked(self._summary.sample_dist_chk.isChecked()) # Solid angle correction flag self._summary.solid_angle_chk.setChecked(state.solid_angle_corr) # Dark current self._summary.dark_current_check.setChecked(state.dark_current_corr) self._summary.dark_file_edit.setText(state.dark_current_data) self._dark_clicked(self._summary.dark_current_check.isChecked()) # Q range self._summary.n_q_bins_edit.setText(str(state.n_q_bins)) self._summary.log_binning_radio.setChecked(state.log_binning) self._summary.lin_binning_radio.setChecked(not state.log_binning) # TOF cuts self._summary.tof_cut_chk.setChecked(state.use_config_cutoff) self._tof_clicked(self._summary.tof_cut_chk.isChecked()) self._summary.low_tof_edit.setText(str(state.low_TOF_cut)) self._summary.high_tof_edit.setText(str(state.high_TOF_cut)) # Config Mask self._summary.config_mask_chk.setChecked(state.use_config_mask) # Mask self._summary.mask_edit.setText(str(state.mask_file)) self._summary.mask_check.setChecked(state.use_mask_file) self._mask_checked(state.use_mask_file) self._masked_detectors = state.detector_ids self.mask_reload = True # Resolution parameters self._summary.resolution_chk.setChecked(state.compute_resolution) self._summary.sample_apert_edit.setText( str(state.sample_aperture_diameter)) self._resolution_clicked(self._summary.resolution_chk.isChecked()) self._summary.tof_correction_chk.setChecked( state.perform_TOF_correction) self._summary.beam_monitor_chk.setChecked(state.use_beam_monitor) self._summary.beam_monitor_edit.setText( str(state.beam_monitor_reference)) self._beam_monitor_clicked(self._summary.beam_monitor_chk.isChecked()) # Output directory self._summary.select_output_dir_radio.setChecked( not state.use_data_directory) self._summary.use_data_dir_radio.setChecked(state.use_data_directory) if len(state.output_directory.strip()) > 0: self._summary.output_dir_edit.setText(str(state.output_directory)) else: self._summary.output_dir_edit.setText(str(os.path.expanduser('~'))) self._output_dir_clicked()
def set_state(self, state): """ Populate the UI elements with the data from the given state. @param state: InstrumentDescription object """ self._summary.instr_name_label.setText(state.instrument_name) # npixels = "%d x %d" % (state.nx_pixels, state.ny_pixels) # self._summary.n_pixel_label.setText(QtCore.QString(npixels)) # self._summary.pixel_size_label.setText(QtCore.QString(str(state.pixel_size))) # Absolute scaling self._summary.scale_chk.setChecked(state.calculate_scale) self._summary.scale_edit.setText(str(state.scaling_factor)) self._summary.scale_data_edit.setText(state.scaling_direct_file) self._summary.scale_att_trans_edit.setText(str( state.scaling_att_trans)) self._summary.scale_beam_radius_edit.setText( str("%-6.1f" % state.scaling_beam_diam)) if self._beam_diameter is None: self._beam_diameter = state.scaling_beam_diam self._beam_diameter_supplied = state.manual_beam_diam self._summary.beamstop_chk.setChecked(state.manual_beam_diam) util._check_and_get_float_line_edit( self._summary.scale_beam_radius_edit, min=0.0) self._scale_clicked(self._summary.scale_chk.isChecked()) # Detector offset input # is_enabled, stored_value, chk_widget, edit_widget, suppl_value=None, suppl_edit=None # self._prepare_field(state.detector_offset != 0, # state.detector_offset, # self._summary.detector_offset_chk, # self._summary.detector_offset_edit) # # # Sample-detector distance # self._prepare_field(state.sample_detector_distance != 0, # state.sample_detector_distance, # self._summary.sample_dist_chk, # self._summary.sample_dist_edit) # util._check_and_get_float_line_edit(self._summary.sample_dist_edit, min=0) util._check_and_get_float_line_edit(self._summary.sample_si_dist_edit, min=-0.0001) util._check_and_get_float_line_edit(self._summary.detector_offset_edit, min=-0.0001) util._check_and_get_float_line_edit( self._summary.total_detector_distance_edit, min=0) # if self._sample_detector_distance is None: # self._sample_detector_distance = state.sample_detector_distance # self._sample_detector_distance_supplied = self._summary.sample_dist_chk.isChecked() # # # Sample-detector distance takes precedence over offset if both are non-zero # self._sample_dist_clicked(self._summary.sample_dist_chk.isChecked()) # Wavelength value self._prepare_field(state.wavelength != 0, state.wavelength, self._summary.wavelength_chk, self._summary.wavelength_edit, state.wavelength_spread, self._summary.wavelength_spread_edit) if self._wavelength is None: self._wavelength = state.wavelength if self._wavelength_spread is None: self._wavelength_spread = state.wavelength_spread self._wavelength_supplied = self._summary.wavelength_chk.isChecked() # Solid angle correction flag self._summary.solid_angle_chk.setChecked(state.solid_angle_corr) # Dark current self._summary.dark_current_check.setChecked(state.dark_current_corr) self._summary.dark_file_edit.setText(state.dark_current_data) self._dark_clicked(self._summary.dark_current_check.isChecked()) # Normalization if state.normalization == state.NORMALIZATION_NONE: self._summary.normalization_none_radio.setChecked(True) elif state.normalization == state.NORMALIZATION_TIME: self._summary.normalization_time_radio.setChecked(True) elif state.normalization == state.NORMALIZATION_MONITOR: self._summary.normalization_monitor_radio.setChecked(True) # Q range self._summary.n_q_bins_edit.setText(str(state.n_q_bins)) self._summary.n_sub_pix_edit.setText(str(state.n_sub_pix)) self._summary.log_binning_radio.setChecked(state.log_binning) self._summary.align_check.setEnabled(state.log_binning) self._summary.align_check.setChecked(state.align_log_with_decades) self._summary.error_weighting_check.setChecked(state.error_weighting) self._summary.n_wedges_edit.setText(str(state.n_wedges)) self._summary.wedge_angle_edit.setText(str(state.wedge_angle)) self._summary.wedge_offset_edit.setText(str(state.wedge_offset)) # Mask self._summary.mask_edit.setText(str(state.mask_file)) self._summary.mask_check.setChecked(state.use_mask_file) self._mask_checked(state.use_mask_file) self._masked_detectors = state.detector_ids self.mask_reload = True if state.masked_side == 'Front': self._summary.mask_side_front_radio.setChecked(True) elif state.masked_side == 'Back': self._summary.mask_side_back_radio.setChecked(True) else: self._summary.mask_side_none_radio.setChecked(True)
def get_state(self): """ Returns an object with the state of the interface """ m = ReductionOptions() m.instrument_name = self._summary.instr_name_label.text() # Absolute scaling m.scaling_factor = util._check_and_get_float_line_edit( self._summary.scale_edit) m.calculate_scale = self._summary.scale_chk.isChecked() m.scaling_direct_file = unicode(self._summary.scale_data_edit.text()) m.scaling_att_trans = util._check_and_get_float_line_edit( self._summary.scale_att_trans_edit) m.scaling_beam_diam = util._check_and_get_float_line_edit( self._summary.scale_beam_radius_edit, min=0.0) m.manual_beam_diam = self._summary.beamstop_chk.isChecked() # Detector offset input if self._summary.detector_offset_chk.isChecked(): m.detector_offset = util._check_and_get_float_line_edit( self._summary.detector_offset_edit) # Sample-detector distance if self._summary.sample_dist_chk.isChecked(): m.sample_detector_distance = util._check_and_get_float_line_edit( self._summary.sample_dist_edit) # Solid angle correction m.solid_angle_corr = self._summary.solid_angle_chk.isChecked() # Dark current m.dark_current_corr = self._summary.dark_current_check.isChecked() m.dark_current_data = unicode(self._summary.dark_file_edit.text()) # Q range m.n_q_bins = util._check_and_get_int_line_edit( self._summary.n_q_bins_edit) m.log_binning = self._summary.log_binning_radio.isChecked() # TOF cuts m.use_config_cutoff = self._summary.tof_cut_chk.isChecked() m.low_TOF_cut = util._check_and_get_float_line_edit( self._summary.low_tof_edit) m.high_TOF_cut = util._check_and_get_float_line_edit( self._summary.high_tof_edit) # Config Mask m.use_config_mask = self._summary.config_mask_chk.isChecked() # Mask detector IDs m.use_mask_file = self._summary.mask_check.isChecked() m.mask_file = unicode(self._summary.mask_edit.text()) m.detector_ids = self._masked_detectors if AnalysisDataService.doesExist(self.mask_ws): ws, masked_detectors = ExtractMask(InputWorkspace=self.mask_ws, OutputWorkspace="__edited_mask") m.detector_ids = [int(i) for i in masked_detectors] # Resolution parameters m.compute_resolution = self._summary.resolution_chk.isChecked() m.sample_aperture_diameter = util._check_and_get_float_line_edit( self._summary.sample_apert_edit) m.perform_TOF_correction = self._summary.tof_correction_chk.isChecked() m.use_beam_monitor = self._summary.beam_monitor_chk.isChecked() m.beam_monitor_reference = unicode( self._summary.beam_monitor_edit.text()) # Output directory m.use_data_directory = self._summary.use_data_dir_radio.isChecked() m.output_directory = str(self._summary.output_dir_edit.text()) self._settings.data_output_dir = m.output_directory self._settings.emit_key_value("DARK_CURRENT", str(self._summary.dark_file_edit.text())) self._settings.emit_key_value("OUTPUT_DIR", m.output_directory) return m