• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python file_information.SANSFileInformationFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_that_cylinder_masking_is_applied

    def test_that_cylinder_masking_is_applied(self):
        # Arrange
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information("SANS2D00028827")
        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        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:samueljackson92,项目名称:mantid,代码行数:32,代码来源:SANSMaskWorkspaceTest.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: _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


示例4: _process_command_queue

    def _process_command_queue(self, data_state):
        """
        Process the command queue sequentially as FIFO structure

        @param data_state: the data state.
        @return: a SANSState object.
        """
        file_name = data_state.sample_scatter
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information(file_name)

        self._state_director = StateDirectorISIS(data_state, file_information)

        # If we have a clean instruction in there, then we should apply it to all commands
        self._apply_clean_if_required()

        # Evaluate all commands which adds them to the _processed_state_settings dictionary,
        # except for DataCommands which we deal with separately
        for command in self._commands:
            if isinstance(command, DataCommand):
                continue
            command_id = command.command_id
            process_function = self._method_map[command_id]
            process_function(command)

        # The user file state director
        self._state_director.add_state_settings(self._processed_state_settings)
        return self._state_director.construct()
开发者ID:mantidproject,项目名称:mantid,代码行数:28,代码来源:command_interface_state_director.py


示例5: _get_simple_state

    def _get_simple_state(sample_scatter, sample_trans=None, sample_direct=None,
                          can_scatter=None, can_trans=None, can_direct=None, calibration=None,
                          sample_scatter_period=None, sample_trans_period=None, sample_direct_period=None,
                          can_scatter_period=None, can_trans_period=None, can_direct_period=None):
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information(sample_scatter)

        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter(sample_scatter)

        # Set the file names
        if sample_trans is not None:
            data_builder.set_sample_transmission(sample_trans)

        if sample_direct is not None:
            data_builder.set_sample_direct(sample_direct)

        if can_scatter is not None:
            data_builder.set_can_scatter(can_scatter)

        if can_trans is not None:
            data_builder.set_can_transmission(can_trans)

        if can_direct is not None:
            data_builder.set_can_direct(can_direct)

        # Set the periods
        if sample_scatter_period is not None:
            data_builder.set_sample_scatter_period(sample_scatter_period)

        if sample_trans_period is not None:
            data_builder.set_sample_transmission_period(sample_trans_period)

        if sample_direct_period is not None:
            data_builder.set_sample_direct_period(sample_direct_period)

        if can_scatter_period is not None:
            data_builder.set_can_scatter_period(can_scatter_period)

        if can_trans_period is not None:
            data_builder.set_can_transmission_period(can_trans_period)

        if can_direct_period is not None:
            data_builder.set_can_direct_period(can_direct_period)

        # Add the calibration
        if calibration is not None:
            data_builder.set_calibration(calibration)

        data_info = data_builder.build()

        # Get the sample state
        test_director = TestDirector()
        test_director.set_states(data_state=data_info)

        return test_director.construct()
开发者ID:samueljackson92,项目名称:mantid,代码行数:56,代码来源:SANSLoadTest.py


示例6: set_geometry_from_file

def set_geometry_from_file(state, date_info):
    sample_scatter = date_info.sample_scatter
    file_information_factory = SANSFileInformationFactory()
    file_information = file_information_factory.create_sans_file_information(sample_scatter)

    # Get the geometry
    state.height_from_file = file_information.get_height()
    state.width_from_file = file_information.get_width()
    state.thickness_from_file = file_information.get_thickness()
    state.shape_from_file = file_information.get_shape()
开发者ID:DanNixon,项目名称:mantid,代码行数:10,代码来源:scale.py


