Пример #1
0
def set_dc_params(model, entry, task_data):
    """
    Helper method that sets the data collection parameters for a DataCollection.

    :param DataCollectionQueueModel: The model to set parameters of
    :param DataCollectionQueueEntry: The queue entry of the model
    :param dict task_data: Dictionary with new parameters
    """
    acq = model.acquisitions[0]
    params = task_data['parameters']
    acq.acquisition_parameters.set_from_dict(params)


    acq.path_template.set_from_dict(params)
    acq.path_template.base_prefix = params['prefix']

    full_path = os.path.join(mxcube.session.get_base_image_directory(),
                             params.get('path', ''))
    acq.path_template.directory = full_path

    process_path = os.path.join(mxcube.session.get_base_process_directory(),
                                params.get('path', ''))
    acq.path_template.process_directory = process_path

    # If there is a centered position associated with this data collection, get
    # the necessary data for the position and pass it to the collection.
    if params["point"]:
        for cpos in mxcube.diffractometer.savedCentredPos:
            if cpos['posId'] == int(params['point']):
                _cpos = qmo.CentredPosition(cpos['motor_positions'])
                _cpos.index = int(params['point'])
                acq.acquisition_parameters.centred_position = _cpos

    if params["helical"]:
        model.experiment_type = qme.EXPERIMENT_TYPE.HELICAL

        if params["p1"]:
            for cpos in mxcube.diffractometer.savedCentredPos:
                if cpos['posId'] == int(params['p1']):
                    _cpos = qmo.CentredPosition(cpos['motor_positions'])
                    _cpos.index = int(params['p1'])
                    acq.acquisition_parameters.centred_position = _cpos

        if params["p2"]:
            acq2 = qmo.Acquisition()
            for cpos in mxcube.diffractometer.savedCentredPos:
                if cpos['posId'] == int(params['p2']):
                    _cpos = qmo.CentredPosition(cpos['motor_positions'])
                    _cpos.index = int(params['p2'])
                    acq2.acquisition_parameters.centred_position = _cpos
            model.acquisitions.append(acq2)

    model.set_enabled(task_data['checked'])
    entry.set_enabled(task_data['checked'])
    def update_corner_coord(self, coordinates, grid=None):
        """ 
        Descript. : updates corner points and center point of a grid
                    if no grid obejct is passed then currently selected grid is updated
        """
        if not grid:
            treewidget_item = self.mesh_widget.mesh_treewidget.selectedItem()
            grid = self.__list_items[treewidget_item]
        #if drawing_mgr.in_projection_mode():
        if grid:
            # Grid is moved from the drawing position.
            # Grid coordinates are updated via corner points

            corner_points = []
            temp_motor_pos = self.__mini_diff_hwobj.\
               get_centred_point_from_coord(coordinates[0][0],
                                            coordinates[0][1], True)
            corner_points.append(
                queue_model_objects.CentredPosition(temp_motor_pos))

            temp_motor_pos = self.__mini_diff_hwobj.\
               get_centred_point_from_coord(coordinates[1][0],
                                            coordinates[1][1], True)
            corner_points.append(
                queue_model_objects.CentredPosition(temp_motor_pos))

            temp_motor_pos = self.__mini_diff_hwobj.\
               get_centred_point_from_coord(coordinates[2][0],
                                            coordinates[2][1], True)
            corner_points.append(
                queue_model_objects.CentredPosition(temp_motor_pos))

            temp_motor_pos = self.__mini_diff_hwobj.\
               get_centred_point_from_coord(coordinates[3][0],
                                            coordinates[3][1], True)
            corner_points.append(
                queue_model_objects.CentredPosition(temp_motor_pos))
            grid.set_motor_pos_corner(corner_points)
            # Grid is in drawing position, we have to move

            temp_motor_pos = self.__mini_diff_hwobj.\
                   get_centred_point_from_coord(abs((coordinates[0][0] +
                                                     coordinates[1][0]) / 2),
                                                abs((coordinates[0][1] +
                                                     coordinates[2][1]) / 2))

            #cpos = self.__mini_diff_hwobj.convert_from_obj_to_name(temp_motor_pos)
            cpos = queue_model_objects.CentredPosition(temp_motor_pos)
            grid.set_motor_pos_center(cpos)
