本文整理汇总了Python中sans.common.file_information.SANSFileInformationFactory.create_sans_file_information方法的典型用法代码示例。如果您正苦于以下问题:Python SANSFileInformationFactory.create_sans_file_information方法的具体用法?Python SANSFileInformationFactory.create_sans_file_information怎么用?Python SANSFileInformationFactory.create_sans_file_information使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sans.common.file_information.SANSFileInformationFactory
的用法示例。
在下文中一共展示了SANSFileInformationFactory.create_sans_file_information方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_that_cylinder_masking_is_applied
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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)
示例2: test_that_produces_correct_workspace_for_SANS2D
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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)
示例3: _get_data_state
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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()
示例4: _process_command_queue
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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()
示例5: _get_simple_state
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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()
示例6: set_geometry_from_file
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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()
示例7: test_that_single_reduction_evaluates_LAB_for_2D_reduction
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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)
示例8: add_table_entry_no_thread_or_signal
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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)
示例9: test_batch_reduction_on_time_sliced_file
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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)
示例10: test_batch_reduction_on_period_time_sliced_wavelength_range_data
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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)
示例11: set_information_from_file
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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()
示例12: test_that_beam_centre_core_produces_correct_workspaces
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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)
示例13: test_that_angle_masking_is_applied
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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)
示例14: test_that_mask_files_are_applied
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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)
示例15: test_that_reduction_core_evaluates_LAB
# 需要导入模块: from sans.common.file_information import SANSFileInformationFactory [as 别名]
# 或者: from sans.common.file_information.SANSFileInformationFactory import create_sans_file_information [as 别名]
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)