示例7: test_that_single_reduction_evaluates_LAB_for_2D_reduction

    def test_that_single_reduction_evaluates_LAB_for_2D_reduction(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_sample_transmission("SANS2D00034505")
        data_builder.set_sample_direct("SANS2D00034461")
        data_builder.set_can_scatter("SANS2D00034481")
        data_builder.set_can_transmission("SANS2D00034502")
        data_builder.set_can_direct("SANS2D00034461")

        data_builder.set_calibration("TUBE_SANS2D_BOTH_31681_25Sept15.nxs")
        data_info = data_builder.build()

        # Get the rest of the state from the user file
        user_file_director = StateDirectorISIS(data_info, file_information)
        user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt")
        # Set the reduction mode to LAB
        user_file_director.set_reduction_builder_reduction_mode(ISISReductionMode.LAB)
        user_file_director.set_reduction_builder_reduction_dimensionality(ReductionDimensionality.TwoDim)
        user_file_director.set_convert_to_q_builder_reduction_dimensionality(ReductionDimensionality.TwoDim)
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        # 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
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        state = user_file_director.construct()

        # Load the sample workspaces
        sample, sample_monitor, transmission_workspace, direct_workspace, can, can_monitor, \
        can_transmission, can_direct = self._load_workspace(state)  # noqa

        # Act
        output_settings = {"OutputWorkspaceLAB": EMPTY_NAME}
        single_reduction_alg = self._run_single_reduction(state, sample_scatter=sample,
                                                          sample_transmission=transmission_workspace,
                                                          sample_direct=direct_workspace,
                                                          sample_monitor=sample_monitor,
                                                          can_scatter=can,
                                                          can_monitor=can_monitor,
                                                          can_transmission=can_transmission,
                                                          can_direct=can_direct,
                                                          output_settings=output_settings)
        output_workspace = single_reduction_alg.getProperty("OutputWorkspaceLAB").value

        # Compare the output of the reduction with the reference
        reference_file_name = "SANS2D_ws_D20_reference_LAB_2D.nxs"
        self._compare_workspace(output_workspace, reference_file_name)
开发者ID:samueljackson92,项目名称:mantid,代码行数:54,代码来源:SANSSingleReductionTest.py


示例8: add_table_entry_no_thread_or_signal

    def add_table_entry_no_thread_or_signal(self, row, table_index_model):
        table_index_model.id = self._id_count
        self._id_count += 1
        self._table_entries.insert(row, table_index_model)
        if row >= self.get_number_of_rows():
            row = self.get_number_of_rows() - 1

        entry = self._table_entries[row]
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information(entry.sample_scatter)
        self.update_thickness_from_file_information(entry.id, file_information)
开发者ID:samueljackson92,项目名称:mantid,代码行数:11,代码来源:table_model.py


示例9: test_batch_reduction_on_time_sliced_file

    def test_batch_reduction_on_time_sliced_file(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_sample_transmission("SANS2D00034505")
        data_builder.set_sample_direct("SANS2D00034461")
        data_builder.set_can_scatter("SANS2D00034481")
        data_builder.set_can_transmission("SANS2D00034502")
        data_builder.set_can_direct("SANS2D00034461")

        data_builder.set_calibration("TUBE_SANS2D_BOTH_31681_25Sept15.nxs")

        data_info = data_builder.build()

        # Get the rest of the state from the user file
        user_file_director = StateDirectorISIS(data_info, file_information)
        user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt")
        # Set the reduction mode to LAB
        user_file_director.set_reduction_builder_reduction_mode(ISISReductionMode.LAB)
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        # 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
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        user_file_director.set_slice_event_builder_start_time([1.0,3.0])
        user_file_director.set_slice_event_builder_end_time([3.0,5.0])

        state = user_file_director.construct()

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

        expected_workspaces = ["34484rear_1D_1.75_16.5_t1.00_T3.00", "34484rear_1D_1.75_16.5_t3.00_T5.00"]
        reference_file_names = ["SANS2D_event_slice_referance_t1.00_T3.00.nxs", "SANS2D_event_slice_referance_t3.00_T5.00.nxs"]

        for element, reference_file in zip(expected_workspaces, reference_file_names):
            self.assertTrue(AnalysisDataService.doesExist(element))
            # Evaluate it up to a defined point
            self._compare_workspace(element, reference_file)

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


示例10: test_batch_reduction_on_period_time_sliced_wavelength_range_data

    def test_batch_reduction_on_period_time_sliced_wavelength_range_data(self):
        # Arrange
        # Build the data information
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information("SANS2D0005512")

        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter("SANS2D0005512")
        data_builder.set_sample_scatter_period(1)

        data_info = data_builder.build()

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

        user_file_director.set_slice_event_builder_start_time([1.0, 3.0])
        user_file_director.set_slice_event_builder_end_time([3.0, 5.0])

        state = user_file_director.construct()

        start = [1.0, 1.0]
        end = [3.0, 2.0]
        state.wavelength.wavelength_low = start
        state.wavelength.wavelength_high = end

        state.adjustment.normalize_to_monitor.wavelength_low = start
        state.adjustment.normalize_to_monitor.wavelength_high = end

        state.adjustment.calculate_transmission.wavelength_low = start
        state.adjustment.calculate_transmission.wavelength_high = end

        state.adjustment.wavelength_and_pixel_adjustment.wavelength_low = start
        state.adjustment.wavelength_and_pixel_adjustment.wavelength_high = end

        # 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_1.0_2.0Phi-45.0_45.0_t1.00_T3.00", "5512p1rear_1D_1.0_2.0Phi-45.0_45.0_t3.00_T5.00",
                               "5512p1rear_1D_1.0_3.0Phi-45.0_45.0_t1.00_T3.00", "5512p1rear_1D_1.0_3.0Phi-45.0_45.0_t3.00_T5.00"
                               ]
        for element in expected_workspaces:
            self.assertTrue(AnalysisDataService.doesExist(element))

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


示例11: set_information_from_file

def set_information_from_file(data_info):
    file_name = data_info.sample_scatter
    file_information_factory = SANSFileInformationFactory()
    file_information = file_information_factory.create_sans_file_information(file_name)
    instrument = file_information.get_instrument()
    facility = file_information.get_facility()
    run_number = file_information.get_run_number()
    data_info.instrument = instrument
    data_info.facility = facility
    data_info.sample_scatter_run_number = run_number
    data_info.sample_scatter_is_multi_period = file_information.get_number_of_periods() > 1
    data_info.idf_file_path = file_information.get_idf_file_path()
    data_info.ipf_file_path = file_information.get_ipf_file_path()
开发者ID:DanNixon,项目名称:mantid,代码行数:13,代码来源:data.py


示例12: test_that_beam_centre_core_produces_correct_workspaces

    def test_that_beam_centre_core_produces_correct_workspaces(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_sample_transmission("SANS2D00034505")
        data_builder.set_sample_direct("SANS2D00034461")
        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()

        # Load the sample workspaces
        workspace, workspace_monitor, transmission_workspace, direct_workspace = self._load_workspace(state)

        # Act
        reduction_core_alg = self._run_beam_centre_core(state, workspace, workspace_monitor,
                                                        transmission_workspace, direct_workspace)
        output_workspace_left = reduction_core_alg.getProperty("OutputWorkspaceLeft").value
        output_workspace_right = reduction_core_alg.getProperty("OutputWorkspaceRight").value
        output_workspace_top = reduction_core_alg.getProperty("OutputWorkspaceTop").value
        output_workspace_bottom = reduction_core_alg.getProperty("OutputWorkspaceBottom").value

        # Evaluate it up to a defined point
        reference_file_name_left = "SANS2D_ws_D20_reference_left.nxs"
        reference_file_name_right = "SANS2D_ws_D20_reference_right.nxs"
        reference_file_name_top = "SANS2D_ws_D20_reference_top.nxs"
        reference_file_name_bottom = "SANS2D_ws_D20_reference_bottom.nxs"
        self._compare_workspace(output_workspace_left, reference_file_name_left)
        self._compare_workspace(output_workspace_right, reference_file_name_right)
        self._compare_workspace(output_workspace_top, reference_file_name_top)
        self._compare_workspace(output_workspace_bottom, reference_file_name_bottom)
开发者ID:stuartcampbell,项目名称:mantid,代码行数:50,代码来源:SANSBeamCentreFinderCoreTest.py


示例13: test_that_angle_masking_is_applied

    def test_that_angle_masking_is_applied(self):
        # Arrange
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information("SANS2D00028827")
        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter("SANS2D00028827")
        data_info = data_builder.build()

        mask_builder = get_mask_builder(data_info)

        # Expected_spectra
        phi_mirror = False
        phi_min = 0.
        phi_max = 90.
        # This should mask everything except for the upper right quadrant
        # | 120              |-------------------|
        # |                 |---------------------|
        # | 60               |-------------------|
        # |                 |----------------------|
        # |
        # |
        # |-------------------|------------------|
        # 512                256                 0

        expected_spectra = []
        # The strange double pattern arises from the offset of the SANS2D tube geometry (see InstrumentView)
        for y in range(60, 120):
            if y % 2 == 0:
                expected_spectra.extend(((y * 512) + 9 + x for x in range(0, 255)))
            else:
                expected_spectra.extend(((y * 512) + 9 + x for x in range(0, 257)))
        expected_spectra.extend((x for x in range(92169, 122889)))  # HAB

        mask_builder.set_use_mask_phi_mirror(phi_mirror)
        mask_builder.set_phi_min(phi_min)
        mask_builder.set_phi_max(phi_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)

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

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


示例14: test_that_mask_files_are_applied

    def test_that_mask_files_are_applied(self):
        def create_shape_xml_file(xml_string):
            f_name = os.path.join(mantid.config.getString('defaultsave.directory'), 'sample_mask_file.xml')
            if os.path.exists(f_name):
                os.remove(f_name)
            with open(f_name, 'w') as f:
                f.write(xml_string)
            return f_name

        # Arrange
        shape_xml = "<?xml version=\"1.0\"?>\n"\
                    "<detector-masking>\n" \
                    "<group>\n" \
                    "<detids>\n" \
                    "1313191-1313256\n" \
                    "</detids>\n" \
                    "</group>\n" \
                    "</detector-masking >"
        file_name = create_shape_xml_file(shape_xml)

        # Arrange
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information("SANS2D00028827")
        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter("SANS2D00028827")
        data_info = data_builder.build()
        mask_builder = get_mask_builder(data_info)

        # Mask file
        # Got the spectra from the detector view
        expected_spectra = [x for x in range(31432, 31498)]
        mask_builder.set_mask_files([file_name])
        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)

        # Remove
        if os.path.exists(file_name):
            os.remove(file_name)
开发者ID:samueljackson92,项目名称:mantid,代码行数:49,代码来源:SANSMaskWorkspaceTest.py


示例15: test_that_reduction_core_evaluates_LAB

    def test_that_reduction_core_evaluates_LAB(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_sample_transmission("SANS2D00034505")
        data_builder.set_sample_direct("SANS2D00034461")
        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()
        state.adjustment.show_transmission = True

        # Load the sample workspaces
        workspace, workspace_monitor, transmission_workspace, direct_workspace = self._load_workspace(state)

        # Act
        reduction_core_alg = self._run_reduction_core(state, workspace, workspace_monitor,
                                                      transmission_workspace, direct_workspace)
        output_workspace = reduction_core_alg.getProperty("OutputWorkspace").value
        calculated_transmission = reduction_core_alg.getProperty("CalculatedTransmissionWorkspace").value
        unfitted_transmission = reduction_core_alg.getProperty("UnfittedTransmissionWorkspace").value

        # Evaluate it up to a defined point
        reference_file_name = "SANS2D_ws_D20_reference.nxs"
        self._compare_workspace(output_workspace, reference_file_name)

        calculated_transmission_reference_file = "SANS2D_ws_D20_calculated_transmission_reference.nxs"
        unfitted_transmission_reference_file = "SANS2D_ws_D20_unfitted_transmission_reference.nxs"
        self._compare_workspace(calculated_transmission, calculated_transmission_reference_file)
        self._compare_workspace(unfitted_transmission, unfitted_transmission_reference_file)
开发者ID:samueljackson92,项目名称:mantid,代码行数:48,代码来源:SANSReductionCoreTest.py


示例16: test_that_general_time_masking_is_applied

    def test_that_general_time_masking_is_applied(self):
        # Arrange
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information("SANS2D00028827")
        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter("SANS2D00028827")
        data_info = data_builder.build()
        mask_builder = get_mask_builder(data_info)

        # Expected_spectra
        bin_mask_general_start = [30000., 67000.]
        bin_mask_general_stop = [35000., 75000.]

        # bin_mask_start = [14000]
        # bin_mask_stop = FloatListParameter()

        mask_builder.set_bin_mask_general_start(bin_mask_general_start)
        mask_builder.set_bin_mask_general_stop(bin_mask_general_stop)

        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)

        tof_spectra_10_original = workspace.getSpectrum(10).getTofs()
        tof_spectra_11_original = workspace.getSpectrum(11).getTofs()

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

        # Assert
        # Confirm that everything in the ranges 30000-35000  and 67000-75000 is removed from the event list
        tof_spectra_10_masked = workspace.getSpectrum(10).getTofs()
        tof_spectra_11_masked = workspace.getSpectrum(11).getTofs()
        # Spectrum 10
        # Three events should have been removed
        self.assertTrue(len(tof_spectra_10_masked) == len(tof_spectra_10_original) - 3)
        # One event should have been removed
        self.assertTrue(len(tof_spectra_11_masked) == len(tof_spectra_11_original) - 1)

        # Make sure that there are no elements
        for start, stop in zip(bin_mask_general_start, bin_mask_general_stop):
            self.assertFalse(any(elements_in_range(start, stop, tof_spectra_10_masked)))
            self.assertFalse(any(elements_in_range(start, stop, tof_spectra_11_masked)))
开发者ID:samueljackson92,项目名称:mantid,代码行数:47,代码来源:SANSMaskWorkspaceTest.py


示例17: test_that_batch_reduction_evaluates_LAB

    def test_that_batch_reduction_evaluates_LAB(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_sample_transmission("SANS2D00034505")
        data_builder.set_sample_direct("SANS2D00034461")
        data_builder.set_can_scatter("SANS2D00034481")
        data_builder.set_can_transmission("SANS2D00034502")
        data_builder.set_can_direct("SANS2D00034461")

        data_builder.set_calibration("TUBE_SANS2D_BOTH_31681_25Sept15.nxs")

        data_info = data_builder.build()

        # Get the rest of the state from the user file
        user_file_director = StateDirectorISIS(data_info, file_information)
        user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt")
        # Set the reduction mode to LAB
        user_file_director.set_reduction_builder_reduction_mode(ISISReductionMode.LAB)
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        # 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
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        state = user_file_director.construct()

        # Act
        states = [state]
        self._run_batch_reduction(states, use_optimizations=False)
        workspace_name = "34484rear_1D_1.75_16.5"
        output_workspace = AnalysisDataService.retrieve(workspace_name)

        # Evaluate it up to a defined point
        reference_file_name = "SANS2D_ws_D20_reference_LAB_1D.nxs"
        self._compare_workspace(output_workspace, reference_file_name)

        if AnalysisDataService.doesExist(workspace_name):
            AnalysisDataService.remove(workspace_name)
开发者ID:stuartcampbell,项目名称:mantid,代码行数:46,代码来源:SANSBatchReductionTest.py


示例18: test_that_block_masking_is_applied

    def test_that_block_masking_is_applied(self):
        # Arrange
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information("SANS2D00028827")
        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter("SANS2D00028827")
        data_info = data_builder.build()

        mask_builder = get_mask_builder(data_info)

        # Expected_spectra
        expected_spectra = []

        # Block
        # Detector-specific block
        # The block will be evaluated for SANS2D on the LAB as:
        block_horizontal_start = [12, 17]
        block_horizontal_stop = [14, 21]
        block_vertical_start = [45, 87]
        block_vertical_stop = [48, 91]

        for h_start, h_stop, v_start, v_stop in zip(block_horizontal_start, block_horizontal_stop,
                                                    block_vertical_start, block_vertical_stop):
            expected_spectra.extend(((h_start*512 + 9) + y*512 + x for y in range(0, h_stop - h_start + 1)
                                     for x in range(v_start, v_stop + 1)))

        mask_builder.set_LAB_block_horizontal_start(block_horizontal_start)
        mask_builder.set_LAB_block_horizontal_stop(block_horizontal_stop)
        mask_builder.set_LAB_block_vertical_start(block_vertical_start)
        mask_builder.set_LAB_block_vertical_stop(block_vertical_stop)
        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)

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

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


示例19: _get_simple_state

    def _get_simple_state(sample_scatter, lab_x_translation_correction=None, lab_z_translation_correction=None):
        # Set the data
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information(sample_scatter)
        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter(sample_scatter)
        data_info = data_builder.build()

        # Set the move p 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python general_functions.create_child_algorithm函数代码示例发布时间:2022-05-27
下一篇:
Python enums.DetectorType类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap