コード例 #1
0
    def _process_detector_offsets(self, command):
        detector_type = command.values[0]
        x = command.values[1]
        y = command.values[2]
        z = command.values[3]
        rotation = command.values[4]
        radius = command.values[5]
        side = command.values[6]
        x_tilt = command.values[7]
        y_tilt = command.values[8]

        # Set the offsets
        new_state_entries = {DetectorId.correction_x: single_entry_with_detector(entry=x, detector_type=detector_type),
                             DetectorId.correction_y: single_entry_with_detector(entry=y, detector_type=detector_type),
                             DetectorId.correction_z: single_entry_with_detector(entry=z, detector_type=detector_type),
                             DetectorId.correction_rotation:
                                 single_entry_with_detector(entry=rotation, detector_type=detector_type),
                             DetectorId.correction_radius:
                                 single_entry_with_detector(entry=radius, detector_type=detector_type),
                             DetectorId.correction_translation:
                                 single_entry_with_detector(entry=side, detector_type=detector_type),
                             DetectorId.correction_x_tilt:
                                 single_entry_with_detector(entry=x_tilt, detector_type=detector_type),
                             DetectorId.correction_y_tilt:
                                 single_entry_with_detector(entry=y_tilt, detector_type=detector_type),
                             }
        self.add_to_processed_state_settings(new_state_entries)
コード例 #2
0
    def _process_detector_offsets(self, command):
        detector_type = command.values[0]
        x = command.values[1]
        y = command.values[2]
        z = command.values[3]
        rotation = command.values[4]
        radius = command.values[5]
        side = command.values[6]
        x_tilt = command.values[7]
        y_tilt = command.values[8]

        # Set the offsets
        new_state_entries = {
            DetectorId.CORRECTION_X:
            single_entry_with_detector(entry=x, detector_type=detector_type),
            DetectorId.CORRECTION_Y:
            single_entry_with_detector(entry=y, detector_type=detector_type),
            DetectorId.CORRECTION_Z:
            single_entry_with_detector(entry=z, detector_type=detector_type),
            DetectorId.CORRECTION_ROTATION:
            single_entry_with_detector(entry=rotation,
                                       detector_type=detector_type),
            DetectorId.CORRECTION_RADIUS:
            single_entry_with_detector(entry=radius,
                                       detector_type=detector_type),
            DetectorId.CORRECTION_TRANSLATION:
            single_entry_with_detector(entry=side,
                                       detector_type=detector_type),
            DetectorId.CORRECTION_X_TILT:
            single_entry_with_detector(entry=x_tilt,
                                       detector_type=detector_type),
            DetectorId.CORRECTION_Y_TILT:
            single_entry_with_detector(entry=y_tilt,
                                       detector_type=detector_type),
        }
        self.add_to_processed_state_settings(new_state_entries)
