Exemplo n.º 1
0
    def do_move_initial(self, move_info, workspace, coordinates, component,
                        is_transmission_workspace):
        _is_transmission_workspace = is_transmission_workspace  # noqa

        # For LARMOR we only have to coordinates
        assert len(coordinates) == 2

        # Move the sample holder
        move_sample_holder(workspace, move_info.sample_offset,
                           move_info.sample_offset_direction)

        # Shift the low-angle bank detector in the y direction
        y_shift = -coordinates[1]
        coordinates_for_only_y = [0.0, y_shift]
        apply_standard_displacement(move_info, workspace,
                                    coordinates_for_only_y,
                                    DetectorType.to_string(DetectorType.LAB))

        # Shift the low-angle bank detector in the x direction
        angle = coordinates[0]

        bench_rot_tag = "Bench_Rot"
        log_names = [bench_rot_tag]
        log_types = [float]
        log_values = get_single_valued_logs_from_workspace(
            workspace, log_names, log_types)
        bench_rotation = move_info.bench_rotation \
            if log_values[bench_rot_tag] is None else log_values[bench_rot_tag]

        self._rotate_around_y_axis(move_info, workspace, angle,
                                   DetectorType.to_string(DetectorType.LAB),
                                   bench_rotation)
Exemplo n.º 2
0
    def do_move_initial(self, move_info, workspace, coordinates, component, is_transmission_workspace):
        _is_transmission_workspace = is_transmission_workspace  # noqa

        # For LARMOR we only have to coordinates
        assert len(coordinates) == 2

        # Move the sample holder
        move_sample_holder(workspace, move_info.sample_offset, move_info.sample_offset_direction)

        # Shift the low-angle bank detector in the y direction
        y_shift = -coordinates[1]
        coordinates_for_only_y = [0.0, y_shift]
        apply_standard_displacement(move_info, workspace, coordinates_for_only_y,
                                    DetectorType.to_string(DetectorType.LAB))

        # Shift the low-angle bank detector in the x direction
        angle = coordinates[0]

        bench_rot_tag = "Bench_Rot"
        log_names = [bench_rot_tag]
        log_types = [float]
        log_values = get_single_valued_logs_from_workspace(workspace, log_names, log_types)
        bench_rotation = move_info.bench_rotation \
            if log_values[bench_rot_tag] is None else log_values[bench_rot_tag]

        self._rotate_around_y_axis(move_info, workspace, angle,
                                   DetectorType.to_string(DetectorType.LAB), bench_rotation)
Exemplo n.º 3
0
def move_low_angle_bank_for_SANS2D_and_ZOOM(move_info, workspace, coordinates, use_rear_det_z=True):
    # REAR_DET_Z
    if use_rear_det_z:
        lab_detector_z_tag = "Rear_Det_Z"

        log_names = [lab_detector_z_tag]
        log_types = [float]
        log_values = get_single_valued_logs_from_workspace(workspace, log_names, log_types,
                                                           convert_from_millimeter_to_meter=True)

        lab_detector_z = move_info.lab_detector_z \
            if log_values[lab_detector_z_tag] is None else log_values[lab_detector_z_tag]
    else:
        lab_detector_z = 0.

    # Perform x and y tilt
    lab_detector = move_info.detectors[DetectorType.to_string(DetectorType.LAB)]
    SANSMoveSANS2D.perform_x_and_y_tilts(workspace, lab_detector)

    lab_detector_default_sd_m = move_info.lab_detector_default_sd_m
    x_shift = -coordinates[0]
    y_shift = -coordinates[1]

    z_shift = (lab_detector_z + lab_detector.z_translation_correction) - lab_detector_default_sd_m
    detector_name = lab_detector.detector_name
    offset = {CanonicalCoordinates.X: x_shift,
              CanonicalCoordinates.Y: y_shift,
              CanonicalCoordinates.Z: z_shift}
    move_component(workspace, offset, detector_name)
