当前位置: 首页>>代码示例>>Python>>正文


Python data.get_data_builder函数代码示例

本文整理汇总了Python中sans.state.data.get_data_builder函数的典型用法代码示例。如果您正苦于以下问题:Python get_data_builder函数的具体用法?Python get_data_builder怎么用?Python get_data_builder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_data_builder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_data_state

    def _get_data_state(self):
        # Get the data commands
        data_commands = self._get_data_commands()
        data_elements = self._get_elements_with_key(DataCommandId.sample_scatter, data_commands)
        data_element = data_elements[-1]
        file_name = data_element.file_name
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information(file_name)

        # Build the state data
        data_builder = get_data_builder(self._facility, file_information)
        self._set_data_element(data_builder.set_sample_scatter, data_builder.set_sample_scatter_period,
                               DataCommandId.sample_scatter, data_commands)
        self._set_data_element(data_builder.set_sample_transmission, data_builder.set_sample_transmission_period,
                               DataCommandId.sample_transmission, data_commands)
        self._set_data_element(data_builder.set_sample_direct, data_builder.set_sample_direct_period,
                               DataCommandId.sample_direct, data_commands)
        self._set_data_element(data_builder.set_can_scatter, data_builder.set_can_scatter_period,
                               DataCommandId.can_scatter, data_commands)
        self._set_data_element(data_builder.set_can_transmission, data_builder.set_can_transmission_period,
                               DataCommandId.can_transmission, data_commands)
        self._set_data_element(data_builder.set_can_direct, data_builder.set_can_direct_period,
                               DataCommandId.can_direct, data_commands)

        return data_builder.build()
开发者ID:mantidproject,项目名称:mantid,代码行数:25,代码来源:command_interface_state_director.py

示例2: test_that_produces_correct_workspace_for_SANS2D

    def test_that_produces_correct_workspace_for_SANS2D(self):
        # Arrange
        # Build the data information
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information("SANS2D00034484")
        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter("SANS2D00034484")
        data_builder.set_calibration("TUBE_SANS2D_BOTH_31681_25Sept15.nxs")
        data_state = data_builder.build()

        # Get the rest of the state from the user file
        user_file_director = StateDirectorISIS(data_state, file_information)
        user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt")

        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        # COMPATIBILITY BEGIN -- Remove when appropriate
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        # Since we are dealing with event based data but we want to compare it with histogram data from the
        # old reduction system we need to enable the compatibility mode
        user_file_director.set_compatibility_builder_use_compatibility_mode(True)
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        # COMPATIBILITY END
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

        # Construct the final state
        state = user_file_director.construct()

        # Act
        output_workspaces = run_integral('', True, IntegralEnum.Horizontal, DetectorType.LAB, state)
        self.assertEqual(len(output_workspaces), 1)
        # Evaluate it up to a defined point
        reference_file_name = "SANS2D_ws_centred_diagnostic_reference.nxs"
        self._compare_workspace(output_workspaces[0], reference_file_name)
开发者ID:mantidproject,项目名称:mantid,代码行数:33,代码来源:SANSDiagnosticPageTest.py

示例3: test_stat_can_be_crated_from_valid_user_file_and_later_on_reset

    def test_stat_can_be_crated_from_valid_user_file_and_later_on_reset(self):
        # Arrange
        data_builder = get_data_builder(SANSFacility.ISIS)
        data_builder.set_sample_scatter("SANS2D00022024")
        data_builder.set_sample_scatter_period(3)
        data_state = data_builder.build()

        director = StateDirectorISIS(data_state)
        user_file_path = create_user_file(sample_user_file)
        director.set_user_file(user_file_path)

        # Set additional items
        director.set_mask_builder_radius_min(0.001298)
        director.set_mask_builder_radius_max(0.003298)
        director.set_scale_builder_width(1.)
        director.set_scale_builder_height(1.5)
        director.set_scale_builder_thickness(12.)
        director.set_scale_builder_shape(SampleShape.Cuboid)

        # Act
        state = director.construct()

        # Assert
        self.assertTrue(state.mask.radius_min == 0.001298)
        self.assertTrue(state.mask.radius_max == 0.003298)
        self.assertTrue(state.scale.width == 1.)
        self.assertTrue(state.scale.height == 1.5)
        self.assertTrue(state.scale.thickness == 12.)
        self.assertTrue(state.scale.shape is SampleShape.Cuboid)

        # clean up
        if os.path.exists(user_file_path):
            os.remove(user_file_path)
