Exemplo n.º 1
0
    def get_default_characterisation_parameters(self):
        """
        :returns: A CharacterisationsParameters object with default parameters.
        """
        input_fname = self.data_analysis_hwobj.edna_default_file
        hwr_dir = HardwareRepository().getHardwareRepositoryPath()

        with open(os.path.join(hwr_dir, input_fname), 'r') as f:
            edna_default_input = ''.join(f.readlines())

        edna_input = XSDataInputMXCuBE.parseString(edna_default_input)
        diff_plan = edna_input.getDiffractionPlan()
        #edna_beam = edna_input.getExperimentalCondition().getBeam()
        edna_sample = edna_input.getSample()
        char_params = queue_model_objects.CharacterisationParameters()
        char_params.experiment_type = queue_model_enumerables.EXPERIMENT_TYPE.OSC

        # Optimisation parameters
        char_params.use_aimed_resolution = False
        char_params.aimed_resolution = diff_plan.getAimedResolution().getValue(
        )
        char_params.use_aimed_multiplicity = False
        #char_params.aimed_multiplicity = diff_plan.getAimedMultiplicity().getValue()
        char_params.aimed_i_sigma = diff_plan.getAimedIOverSigmaAtHighestResolution(
        ).getValue()
        char_params.aimed_completness = diff_plan.getAimedCompleteness(
        ).getValue()
        char_params.strategy_complexity = 0
        char_params.induce_burn = False
        char_params.use_permitted_rotation = False
        char_params.permitted_phi_start = 0.0
        char_params.permitted_phi_end = 360
        char_params.low_res_pass_strat = False

        # Crystal
        char_params.max_crystal_vdim = edna_sample.getSize().getY().getValue()
        char_params.min_crystal_vdim = edna_sample.getSize().getZ().getValue()
        char_params.max_crystal_vphi = 90
        char_params.min_crystal_vphi = 0.0
        char_params.space_group = ""

        # Characterisation type
        char_params.use_min_dose = True
        char_params.use_min_time = False
        char_params.min_dose = 30.0
        char_params.min_time = 0.0
        char_params.account_rad_damage = True
        char_params.auto_res = True
        char_params.opt_sad = False
        char_params.sad_res = 0.5
        char_params.determine_rad_params = False
        char_params.burn_osc_start = 0.0
        char_params.burn_osc_interval = 3

        # Radiation damage model
        char_params.rad_suscept = edna_sample.getSusceptibility().getValue()
        char_params.beta = 1
        char_params.gamma = 0.06

        return char_params
Exemplo n.º 2
0
    def get_default_characterisation_parameters(self):
        """
        :returns: A CharacterisationsParameters object with default parameters.
        """
        input_fname = self.data_analysis_hwobj.edna_default_file
        hwr_dir = HardwareRepository().getHardwareRepositoryPath()

        with open(os.path.join(hwr_dir, input_fname), 'r') as f:
            edna_default_input = ''.join(f.readlines())

        edna_input = XSDataInputMXCuBE.parseString(edna_default_input)
        diff_plan = edna_input.getDiffractionPlan()
        #edna_beam = edna_input.getExperimentalCondition().getBeam()
        edna_sample = edna_input.getSample()
        char_params = queue_model_objects.CharacterisationParameters()
        char_params.experiment_type = queue_model_enumerables.EXPERIMENT_TYPE.OSC

        # Optimisation parameters
        char_params.use_aimed_resolution = False
        char_params.aimed_resolution = diff_plan.getAimedResolution().getValue()
        char_params.use_aimed_multiplicity = False
        #char_params.aimed_multiplicity = diff_plan.getAimedMultiplicity().getValue()
        char_params.aimed_i_sigma = diff_plan.getAimedIOverSigmaAtHighestResolution().getValue()
        char_params.aimed_completness = diff_plan.getAimedCompleteness().getValue()
        char_params.strategy_complexity = 0
        char_params.induce_burn = False
        char_params.use_permitted_rotation = False
        char_params.permitted_phi_start = 0.0
        char_params.permitted_phi_end = 360
        char_params.low_res_pass_strat = False

        # Crystal
        char_params.max_crystal_vdim = edna_sample.getSize().getY().getValue()
        char_params.min_crystal_vdim = edna_sample.getSize().getZ().getValue()
        char_params.max_crystal_vphi = 90
        char_params.min_crystal_vphi = 0.0
        char_params.space_group = ""

        # Characterisation type
        char_params.use_min_dose = True
        char_params.use_min_time = False
        char_params.min_dose = 30.0
        char_params.min_time = 0.0
        char_params.account_rad_damage = True
        char_params.auto_res = True
        char_params.opt_sad = False
        char_params.sad_res = 0.5
        char_params.determine_rad_params = False
        char_params.burn_osc_start = 0.0
        char_params.burn_osc_interval = 3

        # Radiation damage model
        char_params.rad_suscept = edna_sample.getSusceptibility().getValue()
        char_params.beta = 1
        char_params.gamma = 0.06

        return char_params
