Ejemplo n.º 1
0
    def get(self, sensor, fast, slow, df, ds):
        """Look up a name for a detector with this sensor type (listed in
        detector_helpers) these image dimensions in the fast and slow
        directions, these corresponding pixel sizes, in microns (integers).
        If the sensor is unknown, all sensor types will be tested - be warned
        if there are duplicates."""

        sensor = DetectorFactory.sensor(sensor)

        if sensor == detector_helper_sensors.SENSOR_UNKNOWN:
            for s in detector_helper_sensors.all():
                try:
                    return self.get(s, fast, slow, df, ds)
                except ValueError:
                    pass

            raise ValueError("detector %s %d %d %d %d unknown" %
                             (sensor, fast, slow, df, ds))

        if (sensor, fast, slow, df, ds) in self._detectors:
            return self._detectors[(sensor, fast, slow, df, ds)]

        # OK allow for small variations in the recorded pixel dimensions

        for ddf in -2, -1, 1, 2:
            for dds in -2, -1, 1, 2:
                if (sensor, fast, slow, df + ddf, ds + dds) in self._detectors:
                    return self._detectors[(sensor, fast, slow, df + ddf,
                                            ds + dds)]

        raise ValueError("detector %s %d %d %d %d unknown" %
                         (sensor, fast, slow, df, ds))
Ejemplo n.º 2
0
    def __init__(self):
        detector_lib = os.path.join(
            os.path.split(dxtbx.__file__)[0], "data", "detectors.lib")

        if not os.path.exists(detector_lib):
            raise RuntimeError("detector library not found")

        self._detectors = {}

        with io.open(detector_lib, "r", encoding="ascii") as fh:
            for record in fh:
                if record.startswith(("Sensor", "-----")):
                    continue

                text = record.split("#")[0].strip()

                if not text:
                    continue

                tokens = text.split()

                assert len(tokens) == 6

                sensor = DetectorFactory.sensor(tokens[0])
                fast, slow, df, ds = map(int, tokens[1:5])

                self._detectors[(sensor, fast, slow, df, ds)] = tokens[5]
Ejemplo n.º 3
0
    def get_values(invert_y):
        beam = BeamFactory.simple(wavelength=1)

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

        detector = DetectorFactory.simple(
            sensor=DetectorFactory.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],
        )[0]

        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.pixel_to_millimeter((0, 0))
        v2 = detector.pixel_to_millimeter((1000, 1000))

        return v1, v2
Ejemplo n.º 4
0
    def __init__(self):
        detector_lib = os.path.join(
            os.path.split(dxtbx.__file__)[0], "data", "detectors.lib")

        if not os.path.exists(detector_lib):
            raise RuntimeError("detector library not found")

        self._detectors = {}

        for record in open(detector_lib):
            if "Sensor" in record[:6]:
                continue
            if "------" in record[:6]:
                continue

            text = record.split("#")[0].strip()

            if not text:
                continue

            tokens = text.split()

            assert len(tokens) == 6

            sensor = DetectorFactory.sensor(tokens[0])
            fast, slow, df, ds = map(int, tokens[1:5])

            self._detectors[(sensor, fast, slow, df, ds)] = tokens[5]
Ejemplo n.º 5
0
    def __init__(self):

        import dxtbx

        detector_lib = os.path.join(
            os.path.split(dxtbx.__file__)[0], 'data', 'detectors.lib')

        if not os.path.exists(detector_lib):
            raise RuntimeError, 'detector library not found'

        self._detectors = {}

        for record in open(detector_lib):
            if 'Sensor' in record[:6]:
                continue
            if '------' in record[:6]:
                continue

            text = record.split('#')[0].strip()

            if not text:
                continue

            tokens = text.split()

            assert (len(tokens) == 6)

            sensor = DetectorFactory.sensor(tokens[0])
            fast, slow, df, ds = map(int, tokens[1:5])

            self._detectors[(sensor, fast, slow, df, ds)] = tokens[5]

        return