コード例 #1
0
        def get_values(invert_y):

            from dxtbx.model.beam import beam_factory
            beam = beam_factory.simple(wavelength=1)

            if invert_y:
                y_direction = "-y"
            else:
                y_direction = "+y"

            from dxtbx.model.detector import detector_factory
            detector = detector_factory.simple(
                sensor=detector_factory.sensor("PAD"),
                distance=100,
                beam_centre=[50, 50],
                fast_direction="+x",
                slow_direction=y_direction,
                pixel_size=[0.1, 0.1],
                image_size=[1000, 1000])

            from dxtbx.model import ParallaxCorrectedPxMmStrategy
            from cctbx.eltbx import attenuation_coefficient
            wavelength = beam.get_wavelength()
            thickness = 0.5
            table = attenuation_coefficient.get_table("Si")
            mu = table.mu_at_angstrom(wavelength) / 10.0
            t0 = thickness

            for panel in detector:
                panel.set_px_mm_strategy(ParallaxCorrectedPxMmStrategy(mu, t0))
            v1 = detector[0].pixel_to_millimeter((0, 0))
            v2 = detector[0].pixel_to_millimeter((1000, 1000))

            return v1, v2
コード例 #2
0
    def _beam(self):
        '''
    Create the beam model

    '''
        from dxtbx.model.beam import beam_factory
        configuration = self.header['configuration']
        return beam_factory.simple(configuration['wavelength'])
コード例 #3
0
  def _beam(self):
    '''
    Create the beam model

    '''
    from dxtbx.model.beam import beam_factory
    configuration = self.header['configuration']
    return beam_factory.simple(configuration['wavelength'])