Exemplo n.º 3
0
    def from_params(self, data_collection, char_params):
        edna_input = XSDataInputMXCuBE.parseString(self.edna_default_input)

        if data_collection.id:
            edna_input.setDataCollectionId(XSDataInteger(data_collection.id))

        #Beam object
        beam = edna_input.getExperimentalCondition().getBeam()

        try:
            transmission = self.collect_obj.get_transmission()
            beam.setTransmission(XSDataDouble(transmission))
        except AttributeError:
            pass

        try:
            wavelength = self.collect_obj.get_wavelength()
            beam.setWavelength(XSDataWavelength(wavelength))
        except AttributeError:
            pass

        try:
            beam.setFlux(XSDataFlux(self.collect_obj.get_measured_intensity()))
        except AttributeError:
            pass

        try:
            beamsize = self.get_beam_size()
            if not None in beamsize:
                beam.setSize(
                    XSDataSize(x=XSDataLength(float(beamsize[0])),
                               y=XSDataLength(float(beamsize[1]))))
        except AttributeError:
            pass

        #Optimization parameters
        diff_plan = edna_input.getDiffractionPlan()

        aimed_i_sigma = XSDataDouble(char_params.aimed_i_sigma)
        aimed_completness = XSDataDouble(char_params.aimed_completness)
        aimed_multiplicity = XSDataDouble(char_params.aimed_multiplicity)
        aimed_resolution = XSDataDouble(char_params.aimed_resolution)

        complexity = char_params.strategy_complexity
        complexity = XSDataString(qme.STRATEGY_COMPLEXITY[complexity])

        permitted_phi_start = XSDataAngle(char_params.permitted_phi_start)
        _range = char_params.permitted_phi_end - char_params.permitted_phi_start
        rotation_range = XSDataAngle(_range)

        diff_plan.setAimedIOverSigmaAtHighestResolution(aimed_i_sigma)
        diff_plan.setAimedCompleteness(aimed_completness)

        if char_params.use_aimed_multiplicity:
            diff_plan.setAimedMultiplicity(aimed_multiplicity)

        if char_params.use_aimed_resolution:
            diff_plan.setAimedResolution(aimed_resolution)

        diff_plan.setComplexity(complexity)

        if char_params.use_permitted_rotation:
            diff_plan.setUserDefinedRotationStart(permitted_phi_start)
            diff_plan.setUserDefinedRotationRange(rotation_range)

        #Vertical crystal dimension
        sample = edna_input.getSample()
        sample.getSize().setY(XSDataLength(char_params.max_crystal_vdim))
        sample.getSize().setZ(XSDataLength(char_params.min_crystal_vdim))

        #Radiation damage model
        sample.setSusceptibility(XSDataDouble(char_params.rad_suscept))
        sample.setChemicalComposition(None)
        sample.setRadiationDamageModelBeta(XSDataDouble(char_params.beta /
                                                        1e6))
        sample.setRadiationDamageModelGamma(
            XSDataDouble(char_params.gamma / 1e6))

        diff_plan.setForcedSpaceGroup(XSDataString(char_params.space_group))

        # Characterisation type - Routine DC
        if char_params.use_min_dose:
            pass

        if char_params.use_min_time:
            time = XSDataTime(char_params.min_time)
            diff_plan.setMaxExposureTimePerDataCollection(time)

        # Account for radiation damage
        if char_params.induce_burn:
            diff_plan.setStrategyOption(XSDataString("-DamPar"))
        else:
            diff_plan.setStrategyOption(None)

        # Characterisation type - SAD
        if char_params.opt_sad:
            diff_plan.setAnomalousData(XSDataBoolean(True))
        else:
            diff_plan.setAnomalousData(XSDataBoolean(False))

        #Data set
        data_set = XSDataMXCuBEDataSet()
        acquisition_parameters = data_collection.acquisitions[
            0].acquisition_parameters
        path_template = data_collection.acquisitions[0].path_template
        path_str = os.path.join(path_template.directory,
                                path_template.get_image_file_name())

        for img_num in range(int(acquisition_parameters.num_images)):
            image_file = XSDataFile()
            path = XSDataString()
            path.setValue(path_str % (img_num + 1))
            image_file.setPath(path)
            data_set.addImageFile(image_file)

        edna_input.addDataSet(data_set)
        edna_input.process_directory = path_template.process_directory

        return edna_input