Пример #3
0
    def _create_task(self, sample, shape):
        data_collections = []

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

                    cpos = copy.deepcopy(shape.get_centred_positions()[0])
                    cpos.snapshot_image = snapshot

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

            xrf_scan = queue_model_objects.XRFScan(sample, path_template, cpos)
            xrf_scan.set_name(path_template.get_prefix())
            xrf_scan.set_number(path_template.run_number)
            xrf_scan.count_time = self.count_time

            data_collections.append(xrf_scan)
        else:
            logging.getLogger("user_level_log").\
                info("No count time specified.")

        return data_collections
Пример #4
0
    def _create_task(self, sample, shape):
        data_collections = []

        if self.count_time is not None:
            if not shape:
                cpos = queue_model_objects.CentredPosition()
                cpos.snapshot_image = self._shape_history.get_snapshot([])
            else:
                # Shapes selected and sample is mounted, get the
                # centred positions for the shapes
                if isinstance(shape, shape_history.Point):
                    snapshot = self._shape_history.\
                               get_snapshot([shape.qub_point])
                    cpos = copy.deepcopy(shape.get_centred_positions()[0])
                    cpos.snapshot_image = snapshot

            path_template = self._create_path_template(sample,
                                                       self._path_template)
            xrf_scan = queue_model_objects.XRFScan(sample, path_template, cpos)
            xrf_scan.set_name(path_template.get_prefix())
            xrf_scan.set_number(path_template.run_number)
            xrf_scan.count_time = self.count_time
            data_collections.append(xrf_scan)

            self._path_template.run_number += 1
        else:
            logging.getLogger("user_level_log").\
                info("Incorrect count time value")

        return data_collections
Пример #5
0
    def new_centred_position(self, state, centring_status):
        """
        Descript. : Adds a new centred position, connected to the brick which
                    handles centring (HutchMenuBrick).
        Args.     :
        Return    :
        """
        p_dict = {}

        if 'motors' in centring_status and \
                'extraMotors' in centring_status:

            p_dict = dict(centring_status['motors'],
                          **centring_status['extraMotors'])

        elif 'motors' in centring_status:
            p_dict = dict(centring_status['motors'])

        if p_dict:
            cpos = queue_model_objects.CentredPosition(p_dict)
            screen_pos = self.diffractometer_hwobj.\
                    motor_positions_to_screen(cpos.as_dict())
            point = graphics_manager.GraphicsItemPoint(cpos, True,
                                                       screen_pos[0],
                                                       screen_pos[1])
            if point:
                self.graphics_manager_hwobj.add_shape(point)
                cpos.set_index(point.index)
Пример #6
0
    def _create_task(self, sample, shape):
        """
        Descript. :
        """
        tasks = []

        if isinstance(shape, GraphicsItemPoint):
            snapshot = self._graphics_manager_hwobj.get_scene_snapshot(shape)
            cpos = copy.deepcopy(shape.get_centred_position())
            cpos.snapshot_image = snapshot
        else:
            cpos = queue_model_objects.CentredPosition()
            cpos.snapshot_image = self._graphics_manager_hwobj.get_scene_snapshot() 

        if self._acq_widget.use_inverse_beam():
            total_num_images = self._acquisition_parameters.num_images
            subwedge_size = self._acq_widget.get_num_subwedges()
            osc_range = self._acquisition_parameters.osc_range
            osc_start = self._acquisition_parameters.osc_start
            run_number = self._path_template.run_number

            subwedges = queue_model_objects.create_inverse_beam_sw(total_num_images,
                        subwedge_size, osc_range, osc_start, run_number)

            self._acq_widget.set_use_inverse_beam(False)

            for sw in subwedges:
                tasks.extend(self.create_dc(sample, sw[3], sw[0], sw[1],
                                            sw[2], cpos=cpos,
                                            inverse_beam = True))
                self._path_template.run_number += 1
        else:
            tasks.extend(self.create_dc(sample, cpos=cpos))
            self._path_template.run_number += 1
        return tasks