コード例 #3
0
    def test_that_can_read_user_file(self):
        # Arrange
        user_file_path = create_user_file(sample_user_file)
        reader = UserFileReader(user_file_path)

        # Act
        output = reader.read_user_file()

        # Assert
        expected_values = {LimitsId.wavelength: [simple_range(start=1.5, stop=12.5, step=0.125,
                                                              step_type=RangeStepType.Lin)],
                           LimitsId.q: [q_rebin_values(min=.001, max=.2, rebin_string="0.001,0.001,0.0126,-0.08,0.2")],
                           LimitsId.qxy: [simple_range(0, 0.05, 0.001, RangeStepType.Lin)],
                           BackId.single_monitors: [back_single_monitor_entry(1, 35000, 65000),
                                                    back_single_monitor_entry(2, 85000, 98000)],
                           DetectorId.reduction_mode: [ISISReductionMode.LAB],
                           GravityId.on_off: [True],
                           FitId.general: [fit_general(start=1.5, stop=12.5, fit_type=FitType.Logarithmic,
                                                       data_type=None, polynomial_order=0)],
                           MaskId.vertical_single_strip_mask: [single_entry_with_detector(191, DetectorType.LAB),
                                                               single_entry_with_detector(191, DetectorType.HAB),
                                                               single_entry_with_detector(0, DetectorType.LAB),
                                                               single_entry_with_detector(0, DetectorType.HAB)],
                           MaskId.horizontal_single_strip_mask: [single_entry_with_detector(0, DetectorType.LAB),
                                                                 single_entry_with_detector(0, DetectorType.HAB)],
                           MaskId.horizontal_range_strip_mask: [range_entry_with_detector(190, 191, DetectorType.LAB),
                                                                range_entry_with_detector(167, 172, DetectorType.LAB),
                                                                range_entry_with_detector(190, 191, DetectorType.HAB),
                                                                range_entry_with_detector(156, 159, DetectorType.HAB)
                                                                ],
                           MaskId.time: [range_entry_with_detector(17500, 22000, None)],
                           MonId.direct: [monitor_file("DIRECTM1_15785_12m_31Oct12_v12.dat", DetectorType.LAB),
                                          monitor_file("DIRECTM1_15785_12m_31Oct12_v12.dat", DetectorType.HAB)],
                           MonId.spectrum: [monitor_spectrum(1, True, True), monitor_spectrum(1, False, True)],
                           SetId.centre: [position_entry(155.45, -169.6, DetectorType.LAB)],
                           SetId.scales: [set_scales_entry(0.074, 1.0, 1.0, 1.0, 1.0)],
                           SampleId.offset: [53.0],
                           DetectorId.correction_x: [single_entry_with_detector(-16.0, DetectorType.LAB),
                                                     single_entry_with_detector(-44.0, DetectorType.HAB)],
                           DetectorId.correction_y: [single_entry_with_detector(-20.0, DetectorType.HAB)],
                           DetectorId.correction_z: [single_entry_with_detector(47.0, DetectorType.LAB),
                                                     single_entry_with_detector(47.0, DetectorType.HAB)],
                           DetectorId.correction_rotation: [single_entry_with_detector(0.0, DetectorType.HAB)],
                           LimitsId.events_binning: ["7000.0,500.0,60000.0"],
                           MaskId.clear_detector_mask: [True],
                           MaskId.clear_time_mask: [True],
                           LimitsId.radius: [range_entry(12, 15)],
                           TransId.spec_shift: [-70.],
                           PrintId.print_line: ["for changer"],
                           BackId.all_monitors: [range_entry(start=3500, stop=4500)],
                           FitId.monitor_times: [range_entry(start=1000, stop=2000)],
                           TransId.spec: [4],
                           BackId.trans: [range_entry(start=123, stop=466)],
                           TransId.radius: [7.0],
                           TransId.roi: ["test.xml", "test2.xml"],
                           TransId.mask: ["test3.xml", "test4.xml"],
                           SampleId.path: [True],
                           LimitsId.radius_cut: [200.0],
                           LimitsId.wavelength_cut: [8.0],
                           QResolutionId.on: [True],
                           QResolutionId.delta_r: [11.],
                           QResolutionId.collimation_length: [12.],
                           QResolutionId.a1: [13.],
                           QResolutionId.a2: [14.],
                           QResolutionId.moderator: ["moderator_rkh_file.txt"],
                           TubeCalibrationFileId.file: ["TUBE_SANS2D_BOTH_31681_25Sept15.nxs"]}

        self.assertEqual(len(expected_values), len(output))
        for key, value in list(expected_values.items()):
            self.assertTrue(key in output)
            self.assertEqual(len(output[key]), len(value))
            elements = output[key]
            # Make sure that the different entries are sorted
            UserFileReaderTest._sort_list(elements)
            UserFileReaderTest._sort_list(value)
            self.assertEqual(elements, value, "{} is not {}".format(elements, value))

        # clean up
        if os.path.exists(user_file_path):
            os.remove(user_file_path)