Exemplo n.º 4
0
    def from_params(self, data_collection, char_params):
        edna_input = XSDataInputMXCuBE.parseString(EDNA_DEFAULT_INPUT)

        if data_collection.id:
            edna_input.setDataCollectionId(XSDataInteger(data_collection.id))

        #Beam object
        beam = edna_input.getExperimentalCondition().getBeam()

        try:
            beam.setTransmission(XSDataDouble(self.collect_obj.get_transmission()))
        except AttributeError:
            pass

        try:
            beam.setWavelength(XSDataWavelength(self.collect_obj.get_wavelength()))
        except AttributeError:
            pass

        try:
            beam.setFlux(XSDataFlux(self.collect_obj.get_measured_intensity()))
        except AttributeError:
            pass

        try:
            beamsize = self.get_beam_size()
            if not None in beamsize:
                beam.setSize(XSDataSize(x=XSDataLength(float(beamsize[0])),
                                        y=XSDataLength(float(beamsize[1]))))
        except AttributeError:
            pass

        #Optimization parameters
        diff_plan = edna_input.getDiffractionPlan()

        diff_plan.setAimedIOverSigmaAtHighestResolution(\
            XSDataDouble(char_params.aimed_i_sigma))

        diff_plan.setAimedCompleteness(XSDataDouble(char_params.\
                                                    aimed_completness))

        if char_params.use_aimed_multiplicity:
            diff_plan.setAimedMultiplicity(XSDataDouble(char_params.\
                                                        aimed_multiplicity))
            
        if char_params.use_aimed_resolution:
            diff_plan.setAimedResolution(XSDataDouble(char_params.aimed_resolution))

        diff_plan.setComplexity(XSDataString(\
                queue_model_enumerables.STRATEGY_COMPLEXITY[char_params.strategy_complexity]))

        if char_params.use_permitted_rotation:
            diff_plan.setUserDefinedRotationStart(XSDataAngle(char_params.\
                                                              permitted_phi_start))

            diff_plan.setUserDefinedRotationRange(XSDataAngle(char_params.permitted_phi_end -\
                                                              char_params.permitted_phi_start))


        #Vertical crystal dimension
        sample = edna_input.getSample()
        sample.getSize().setY(XSDataLength(char_params.max_crystal_vdim))
        sample.getSize().setZ(XSDataLength(char_params.min_crystal_vdim))


        #Radiation damage model
        sample.setSusceptibility(XSDataDouble(char_params.rad_suscept))
        sample.setChemicalComposition(None)
        sample.setRadiationDamageModelBeta(XSDataDouble(char_params.beta/1e6))
        sample.setRadiationDamageModelGamma(XSDataDouble(char_params.gamma/1e6))
            

        diff_plan.setForcedSpaceGroup(XSDataString(char_params.\
                                                   space_group))


        # Characterisation type - Routine DC
        if char_params.use_min_dose:
            pass

        if char_params.use_min_time:
            diff_plan.setMaxExposureTimePerDataCollection(XSDataTime(char_params.\
                                                                     min_time))

        
        # Account for radiation damage
        if char_params.induce_burn:
            diff_plan.setStrategyOption(XSDataString("-DamPar")) # What is -DamPar ?
        else:
            diff_plan.setStrategyOption(None)


        # Characterisation type - SAD
        if queue_model_enumerables.EXPERIMENT_TYPE[char_params.experiment_type] is \
               queue_model_enumerables.EXPERIMENT_TYPE.SAD:
            diff_plan.setAnomalousData(XSDataBoolean(True))
        else:
            diff_plan.setAnomalousData(XSDataBoolean(False))

        
        #Data set
        data_set = XSDataMXCuBEDataSet()
        acquisition_parameters = data_collection.acquisitions[0].acquisition_parameters
        path_str = os.path.join(data_collection.acquisitions[0].path_template.directory,
                                data_collection.acquisitions[0].path_template.get_image_file_name())
        
        for img_num in range(int(acquisition_parameters.num_images)):
            image_file = XSDataFile()
            path = XSDataString()
            path.setValue(path_str % (img_num + 1))
            image_file.setPath(path)
            data_set.addImageFile(image_file)

        edna_input.addDataSet(data_set)
        edna_input.process_directory = data_collection.acquisitions[0].path_template.process_directory
        
        return edna_input
    def get_default_characterisation_parameters(self):
        """
        Returns:
            (queue_model_objects.CharacterisationsParameters) object with default
            parameters.
        """
        edna_input = XSDataInputMXCuBE.parseString(self.edna_default_input)
        diff_plan = edna_input.getDiffractionPlan()

        edna_sample = edna_input.getSample()
        char_params = qmo.CharacterisationParameters()
        char_params.experiment_type = qme.EXPERIMENT_TYPE.OSC

        # Optimisation parameters
        char_params.use_aimed_resolution = False
        try:
            char_params.aimed_resolution = diff_plan.getAimedResolution().getValue()
        except Exception:
            char_params.aimed_resolution = None

        char_params.use_aimed_multiplicity = False
        try:
            char_params.aimed_i_sigma = (
                diff_plan.getAimedIOverSigmaAtHighestResolution().getValue()
            )
            char_params.aimed_completness = diff_plan.getAimedCompleteness().getValue()
        except Exception:
            char_params.aimed_i_sigma = None
            char_params.aimed_completness = None

        char_params.strategy_complexity = 0
        char_params.induce_burn = False
        char_params.use_permitted_rotation = False
        char_params.permitted_phi_start = 0.0
        char_params.permitted_phi_end = 360
        char_params.low_res_pass_strat = False

        # Crystal
        char_params.max_crystal_vdim = edna_sample.getSize().getY().getValue()
        char_params.min_crystal_vdim = edna_sample.getSize().getZ().getValue()
        char_params.max_crystal_vphi = 90
        char_params.min_crystal_vphi = 0.0
        char_params.space_group = ""

        # Characterisation type
        char_params.use_min_dose = True
        char_params.use_min_time = False
        char_params.min_dose = 30.0
        char_params.min_time = 0.0
        char_params.account_rad_damage = True
        char_params.auto_res = True
        char_params.opt_sad = False
        char_params.sad_res = 0.5
        char_params.determine_rad_params = False
        char_params.burn_osc_start = 0.0
        char_params.burn_osc_interval = 3

        # Radiation damage model
        char_params.rad_suscept = edna_sample.getSusceptibility().getValue()
        char_params.beta = 1
        char_params.gamma = 0.06

        return char_params
    def from_params(self, data_collection, char_params):
        edna_input = XSDataInputMXCuBE.parseString(self.edna_default_input)

        if data_collection.id:
            edna_input.setDataCollectionId(XSDataInteger(data_collection.id))

        # Beam object
        beam = edna_input.getExperimentalCondition().getBeam()

        try:
            transmission = self.collect_obj.get_transmission()
            beam.setTransmission(XSDataDouble(transmission))
        except AttributeError:
            import traceback

            logging.getLogger("HWR").debug("DataAnalysis. transmission not saved ")
            logging.getLogger("HWR").debug(traceback.format_exc())

        try:
            wavelength = self.collect_obj.get_wavelength()
            beam.setWavelength(XSDataWavelength(wavelength))
        except AttributeError:
            pass

        try:
            beam.setFlux(XSDataFlux(self.collect_obj.get_measured_intensity()))
        except AttributeError:
            pass

        try:
            min_exp_time = self.collect_obj.detector_hwobj.get_exposure_time_limits()[0]
            beam.setMinExposureTimePerImage(XSDataTime(min_exp_time))
        except AttributeError:
            pass

        try:
            beamsize = self.get_beam_size()
            if None not in beamsize:
                beam.setSize(
                    XSDataSize(
                        x=XSDataLength(float(beamsize[0])),
                        y=XSDataLength(float(beamsize[1])),
                    )
                )
        except AttributeError:
            pass

        # Optimization parameters
        diff_plan = edna_input.getDiffractionPlan()

        aimed_i_sigma = XSDataDouble(char_params.aimed_i_sigma)
        aimed_completness = XSDataDouble(char_params.aimed_completness)
        aimed_multiplicity = XSDataDouble(char_params.aimed_multiplicity)
        aimed_resolution = XSDataDouble(char_params.aimed_resolution)

        complexity = char_params.strategy_complexity
        complexity = XSDataString(qme.STRATEGY_COMPLEXITY[complexity])

        permitted_phi_start = XSDataAngle(char_params.permitted_phi_start)
        _range = char_params.permitted_phi_end - char_params.permitted_phi_start
        rotation_range = XSDataAngle(_range)

        if char_params.aimed_i_sigma:
            diff_plan.setAimedIOverSigmaAtHighestResolution(aimed_i_sigma)

        if char_params.aimed_completness:
            diff_plan.setAimedCompleteness(aimed_completness)

        if char_params.use_aimed_multiplicity:
            diff_plan.setAimedMultiplicity(aimed_multiplicity)

        if char_params.use_aimed_resolution:
            diff_plan.setAimedResolution(aimed_resolution)

        diff_plan.setComplexity(complexity)

        if char_params.use_permitted_rotation:
            diff_plan.setUserDefinedRotationStart(permitted_phi_start)
            diff_plan.setUserDefinedRotationRange(rotation_range)

        # Vertical crystal dimension
        sample = edna_input.getSample()
        sample.getSize().setY(XSDataLength(char_params.max_crystal_vdim))
        sample.getSize().setZ(XSDataLength(char_params.min_crystal_vdim))

        # Radiation damage model
        sample.setSusceptibility(XSDataDouble(char_params.rad_suscept))
        sample.setChemicalComposition(None)
        sample.setRadiationDamageModelBeta(XSDataDouble(char_params.beta / 1e6))
        sample.setRadiationDamageModelGamma(XSDataDouble(char_params.gamma / 1e6))

        diff_plan.setForcedSpaceGroup(XSDataString(char_params.space_group))

        # Characterisation type - Routine DC
        if char_params.use_min_dose:
            pass

        if char_params.use_min_time:
            time = XSDataTime(char_params.min_time)
            diff_plan.setMaxExposureTimePerDataCollection(time)

        # Account for radiation damage
        if char_params.induce_burn:
            self.modify_strategy_option(diff_plan, "-DamPar")

        # Characterisation type - SAD
        if char_params.opt_sad:
            if char_params.auto_res:
                diff_plan.setAnomalousData(XSDataBoolean(True))
            else:
                diff_plan.setAnomalousData(XSDataBoolean(False))
                self.modify_strategy_option(diff_plan, "-SAD yes")
                diff_plan.setAimedResolution(XSDataDouble(char_params.sad_res))
        else:
            diff_plan.setAnomalousData(XSDataBoolean(False))

        # Data set
        data_set = XSDataMXCuBEDataSet()
        acquisition_parameters = data_collection.acquisitions[0].acquisition_parameters
        path_template = data_collection.acquisitions[0].path_template
        path_str = os.path.join(
            path_template.directory, path_template.get_image_file_name()
        )

        for img_num in range(int(acquisition_parameters.num_images)):
            image_file = XSDataFile()
            path = XSDataString()
            path.setValue(path_str % (img_num + 1))
            image_file.setPath(path)
            data_set.addImageFile(image_file)

        edna_input.addDataSet(data_set)
        edna_input.process_directory = path_template.process_directory

        return edna_input