开发者ID:DanNixon,项目名称:mantid,代码行数:33,代码来源:state_director_test.py

示例4: test_that_wavelength_and_pixel_adjustment_state_can_be_built

    def test_that_wavelength_and_pixel_adjustment_state_can_be_built(self):
        # Arrange
        facility = SANSFacility.ISIS
        file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044)
        data_builder = get_data_builder(facility, file_information)
        data_builder.set_sample_scatter("LOQ74044")
        data_info = data_builder.build()

        # Act
        builder = get_wavelength_and_pixel_adjustment_builder(data_info)
        self.assertTrue(builder)

        builder.set_HAB_pixel_adjustment_file("test")
        builder.set_HAB_wavelength_adjustment_file("test2")
        builder.set_wavelength_low([1.5])
        builder.set_wavelength_high([2.7])
        builder.set_wavelength_step(0.5)
        builder.set_wavelength_step_type(RangeStepType.Lin)

        state = builder.build()

        # Assert
        self.assertTrue(state.adjustment_files[DetectorType.to_string(
                                                                     DetectorType.HAB)].pixel_adjustment_file == "test")
        self.assertTrue(state.adjustment_files[DetectorType.to_string(
                                                              DetectorType.HAB)].wavelength_adjustment_file == "test2")
        self.assertTrue(state.wavelength_low == [1.5])
        self.assertTrue(state.wavelength_high == [2.7])
        self.assertTrue(state.wavelength_step == 0.5)
        self.assertTrue(state.wavelength_step_type is RangeStepType.Lin)
开发者ID:mantidproject,项目名称:mantid,代码行数:30,代码来源:wavelength_and_pixel_adjustment_test.py

示例5: test_that_slice_event_state_can_be_built

    def test_that_slice_event_state_can_be_built(self):
        # Arrange
        facility = SANSFacility.ISIS
        file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044)
        data_builder = get_data_builder(facility, file_information)
        data_builder.set_sample_scatter("LOQ74044")
        data_info = data_builder.build()

        # Act
        builder = get_slice_event_builder(data_info)
        self.assertTrue(builder)

        start_time = [0.1, 1.3]
        end_time = [0.2, 1.6]
        builder.set_start_time(start_time)
        builder.set_end_time(end_time)

        # Assert
        state = builder.build()
        self.assertTrue(len(state.start_time) == 2)
        self.assertTrue(state.start_time[0] == start_time[0])
        self.assertTrue(state.start_time[1] == start_time[1])

        self.assertTrue(len(state.end_time) == 2)
        self.assertTrue(state.end_time[0] == end_time[0])
        self.assertTrue(state.end_time[1] == end_time[1])
开发者ID:mantidproject,项目名称:mantid,代码行数:26,代码来源:slice_event_test.py

示例6: test_state_can_be_created_from_valid_user_file_with_data_information

    def test_state_can_be_created_from_valid_user_file_with_data_information(self):
        # Arrange
        data_builder = get_data_builder(SANSFacility.ISIS)
        data_builder.set_sample_scatter("SANS2D00022024")
        data_builder.set_sample_scatter_period(3)
        data_state = data_builder.build()

        director = StateDirectorISIS(data_state)
        user_file_path = create_user_file(sample_user_file)

        director.set_user_file(user_file_path)
        state = director.construct()

        # Assert
        self._assert_data(state)
        self._assert_move(state)
        self._assert_mask(state)
        self._assert_reduction(state)
        self._assert_wavelength(state)
        self._assert_scale(state)
        self._assert_adjustment(state)
        self._assert_convert_to_q(state)

        # clean up
        if os.path.exists(user_file_path):
            os.remove(user_file_path)
开发者ID:DanNixon,项目名称:mantid,代码行数:26,代码来源:state_director_test.py