コード例 #4
0
    def test_that_can_read_user_file(self):
        # Arrange
        user_file_path = create_user_file(sample_user_file)
        reader = UserFileReader(user_file_path)

        # Act
        output = reader.read_user_file()

        # Assert
        expected_values = {
            LimitsId.wavelength: [
                simple_range(start=1.5,
                             stop=12.5,
                             step=0.125,
                             step_type=RangeStepType.Lin)
            ],
            LimitsId.q: [
                q_rebin_values(min=.001,
                               max=.2,
                               rebin_string="0.001,0.001,0.0126,-0.08,0.2")
            ],
            LimitsId.qxy: [simple_range(0, 0.05, 0.001, RangeStepType.Lin)],
            BackId.single_monitors: [
                back_single_monitor_entry(1, 35000, 65000),
                back_single_monitor_entry(2, 85000, 98000)
            ],
            DetectorId.reduction_mode: [ISISReductionMode.LAB],
            GravityId.on_off: [True],
            FitId.general: [
                fit_general(start=1.5,
                            stop=12.5,
                            fit_type=FitType.Logarithmic,
                            data_type=None,
                            polynomial_order=0)
            ],
            MaskId.vertical_single_strip_mask: [
                single_entry_with_detector(191, DetectorType.LAB),
                single_entry_with_detector(191, DetectorType.HAB),
                single_entry_with_detector(0, DetectorType.LAB),
                single_entry_with_detector(0, DetectorType.HAB)
            ],
            MaskId.horizontal_single_strip_mask: [
                single_entry_with_detector(0, DetectorType.LAB),
                single_entry_with_detector(0, DetectorType.HAB)
            ],
            MaskId.horizontal_range_strip_mask: [
                range_entry_with_detector(190, 191, DetectorType.LAB),
                range_entry_with_detector(167, 172, DetectorType.LAB),
                range_entry_with_detector(190, 191, DetectorType.HAB),
                range_entry_with_detector(156, 159, DetectorType.HAB)
            ],
            MaskId.time: [range_entry_with_detector(17500, 22000, None)],
            MonId.direct: [
                monitor_file("DIRECTM1_15785_12m_31Oct12_v12.dat",
                             DetectorType.LAB),
                monitor_file("DIRECTM1_15785_12m_31Oct12_v12.dat",
                             DetectorType.HAB)
            ],
            MonId.spectrum: [
                monitor_spectrum(1, True, True),
                monitor_spectrum(1, False, True)
            ],
            SetId.centre: [position_entry(155.45, -169.6, DetectorType.LAB)],
            SetId.scales: [set_scales_entry(0.074, 1.0, 1.0, 1.0, 1.0)],
            SampleId.offset: [53.0],
            DetectorId.correction_x: [
                single_entry_with_detector(-16.0, DetectorType.LAB),
                single_entry_with_detector(-44.0, DetectorType.HAB)
            ],
            DetectorId.correction_y:
            [single_entry_with_detector(-20.0, DetectorType.HAB)],
            DetectorId.correction_z: [
                single_entry_with_detector(47.0, DetectorType.LAB),
                single_entry_with_detector(47.0, DetectorType.HAB)
            ],
            DetectorId.correction_rotation:
            [single_entry_with_detector(0.0, DetectorType.HAB)],
            LimitsId.events_binning: ["7000.0,500.0,60000.0"],
            MaskId.clear_detector_mask: [True],
            MaskId.clear_time_mask: [True],
            LimitsId.radius: [range_entry(12, 15)],
            TransId.spec_shift: [-70.],
            PrintId.print_line: ["for changer"],
            BackId.all_monitors: [range_entry(start=3500, stop=4500)],
            FitId.monitor_times: [range_entry(start=1000, stop=2000)],
            TransId.spec: [4],
            BackId.trans: [range_entry(start=123, stop=466)],
            TransId.radius: [7.0],
            TransId.roi: ["test.xml", "test2.xml"],
            TransId.mask: ["test3.xml", "test4.xml"],
            SampleId.path: [True],
            LimitsId.radius_cut: [200.0],
            LimitsId.wavelength_cut: [8.0],
            QResolutionId.on: [True],
            QResolutionId.delta_r: [11.],
            QResolutionId.collimation_length: [12.],
            QResolutionId.a1: [13.],
            QResolutionId.a2: [14.],
            QResolutionId.moderator: ["moderator_rkh_file.txt"],
            TubeCalibrationFileId.file:
            ["TUBE_SANS2D_BOTH_31681_25Sept15.nxs"]
        }

        self.assertTrue(len(expected_values) == len(output))
        for key, value in list(expected_values.items()):
            self.assertTrue(key in output)
            self.assertTrue(len(output[key]) == len(value))
            elements = output[key]
            # Make sure that the different entries are sorted
            UserFileReaderTest._sort_list(elements)
            UserFileReaderTest._sort_list(value)
            self.assertTrue(elements == value)

        # clean up
        if os.path.exists(user_file_path):
            os.remove(user_file_path)
