Exemple #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 _create_acq(self, sample):
        parameters = self._acquisition_parameters
        path_template = self._path_template
        processing_parameters = self._processing_parameters
        bl_setup = self._beamline_setup_hwobj

        acq = queue_model_objects.Acquisition()
        acq.acquisition_parameters = \
            copy.deepcopy(parameters)
        acq.acquisition_parameters.collect_agent = \
            queue_model_enumerables.COLLECTION_ORIGIN.MXCUBE

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

        if self._in_plate_mode:
            acq.acquisition_parameters.take_snapshots = 1

        return acq
Exemple #3
0
    def _create_acq(self, sample):
        parameters = self._acquisition_parameters
        path_template = self._path_template
        shape_history = self._shape_history
        processing_parameters = self._processing_parameters
        bl_setup = self._beamline_setup_hwobj

        acq = queue_model_objects.Acquisition()
        acq.acquisition_parameters = \
            copy.deepcopy(parameters)
        acq.acquisition_parameters.collect_agent = \
            queue_model_enumerables.COLLECTION_ORIGIN.MXCUBE
        
        acq.path_template = self._create_path_template(sample, path_template)

        """
        if bl_setup.diffractometer_hwobj.in_plate_mode():
            acq.acquisition_parameters.take_snapshots = False
        else:
            acq.acquisition_parameters.take_snapshots = True
        """

        return acq
Exemple #4
0
    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 = qmo.Acquisition()
        acq.acquisition_parameters = \
            copy.deepcopy(self._acquisition_parameters)
        acq.acquisition_parameters.collect_agent = \
            queue_model_enumerables.COLLECTION_ORIGIN.MXCUBE
        acq.path_template = copy.deepcopy(self._path_template)
        acq.acquisition_parameters.centred_position = cpos

        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)

        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

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

        processing_parameters = copy.deepcopy(self._processing_parameters)
        dc = qmo.DataCollection([acq], sample.crystals[0],
                                processing_parameters)

        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

        tasks.append(dc)

        return tasks
Exemple #5
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
Exemple #6
0
    def _create_task(self, sample, shape):
        data_collections = []

        if isinstance(shape, shape_history.Line):
            if shape.get_qub_objects() is not None:
                snapshot = self._shape_history.get_snapshot(
                    shape.get_qub_objects())
            else:
                snapshot = self._shape_history.get_snapshot([])

            # Acquisition for start position
            start_acq = qmo.Acquisition()
            start_acq.acquisition_parameters = \
                copy.deepcopy(self._acquisition_parameters)
            start_acq.acquisition_parameters.collect_agent = \
                COLLECTION_ORIGIN.MXCUBE
            start_acq.acquisition_parameters.\
                centred_position = copy.deepcopy(shape.start_cpos)
            start_acq.path_template = copy.deepcopy(self._path_template)
            start_acq.acquisition_parameters.centred_position.\
                snapshot_image = snapshot

            start_acq.path_template.suffix = self._session_hwobj.suffix

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

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

                start_acq.path_template.process_directory = start_acq.path_template.process_directory.\
                                                            replace('<sample_name>', name)

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

            # Add another acquisition for the end position
            end_acq = qmo.Acquisition()
            end_acq.acquisition_parameters = \
                copy.deepcopy(self._acquisition_parameters)
            end_acq.acquisition_parameters.collect_agent = \
                COLLECTION_ORIGIN.MXCUBE
            end_acq.acquisition_parameters.\
                centred_position = shape.end_cpos
            end_acq.path_template = copy.deepcopy(self._path_template)
            end_acq.acquisition_parameters.centred_position.\
                snapshot_image = snapshot

            end_acq.path_template.suffix = self._session_hwobj.suffix

            processing_parameters = copy.deepcopy(self._processing_parameters)

            dc = qmo.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.experiment_type = EXPERIMENT_TYPE.HELICAL

            data_collections.append(dc)
            self._path_template.run_number += 1

        return data_collections