Пример #7
0
    def _create_task(self, sample, shape):
        data_collections = []

        if self.periodic_table.current_edge:
            
            if not shape:
                cpos = queue_model_objects.CentredPosition()
                cpos.snapshot_image = self._shape_history.get_snapshot([])
            else:
                # Shapes selected and sample is mounted, get the
                # centred positions for the shapes
                if isinstance(shape, shape_history.Point):
                    snapshot = self._shape_history.\
                               get_snapshot([shape.qub_point])

                    cpos = copy.deepcopy(shape.get_centred_positions()[0])
                    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 = self.periodic_table.current_element
            energy_scan.edge = self.periodic_table.current_edge

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

        return data_collections
Пример #8
0
    def create_centring_point(self, centring_state, centring_status):
        """Creates a new centring position and adds it to graphics point.

        :param centring_state: 
        :type centring_state: str
        :param centring_status: dictionary with motor pos and etc
        :type centring_status: dict
        :emits: centringInProgress
        """
        p_dict = {}

        if 'motors' in centring_status and \
                'extraMotors' in centring_status:

            p_dict = dict(centring_status['motors'],
                          **centring_status['extraMotors'])
        elif 'motors' in centring_status:
            p_dict = dict(centring_status['motors'])

        if p_dict:
            cpos = queue_model_objects.CentredPosition(p_dict)
            screen_pos = self.diffractometer_hwobj.\
                    motor_positions_to_screen(cpos.as_dict())
            point = GraphicsLib.GraphicsItemPoint(cpos, True, 
                    screen_pos[0], screen_pos[1])
            if point:
                self.add_shape(point)
                cpos.set_index(point.index)
        self.emit("centringInProgress", False)
Пример #9
0
    def diffractometer_changed(self, *args):
        """Method called when diffractometer state changed.
           Updates point screen coordinates and grid coorner coordinates.
           If diffractometer not ready then hides all shapes.
        """
        if self.diffractometer_hwobj.isReady():
            for shape in self.get_shapes():
                if isinstance(shape, GraphicsLib.GraphicsItemPoint):
                    cpos =  shape.get_centred_position()
                    new_x, new_y = self.diffractometer_hwobj.\
                        motor_positions_to_screen(cpos.as_dict())
                    shape.set_start_position(new_x, new_y)
                elif isinstance(shape, GraphicsLib.GraphicsItemGrid):
                    grid_cpos = shape.get_centred_position()
                    current_cpos = queue_model_objects.CentredPosition(\
                        self.diffractometer_hwobj.get_positions())

                    if current_cpos == grid_cpos:
                        shape.set_center_coord((self.diffractometer_hwobj.\
                            motor_positions_to_screen(grid_cpos.as_dict())))
                        shape.set_projection_mode(False)
                    else:    
                        corner_coord = []
                        for motor_pos in shape.get_motor_pos_corner():
                            corner_coord.append((self.diffractometer_hwobj.\
                                motor_positions_to_screen(motor_pos)))
                        shape.set_corner_coord(corner_coord) 
                        shape.set_projection_mode(True)

            for shape in self.get_shapes():
                shape.show()
            self.graphics_view.graphics_scene.update()
        else:
            for shape in self.get_shapes():
                shape.hide()
Пример #10
0
    def new_centred_position(self, state, centring_status):
        """
        Adds a new centred position, connected to the brick which handles
        centring (HutchMenuBrick).
        """
        p_dict = {}

        if 'motors' in centring_status and \
                'extraMotors' in centring_status:

            p_dict = dict(centring_status['motors'],
                          **centring_status['extraMotors'])

        elif 'motors' in centring_status:
            p_dict = dict(centring_status['motors'])

        if p_dict:
            cpos = queue_model_objects.CentredPosition(p_dict)
            #self.position_history.add_centred_position(state, cpos)

            try:
                screen_pos = self.diffractometer_hwobj.\
                             motor_positions_to_screen(cpos.as_dict())

                point = shape_history.Point(self.shape_history.get_drawing(),
                                            cpos, screen_pos)
                #qub_point = self.shape_history.draw_position(screen_pos)

                if point:
                    #self.shape_history.add_point(cpos, qub_point)
                    self.shape_history.add_shape(point)
            except:
                logging.getLogger('HWR').\
                    exception('Could not get screen positons for %s' % cpos)
                traceback.print_exc()
    def _create_task(self, sample, shape):
        data_collections = []

        if self.count_time is not None:
            if not shape:
                cpos = queue_model_objects.CentredPosition()
                cpos.snapshot_image = self._graphics_manager_hwobj.get_scene_snapshot(
                )
            else:
                # Shapes selected and sample is mounted, get the
                # centred positions for the shapes
                if isinstance(shape, GraphicsItemPoint):
                    snapshot = self._graphics_manager_hwobj.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)

            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