Exemplo n.º 4
0
def move_low_angle_bank_for_SANS2D_and_ZOOM(move_info, workspace, coordinates, use_rear_det_z=True):
    # REAR_DET_Z
    if use_rear_det_z:
        lab_detector_z_tag = "Rear_Det_Z"

        log_names = [lab_detector_z_tag]
        log_types = [float]
        log_values = get_single_valued_logs_from_workspace(workspace, log_names, log_types,
                                                           convert_from_millimeter_to_meter=True)

        lab_detector_z = move_info.lab_detector_z \
            if log_values[lab_detector_z_tag] is None else log_values[lab_detector_z_tag]
    else:
        lab_detector_z = 0.

    # Perform x and y tilt
    lab_detector = move_info.detectors[DetectorType.LAB.value]
    SANSMoveSANS2D.perform_x_and_y_tilts(workspace, lab_detector)

    lab_detector_default_sd_m = move_info.lab_detector_default_sd_m
    x_shift = -coordinates[0]
    y_shift = -coordinates[1]

    z_shift = (lab_detector_z + lab_detector.z_translation_correction) - lab_detector_default_sd_m
    detector_name = lab_detector.detector_name
    offset = {CanonicalCoordinates.X: x_shift,
              CanonicalCoordinates.Y: y_shift,
              CanonicalCoordinates.Z: z_shift}
    move_component(workspace, offset, detector_name)
Exemplo n.º 5
0
    def _move_high_angle_bank(move_info, workspace, coordinates):
        # Get FRONT_DET_X, FRONT_DET_Z, FRONT_DET_ROT, REAR_DET_X

        hab_detector_x_tag = "Front_Det_X"
        hab_detector_z_tag = "Front_Det_Z"
        hab_detector_rotation_tag = "Front_Det_ROT"
        lab_detector_x_tag = "Rear_Det_X"

        log_names = [
            hab_detector_x_tag, hab_detector_z_tag, hab_detector_rotation_tag,
            lab_detector_x_tag
        ]
        log_types = [float, float, float, float]
        log_values = get_single_valued_logs_from_workspace(
            workspace,
            log_names,
            log_types,
            convert_from_millimeter_to_meter=True)

        hab_detector_x = move_info.hab_detector_x \
            if log_values[hab_detector_x_tag] is None else log_values[hab_detector_x_tag]

        hab_detector_z = move_info.hab_detector_z \
            if log_values[hab_detector_z_tag] is None else log_values[hab_detector_z_tag]

        hab_detector_rotation = move_info.hab_detector_rotation \
            if log_values[hab_detector_rotation_tag] is None else log_values[hab_detector_rotation_tag]
        # When we read in the FRONT_Det_ROT tag, we divided by 1000. (since we converted the others to meter)
        if log_values[hab_detector_rotation_tag] is not None:
            hab_detector_rotation *= 1000.

        lab_detector_x = move_info.lab_detector_x \
            if log_values[lab_detector_x_tag] is None else log_values[lab_detector_x_tag]

        # Fixed values
        hab_detector_radius = move_info.hab_detector_radius
        hab_detector_default_x_m = move_info.hab_detector_default_x_m
        hab_detector_default_sd_m = move_info.hab_detector_default_sd_m

        # Detector and name
        hab_detector = move_info.detectors[DetectorType.to_string(
            DetectorType.HAB)]
        detector_name = hab_detector.detector_name

        # Perform x and y tilt
        SANSMoveSANS2D.perform_x_and_y_tilts(workspace, hab_detector)

        # Perform rotation of around the Y-AXIS. This is more complicated as the high angle bank detector is
        # offset.
        rotation_angle = (-hab_detector_rotation -
                          hab_detector.rotation_correction)
        rotation_direction = {
            CanonicalCoordinates.X: 0.0,
            CanonicalCoordinates.Y: 1.0,
            CanonicalCoordinates.Z: 0.0
        }
        rotate_component(workspace, rotation_angle, rotation_direction,
                         detector_name)

        # Add translational corrections
        x = coordinates[0]
        y = coordinates[1]
        lab_detector = move_info.detectors[DetectorType.to_string(
            DetectorType.LAB)]
        rotation_in_radians = math.pi * (
            hab_detector_rotation + hab_detector.rotation_correction) / 180.

        x_shift = ((lab_detector_x + lab_detector.x_translation_correction -
                    hab_detector_x - hab_detector.x_translation_correction -
                    hab_detector.side_correction *
                    (1.0 - math.cos(rotation_in_radians)) +
                    (hab_detector_radius + hab_detector.radius_correction) *
                    (math.sin(rotation_in_radians))) -
                   hab_detector_default_x_m - x)
        y_shift = hab_detector.y_translation_correction - y
        z_shift = (hab_detector_z + hab_detector.z_translation_correction +
                   (hab_detector_radius + hab_detector.radius_correction) *
                   (1.0 - math.cos(rotation_in_radians)) -
                   hab_detector.side_correction *
                   math.sin(rotation_in_radians)) - hab_detector_default_sd_m

        offset = {
            CanonicalCoordinates.X: x_shift,
            CanonicalCoordinates.Y: y_shift,
            CanonicalCoordinates.Z: z_shift
        }

        move_component(workspace, offset, detector_name)