示例7: test_that_divide_uses_settings_from_workspace

    def test_that_divide_uses_settings_from_workspace(self):
        # Arrange
        facility = SANSFacility.ISIS
        data_builder = get_data_builder(facility)
        data_builder.set_sample_scatter("SANS2D00022024")
        data_state = data_builder.build()

        scale_builder = get_scale_builder(data_state)
        scale_state = scale_builder.build()

        test_director = TestDirector()
        test_director.set_states(scale_state=scale_state, data_state=data_state)
        state = test_director.construct()

        divide_factory = DivideByVolumeFactory()
        divider = divide_factory.create_divide_by_volume(state)

        # Apply the settings from the SANS2D00022024 workspace
        width = 8.
        height = 8.
        thickness = 1.
        shape = 3

        workspace = ScaleHelperTest._get_workspace(width, height, thickness, shape)

        # Act
        output_workspace = divider.divide_by_volume(workspace, scale_state)

        # Assert
        expected_volume = thickness * math.pi * math.pow(width, 2) / 4.0
        expected_value = 0.3 / expected_volume
        data_y = output_workspace.dataY(0)
        self.assertEqual(data_y[0], expected_value)
开发者ID:DanNixon,项目名称:mantid,代码行数:33,代码来源:scale_helper_test.py

示例8: test_that_divide_uses_settings_from_state_if_they_are_set

    def test_that_divide_uses_settings_from_state_if_they_are_set(self):
        # Arrange
        facility = SANSFacility.ISIS
        data_builder = get_data_builder(facility)
        data_builder.set_sample_scatter("SANS2D00022024")
        data_state = data_builder.build()

        scale_builder = get_scale_builder(data_state)
        width = 10.
        height = 5.
        thickness = 2.
        scale_builder.set_shape(SampleShape.CylinderAxisAlong)
        scale_builder.set_thickness(thickness)
        scale_builder.set_width(width)
        scale_builder.set_height(height)
        scale_state = scale_builder.build()

        test_director = TestDirector()
        test_director.set_states(scale_state=scale_state, data_state=data_state)
        state = test_director.construct()

        divide_factory = DivideByVolumeFactory()
        divider = divide_factory.create_divide_by_volume(state)

        workspace = ScaleHelperTest._get_workspace()

        # Act
        output_workspace = divider.divide_by_volume(workspace, scale_state)

        # Assert
        expected_volume = thickness * math.pi * math.pow(width, 2) / 4.0
        expected_value = 0.3 / expected_volume
        data_y = output_workspace.dataY(0)
        self.assertEqual(data_y[0], expected_value)
开发者ID:DanNixon,项目名称:mantid,代码行数:34,代码来源:scale_helper_test.py

示例9: test_that_correct_scale_strategy_is_selected_for_loq_2

    def test_that_correct_scale_strategy_is_selected_for_loq_2(self):
        # Arrange
        facility = SANSFacility.ISIS
        data_builder = get_data_builder(facility)
        data_builder.set_sample_scatter("LOQ74044")
        data_state = data_builder.build()

        scale_builder = get_scale_builder(data_state)
        scale_builder.set_scale(2.4)
        scale_state = scale_builder.build()

        test_director = TestDirector()
        test_director.set_states(scale_state=scale_state, data_state=data_state)
        state_loq = test_director.construct()

        absolute_multiply_factory = MultiplyByAbsoluteScaleFactory()
        multiplier = absolute_multiply_factory.create_multiply_by_absolute(state_loq)

        workspace = self._get_workspace()

        # Act
        output_workspace = multiplier.multiply_by_absolute_scale(workspace, state_loq.scale)

        # Assert
        expected_value = 0.3 * 2.4 / math.pi * 100.
        data_y = output_workspace.dataY(0)
        self.assertEqual(data_y[0], expected_value)
开发者ID:DanNixon,项目名称:mantid,代码行数:27,代码来源:scale_helper_test.py