Пример #12
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._drawing = drawing

        self.qub_point = self.draw(screen_pos)
Пример #13
0
    def __init__(self, centred_position = None, full_centring = True,
                 position_x = 0, position_y = 0):
        GraphicsItem.__init__(self, position_x, position_y)

        self.full_centring = full_centring
        self.setFlags(QtGui.QGraphicsItem.ItemIsSelectable) 

        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.set_size(20, 20)
        self.set_position(position_x, position_y)
Пример #14
0
    def _create_task(self, sample, shape):
        """
        Descript. :
        """
        tasks = []

        if not shape or not isinstance(shape, GraphicsItemPoint):
            cpos = queue_model_objects.CentredPosition()
            cpos.snapshot_image = self._graphics_manager_hwobj.get_scene_snapshot(
            )
        else:
            # Shapes selected and sample is mounted, get the
            # centred positions for the shapes
            snapshot = self._graphics_manager_hwobj.\
                        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(
        )

        tasks.append(char)
        self._path_template.run_number += 1

        return tasks
Пример #15
0
    def _create_task(self, sample, shape):
        tasks = []

        if not shape:
            cpos = qmo.CentredPosition()
            cpos.snapshot_image = self._shape_history.get_snapshot([])
        else:
            # Shapes selected and sample is mounted, get the
            # centred positions for the shapes
            if isinstance(shape, shape_history.Point):
                snapshot = self._shape_history.\
                           get_snapshot([shape.qub_point])

                cpos = copy.deepcopy(shape.get_centred_positions()[0])
                cpos.snapshot_image = snapshot

        if self._acq_widget.use_inverse_beam():
            total_num_images = self._acquisition_parameters.num_images
            subwedge_size = self._acq_widget.get_num_subwedges()
            osc_range = self._acquisition_parameters.osc_range
            osc_start = self._acquisition_parameters.osc_start
            run_number = self._path_template.run_number

            subwedges = qmo.create_inverse_beam_sw(total_num_images,
                                                   subwedge_size, osc_range,
                                                   osc_start, run_number)

            self._acq_widget.set_use_inverse_beam(False)

            for sw in subwedges:
                tasks.extend(
                    self.create_dc(sample,
                                   sw[3],
                                   sw[0],
                                   sw[1],
                                   sw[2],
                                   cpos=cpos,
                                   inverse_beam=True))
                self._path_template.run_number += 1
        else:
            tasks.extend(self.create_dc(sample, cpos=cpos))
            self._path_template.run_number += 1

        return tasks
Пример #16
0
    def _create_task(self, sample, shape):
        tasks = []

        if not shape:
            cpos = queue_model_objects.CentredPosition()
            cpos.snapshot_image = self._shape_history.get_snapshot([])
        else:
            # Shapes selected and sample is mounted, get the
            # centred positions for the shapes
            if isinstance(shape, shape_history.Point):
                snapshot = self._shape_history.\
                           get_snapshot([shape.qub_point])

                #cpos = shape.get_centred_positions()[0]
                cpos = copy.deepcopy(shape.get_centred_positions()[0])
                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

        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)

        tasks.append(char)
        self._path_template.run_number += 1

        return tasks
    def _create_task(self, sample, shape):
        """
        Descript. :
        """
        tasks = []

        if isinstance(shape, GraphicsItemPoint):
            snapshot = self._graphics_manager_hwobj.get_scene_snapshot(shape)
            cpos = copy.deepcopy(shape.get_centred_position())
            cpos.snapshot_image = snapshot
        else:
            cpos = queue_model_objects.CentredPosition()
            cpos.snapshot_image = self._graphics_manager_hwobj.get_scene_snapshot(
            )

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

        return tasks
