def __init__(self, test_nave_model = False): # Set up experimental models with regular geometry from dxtbx.model.experiment import beam_factory from dxtbx.model.experiment import goniometer_factory from dxtbx.model.experiment import detector_factory from dxtbx.model.crystal import crystal_model # Beam along the Z axis self.beam = beam_factory.make_beam(unit_s0 = matrix.col((0, 0, 1)), wavelength = 1.0) # Goniometer (used only for index generation) along X axis self.goniometer = goniometer_factory.known_axis(matrix.col((1, 0, 0))) # Detector fast, slow along X, -Y; beam in the centre, 200 mm distance dir1 = matrix.col((1, 0, 0)) dir2 = matrix.col((0, -1, 0)) n = matrix.col((0, 0, 1)) centre = matrix.col((0, 0, 200)) npx_fast = npx_slow = 1000 pix_size = 0.2 origin = centre - (0.5 * npx_fast * pix_size * dir1 + 0.5 * npx_slow * pix_size * dir2) self.detector = detector_factory.make_detector("PAD", dir1, dir2, origin, (pix_size, pix_size), (npx_fast, npx_slow), (0, 1.e6)) # Cubic 100 A^3 crystal a = matrix.col((100, 0, 0)) b = matrix.col((0, 100, 0)) c = matrix.col((0, 0, 100)) self.crystal = crystal_model(a, b, c, space_group_symbol = "P 1") if test_nave_model: self.crystal._ML_half_mosaicity_deg = 500 self.crystal._ML_domain_size_ang = 0.2 # Collect these models in an Experiment (ignoring the goniometer) from dxtbx.model.experiment.experiment_list import Experiment self.experiment = Experiment(beam=self.beam, detector=self.detector, goniometer=None, scan=None, crystal=self.crystal, imageset=None) # Generate some reflections self.reflections = self.generate_reflections() return
def build_detector(self): assert self._params.detector.directions.method in \ ['close_to', 'exactly'] if self._params.detector.directions.method == 'close_to': temp = self._params.detector.directions.close_to.dir1 dir1 = random_vector_close_to(temp, sd = self._params.detector.directions.close_to.sd) n = random_vector_close_to( self._params.detector.directions.close_to.norm, sd=self._params.detector.directions.close_to.sd) elif self._params.detector.directions.method == 'exactly': temp = self._params.detector.directions.exactly.dir1 dir1 = matrix.col(temp) n = matrix.col( self._params.detector.directions.exactly.norm) dir2 = n.cross(dir1).normalize() assert self._params.detector.centre.method in \ ['close_to','exactly'] if self._params.detector.centre.method == 'close_to': centre = random_vector_close_to( self._params.detector.centre.close_to.value, sd = self._params.detector.centre.close_to.sd) elif self._params.detector.centre.method == 'exactly': temp = self._params.detector.centre.exactly.value centre = matrix.col(temp) origin = centre - (0.5 * self._params.detector.npx_fast * self._params.detector.pix_size * dir1 + 0.5 * self._params.detector.npx_slow * self._params.detector.pix_size * dir2) self.detector = detector_factory.make_detector("PAD", dir1, dir2, origin, (self._params.detector.pix_size, self._params.detector.pix_size), (self._params.detector.npx_fast, self._params.detector.npx_slow), (0, 1.e6))
def __init__(self, plots = False): # Do we make scatterplots? self.do_plots = plots # Let's say we have a scan of 100 images self.image_range = (1, 100) # Make a random P1 crystal a = random.uniform(10,50) * \ self.random_direction_close_to(matrix.col((1, 0, 0))) b = random.uniform(10,50) * \ self.random_direction_close_to(matrix.col((0, 1, 0))) c = random.uniform(10,50) * \ self.random_direction_close_to(matrix.col((0, 0, 1))) self.xl = crystal_model(a, b, c, space_group_symbol = "P 1") # Make a beam with wavelength in the range 0.8--1.2 and s0 direction close # to 0,0,1 s0 = random.uniform(0.8, 1.2) * \ self.random_direction_close_to(matrix.col((0, 0, 1))) self.beam = Beam(s0) # Make a standard goniometer model along X self.goniometer = Goniometer((1,0,0)) # Make a simple single panel detector d1 = matrix.col((1, 0, 0)) d2 = matrix.col((0, -1, 0)) npx_fast = 1475 npx_slow = 1679 pix_size_f = pix_size_s = 0.172 from dxtbx.model.experiment import detector_factory self.detector = detector_factory.make_detector("PAD", d1, d2, matrix.col((0, 0, -110)), (pix_size_f, pix_size_s), (npx_fast, npx_slow), (0, 2e20))
if __name__ == '__main__': # set the random seed to make the test reproducible random.seed(1337) # set up a simple detector frame with directions aligned with # principal axes and sensor origin located on the z-axis at -110 d1 = matrix.col((1, 0, 0)) d2 = matrix.col((0, -1, 0)) #lim = (0,50) npx_fast = 1475 npx_slow = 1679 pix_size_f = pix_size_s = 0.172 detector = detector_factory.make_detector("PAD", d1, d2, matrix.col((0, 0, -110)), (pix_size_f, pix_size_s), (npx_fast, npx_slow), (0, 2e20)) dp = DetectorParameterisationSinglePanel(detector) beam = beam_factory().make_beam( sample_to_source=-1*(matrix.col((0, 0, -110)) + 10 * d1 + 10 * d2), wavelength=1.0) # Test change of parameters # ========================= # 1. shift detector plane so that the z-axis intercepts its centre # at a distance of 100 along the initial normal direction. As the # initial normal is along -z, we expect the frame to intercept the # z-axis at -100.
if __name__ == '__main__': # set the random seed to make the test reproducible random.seed(1337) # set up a simple detector frame with directions aligned with # principal axes and sensor origin located on the z-axis at -110 d1 = matrix.col((1, 0, 0)) d2 = matrix.col((0, -1, 0)) #lim = (0,50) npx_fast = 1475 npx_slow = 1679 pix_size_f = pix_size_s = 0.172 detector = detector_factory.make_detector("PAD", d1, d2, matrix.col((0, 0, -110)), (pix_size_f, pix_size_s), (npx_fast, npx_slow), (0, 2e20)) dp = DetectorParameterisationSinglePanel(detector) beam = beam_factory().make_beam(sample_to_source=-1 * (matrix.col( (0, 0, -110)) + 10 * d1 + 10 * d2), wavelength=1.0) # Test change of parameters # ========================= # 1. shift detector plane so that the z-axis intercepts its centre # at a distance of 100 along the initial normal direction. As the # initial normal is along -z, we expect the frame to intercept the # z-axis at -100.