コード例 #4
0
  def __init__(self,params):
    import cPickle as pickle
    from dxtbx.model.beam import beam_factory
    from dxtbx.model.detector import detector_factory
    from dxtbx.model.crystal import crystal_model
    from cctbx.crystal_orientation import crystal_orientation,basis_type
    from dxtbx.model.experiment.experiment_list 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 = beam_factory.simple(wavelength = wavelength)

      detector = detector_factory.simple(
        sensor = detector_factory.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 = "P63",  # XXX obviously another gap in the database paradigm
        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()
コード例 #5
0
  def prepare_dxtbx_models(self,setting_specific_ai,sg,isoform=None):

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

    from dxtbx.model.detector import detector_factory
    detector = detector_factory.simple(
      sensor = detector_factory.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.crystal import crystal_model
    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 = sg,
      mosaicity = setting_specific_ai.getMosaicity()
    )
    if isoform is not None:
      newB = matrix.sqr(isoform.fractionalization_matrix()).transpose()
      crystal.set_B(newB)

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

    print beam
    print detector
    print crystal
    return experiments
コード例 #6
0
    def __init__(self, params):
        import cPickle as pickle
        from dxtbx.model.beam import beam_factory
        from dxtbx.model.detector import detector_factory
        from dxtbx.model.crystal import crystal_model
        from cctbx.crystal_orientation import crystal_orientation, basis_type
        from dxtbx.model.experiment.experiment_list 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 = beam_factory.simple(wavelength=wavelength)

            detector = detector_factory.simple(
                sensor=detector_factory.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()
コード例 #7
0
            (-float(fs_x.rstrip('x')), float(fs_y.rstrip('y')), 0.0))
        slow = matrix.col(
            (-float(ss_x.rstrip('x')), float(ss_y.rstrip('y')), 0.0))

        origin = matrix.col(
            (-float(geom[key]['corner_x']) * params.pixel_size,
             float(geom[key]['corner_y']) * params.pixel_size, 0.0))

        # OBS! you need to set the panel to a root before set local frame...
        p = root.add_panel()
        p.set_name('panel-%s' % key)
        p.set_image_size((512, 1024))
        p.set_trusted_range((-1, 1000000))
        p.set_pixel_size((params.pixel_size, params.pixel_size))
        p.set_local_frame(fast.elems, slow.elems, origin.elems)

    from dxtbx.model.beam import beam_factory
    wavelength = params.wavelength
    beam = beam_factory.simple(wavelength)

    from dxtbx.model.experiment.experiment_list import Experiment, ExperimentList, ExperimentListDumper
    experiments = ExperimentList()
    experiment = Experiment(detector=detector, beam=beam)
    experiments.append(experiment)
    dump = ExperimentListDumper(experiments)
    dump.as_json("geometry.json")


if __name__ == "__main__":
    run(sys.argv[1:])
コード例 #8
0
    from xfel.cftbx.detector.cspad_cbf_tbx import read_slac_metrology, get_cspad_cbf_handle
    from dxtbx.format.FormatCBFCspad import FormatCBFCspadInMemory
    from dxtbx.model.beam import beam_factory
    metro = read_slac_metrology(path=params.optical_metrology_path)
    cbf = get_cspad_cbf_handle(None,
                               metro,
                               'cbf',
                               None,
                               "test",
                               None,
                               params.distance,
                               verbose=True,
                               header_only=True)
    img = FormatCBFCspadInMemory(cbf)
    beam = beam_factory.simple(params.wavelength).get_s0()
    beam_center = (0, 0)

    data = numpy.zeros((11840, 194))

    if annulus:
        inner = params.distance * math.tan(
            2 * math.sinh(params.wavelength / (2 * params.annulus_inner)))
        outer = params.distance * math.tan(
            2 * math.sinh(params.wavelength / (2 * params.annulus_outer)))
        print "Inner (mm):", inner
        print "Outer (mm):", outer
    if params.resolution is not None:
        radius = params.distance * math.tan(
            2 * math.sinh(params.wavelength / (2 * params.resolution)))
        print "Radius (mm):", radius
コード例 #9
0
      print "Generating annular gain mask between %f and %f angstroms, assuming a distance %s mm and wavelength %s angstroms" % \
        (params.annulus_inner, params.annulus_outer, params.distance, params.wavelength)
    else:
      print "Generating annular gain mask between %f and %f angstroms, assuming a distance %s mm and wavelength %s angstroms. Also, pixels higher than %f angstroms will be set to low gain." % \
        (params.annulus_inner, params.annulus_outer, params.distance, params.wavelength, params.resolution)
  elif params.resolution is not None:
    print "Generating circular gain mask %s angstroms, assuming a distance %s mm and wavelength %s angstroms" % \
      (params.resolution, params.distance, params.wavelength)

  from xfel.cftbx.detector.cspad_cbf_tbx import read_slac_metrology, get_cspad_cbf_handle
  from dxtbx.format.FormatCBFCspad import FormatCBFCspadInMemory
  from dxtbx.model.beam import beam_factory
  metro = read_slac_metrology(path = params.optical_metrology_path)
  cbf = get_cspad_cbf_handle(None, metro, 'cbf', None, "test", None, params.distance, verbose = True, header_only = True)
  img = FormatCBFCspadInMemory(cbf)
  beam = beam_factory.simple(params.wavelength).get_s0()
  beam_center = (0,0)

  data = numpy.zeros((11840,194))

  if annulus:
    inner = params.distance * math.tan(2*math.sinh(params.wavelength/(2*params.annulus_inner)))
    outer = params.distance * math.tan(2*math.sinh(params.wavelength/(2*params.annulus_outer)))
    print "Inner (mm):", inner
    print "Outer (mm):", outer
  if params.resolution is not None:
    radius = params.distance * math.tan(2*math.sinh(params.wavelength/(2*params.resolution)))
    print "Radius (mm):", radius

  print "Panel:",; sys.stdout.flush()
  for p_id, panel in enumerate(img.get_detector()):
コード例 #10
0
    slow = matrix.col((-float(ss_x.rstrip('x')),float(ss_y.rstrip('y')), 0.0))

    origin = matrix.col((-float(geom[key]['corner_x']) * params.pixel_size,
                          float(geom[key]['corner_y']) * params.pixel_size,
                          0.0))

    # OBS! you need to set the panel to a root before set local frame...
    p = root.add_panel()
    p.set_name('panel-%s' % key)
    p.set_image_size((512, 1024))
    p.set_trusted_range((-1, 1000000))
    p.set_pixel_size((params.pixel_size, params.pixel_size))
    p.set_local_frame(
      fast.elems,
      slow.elems,
      origin.elems)

  from dxtbx.model.beam import beam_factory
  wavelength = params.wavelength
  beam = beam_factory.simple(wavelength)

  from dxtbx.model.experiment.experiment_list import Experiment, ExperimentList, ExperimentListDumper
  experiments = ExperimentList()
  experiment = Experiment(detector = detector, beam = beam)
  experiments.append(experiment)
  dump = ExperimentListDumper(experiments)
  dump.as_json("geometry.json")

if __name__ == "__main__":
  run(sys.argv[1:])