示例10: test_that_reduction_state_can_be_built

    def test_that_reduction_state_can_be_built(self):
        # Arrange
        facility = SANSFacility.ISIS
        file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044)
        data_builder = get_data_builder(facility, file_information)
        data_builder.set_sample_scatter("LOQ74044")
        data_info = data_builder.build()

        # Act
        builder = get_save_builder(data_info)
        self.assertTrue(builder)

        user_specified_output_name = "test_file_name"
        zero_free_correction = True
        file_format = [SaveType.Nexus, SaveType.CanSAS]

        builder.set_user_specified_output_name(user_specified_output_name)
        builder.set_zero_free_correction(zero_free_correction)
        builder.set_file_format(file_format)
        state = builder.build()

        # Assert
        self.assertTrue(state.user_specified_output_name == user_specified_output_name)
        self.assertTrue(state.zero_free_correction == zero_free_correction)
        self.assertTrue(state.file_format == file_format)
开发者ID:mantidproject,项目名称:mantid,代码行数:25,代码来源:save_test.py

示例11: test_batch_reduction_on_multiperiod_file

    def test_batch_reduction_on_multiperiod_file(self):
        # Arrange
        # Build the data information
        data_builder = get_data_builder(SANSFacility.ISIS)
        data_builder.set_sample_scatter("SANS2D0005512")

        data_info = data_builder.build()

        # Get the rest of the state from the user file
        user_file_director = StateDirectorISIS(data_info)
        user_file_director.set_user_file("MASKSANS2Doptions.091A")
        # Set the reduction mode to LAB
        user_file_director.set_reduction_builder_reduction_mode(ISISReductionMode.LAB)
        state = user_file_director.construct()

        # Act
        states = [state]
        self._run_batch_reduction(states, use_optimizations=False)

        # Assert
        # We only assert that the expected workspaces exist on the ADS
        expected_workspaces = ["5512p1rear_1D_2.0_14.0Phi-45.0_45.0", "5512p2rear_1D_2.0_14.0Phi-45.0_45.0",
                               "5512p3rear_1D_2.0_14.0Phi-45.0_45.0", "5512p4rear_1D_2.0_14.0Phi-45.0_45.0",
                               "5512p5rear_1D_2.0_14.0Phi-45.0_45.0", "5512p6rear_1D_2.0_14.0Phi-45.0_45.0",
                               "5512p7rear_1D_2.0_14.0Phi-45.0_45.0", "5512p8rear_1D_2.0_14.0Phi-45.0_45.0",
                               "5512p9rear_1D_2.0_14.0Phi-45.0_45.0", "5512p10rear_1D_2.0_14.0Phi-45.0_45.0",
                               "5512p11rear_1D_2.0_14.0Phi-45.0_45.0", "5512p12rear_1D_2.0_14.0Phi-45.0_45.0",
                               "5512p13rear_1D_2.0_14.0Phi-45.0_45.0"]
        for element in expected_workspaces:
            self.assertTrue(AnalysisDataService.doesExist(element))

        # Clean up
        for element in expected_workspaces:
            AnalysisDataService.remove(element)
开发者ID:DanNixon,项目名称:mantid,代码行数:34,代码来源:SANSBatchReductionTest.py

示例12: test_that_slice_event_state_can_be_built

    def test_that_slice_event_state_can_be_built(self):
        # Arrange
        facility = SANSFacility.ISIS
        file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044)
        data_builder = get_data_builder(facility, file_information)
        data_builder.set_sample_scatter("LOQ74044")
        data_info = data_builder.build()

        # Act
        builder = get_wavelength_builder(data_info)
        self.assertTrue(builder)

        builder.set_wavelength_low([10.0])
        builder.set_wavelength_high([20.0])
        builder.set_wavelength_step(3.0)
        builder.set_wavelength_step_type(RangeStepType.Lin)
        builder.set_rebin_type(RebinType.Rebin)

        # Assert
        state = builder.build()

        self.assertTrue(state.wavelength_low == [10.0])
        self.assertTrue(state.wavelength_high == [20.0])
        self.assertTrue(state.wavelength_step_type is RangeStepType.Lin)
        self.assertTrue(state.rebin_type is RebinType.Rebin)
开发者ID:mantidproject,项目名称:mantid,代码行数:25,代码来源:wavelength_test.py