Exemplo n.º 6
0
    def _move_high_angle_bank(move_info, workspace, coordinates):
        # Get FRONT_DET_X, FRONT_DET_Z, FRONT_DET_ROT, REAR_DET_X

        hab_detector_x_tag = "Front_Det_X"
        hab_detector_z_tag = "Front_Det_Z"
        hab_detector_rotation_tag = "Front_Det_ROT"
        lab_detector_x_tag = "Rear_Det_X"

        log_names = [hab_detector_x_tag, hab_detector_z_tag, hab_detector_rotation_tag, lab_detector_x_tag]
        log_types = [float, float, float, float]
        log_values = get_single_valued_logs_from_workspace(workspace, log_names, log_types,
                                                           convert_from_millimeter_to_meter=True)

        hab_detector_x = move_info.hab_detector_x \
            if log_values[hab_detector_x_tag] is None else log_values[hab_detector_x_tag]

        hab_detector_z = move_info.hab_detector_z \
            if log_values[hab_detector_z_tag] is None else log_values[hab_detector_z_tag]

        hab_detector_rotation = move_info.hab_detector_rotation \
            if log_values[hab_detector_rotation_tag] is None else log_values[hab_detector_rotation_tag]
        # When we read in the FRONT_Det_ROT tag, we divided by 1000. (since we converted the others to meter)
        if log_values[hab_detector_rotation_tag] is not None:
            hab_detector_rotation *= 1000.

        lab_detector_x = move_info.lab_detector_x \
            if log_values[lab_detector_x_tag] is None else log_values[lab_detector_x_tag]

        # Fixed values
        hab_detector_radius = move_info.hab_detector_radius
        hab_detector_default_x_m = move_info.hab_detector_default_x_m
        hab_detector_default_sd_m = move_info.hab_detector_default_sd_m

        # Detector and name
        hab_detector = move_info.detectors[DetectorType.to_string(DetectorType.HAB)]
        detector_name = hab_detector.detector_name

        # Perform x and y tilt
        SANSMoveSANS2D.perform_x_and_y_tilts(workspace, hab_detector)

        # Perform rotation of around the Y-AXIS. This is more complicated as the high angle bank detector is
        # offset.
        rotation_angle = (-hab_detector_rotation - hab_detector.rotation_correction)
        rotation_direction = {CanonicalCoordinates.X: 0.0,
                              CanonicalCoordinates.Y: 1.0,
                              CanonicalCoordinates.Z: 0.0}
        rotate_component(workspace, rotation_angle, rotation_direction, detector_name)

        # Add translational corrections
        x = coordinates[0]
        y = coordinates[1]
        lab_detector = move_info.detectors[DetectorType.to_string(DetectorType.LAB)]
        rotation_in_radians = math.pi * (hab_detector_rotation + hab_detector.rotation_correction)/180.

        x_shift = ((lab_detector_x + lab_detector.x_translation_correction -
                    hab_detector_x - hab_detector.x_translation_correction -
                    hab_detector.side_correction*(1.0 - math.cos(rotation_in_radians)) +
                    (hab_detector_radius + hab_detector.radius_correction)*(math.sin(rotation_in_radians))) -
                   hab_detector_default_x_m - x)
        y_shift = hab_detector.y_translation_correction - y
        z_shift = (hab_detector_z + hab_detector.z_translation_correction +
                   (hab_detector_radius + hab_detector.radius_correction) * (1.0 - math.cos(rotation_in_radians)) -
                   hab_detector.side_correction * math.sin(rotation_in_radians)) - hab_detector_default_sd_m

        offset = {CanonicalCoordinates.X: x_shift,
                  CanonicalCoordinates.Y: y_shift,
                  CanonicalCoordinates.Z: z_shift}

        move_component(workspace, offset, detector_name)