Exemplo n.º 1
0
  def __init__(self, filename, experiment, HKL, i_sigi, measurements, params):
    from libtbx import adopt_init_args
    adopt_init_args(self, locals())
    self.stash_type = None
    self.stash_res_filter = None

    from dxtbx.model import DetectorFactory
    self.dummy_detector = DetectorFactory.simple(
      sensor = DetectorFactory.sensor("PAD"),
      distance = 100,
      beam_centre = [1000, 1000],
      fast_direction = "+x",
      slow_direction = "+y",
      pixel_size = [0.2,0.2],
      image_size = [2000,2000],
      )
    def prepare_dxtbx_models(self, setting_specific_ai, sg, isoform=None):

        from dxtbx.model import BeamFactory
        beam = BeamFactory.simple(wavelength=self.inputai.wavelength)

        from dxtbx.model import DetectorFactory
        detector = DetectorFactory.simple(
            sensor=DetectorFactory.sensor("PAD"),
            distance=setting_specific_ai.distance(),
            beam_centre=[
                setting_specific_ai.xbeam(),
                setting_specific_ai.ybeam()
            ],
            fast_direction="+x",
            slow_direction="+y",
            pixel_size=[self.pixel_size, self.pixel_size],
            image_size=[self.inputpd['size1'], self.inputpd['size1']],
        )

        direct = matrix.sqr(
            setting_specific_ai.getOrientation().direct_matrix())
        from dxtbx.model import Crystal
        crystal = Crystal(
            real_space_a=matrix.row(direct[0:3]),
            real_space_b=matrix.row(direct[3:6]),
            real_space_c=matrix.row(direct[6:9]),
            space_group_symbol=sg,
        )
        crystal.set_mosaicity(setting_specific_ai.getMosaicity())
        if isoform is not None:
            newB = matrix.sqr(isoform.fractionalization_matrix()).transpose()
            crystal.set_B(newB)

        from dxtbx.model import Experiment, ExperimentList
        experiments = ExperimentList()
        experiments.append(
            Experiment(beam=beam, detector=detector, crystal=crystal))

        print beam
        print detector
        print crystal
        return experiments
Exemplo n.º 3
0
    def __init__(self, params):
        import cPickle as pickle
        from dxtbx.model import BeamFactory
        from dxtbx.model import DetectorFactory
        from dxtbx.model.crystal import crystal_model
        from cctbx.crystal_orientation import crystal_orientation, basis_type
        from dxtbx.model import Experiment, ExperimentList
        from scitbx import matrix
        self.experiments = ExperimentList()
        self.unique_file_names = []

        self.params = params
        data = pickle.load(
            open(self.params.output.prefix + "_frame.pickle", "rb"))
        frames_text = data.split("\n")

        for item in frames_text:
            tokens = item.split(' ')
            wavelength = float(tokens[order_dict["wavelength"]])

            beam = BeamFactory.simple(wavelength=wavelength)

            detector = DetectorFactory.simple(
                sensor=DetectorFactory.sensor(
                    "PAD"),  # XXX shouldn't hard code for XFEL
                distance=float(tokens[order_dict["distance"]]),
                beam_centre=[
                    float(tokens[order_dict["beam_x"]]),
                    float(tokens[order_dict["beam_y"]])
                ],
                fast_direction="+x",
                slow_direction="+y",
                pixel_size=[self.params.pixel_size, self.params.pixel_size],
                image_size=[1795,
                            1795],  # XXX obviously need to figure this out
            )

            reciprocal_matrix = matrix.sqr([
                float(tokens[order_dict[k]]) for k in [
                    'res_ori_1', 'res_ori_2', 'res_ori_3', 'res_ori_4',
                    'res_ori_5', 'res_ori_6', 'res_ori_7', 'res_ori_8',
                    'res_ori_9'
                ]
            ])
            ORI = crystal_orientation(reciprocal_matrix, basis_type.reciprocal)
            direct = matrix.sqr(ORI.direct_matrix())
            crystal = crystal_model(
                real_space_a=matrix.row(direct[0:3]),
                real_space_b=matrix.row(direct[3:6]),
                real_space_c=matrix.row(direct[6:9]),
                space_group_symbol=self.params.target_space_group.type().
                lookup_symbol(),
                mosaicity=float(tokens[order_dict["half_mosaicity_deg"]]),
            )
            crystal.domain_size = float(tokens[order_dict["domain_size_ang"]])
            #if isoform is not None:
            #  newB = matrix.sqr(isoform.fractionalization_matrix()).transpose()
            #  crystal.set_B(newB)

            self.experiments.append(
                Experiment(
                    beam=beam,
                    detector=None,  #dummy for now
                    crystal=crystal))
            self.unique_file_names.append(
                tokens[order_dict["unique_file_name"]])

        self.show_summary()