Example #1
0
    def _detector(self):
        """
        Create the detector model
        """
        from scitbx import matrix
        from dxtbx.model.detector import DetectorFactory

        configuration = self.header["configuration"]
        info = self.header["info"]

        #   from pprint import pprint
        #   pprint(configuration)

        # Set the trusted range
        #   trusted_range = 0, configuration['countrate_correction_count_cutoff']
        trusted_range = 0, 2**configuration["bit_depth_readout"] - 1

        # Get the sensor material and thickness
        sensor_material = str(configuration["sensor_material"])
        sensor_thickness = configuration["sensor_thickness"]

        beam_center = configuration["beam_center_x"], configuration[
            "beam_center_y"]
        distance = configuration["detector_distance"]

        # Get the pixel and image sizes
        pixel_size = (configuration["x_pixel_size"],
                      configuration["y_pixel_size"])
        # Image size is not x/y_pixels_in_detector, which are likely the physical dimensions
        image_size = (info["shape"][0], info["shape"][1])

        # Get the detector axes
        # TODO Spec doesn't have detector_orientation
        # TODO THIS NEEDS FIXING
        # fast_axis = (1, 0, 0)
        # slow_axis = (0, 1, 0)
        # origin = (0, 0, -1)
        fast_axis = configuration["detector_orientation"][0:3]
        slow_axis = configuration["detector_orientation"][3:6]
        origin = matrix.col(
            configuration["detector_translation"]) + matrix.col(
                (0, 0, -distance))

        # Create the detector model
        return DetectorFactory.make_detector(
            "SENSOR_PAD",
            fast_axis,
            slow_axis,
            origin,
            pixel_size,
            image_size,
            trusted_range,
            px_mm=None,
            name="Panel",
            thickness=sensor_thickness,
            material=sensor_material,
            mu=0.0,
        )
Example #2
0
 def simple_detector(detector_distance_mm, pixelsize_mm, image_shape, fast=(1, 0, 0), slow=(0, -1, 0)):
   from dxtbx.model.detector import DetectorFactory
   import numpy as np
   trusted_range = (0, 200000000000000.0)
   detsize_s = image_shape[0] * pixelsize_mm
   detsize_f = image_shape[1] * pixelsize_mm
   cent_s = (detsize_s + pixelsize_mm * 2) / 2.0
   cent_f = (detsize_f + pixelsize_mm * 2) / 2.0
   beam_axis = np.cross(fast, slow)
   origin = -np.array(fast) * cent_f - np.array(slow) * cent_s + beam_axis * detector_distance_mm
   return DetectorFactory.make_detector('', fast, slow, origin, (
     pixelsize_mm, pixelsize_mm), image_shape, trusted_range)
    def _detector(self):
        '''
    Create the detector model

    '''
        from scitbx import matrix
        from dxtbx.model.detector import DetectorFactory
        configuration = self.header['configuration']

        # Set the trusted range
        trusted_range = 0, configuration['countrate_correction_count_cutoff']

        # Get the sensor material and thickness
        sensor_material = str(configuration['sensor_material'])
        sensor_thickness = configuration['sensor_thickness']

        beam_center = configuration['beam_center_x'], configuration[
            'beam_center_y']
        distance = configuration['detector_distance']

        # Get the pixel and image sizes
        pixel_size = (configuration['x_pixel_size'],
                      configuration['y_pixel_size'])
        image_size = (configuration['x_pixels_in_detector'],
                      configuration['y_pixels_in_detector'])

        # Get the detector axes
        # TODO Spec doesn't have detector_orientation
        # TODO THIS NEEDS FIXING
        fast_axis = (1, 0, 0)
        slow_axis = (0, 1, 0)
        origin = (0, 0, -1)
        # fast_axis = configuration['detector_orientation'][0:3]
        # slow_axis = configuration['detector_orientation'][3:6]
        #origin = matrix.col(configuration['detector_translation']) + matrix.col((0,0,-distance))

        # Create the detector model
        return DetectorFactory.make_detector('SENSOR_PAD',
                                             fast_axis,
                                             slow_axis,
                                             origin,
                                             pixel_size,
                                             image_size,
                                             trusted_range,
                                             px_mm=None,
                                             name='Panel',
                                             thickness=sensor_thickness,
                                             material=sensor_material,
                                             mu=0.0)
Example #4
0
    def _detector(self):
        """
        Create the detector model
        """
        configuration = self.header["configuration"]
        info = self.header["info"]

        #   from pprint import pprint
        #   pprint(configuration)

        # Set the trusted range
        trusted_range = 0, 2**configuration["bit_depth_readout"] - 1

        # Get the sensor material and thickness
        sensor_material = str(configuration["sensor_material"])
        sensor_thickness = configuration["sensor_thickness"]
        distance = configuration["detector_distance"]

        # Get the pixel and image sizes
        pixel_size = (configuration["x_pixel_size"],
                      configuration["y_pixel_size"])
        # Image size is not x/y_pixels_in_detector, which are likely the physical dimensions
        image_size = (info["shape"][0], info["shape"][1])

        # Get the detector axes
        fast_axis = configuration["detector_orientation"][0:3]
        slow_axis = configuration["detector_orientation"][3:6]
        origin = matrix.col(
            configuration["detector_translation"]) + matrix.col(
                (0, 0, -distance))

        # Create the detector model
        return DetectorFactory.make_detector(
            "SENSOR_PAD",
            fast_axis,
            slow_axis,
            origin,
            pixel_size,
            image_size,
            trusted_range,
            px_mm=None,
            name="Panel",
            thickness=sensor_thickness,
            material=sensor_material,
            mu=0.0,
        )
# ------------------------


if lab_geom == "canonical":
    s = 1  # scale factor, divide pixel size by this factor 
    pixsize = .10992/s # mm
    detdist = 125  # mm
    wavelen = 1.385
    orig = col((-s*1536*pixsize/2.,
                s*1536*pixsize/2.,
                -detdist))
    # Initialise detector frame
    fast = col((1.0, 0.0, 0.0))
    slow = col((0.0, -1.0, 0.0))
    det = DetectorFactory.make_detector(
        "", fast, slow, orig,
        (pixsize, pixsize), (s*1536,s*1536)) #, trusted_range=(0, 10000000))
    beam_descr = {
        'direction': (7.010833160725592e-06, -3.710515413340211e-06, 0.9999999999685403),
        'divergence': 0.0,
        'flux': 0.0,
        'polarization_fraction': 0.999,
        'polarization_normal': (0.0, 1.0, 0.0),
        'sigma_divergence': 0.0,
        'transmission': 1.0,
        'wavelength': 1.385}
    #beam = BeamFactory.simple(wavelen)
    beam = BeamFactory.from_dict(beam_descr)

elif lab_geom == "cspad":
    det = DetectorFactory.from_dict(dxtbx_cspad.cspad)