Skip to content
Snippets Groups Projects
Commit 392b0603 authored by Tom Titcombe's avatar Tom Titcombe
Browse files

Finish centring on SANSLoad

Remove optional flag for moving workspace. Always move workspace

Refs #23960
parent 6b1db88c
No related branches found
No related tags found
No related merge requests found
...@@ -41,10 +41,6 @@ class SANSLoad(ParallelDataProcessorAlgorithm): ...@@ -41,10 +41,6 @@ class SANSLoad(ParallelDataProcessorAlgorithm):
self.declareProperty("UseCached", True, direction=Direction.Input, self.declareProperty("UseCached", True, direction=Direction.Input,
doc="Checks if there are loaded files available. If they are, those files are used.") doc="Checks if there are loaded files available. If they are, those files are used.")
self.declareProperty("MoveWorkspace", defaultValue=False, direction=Direction.Input,
doc="Move the workspace according to the SANSState setting. This might be useful"
"for manual inspection.")
# Beam coordinates if an initial move of the workspace is requested # Beam coordinates if an initial move of the workspace is requested
enabled_condition = EnabledWhenProperty("MoveWorkspace", PropertyCriterion.IsNotDefault) enabled_condition = EnabledWhenProperty("MoveWorkspace", PropertyCriterion.IsNotDefault)
self.declareProperty(FloatArrayProperty(name='BeamCoordinates', values=[]), self.declareProperty(FloatArrayProperty(name='BeamCoordinates', values=[]),
...@@ -144,17 +140,9 @@ class SANSLoad(ParallelDataProcessorAlgorithm): ...@@ -144,17 +140,9 @@ class SANSLoad(ParallelDataProcessorAlgorithm):
parent_alg=self) parent_alg=self)
progress.report("Loaded the data.") progress.report("Loaded the data.")
# Centre the workspaces
#progress.report("Centring the workspace.")
#self._centre(workspaces, state)
#progress.report("Finished centring the workspace")
# Check if a move has been requested and perform it. This can be useful if scientists want to load the data and
# have it moved in order to inspect it with other tools
move_workspaces = self.getProperty("MoveWorkspace").value
progress_move = Progress(self, start=0.8, end=1.0, nreports=2) progress_move = Progress(self, start=0.8, end=1.0, nreports=2)
progress_move.report("Starting to move the workspaces.") progress_move.report("Starting to move the workspaces.")
workspaces = self._perform_initial_move(workspaces, state, move_workspaces) self._perform_initial_move(workspaces, state)
progress_move.report("Finished moving the workspaces.") progress_move.report("Finished moving the workspaces.")
# Set output workspaces # Set output workspaces
...@@ -337,59 +325,38 @@ class SANSLoad(ParallelDataProcessorAlgorithm): ...@@ -337,59 +325,38 @@ class SANSLoad(ParallelDataProcessorAlgorithm):
number_of_workspaces_name = "NumberOf" + name + "s" number_of_workspaces_name = "NumberOf" + name + "s"
self.setProperty(number_of_workspaces_name, counter) self.setProperty(number_of_workspaces_name, counter)
def _centre(self, workspaces, state): def _perform_initial_move(self, workspaces, state):
move_name = "SANSMove" move_name = "SANSMove"
state_dict = state.property_manager state_dict = state.property_manager
move_options = {"SANSState": state_dict,
"MoveType": "SetToZero",
"Component": ""}
move_alg = create_child_algorithm(self, move_name, **move_options)
# The workspaces are stored in a dict: workspace_names (sample_scatter, etc) : ListOfWorkspaces
for key, workspace_list in list(workspaces.items()):
for workspace in workspace_list:
move_alg.setProperty("Workspace", workspace)
move_alg.execute()
def _perform_initial_move(self, workspaces, state, perform_move):
move_name = "SANSMove"
state_dict = state.property_manager
zero_options = {"SANSState": state_dict, zero_options = {"SANSState": state_dict,
"MoveType": "SetToZero", "MoveType": "SetToZero",
"Component": ""} "Component": ""}
zero_alg = create_child_algorithm(self, move_name, **zero_options)
move_options = {"SANSState": state_dict, move_options = {"SANSState": state_dict,
"MoveType": "InitialMove"} "MoveType": "InitialMove"}
zero_alg = create_child_algorithm(self, move_name, **zero_options)
move_alg = create_child_algorithm(self, move_name, **move_options) move_alg = create_child_algorithm(self, move_name, **move_options)
# The workspaces are stored in a dict: workspace_names (sample_scatter, etc) : ListOfWorkspaces # The workspaces are stored in a dict: workspace_names (sample_scatter, etc) : ListOfWorkspaces
new_ws = {}
for key, workspace_list in list(workspaces.items()): for key, workspace_list in list(workspaces.items()):
new_ws_list = []
for workspace in workspace_list: for workspace in workspace_list:
zero_alg.setProperty("Workspace", workspace) zero_alg.setProperty("Workspace", workspace)
zero_alg.execute() zero_alg.execute()
new_workspace = zero_alg.getProperty("Workspace").value zeroed_workspace = zero_alg.getProperty("Workspace").value
if perform_move: # If beam centre was specified then use it
# If beam centre was specified then use it beam_coordinates = self.getProperty("BeamCoordinates").value
beam_coordinates = self.getProperty("BeamCoordinates").value if beam_coordinates:
if beam_coordinates: move_alg.setProperty("BeamCoordinates", beam_coordinates)
move_alg.setProperty("BeamCoordinates", beam_coordinates)
# If component was specified then use it
# If component was specified then use it component = self.getProperty("Component").value
component = self.getProperty("Component").value if beam_coordinates:
if beam_coordinates: move_alg.setProperty("Component", component)
move_alg.setProperty("Component", component)
move_alg.setProperty("Workspace", zeroed_workspace)
move_alg.setProperty("Workspace", new_workspace) move_alg.execute()
move_alg.execute()
new_workspace = move_alg.getProperty("Workspace").value
new_ws_list.append(new_workspace)
new_ws[key] = new_ws_list
return new_ws
def _get_progress_for_file_loading(self, data): def _get_progress_for_file_loading(self, data):
# Get the number of workspaces which are to be loaded # Get the number of workspaces which are to be loaded
...@@ -399,10 +366,9 @@ class SANSLoad(ParallelDataProcessorAlgorithm): ...@@ -399,10 +366,9 @@ class SANSLoad(ParallelDataProcessorAlgorithm):
data.calibration]) data.calibration])
progress_steps = number_of_files_to_load + 1 progress_steps = number_of_files_to_load + 1
# Check if there is a move operation to be performed # Check if there is a move operation to be performed
uses_move = self.getProperty("MoveWorkspace").value
# The partitioning of the progress bar is 80% for loading if there is a move else 100% # The partitioning of the progress bar is 80% for loading if there is a move else 100%
end = 0.8 if uses_move else 1.0 end = 1.0
progress = Progress(self, start=0.0, end=end, nreports=progress_steps) progress = Progress(self, start=0.0, end=end, nreports=progress_steps)
return progress return progress
......
...@@ -206,7 +206,6 @@ class SANSLoadTest(unittest.TestCase): ...@@ -206,7 +206,6 @@ class SANSLoadTest(unittest.TestCase):
load_alg.setProperty("SANSState", state_dict) load_alg.setProperty("SANSState", state_dict)
load_alg.setProperty("PublishToCache", publish_to_cache) load_alg.setProperty("PublishToCache", publish_to_cache)
load_alg.setProperty("UseCached", use_cached) load_alg.setProperty("UseCached", use_cached)
load_alg.setProperty("MoveWorkspace", move_workspace)
if move_workspace: if move_workspace:
load_alg.setProperty("Component", component) load_alg.setProperty("Component", component)
load_alg.setProperty("BeamCoordinates", beam_coordinates) load_alg.setProperty("BeamCoordinates", beam_coordinates)
...@@ -537,33 +536,6 @@ class SANSLoadTest(unittest.TestCase): ...@@ -537,33 +536,6 @@ class SANSLoadTest(unittest.TestCase):
# Cleanup # Cleanup
remove_all_workspaces_from_ads() remove_all_workspaces_from_ads()
def test_that_centres_workspace_on_load(self):
# Arrange
state = SANSLoadTest._get_simple_state(sample_scatter="SANS2D00028827",
sample_trans="SANS2D00028784",
sample_direct="SANS2D00028804")
# Act
output_workspace_names = {"SampleScatterWorkspace": "sample_scatter",
"SampleScatterMonitorWorkspace": "sample_monitor_scatter",
"SampleTransmissionWorkspace": "sample_transmission",
"SampleDirectWorkspace": "sample_direct"}
kwargs = {"state": state, "publish_to_cache": False, "use_cached": False, "move_workspace": False,
"output_workspace_names": output_workspace_names}
load_alg = self._run_load(**kwargs)
# Assert
expected_number_of_workspaces = [1, 1, 1, 0, 0, 0]
expected_number_on_ads = 0
workspace_type = [EventWorkspace, Workspace2D, Workspace2D, None, None, None]
self._do_test_output(load_alg, expected_number_of_workspaces, expected_number_on_ads, workspace_type)
for workspace_name, _ in output_workspace_names.items():
workspace = load_alg.getProperty(workspace_name).value
self._check_that_sets_to_zero(workspace, state.move, comp_name=None)
class SANSLoadDataRunnerTest(systemtesting.MantidSystemTest): class SANSLoadDataRunnerTest(systemtesting.MantidSystemTest):
def __init__(self): def __init__(self):
......
...@@ -339,8 +339,7 @@ def provide_loaded_data(state, use_optimizations, workspace_to_name, workspace_t ...@@ -339,8 +339,7 @@ def provide_loaded_data(state, use_optimizations, workspace_to_name, workspace_t
load_name = "SANSLoad" load_name = "SANSLoad"
load_options = {"SANSState": state_serialized, load_options = {"SANSState": state_serialized,
"PublishToCache": use_optimizations, "PublishToCache": use_optimizations,
"UseCached": use_optimizations, "UseCached": use_optimizations}
"MoveWorkspace": False}
# Set the output workspaces # Set the output workspaces
set_output_workspaces_on_load_algorithm(load_options, state) set_output_workspaces_on_load_algorithm(load_options, state)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment