예제 #1
0
    def _create_task(self, sample, shape, comments=None):
        data_collections = []
        selected_element, selected_edge = (
            self._periodic_table_widget.get_selected_element_edge()
        )

        if selected_element:
            if not shape:
                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
                if isinstance(shape, GraphicsItemPoint):
                    snapshot = HWR.beamline.sample_view.get_scene_snapshot(shape)

                    cpos = copy.deepcopy(shape.get_centred_position())
                    cpos.snapshot_image = snapshot

            path_template = self._create_path_template(sample, self._path_template)

            energy_scan = queue_model_objects.EnergyScan(sample, path_template, cpos)
            energy_scan.set_name(path_template.get_prefix())
            energy_scan.set_number(path_template.run_number)
            energy_scan.element_symbol = selected_element
            energy_scan.edge = selected_edge

            data_collections.append(energy_scan)
            self._path_template.run_number += 1
        else:
            logging.getLogger("GUI").info(
                "No element selected, please select an element."
            )

        return data_collections
예제 #2
0
    def _create_task(self, sample, shape, comments=None):
        data_collections = []

        if self.count_time is not None:
            if not shape:
                cpos = queue_model_objects.CentredPosition()
                cpos.snapshot_image = HWR.beamline.sample_view.get_snapshot()
            else:
                # Shapes selected and sample is mounted, get the
                # centred positions for the shapes
                if isinstance(shape, GraphicsItemPoint):
                    snapshot = HWR.beamline.sample_view.get_snapshot(
                        shape=shape)

                    cpos = copy.deepcopy(shape.get_centred_position())
                    cpos.snapshot_image = snapshot

            path_template = self._create_path_template(sample,
                                                       self._path_template)

            xrf_spectrum = queue_model_objects.XRFSpectrum(
                sample, path_template, cpos)
            xrf_spectrum.set_name(path_template.get_prefix())
            xrf_spectrum.set_number(path_template.run_number)
            xrf_spectrum.count_time = self.count_time
            xrf_spectrum.adjust_transmission = self.adjust_transmission_cbox.isChecked(
            )

            data_collections.append(xrf_spectrum)
        else:
            logging.getLogger("GUI").error("No count time specified.")

        return data_collections
예제 #3
0
    def __init__(self, drawing, centred_position, screen_pos):
        Shape.__init__(self)

        self.qub_point = None

        if centred_position is None:
            self.centred_position = queue_model_objects.CentredPosition()
            self.centred_position.centring_method = False
        else:
            self.centred_position = centred_position
        self.screen_pos = screen_pos
        self.point_index = None
        self._drawing = drawing

        self.qub_point = self.draw(screen_pos)
예제 #4
0
    def _create_task(self, sample, shape, comments=None):
        """
        Creates a new Still scan task
        :param sample: sample node
        :param shape: centering point
        :return: Acquisition item
        """
        tasks = []

        cpos = queue_model_objects.CentredPosition()
        cpos.snapshot_image = HWR.beamline.sample_view.get_snapshot()

        tasks.extend(self.create_dc(sample, cpos=cpos, comments=comments))
        self._path_template.run_number += 1

        return tasks
예제 #5
0
    def _create_task(self, sample, shape, comments=None):
        if isinstance(shape, GraphicsItemPoint):
            snapshot = HWR.beamline.sample_view.get_snapshot(shape=shape)
            cpos = copy.deepcopy(shape.get_centred_position())
            cpos.snapshot_image = snapshot
        else:
            cpos = queue_model_objects.CentredPosition()
            cpos.snapshot_image = HWR.beamline.sample_view.get_snapshot()

        detector_distance_list = []
        dc_list = []

        if self.distance_listwidget.count() > 1:
            for index in range(self.distance_listwidget.count()):
                detector_distance_list.append(
                    float(self.distance_listwidget.item(index).text()))
        else:
            #TODO do not read distance again
            detector_distance_list.append(
                self._xray_imaging_parameters.detector_distance)

        do_it = True

        for detector_distance in detector_distance_list:
            xray_imaging_parameters = copy.deepcopy(
                self._xray_imaging_parameters)
            xray_imaging_parameters.detector_distance = detector_distance

            acq = self._create_acq(sample)
            acq.acquisition_parameters.centred_position = cpos
            #acq.path_template.base_prefix = self.get_default_prefix(sample)

            if do_it:
                do_it = False
                acq.path_template.run_number = \
                    HWR.beamline.queue_model.get_next_run_number(
                    acq.path_template)
                acq.path_template.run_number = self._path_template.run_number

            dc = queue_model_objects.XrayImaging(xray_imaging_parameters, acq,
                                                 sample.crystals[0])
            dc.set_name(acq.path_template.get_prefix())
            dc.set_number(acq.path_template.run_number)

            dc_list.append(dc)
            self._path_template.run_number += 1
        return dc_list
예제 #6
0
    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
예제 #7
0
    def _create_task(self, sample, shape, comments=None):
        """
        Called by the owning widget (task_toolbox_widget) to create
        a collection. When a data collection group is selected.
        :param sample:
        :param shape:
        :return:
        """
        tasks = []

        if isinstance(shape, GraphicsItemPoint):
            snapshot = HWR.beamline.sample_view.get_snapshot(shape)
            cpos = copy.deepcopy(shape.get_centred_position())
            cpos.snapshot_image = snapshot
        else:
            cpos = queue_model_objects.CentredPosition()
            cpos.snapshot_image = HWR.beamline.sample_view.get_snapshot()

        tasks.extend(self.create_dc(sample, cpos=cpos))
        self._path_template.run_number += 1

        return tasks
예제 #8
0
    def _create_task(self, sample, shape, comments=None):
        """Creates tasks based on selected grids

        :param sample: selected sample object
        :type sample: SampleQueueItem
        :param shape: selected shape
        :type shape: GraphicsLib.GraphicsItem
        """

        tasks = []
        selected_grid = self.get_selected_shapes()[0]
        mesh_dc = self._create_dc_from_grid(sample, selected_grid)

        cpos = queue_model_objects.CentredPosition()
        cpos.snapshot_image = HWR.beamline.sample_view.get_snapshot()

        exp_type = str(self._advanced_methods_widget.method_combo.currentText())
        if exp_type == "MeshScan":
            tasks.append(mesh_dc)
        elif exp_type == "XrayCentering":
            xray_centering = queue_model_objects.XrayCentering(mesh_dc)
            tasks.append(xray_centering)
        elif exp_type == "MXPressO":
            optical_centering = queue_model_objects.OpticalCentring()
 
            dc_task = self.create_dc(sample, cpos=cpos)[0]
            dc_task.set_requires_centring(False)
            
            tasks.append(optical_centering)
            tasks.append(dc_task)

        else:
            logging.getLogger("GUI").warning(
                "Method %s does not exist in queue_model_objects" % exp_type
            )
        mesh_dc.run_online_processing = exp_type

        return tasks
예제 #9
0
 def add_cp_from_mp(self, mpos_list):
     for mp in mpos_list:
         self.cp_list.append(queue_model_objects.CentredPosition(mp))