示例13: test_that_reduction_state_can_be_built

    def test_that_reduction_state_can_be_built(self):
        # Arrange
        facility = SANSFacility.ISIS
        file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044)
        data_builder = get_data_builder(facility, file_information)
        data_builder.set_sample_scatter("LOQ74044")
        data_info = data_builder.build()

        # Act
        builder = get_adjustment_builder(data_info)
        self.assertTrue(builder)

        builder.set_calculate_transmission(MockStateCalculateTransmission())
        builder.set_normalize_to_monitor(MockStateNormalizeToMonitor())
        builder.set_wavelength_and_pixel_adjustment(MockStateWavelengthAndPixelAdjustment())
        builder.set_wide_angle_correction(False)
        state = builder.build()

        # # Assert
        self.assertTrue(not state.wide_angle_correction)
        try:
            state.validate()
            is_valid = True
        except ValueError:
            is_valid = False
        self.assertTrue(is_valid)
开发者ID:mantidproject,项目名称:mantid,代码行数:26,代码来源:adjustment_test.py

示例14: test_that_cylinder_masking_is_applied

    def test_that_cylinder_masking_is_applied(self):
        # Arrange
        data_builder = get_data_builder(SANSFacility.ISIS)
        data_builder.set_sample_scatter("SANS2D00028827")
        data_info = data_builder.build()
        mask_builder = get_mask_builder(data_info)

        # Radius Mask
        radius_min = 0.01
        radius_max = 10.

        expected_spectra = []
        expected_spectra.extend([30469, 30470, 30471, 30472, 30473, 30474, 30475, 30476, 30477, 30980,
                                 30981, 30982, 30983, 30984, 30985, 30986, 30987, 30988])
        mask_builder.set_radius_min(radius_min)
        mask_builder.set_radius_max(radius_max)

        mask_info = mask_builder.build()

        test_director = TestDirector()
        test_director.set_states(data_state=data_info, mask_state=mask_info)
        state = test_director.construct()

        workspace = self._load_workspace(state, move_workspace=False)

        # Act
        workspace = self._run_mask(state, workspace, "LAB")

        # Assert
        self._do_assert(workspace, expected_spectra)
开发者ID:DanNixon,项目名称:mantid,代码行数:30,代码来源:SANSMaskWorkspaceTest.py

示例15: _get_sample_state

    def _get_sample_state(q_min=1., q_max=2., q_step=0.1, q_step_type=RangeStepType.Lin,
                          q_xy_max=None, q_xy_step=None, q_xy_step_type=None,
                          use_gravity=False, dim=ReductionDimensionality.OneDim):
        # Arrange
        facility = SANSFacility.ISIS
        data_builder = get_data_builder(facility)
        data_builder.set_sample_scatter("LOQ74044")
        data_state = data_builder.build()

        convert_to_q_builder = get_convert_to_q_builder(data_state)
        convert_to_q_builder.set_reduction_dimensionality(dim)
        convert_to_q_builder.set_use_gravity(use_gravity)
        convert_to_q_builder.set_radius_cutoff(0.002)
        convert_to_q_builder.set_wavelength_cutoff(2.)
        convert_to_q_builder.set_q_min(q_min)
        convert_to_q_builder.set_q_max(q_max)
        prefix = 1. if q_step_type is RangeStepType.Lin else -1.
        q_step *= prefix
        rebin_string = str(q_min) + "," + str(q_step) + "," + str(q_max)
        convert_to_q_builder.set_q_1d_rebin_string(rebin_string)
        if q_xy_max is not None:
            convert_to_q_builder.set_q_xy_max(q_xy_max)
        if q_xy_step is not None:
            convert_to_q_builder.set_q_xy_step(q_xy_step)
        if q_xy_step_type is not None:
            convert_to_q_builder.set_q_xy_step_type(q_xy_step_type)

        convert_to_q_state = convert_to_q_builder.build()

        test_director = TestDirector()
        test_director.set_states(convert_to_q_state=convert_to_q_state, data_state=data_state)

        return test_director.construct().property_manager
开发者ID:DanNixon,项目名称:mantid,代码行数:33,代码来源:SANSConvertToQTest.py


注:本文中的sans.state.data.get_data_builder函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。