Пример #18
0
    def _create_task(self, sample, shape):
        """
        Descript. :
        """
        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 = self._graphics_manager_hwobj.get_scene_snapshot(
                )
            else:
                # Shapes selected and sample is mounted, get the
                # centred positions for the shapes
                if isinstance(shape, GraphicsItemPoint):
                    snapshot = self._graphics_manager_hwobj.\
                           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
Пример #19
0
    def execute(self):
        BaseQueueEntry.execute(self)

        self.get_view().setText(1, 'Waiting for input')
        log = logging.getLogger("user_level_log")
        log.warning("Please select a centred position, and press continue.")

        self.get_queue_controller().pause(True)
        pos = None

        if len(self.shape_history.selected_shapes):
            pos = self.shape_history.selected_shapes.values()[0]
        elif len(self.shape_history.shapes):
            pos = self.shape_history.shapes.values()[0]
        else:
            msg = "No centred position selected, using current position."
            log.info(msg)

            # Create a centred postions of the current postion
            pos_dict = self.diffractometer_hwobj.getPositions()
            cpos = queue_model_objects.CentredPosition(pos_dict)
            pos = shape_history.Point(None, cpos, None)

        # Get tasks associated with this centring
        tasks = self.get_data_model().get_tasks()

        for task in tasks:
            cpos = pos.get_centred_positions()[0]

            if pos.qub_point is not None:
                snapshot = self.shape_history.\
                           get_snapshot([pos.qub_point])
            else:
                snapshot = self.shape_history.get_snapshot([])

            cpos.snapshot_image = snapshot
            task.set_centred_positions(cpos)

        self.get_view().setText(1, 'Input accepted')
    def _create_task(self, sample, shape):
        """
        Descript. :
        """
        if isinstance(shape, GraphicsItemPoint):
            snapshot = self._graphics_manager_hwobj.get_scene_snapshot(shape)
            cpos = copy.deepcopy(shape.get_centred_position())
            cpos.snapshot_image = snapshot
        else:
            cpos = queue_model_objects.CentredPosition()
            cpos.snapshot_image = self._graphics_manager_hwobj.get_scene_snapshot(
            )

        self._path_template.run_number += 1

        acq = self._create_acq(sample)
        acq.acquisition_parameters.centred_position = cpos
        dc = queue_model_objects.XrayImaging(
            self._xray_imaging_parameters.copy(), [acq], sample.crystals[0])
        dc.set_name(acq.path_template.get_prefix())
        dc.set_number(acq.path_template.run_number)
        dc.experiment_type = queue_model_enumerables.EXPERIMENT_TYPE.NATIVE

        return [dc]
Пример #21
0
    def _create_task(self, sample, shape):
        tasks = []

        if not shape:
            cpos = queue_model_objects.CentredPosition()
            cpos.snapshot_image = self._shape_history.get_snapshot([])
        else:
            # Shapes selected and sample is mounted, get the
            # centred positions for the shapes
            if isinstance(shape, shape_history.Point):
                snapshot = self._shape_history.\
                           get_snapshot([shape.qub_point])

                cpos = shape.get_centred_positions()[0]
                cpos.snapshot_image = snapshot

        char_params = copy.deepcopy(self._char_params)

        # Acquisition for start position
        acq = queue_model_objects.Acquisition()
        acq.acquisition_parameters = \
            copy.deepcopy(self._acquisition_parameters)
        acq.acquisition_parameters.collect_agent = \
                    queue_model_enumerables.COLLECTION_ORIGIN.MXCUBE
        acq.acquisition_parameters.centred_position = cpos
        acq.path_template = copy.deepcopy(self._path_template)

        if self._beamline_setup_hwobj.in_plate_mode():
            acq.acquisition_parameters.take_snapshots = False
        else:
            acq.acquisition_parameters.take_snapshots = True

        if '<sample_name>' in acq.path_template.directory:
            name = sample.get_name().replace(':', '-')
            acq.path_template.directory = acq.path_template.directory.\
                                          replace('<sample_name>', name)
            acq.path_template.process_directory = acq.path_template.process_directory.\
                                                  replace('<sample_name>', name)

        if '<acronym>-<name>' in acq.path_template.base_prefix:
            acq.path_template.base_prefix = self.get_default_prefix(sample)
            acq.path_template.run_numer = self._beamline_setup_hwobj.queue_model_hwobj.\
                                          get_next_run_number(acq.path_template)

        processing_parameters = copy.deepcopy(self._processing_parameters)

        data_collection = queue_model_objects.\
                          DataCollection([acq], sample.crystals[0],
                                         self._processing_parameters)

        # Referance images for characterisations should be taken 90 deg apart
        # this is achived by setting overap to -89
        acq.acquisition_parameters.overlap = -89
        data_collection.acquisitions[0] = acq
        data_collection.experiment_type = queue_model_enumerables.EXPERIMENT_TYPE.EDNA_REF

        char = queue_model_objects.Characterisation(data_collection,
                                                    char_params)
        char.set_name(data_collection.acquisitions[0].\
                      path_template.get_prefix())
        char.set_number(data_collection.acquisitions[0].\
                        path_template.run_number)

        tasks.append(char)
        self._path_template.run_number += 1

        return tasks
