def get_default_acquisition_parameters(self, parent_key=None): """ :returns: A AcquisitionParameters object with all default parameters. """ default_key = "default_acquisition_values" if parent_key is None: parent_key = default_key acq_parameters = queue_model_objects.AcquisitionParameters() try: self[parent_key] except KeyError: logging.warning("No key %s in beamline setup, using %s", parent_key, default_key) parent_key = default_key img_start_num = self[parent_key].getProperty("start_image_number") num_images = self[parent_key].getProperty("number_of_images") osc_range = round(float(self[parent_key].getProperty("range")), 2) overlap = round(float(self[parent_key].getProperty("overlap")), 2) exp_time = round(float(self[parent_key].getProperty("exposure_time")), 5) num_passes = int(self[parent_key].getProperty("number_of_passes")) shutterless = self.detector_has_shutterless() try: detector_mode = self.detector_hwobj.default_mode() except AttributeError: detector_mode = None acq_parameters.first_image = img_start_num acq_parameters.num_images = num_images acq_parameters.osc_start = self._get_omega_axis_position() acq_parameters.osc_range = osc_range acq_parameters.kappa = self._get_kappa_axis_position() acq_parameters.kappa_phi = self._get_kappa_phi_axis_position() acq_parameters.overlap = overlap acq_parameters.exp_time = exp_time acq_parameters.num_passes = num_passes acq_parameters.resolution = self._get_resolution() acq_parameters.energy = self._get_energy() acq_parameters.transmission = self._get_transmission() acq_parameters.shutterless = self._has_shutterless() acq_parameters.detector_mode = self._get_detector_mode() acq_parameters.inverse_beam = False acq_parameters.take_dark_current = True acq_parameters.skip_existing_images = False acq_parameters.take_snapshots = True return acq_parameters
def init_acq_model(self): if self._acq_widget: def_acq_parameters = HWR.beamline.get_default_acquisition_parameters() self._acquisition_parameters.set_from_dict(def_acq_parameters.as_dict()) if HWR.beamline.diffractometer.in_plate_mode(): self._acq_widget.use_kappa(False) self._acq_widget.use_max_osc_range(True) else: self._acq_widget.use_kappa(True) self._acq_widget.use_max_osc_range(False) self._acq_widget.update_osc_total_range() else: self._acquisition_parameters = queue_model_objects.AcquisitionParameters()
def get_default_char_acq_parameters(self): """ :returns: A AcquisitionParameters object with all default parameters. """ acq_parameters = queue_model_objects.AcquisitionParameters() parent_key = "default_characterisation_values" img_start_num = self[parent_key].getProperty("start_image_number") num_images = self[parent_key].getProperty("number_of_images") num_wedges = self[parent_key].getProperty("number_of_wedges") osc_range = round(float(self[parent_key].getProperty("range")), 2) overlap = round(float(self[parent_key].getProperty("overlap")), 2) exp_time = round(float(self[parent_key].getProperty("exposure_time")), 4) num_passes = int(self[parent_key].getProperty("number_of_passes")) wedge_size = int(self[parent_key].getProperty("wedge_size")) shutterless = self.detector_has_shutterless() try: detector_mode = self.detector_hwobj.default_mode() except AttributeError: detector_mode = None acq_parameters.first_image = int(img_start_num) acq_parameters.num_images = int(num_images) acq_parameters.osc_start = self._get_omega_axis_position() acq_parameters.osc_range = osc_range acq_parameters.num_wedges = num_wedges acq_parameters.wedge_size = wedge_size acq_parameters.kappa = self._get_kappa_axis_position() acq_parameters.kappa_phi = self._get_kappa_phi_axis_position() acq_parameters.overlap = overlap acq_parameters.exp_time = exp_time acq_parameters.num_passes = num_passes acq_parameters.resolution = self._get_resolution() acq_parameters.energy = self._get_energy() acq_parameters.transmission = self._get_transmission() acq_parameters.shutterless = self._has_shutterless() acq_parameters.detector_mode = self._get_roi_modes() acq_parameters.inverse_beam = False acq_parameters.take_dark_current = True acq_parameters.skip_existing_images = False acq_parameters.take_snapshots = True return acq_parameters
def __init__( self, parent=None, name=None, fl=0, acq_params=None, path_template=None, layout=None, ): QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(fl)) if name is not None: self.setObjectName(name) # Internal variables -------------------------------------------------- self.value_changed_list = [] # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------- # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- if acq_params is None: self._acquisition_parameters = queue_model_objects.AcquisitionParameters( ) else: self._acquisition_parameters = acq_params if path_template is None: self._path_template = queue_model_objects.PathTemplate() else: self._path_template = path_template self._acquisition_mib = DataModelInputBinder( self._acquisition_parameters) self.acq_widget_layout = QtImport.load_ui_file( "acquisition_widget_vertical_simple_layout.ui") # Layout -------------------------------------------------------------- main_layout = QtImport.QVBoxLayout(self) main_layout.addWidget(self.acq_widget_layout) main_layout.setSpacing(0) main_layout.setContentsMargins(0, 0, 0, 0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self.acq_widget_layout.osc_start_cbox.stateChanged.connect( self.use_osc_start) self.acq_widget_layout.num_images_cbox.activated.connect( self.update_num_images) self.acq_widget_layout.detector_roi_mode_combo.activated.connect( self.detector_roi_mode_changed) # Other --------------------------------------------------------------- self.osc_start_validator = QtImport.QDoubleValidator( -10000, 10000, 4, self.acq_widget_layout.osc_start_ledit) self.osc_range_validator = QtImport.QDoubleValidator( -10000, 10000, 4, self.acq_widget_layout.osc_range_ledit) self.kappa_validator = QtImport.QDoubleValidator( 0, 360, 4, self.acq_widget_layout.kappa_ledit) self.kappa_phi_validator = QtImport.QDoubleValidator( 0, 360, 4, self.acq_widget_layout.kappa_phi_ledit) self.energy_validator = QtImport.QDoubleValidator( 0, 25, 5, self.acq_widget_layout.energy_ledit) self.resolution_validator = QtImport.QDoubleValidator( 0, 15, 3, self.acq_widget_layout.resolution_ledit) self.transmission_validator = QtImport.QDoubleValidator( 0, 100, 3, self.acq_widget_layout.transmission_ledit) self.exp_time_validator = QtImport.QDoubleValidator( 0, 10000, 6, self.acq_widget_layout.exp_time_ledit) self.acq_widget_layout.num_images_cbox.setCurrentIndex(1) self.acq_widget_layout.detector_roi_mode_label.setEnabled(False) self.acq_widget_layout.detector_roi_mode_combo.setEnabled(False) self.set_tunable_energy(HWR.beamline.tunable_wavelength) if HWR.beamline.diffractometer.in_plate_mode(): self.acq_widget_layout.num_images_cbox.clear() self.acq_widget_layout.num_images_cbox.addItem("1") self.acq_widget_layout.num_images_cbox.setCurrentIndex(0) self.init_detector_roi_modes() self.init_limits()
def __init__( self, parent=None, name=None, fl=0, acq_params=None, path_template=None, layout="vertical", ): """ Loads ui file that defines the gui layout. Initiates QLineEdits by adding limits, precision Connects to qt signals to update acquisition parameters :param parent: :param name: :param fl: :param acq_params: :param path_template: :param layout: """ QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(fl)) if name is not None: self.setObjectName(name) # Internal variables -------------------------------------------------- self.value_changed_list = [] # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------- # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- if acq_params is None: self._acquisition_parameters = queue_model_objects.AcquisitionParameters( ) else: self._acquisition_parameters = acq_params if path_template is None: self._path_template = queue_model_objects.PathTemplate() else: self._path_template = path_template self._acquisition_mib = DataModelInputBinder( self._acquisition_parameters) self.acq_widget_layout = QtImport.load_ui_file( "acquisition_widget_vertical_still_layout.ui") # Layout -------------------------------------------------------------- __main_vlayout = QtImport.QVBoxLayout(self) __main_vlayout.addWidget(self.acq_widget_layout) __main_vlayout.setSpacing(0) __main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self.acq_widget_layout.num_triggers_ledit.textChanged.connect( self.num_triggers_ledit_changed) self.acq_widget_layout.num_images_per_trigger_ledit.textChanged.connect( self.num_images_per_trigger_ledit_changed) self.acq_widget_layout.exp_time_ledit.textChanged.connect( self.exposure_time_ledit_changed) self.acq_widget_layout.detector_roi_mode_combo.activated.connect( self.detector_roi_mode_changed) self.acq_widget_layout.energy_ledit.textEdited.connect( self.energy_ledit_changed) self.acq_widget_layout.transmission_ledit.textEdited.connect( self.transmission_ledit_changed) self.acq_widget_layout.resolution_ledit.textEdited.connect( self.resolution_ledit_changed) # Other --------------------------------------------------------------- self.energy_validator = QtImport.QDoubleValidator( 4, 25, 4, self.acq_widget_layout.energy_ledit) self.resolution_validator = QtImport.QDoubleValidator( 0, 15, 3, self.acq_widget_layout.resolution_ledit) self.transmission_validator = QtImport.QDoubleValidator( 0, 100, 3, self.acq_widget_layout.transmission_ledit) self.exp_time_validator = QtImport.QDoubleValidator( 0.0001, 10000, 7, self.acq_widget_layout.exp_time_ledit) self.num_triggers_validator = QtImport.QIntValidator( 1, 9999999, self.acq_widget_layout.num_triggers_ledit) self.num_images_per_trigger_validator = QtImport.QIntValidator( 1, 9999999, self.acq_widget_layout.num_images_per_trigger_ledit) self.num_img_validator = QtImport.QIntValidator( 1, 9999999, self.acq_widget_layout.num_images_ledit) self.hare_num_validator = QtImport.QIntValidator( 1, 9999999, self.acq_widget_layout.hare_num_ledit) limits_dict = HWR.beamline.acquisition_limit_values tpl = limits_dict.get("exposure_time") if tpl: self.exp_time_validator.setRange(tpl[0], tpl[1], 6) self._acquisition_mib.bind_value_update( "exp_time", self.acq_widget_layout.exp_time_ledit, float, self.exp_time_validator, ) self._acquisition_mib.bind_value_update( "num_triggers", self.acq_widget_layout.num_triggers_ledit, int, self.num_triggers_validator, ) self._acquisition_mib.bind_value_update( "num_images_per_trigger", self.acq_widget_layout.num_images_per_trigger_ledit, int, self.num_images_per_trigger_validator, ) self._acquisition_mib.bind_value_update( "hare_num", self.acq_widget_layout.hare_num_ledit, int, self.hare_num_validator, ) tpl = limits_dict.get("number_of_images") if tpl: self.num_img_validator.setRange(tpl[0], tpl[1]) self._acquisition_mib.bind_value_update( "num_images", self.acq_widget_layout.num_images_ledit, int, self.num_img_validator, ) self._acquisition_mib.bind_value_update( "energy", self.acq_widget_layout.energy_ledit, float, self.energy_validator) self.update_energy_limits( (self.energy_validator.bottom(), self.energy_validator.top())) self._acquisition_mib.bind_value_update( "transmission", self.acq_widget_layout.transmission_ledit, float, self.transmission_validator, ) self.update_transmission_limits((self.transmission_validator.bottom(), self.transmission_validator.top())) self._acquisition_mib.bind_value_update( "resolution", self.acq_widget_layout.resolution_ledit, float, self.resolution_validator, ) self.init_detector_roi_modes() self.acq_widget_layout.detector_roi_mode_label.setEnabled(False) self.acq_widget_layout.detector_roi_mode_combo.setEnabled(False) self.update_exp_time_limits()
def get_default_acquisition_parameters(self, acquisition_type="default"): """ :returns: A AcquisitionParameters object with all default parameters for the specified acquisition type. "default" is a standard acqquisition """ # Imported here to avoid circular imports from HardwareRepository.HardwareObjects import queue_model_objects acq_parameters = queue_model_objects.AcquisitionParameters() params = self.default_acquisition_parameters["default"].copy() if acquisition_type != "default": dd0 = self.default_acquisition_parameters.get(acquisition_type) if dd0 is None: logging.getLogger("HWR").warning( "No separate parameters for acquisition type: %s - using default." % acquisition_type) else: params.update(dd0) for tag, val in params.items(): setattr(acq_parameters, tag, val) motor_positions = self.diffractometer.get_positions() osc_start = motor_positions.get("phi", params["osc_start"]) acq_parameters.osc_start = round(float(osc_start), 2) kappa = motor_positions.get("kappa", 0.0) kappa = kappa if kappa else 0.0 acq_parameters.kappa = round(float(kappa), 2) kappa_phi = motor_positions.get("kappa_phi", 0.0) kappa_phi = kappa_phi if kappa_phi else 0.0 acq_parameters.kappa_phi = round(float(kappa_phi), 2) try: acq_parameters.resolution = self.resolution.get_value() except: logging.getLogger("HWR").warning( "get_default_acquisition_parameters: " "No current resolution, setting to 0.0") acq_parameters.resolution = 0.0 try: acq_parameters.energy = self.energy.get_value() except: logging.getLogger("HWR").warning( "get_default_acquisition_parameters: " "No current energy, setting to 0.0") acq_parameters.energy = 0.0 try: acq_parameters.transmission = self.transmission.get_value() except: logging.getLogger("HWR").warning( "get_default_acquisition_parameters: " "No current transmission, setting to 0.0") acq_parameters.transmission = 0.0 try: acq_parameters.shutterless = self.detector.has_shutterless() except: logging.getLogger("HWR").warning( "get_default_acquisition_parameters: " "Could not get has_shutterless, setting to False") acq_parameters.shutterless = False try: acq_parameters.detector_binning_mode = self.detector.get_binning_mode( ) except: logging.getLogger("HWR").warning( "get_default_acquisition_parameters: " "Could not get detector mode, setting to ''") acq_parameters.detector_binning_mode = "" try: acq_parameters.detector_roi_mode = self.detector.get_roi_mode() except: logging.getLogger("HWR").warning( "get_default_acquisition_parameters: " "Could not get roi mode, setting to ''") acq_parameters.detector_roi_mode = "" return acq_parameters
def __init__( self, parent=None, name=None, fl=0, acq_params=None, path_template=None, layout="horizontal", ): QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(fl)) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- # Internal variables -------------------------------------------------- self.previous_energy = 0 # If the acq. widget is used with grids then total osc range is not # equal to num_images * osc_range, but num_images_per_line * osc_range # For grids the osc total range is updated when a grid is selected self.grid_mode = False # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------- # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- if acq_params is None: self._acquisition_parameters = queue_model_objects.AcquisitionParameters() else: self._acquisition_parameters = acq_params if path_template is None: self._path_template = queue_model_objects.PathTemplate() else: self._path_template = path_template self._acquisition_mib = DataModelInputBinder(self._acquisition_parameters) if layout == "horizontal": self.acq_widget_layout = QtImport.load_ui_file( "acquisition_widget_horizontal_layout.ui" ) self.use_osc_start(False) else: self.acq_widget_layout = QtImport.load_ui_file( "acquisition_widget_vertical_layout.ui" ) # Layout -------------------------------------------------------------- __main_vlayout = QtImport.QVBoxLayout(self) __main_vlayout.addWidget(self.acq_widget_layout) __main_vlayout.setSpacing(0) __main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self.acq_widget_layout.osc_start_cbox.stateChanged.connect(self.fix_osc_start) self.acq_widget_layout.exp_time_ledit.textChanged.connect( self.exposure_time_ledit_changed ) self.acq_widget_layout.exp_time_total_ledit.textEdited.connect( self.exp_time_total_ledit_changed ) self.acq_widget_layout.first_image_ledit.textChanged.connect( self.first_image_ledit_change ) self.acq_widget_layout.num_images_ledit.textChanged.connect( self.num_images_ledit_change ) self.acq_widget_layout.detector_roi_mode_combo.activated.connect( self.detector_roi_mode_changed ) self.acq_widget_layout.energies_combo.activated.connect(self.energy_selected) self.acq_widget_layout.mad_cbox.toggled.connect(self.use_mad) self.acq_widget_layout.osc_start_ledit.textEdited.connect( self.osc_start_ledit_changed ) self.acq_widget_layout.osc_range_ledit.textEdited.connect( self.osc_range_per_frame_ledit_changed ) self.acq_widget_layout.osc_total_range_ledit.textEdited.connect( self.osc_total_range_ledit_changed ) self.acq_widget_layout.energy_ledit.textEdited.connect( self.energy_ledit_changed ) self.acq_widget_layout.transmission_ledit.textEdited.connect( self.transmission_ledit_changed ) self.acq_widget_layout.resolution_ledit.textEdited.connect( self.resolution_ledit_changed ) self.acq_widget_layout.kappa_ledit.textEdited.connect(self.kappa_ledit_changed) self.acq_widget_layout.kappa_phi_ledit.textEdited.connect( self.kappa_phi_ledit_changed ) if self.acq_widget_layout.findChild(QtImport.QLineEdit, "overlap_ledit"): self.acq_widget_layout.overlap_ledit.textChanged.connect( self.overlap_changed ) if self.acq_widget_layout.findChild(QtImport.QCheckBox, "max_osc_range_cbx"): self.acq_widget_layout.max_osc_range_cbx.toggled.connect( self.max_osc_range_toggled ) # Other --------------------------------------------------------------- self.value_changed_list = [] self.acq_widget_layout.energies_combo.setDisabled(True) self.acq_widget_layout.energies_combo.addItems( ["ip: -", "pk: -", "rm1: -", "rm2: -"] ) self.osc_start_validator = QtImport.QDoubleValidator( -10000, 10000, 4, self.acq_widget_layout.osc_start_ledit ) self.osc_range_per_frame_validator = QtImport.QDoubleValidator( 0, 10000, 4, self.acq_widget_layout.osc_range_ledit ) self.osc_total_range_validator = QtImport.QDoubleValidator( 0, 10000, 4, self.acq_widget_layout.osc_total_range_ledit ) self.kappa_validator = QtImport.QDoubleValidator( -0.01, 360, 4, self.acq_widget_layout.kappa_ledit ) self.kappa_phi_validator = QtImport.QDoubleValidator( -360, 360, 4, self.acq_widget_layout.kappa_phi_ledit ) self.energy_validator = QtImport.QDoubleValidator( 4, 25, 5, self.acq_widget_layout.energy_ledit ) self.resolution_validator = QtImport.QDoubleValidator( 0, 15, 3, self.acq_widget_layout.resolution_ledit ) self.transmission_validator = QtImport.QDoubleValidator( 0, 100, 3, self.acq_widget_layout.transmission_ledit ) self.exp_time_validator = QtImport.QDoubleValidator( 0.0001, 10000, 7, self.acq_widget_layout.exp_time_ledit ) self.first_img_validator = QtImport.QIntValidator( 0, 99999, self.acq_widget_layout.first_image_ledit ) self.num_img_validator = QtImport.QIntValidator( 1, 9999999, self.acq_widget_layout.num_images_ledit ) self.acq_widget_layout.detector_roi_mode_label.setEnabled(False) self.acq_widget_layout.detector_roi_mode_combo.setEnabled(False) self.init_limits()