def get_dxtbx_from_params(params, detector_size): """ Build a dxtbx format object for the Rayonix based on input paramters (beam center and binning) """ from xfel.cftbx.detector.cspad_cbf_tbx import basis from scitbx.matrix import col fake_distance = 100 null_ori = col((0, 0, 1)).axis_and_angle_as_unit_quaternion(0, deg=True) if params.override_beam_x is None and params.override_beam_y is None: metro = {(0, ): basis(null_ori, col((0, 0, 0)))} elif params.override_beam_x is not None and params.override_beam_y is not None: # compute the offset from the origin given the provided beam center override pixel_size = get_rayonix_pixel_size(params.bin_size) image_center = col(detector_size) / 2 override_center = col((params.override_beam_x, params.override_beam_y)) delta = (image_center - override_center) * pixel_size metro = { (0, ): basis(null_ori, col((delta[0], -delta[1], 0))) } # note the -Y else: assert False, "Please provide both override_beam_x and override_beam_y or provide neither" cbf = get_rayonix_cbf_handle(None, metro, None, "test", None, fake_distance, params.bin_size, detector_size, verbose=True, header_only=True) base_dxtbx = FormatCBFRayonixInMemory(cbf) return base_dxtbx
def get_full_basis_shift(pg): """Compute basis shift from pg to lab space""" shift = basis(panelgroup=pg) while True: parent = pg.parent() if parent is None: break shift = basis(panelgroup=parent) * shift pg = parent return shift
def recursive_setup_dict(panelgroup, key): metro[key] = basis(panelgroup=panelgroup) if panelgroup.is_panel(): return for i, child in enumerate(panelgroup): childkey = tuple(list(key) + [i]) recursive_setup_dict(child, childkey)
c[0] += corrections_params.distl.quad_translations[2 * phil_quad + 0] + \ corrections_params.distl.tile_translations[4 * itile + 0] c[1] += corrections_params.distl.quad_translations[2 * phil_quad + 1] + \ corrections_params.distl.tile_translations[4 * itile + 1] s.center = tuple(c) if params.round_and_orthogonalize: # In order to match the image pickle metrology, we have to discard the tilts and offets in the # section objects, and instead use the active areas returned by corners_asic as the tile # locations. from xfel.cftbx.detector.cspad_cbf_tbx import basis, pixel_size, asic_dimension, asic_gap null_ori = col((0,0,1)).axis_and_angle_as_unit_quaternion(0, deg=True) # the detector is rotated 90 degrees from how corners_asic reports things rot_ori = col((0,0,1)).axis_and_angle_as_unit_quaternion(-90, deg=True) metro = { (0,): basis(rot_ori, col((0,0,0))) } # basis dictionary used to build cbf header for quad_id, quad in enumerate(sections): quad_asics = [] for sensor in quad: quad_asics.extend(sensor.corners_asic()) quad_center = col(get_asics_center(quad_asics)) v = (quad_center-beam)*pixel_size # vector from beam center to quad center metro[(0,quad_id)] = basis(null_ori, col((v[0],v[1],0))) for sensor_id, sensor in enumerate(quad): sensor_center = get_asics_center(sensor.corners_asic()) # include sensor rotation, rounded to 90 degrees ori = col((0,0,1)).axis_and_angle_as_unit_quaternion(90.0 * round(sensor.angle / 90.0), deg=True) v = (sensor_center - quad_center)*pixel_size # vector from quad center to 2x1 center metro[(0,quad_id,sensor_id)] = basis(ori, col((v[0],v[1],0))) # add the two asics w = pixel_size * (asic_dimension[0]/2 + asic_gap/2)
corrections_params.distl.tile_translations[4 * itile + 1] s.center = tuple(c) if params.round_and_orthogonalize: # In order to match the image pickle metrology, we have to discard the tilts and offets in the # section objects, and instead use the active areas returned by corners_asic as the tile # locations. from xfel.cftbx.detector.cspad_cbf_tbx import basis, pixel_size, asic_dimension, asic_gap null_ori = col( (0, 0, 1)).axis_and_angle_as_unit_quaternion(0, deg=True) # the detector is rotated 90 degrees from how corners_asic reports things rot_ori = col( (0, 0, 1)).axis_and_angle_as_unit_quaternion(-90, deg=True) metro = { (0, ): basis(rot_ori, col((0, 0, 0))) } # basis dictionary used to build cbf header for quad_id, quad in enumerate(sections): quad_asics = [] for sensor in quad: quad_asics.extend(sensor.corners_asic()) quad_center = col(get_asics_center(quad_asics)) v = (quad_center - beam ) * pixel_size # vector from beam center to quad center metro[(0, quad_id)] = basis(null_ori, col((v[0], v[1], 0))) for sensor_id, sensor in enumerate(quad): sensor_center = get_asics_center(sensor.corners_asic()) # include sensor rotation, rounded to 90 degrees ori = col((0, 0, 1)).axis_and_angle_as_unit_quaternion( 90.0 * round(sensor.angle / 90.0), deg=True) v = (