def _create_dc_from_grid(self, sample, grid=None): if grid is None: grid = HWR.beamline.sample_view.create_auto_grid() grid.set_snapshot(HWR.beamline.sample_view.get_snapshot(grid)) grid_properties = grid.get_properties() acq = self._create_acq(sample) acq.acquisition_parameters.centred_position = grid.get_centred_position() acq.acquisition_parameters.mesh_range = [ grid_properties["dx_mm"], grid_properties["dy_mm"], ] acq.acquisition_parameters.num_lines = grid_properties["num_lines"] acq.acquisition_parameters.num_images = ( grid_properties["num_lines"] * grid_properties["num_images_per_line"] ) grid.set_osc_range(acq.acquisition_parameters.osc_range) processing_parameters = deepcopy(self._processing_parameters) dc = queue_model_objects.DataCollection( [acq], sample.crystals[0], processing_parameters ) dc.set_name(acq.path_template.get_prefix()) dc.set_number(acq.path_template.run_number) dc.set_experiment_type(queue_model_enumerables.EXPERIMENT_TYPE.MESH) dc.set_requires_centring(False) dc.grid = grid self._path_template.run_number += 1 return dc
def create_dc( self, sample, run_number=None, start_image=None, num_images=None, osc_start=None, sc=None, cpos=None, inverse_beam=False, ): tasks = [] # Acquisition for start position acq = self._create_acq(sample) if run_number: acq.path_template.run_number = run_number if start_image: acq.acquisition_parameters.first_image = start_image acq.path_template.start_num = start_image if num_images: acq.acquisition_parameters.num_images = num_images acq.path_template.num_files = num_images if osc_start: acq.acquisition_parameters.osc_start = osc_start if inverse_beam: acq.acquisition_parameters.inverse_beam = False acq.acquisition_parameters.centred_position = cpos processing_parameters = copy.deepcopy(self._processing_parameters) data_collection = queue_model_objects.DataCollection( [acq], sample.crystals[0], processing_parameters ) data_collection.set_name(acq.path_template.get_prefix()) data_collection.set_number(acq.path_template.run_number) data_collection.experiment_type = queue_model_enumerables.EXPERIMENT_TYPE.NATIVE run_processing_after, run_online_processing = \ self._processing_widget.get_processing_state() data_collection.run_processing_after = run_processing_after if run_online_processing: data_collection.run_online_processing = "Undefined" tasks.append(data_collection) return tasks
def _create_task(self, sample, shape, comments=None): data_collections = [] for shape in self.get_selected_shapes(): snapshot = HWR.beamline.sample_view.get_scene_snapshot(shape) # Acquisition for start position start_acq = self._create_acq(sample) start_graphical_point, end_graphical_point = shape.get_graphical_points( ) start_acq.acquisition_parameters.centred_position = copy.deepcopy( start_graphical_point.get_centred_position()) start_acq.acquisition_parameters.centred_position.snapshot_image = snapshot start_acq.path_template.suffix = HWR.beamline.session.suffix # Add another acquisition for the end position end_acq = self._create_acq(sample) end_acq.acquisition_parameters.centred_position = copy.deepcopy( end_graphical_point.get_centred_position()) end_acq.acquisition_parameters.centred_position.snapshot_image = snapshot end_acq.path_template.suffix = HWR.beamline.session.suffix processing_parameters = copy.deepcopy(self._processing_parameters) dc = queue_model_objects.DataCollection([start_acq, end_acq], sample.crystals[0], processing_parameters) dc.set_name(start_acq.path_template.get_prefix()) dc.set_number(start_acq.path_template.run_number) dc.set_experiment_type(EXPERIMENT_TYPE.HELICAL) dc.set_requires_centring(False) dc.run_processing_after = ( self._processing_widget.processing_widget. run_processing_after_cbox.isChecked()) if (self._processing_widget.processing_widget. run_processing_parallel_cbox.isChecked()): dc.run_processing_parallel = "LineScan" data_collections.append(dc) self._path_template.run_number += 1 return data_collections
def _create_task(self, sample, shape, comments=None): tasks = [] if not shape or not isinstance(shape, GraphicsItemPoint): cpos = queue_model_objects.CentredPosition() cpos.snapshot_image = HWR.beamline.sample_view.get_scene_snapshot() else: # Shapes selected and sample is mounted, get the # centred positions for the shapes snapshot = HWR.beamline.sample_view.get_scene_snapshot(shape) cpos = copy.deepcopy(shape.get_centred_position()) cpos.snapshot_image = snapshot char_params = copy.deepcopy(self._char_params) acq = self._create_acq(sample) dc = queue_model_objects.DataCollection([acq], sample.crystals[0], self._processing_parameters) # Reference images for characterisations should be taken 90 deg apart # this is achived by setting overap to -89 acq.acquisition_parameters.overlap = -89 acq.acquisition_parameters.centred_position = cpos dc.acquisitions[0] = acq dc.experiment_type = queue_model_enumerables.EXPERIMENT_TYPE.EDNA_REF dc.run_processing_parallel = False char = queue_model_objects.Characterisation(dc, char_params) char.set_name(dc.acquisitions[0].path_template.get_prefix()) char.set_number(dc.acquisitions[0].path_template.run_number) char.run_characterisation = self._char_widget.characterisation_gbox.isChecked( ) char.wait_result = self._char_widget.wait_result_cbx.isChecked() char.run_diffraction_plan = self._char_widget.execute_plan_cbx.isChecked( ) char.diff_plan_compression = self._tree_brick.compression_state tasks.append(char) self._path_template.run_number += 1 if HWR.beamline.flux.get_value() < 1e9: logging.getLogger("GUI").error( "No flux reading is available! " + "Characterisation result may be wrong. " "Measure flux before running the characterisation.") return tasks
def dc_from_output(self, edna_result, reference_image_collection): data_collections = [] crystal = copy.deepcopy(reference_image_collection.crystal) ref_proc_params = reference_image_collection.processing_parameters processing_parameters = copy.deepcopy(ref_proc_params) try: char_results = edna_result.getCharacterisationResult() edna_strategy = char_results.getStrategyResult() collection_plan = edna_strategy.getCollectionPlan()[0] wedges = collection_plan.getCollectionStrategy().getSubWedge() except Exception: pass else: try: resolution = (collection_plan.getStrategySummary(). getResolution().getValue()) resolution = round(resolution, 3) except AttributeError: resolution = None try: transmission = (collection_plan.getStrategySummary(). getAttenuation().getValue()) transmission = round(transmission, 2) except AttributeError: transmission = None try: screening_id = edna_result.getScreeningId().getValue() except AttributeError: screening_id = None for i in range(0, len(wedges)): wedge = wedges[i] exp_condition = wedge.getExperimentalCondition() goniostat = exp_condition.getGoniostat() beam = exp_condition.getBeam() acq = qmo.Acquisition() acq.acquisition_parameters = ( HWR.beamline.get_default_acquisition_parameters()) acquisition_parameters = acq.acquisition_parameters acquisition_parameters.centred_position = reference_image_collection.acquisitions[ 0].acquisition_parameters.centred_position acq.path_template = HWR.beamline.get_default_path_template() # Use the same path template as the reference_collection # and update the members the needs to be changed. Keeping # the directories of the reference collection. ref_pt = reference_image_collection.acquisitions[ 0].path_template acq.path_template = copy.deepcopy(ref_pt) acq.path_template.wedge_prefix = "w" + str(i + 1) acq.path_template.reference_image_prefix = str() if resolution: acquisition_parameters.resolution = resolution if transmission: acquisition_parameters.transmission = transmission if screening_id: acquisition_parameters.screening_id = screening_id try: acquisition_parameters.osc_start = ( goniostat.getRotationAxisStart().getValue()) except AttributeError: pass try: acquisition_parameters.osc_end = ( goniostat.getRotationAxisEnd().getValue()) except AttributeError: pass try: acquisition_parameters.osc_range = ( goniostat.getOscillationWidth().getValue()) except AttributeError: pass try: num_images = int( abs(acquisition_parameters.osc_end - acquisition_parameters.osc_start) / acquisition_parameters.osc_range) acquisition_parameters.first_image = 1 acquisition_parameters.num_images = num_images acq.path_template.num_files = num_images acq.path_template.start_num = 1 except AttributeError: pass try: acquisition_parameters.transmission = ( beam.getTransmission().getValue()) except AttributeError: pass try: acquisition_parameters.energy = round( (123984.0 / beam.getWavelength().getValue()) / 10000.0, 4) except AttributeError: pass try: acquisition_parameters.exp_time = beam.getExposureTime( ).getValue() except AttributeError: pass dc = qmo.DataCollection([acq], crystal, processing_parameters) data_collections.append(dc) return data_collections
def create_dc(self, sample, run_number=None, start_image=None, num_images=None, osc_start=None, sc=None, cpos=None, inverse_beam=False, comments=None): """ Creates a new data collection item :param sample: Sample :param run_number: int :param start_image: int :param num_images: int :param osc_start: float :param sc: :param cpos: centered position :param inverse_beam: boolean :return: """ tasks = [] # Acquisition for start position acq = self._create_acq(sample) if run_number: acq.path_template.run_number = run_number if start_image: acq.acquisition_parameters.first_image = start_image acq.path_template.start_num = start_image if num_images: acq.acquisition_parameters.num_images = num_images acq.path_template.num_files = num_images if osc_start: acq.acquisition_parameters.osc_start = osc_start if inverse_beam: acq.acquisition_parameters.inverse_beam = False acq.acquisition_parameters.centred_position = cpos if comments: acq.acquisition_parameters.comments = comments processing_parameters = copy.deepcopy(self._processing_parameters) data_collection = queue_model_objects.DataCollection( [acq], sample.crystals[0], processing_parameters) data_collection.set_name(acq.path_template.get_prefix()) data_collection.set_number(acq.path_template.run_number) data_collection.experiment_type = queue_model_enumerables.EXPERIMENT_TYPE.OSC run_processing_after, run_processing_parallel = \ self._processing_widget.get_processing_state() data_collection.run_processing_after = run_processing_after if run_processing_parallel: data_collection.run_processing_parallel = "Still" data_collection.set_requires_centring(False) tasks.append(data_collection) return tasks