コード例 #5
0
    def test_that_can_read_user_file(self):
        # Arrange
        user_file_path = create_user_file(sample_user_file)
        reader = UserFileReader(user_file_path)

        # Act
        output = reader.read_user_file()

        # Assert
        expected_values = {
            LimitsId.WAVELENGTH: [
                simple_range(start=1.5,
                             stop=12.5,
                             step=0.125,
                             step_type=RangeStepType.LIN)
            ],
            LimitsId.Q: [
                q_rebin_values(min=.001,
                               max=.2,
                               rebin_string="0.001,0.001,0.0126,-0.08,0.2")
            ],
            LimitsId.QXY: [simple_range(0, 0.05, 0.001, RangeStepType.LIN)],
            BackId.SINGLE_MONITORS: [
                back_single_monitor_entry(1, 35000, 65000),
                back_single_monitor_entry(2, 85000, 98000)
            ],
            DetectorId.REDUCTION_MODE: [ReductionMode.LAB],
            GravityId.ON_OFF: [True],
            FitId.GENERAL: [
                fit_general(start=1.5,
                            stop=12.5,
                            fit_type=FitType.LOGARITHMIC,
                            data_type=None,
                            polynomial_order=0)
            ],
            MaskId.VERTICAL_SINGLE_STRIP_MASK: [
                single_entry_with_detector(191, DetectorType.LAB),
                single_entry_with_detector(191, DetectorType.HAB),
                single_entry_with_detector(0, DetectorType.LAB),
                single_entry_with_detector(0, DetectorType.HAB)
            ],
            MaskId.HORIZONTAL_SINGLE_STRIP_MASK: [
                single_entry_with_detector(0, DetectorType.LAB),
                single_entry_with_detector(0, DetectorType.HAB)
            ],
            MaskId.HORIZONTAL_RANGE_STRIP_MASK: [
                range_entry_with_detector(190, 191, DetectorType.LAB),
                range_entry_with_detector(167, 172, DetectorType.LAB),
                range_entry_with_detector(190, 191, DetectorType.HAB),
                range_entry_with_detector(156, 159, DetectorType.HAB)
            ],
            MaskId.TIME: [range_entry_with_detector(17500, 22000, None)],
            MonId.DIRECT: [
                monitor_file("DIRECTM1_15785_12m_31Oct12_v12.dat",
                             DetectorType.LAB),
                monitor_file("DIRECTM1_15785_12m_31Oct12_v12.dat",
                             DetectorType.HAB)
            ],
            MonId.SPECTRUM: [
                monitor_spectrum(1, True, True),
                monitor_spectrum(1, False, True)
            ],
            SetId.CENTRE: [position_entry(155.45, -169.6, DetectorType.LAB)],
            SetId.SCALES: [set_scales_entry(0.074, 1.0, 1.0, 1.0, 1.0)],
            SampleId.OFFSET: [53.0],
            DetectorId.CORRECTION_X: [
                single_entry_with_detector(-16.0, DetectorType.LAB),
                single_entry_with_detector(-44.0, DetectorType.HAB)
            ],
            DetectorId.CORRECTION_Y:
            [single_entry_with_detector(-20.0, DetectorType.HAB)],
            DetectorId.CORRECTION_Z: [
                single_entry_with_detector(47.0, DetectorType.LAB),
                single_entry_with_detector(47.0, DetectorType.HAB)
            ],
            DetectorId.CORRECTION_ROTATION:
            [single_entry_with_detector(0.0, DetectorType.HAB)],
            LimitsId.EVENTS_BINNING: ["7000.0,500.0,60000.0"],
            MaskId.CLEAR_DETECTOR_MASK: [True],
            MaskId.CLEAR_TIME_MASK: [True],
            LimitsId.RADIUS: [range_entry(12, 15)],
            TransId.SPEC_4_SHIFT: [-70.],
            PrintId.PRINT_LINE: ["for changer"],
            BackId.ALL_MONITORS: [range_entry(start=3500, stop=4500)],
            FitId.MONITOR_TIMES: [range_entry(start=1000, stop=2000)],
            TransId.SPEC: [4],
            BackId.TRANS: [range_entry(start=123, stop=466)],
            TransId.RADIUS: [7.0],
            TransId.ROI: ["test.xml", "test2.xml"],
            TransId.MASK: ["test3.xml", "test4.xml"],
            SampleId.PATH: [True],
            LimitsId.RADIUS_CUT: [200.0],
            LimitsId.WAVELENGTH_CUT: [8.0],
            QResolutionId.ON: [True],
            QResolutionId.DELTA_R: [11.],
            QResolutionId.COLLIMATION_LENGTH: [12.],
            QResolutionId.A1: [13.],
            QResolutionId.A2: [14.],
            QResolutionId.MODERATOR: ["moderator_rkh_file.txt"],
            TubeCalibrationFileId.FILE:
            ["TUBE_SANS2D_BOTH_31681_25Sept15.nxs"]
        }

        self.assertEqual(len(expected_values), len(output))
        for key, value in list(expected_values.items()):
            self.assertTrue(key in output)
            self.assertEqual(len(output[key]), len(value))
            elements = output[key]
            # Make sure that the different entries are sorted
            UserFileReaderTest._sort_list(elements)
            UserFileReaderTest._sort_list(value)
            self.assertEqual(elements, value,
                             "{} is not {}".format(elements, value))

        # clean up
        if os.path.exists(user_file_path):
            os.remove(user_file_path)