Пример #22
0
    def collect_dc(self, dc, list_item):
        log = logging.getLogger("user_level_log")

        if self.collect_hwobj:
            acq_1 = dc.acquisitions[0]
            cpos = acq_1.acquisition_parameters.centred_position
            sample = self.get_data_model().get_parent().get_parent()
            param_list = queue_model_objects.\
                to_collect_dict(dc, self.session, sample)

            try:
                if dc.experiment_type is EXPERIMENT_TYPE.HELICAL:
                    acq_1, acq_2 = (dc.acquisitions[0], dc.acquisitions[1])
                    self.collect_hwobj.getChannelObject("helical").setValue(1)

                    start_cpos = acq_1.acquisition_parameters.centred_position
                    end_cpos = acq_2.acquisition_parameters.centred_position

                    dc.lims_end_pos_id = self.lims_client_hwobj.\
                                         store_centred_position(end_cpos)

                    helical_oscil_pos = {
                        '1': start_cpos.as_dict(),
                        '2': end_cpos.as_dict()
                    }
                    self.collect_hwobj.getChannelObject(
                        'helical_pos').setValue(helical_oscil_pos)

                    msg = "Helical data collection, moving to start position"
                    log.info(msg)
                    log.info("Moving sample to given position ...")
                    list_item.setText(1, "Moving sample")
                else:
                    self.collect_hwobj.getChannelObject("helical").setValue(0)

                empty_cpos = queue_model_objects.CentredPosition()

                if cpos != empty_cpos:
                    log.info("Moving sample to given position ...")
                    list_item.setText(1, "Moving sample")
                    self.shape_history.select_shape_with_cpos(cpos)
                    self.centring_task = self.diffractometer_hwobj.\
                                         moveToCentredPosition(cpos)
                    self.centring_task.get()
                else:
                    pos_dict = self.diffractometer_hwobj.getPositions()
                    cpos = queue_model_objects.CentredPosition(pos_dict)
                    snapshot = self.shape_history.get_snapshot([])
                    acq_1.acquisition_parameters.centred_position = cpos
                    acq_1.acquisition_parameters.centred_position.snapshot_image = snapshot

                dc.lims_start_pos_id = self.lims_client_hwobj.store_centred_position(
                    cpos)
                self.collect_task = self.collect_hwobj.\
                                    collect(COLLECTION_ORIGIN_STR.MXCUBE,
                                            param_list)
                self.collect_task.get()

                if 'collection_id' in param_list[0]:
                    dc.id = param_list[0]['collection_id']

                dc.acquisitions[0].path_template.xds_dir = param_list[0][
                    'xds_dir']

            except gevent.GreenletExit:
                #log.warning("Collection stopped by user.")
                list_item.setText(1, 'Stopped')
                raise QueueAbortedException('queue stopped by user', self)
            except Exception as ex:
                print traceback.print_exc()
                raise QueueExecutionException(ex.message, self)
        else:
            log.error("Could not call the data collection routine," +\
                      " check the beamline configuration")
            list_item.setText(1, 'Failed')
            msg = "Could not call the data collection" +\
                  " routine, check the beamline configuration"
            raise QueueExecutionException(msg, self)
Пример #23
0
 def add_cp_from_mp(self, mpos_list):
     for mp in mpos_list:
         self.cp_list.append(queue_model_objects.CentredPosition(mp))