From 392b0603336802ffe7a957294354ffe30adc03f4 Mon Sep 17 00:00:00 2001 From: Tom Titcombe <t.j.titcombe@gmail.com> Date: Mon, 14 Jan 2019 15:24:31 +0000 Subject: [PATCH] Finish centring on SANSLoad Remove optional flag for moving workspace. Always move workspace Refs #23960 --- .../WorkflowAlgorithms/SANS/SANSLoad.py | 72 +++++-------------- .../tests/analysis/SANSLoadTest.py | 28 -------- .../sans/algorithm_detail/batch_execution.py | 3 +- 3 files changed, 20 insertions(+), 83 deletions(-) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSLoad.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSLoad.py index 091353a997c..98e50cd5767 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSLoad.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSLoad.py @@ -41,10 +41,6 @@ class SANSLoad(ParallelDataProcessorAlgorithm): self.declareProperty("UseCached", True, direction=Direction.Input, 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 enabled_condition = EnabledWhenProperty("MoveWorkspace", PropertyCriterion.IsNotDefault) self.declareProperty(FloatArrayProperty(name='BeamCoordinates', values=[]), @@ -144,17 +140,9 @@ class SANSLoad(ParallelDataProcessorAlgorithm): parent_alg=self) 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.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.") # Set output workspaces @@ -337,59 +325,38 @@ class SANSLoad(ParallelDataProcessorAlgorithm): number_of_workspaces_name = "NumberOf" + name + "s" self.setProperty(number_of_workspaces_name, counter) - def _centre(self, workspaces, state): + def _perform_initial_move(self, workspaces, state): move_name = "SANSMove" 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, "MoveType": "SetToZero", "Component": ""} + zero_alg = create_child_algorithm(self, move_name, **zero_options) + move_options = {"SANSState": state_dict, "MoveType": "InitialMove"} - - zero_alg = create_child_algorithm(self, move_name, **zero_options) move_alg = create_child_algorithm(self, move_name, **move_options) # The workspaces are stored in a dict: workspace_names (sample_scatter, etc) : ListOfWorkspaces - new_ws = {} for key, workspace_list in list(workspaces.items()): - new_ws_list = [] for workspace in workspace_list: zero_alg.setProperty("Workspace", workspace) zero_alg.execute() - new_workspace = zero_alg.getProperty("Workspace").value - - if perform_move: - # If beam centre was specified then use it - beam_coordinates = self.getProperty("BeamCoordinates").value - if beam_coordinates: - move_alg.setProperty("BeamCoordinates", beam_coordinates) - - # If component was specified then use it - component = self.getProperty("Component").value - if beam_coordinates: - move_alg.setProperty("Component", component) - - move_alg.setProperty("Workspace", new_workspace) - 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 + zeroed_workspace = zero_alg.getProperty("Workspace").value + + # If beam centre was specified then use it + beam_coordinates = self.getProperty("BeamCoordinates").value + if beam_coordinates: + move_alg.setProperty("BeamCoordinates", beam_coordinates) + + # If component was specified then use it + component = self.getProperty("Component").value + if beam_coordinates: + move_alg.setProperty("Component", component) + + move_alg.setProperty("Workspace", zeroed_workspace) + move_alg.execute() def _get_progress_for_file_loading(self, data): # Get the number of workspaces which are to be loaded @@ -399,10 +366,9 @@ class SANSLoad(ParallelDataProcessorAlgorithm): data.calibration]) progress_steps = number_of_files_to_load + 1 # 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% - end = 0.8 if uses_move else 1.0 + end = 1.0 progress = Progress(self, start=0.0, end=end, nreports=progress_steps) return progress diff --git a/Testing/SystemTests/tests/analysis/SANSLoadTest.py b/Testing/SystemTests/tests/analysis/SANSLoadTest.py index e4304baccf0..c6d9b02c87b 100644 --- a/Testing/SystemTests/tests/analysis/SANSLoadTest.py +++ b/Testing/SystemTests/tests/analysis/SANSLoadTest.py @@ -206,7 +206,6 @@ class SANSLoadTest(unittest.TestCase): load_alg.setProperty("SANSState", state_dict) load_alg.setProperty("PublishToCache", publish_to_cache) load_alg.setProperty("UseCached", use_cached) - load_alg.setProperty("MoveWorkspace", move_workspace) if move_workspace: load_alg.setProperty("Component", component) load_alg.setProperty("BeamCoordinates", beam_coordinates) @@ -537,33 +536,6 @@ class SANSLoadTest(unittest.TestCase): # Cleanup 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): def __init__(self): diff --git a/scripts/SANS/sans/algorithm_detail/batch_execution.py b/scripts/SANS/sans/algorithm_detail/batch_execution.py index 939b19448d0..b0720b6d598 100644 --- a/scripts/SANS/sans/algorithm_detail/batch_execution.py +++ b/scripts/SANS/sans/algorithm_detail/batch_execution.py @@ -339,8 +339,7 @@ def provide_loaded_data(state, use_optimizations, workspace_to_name, workspace_t load_name = "SANSLoad" load_options = {"SANSState": state_serialized, "PublishToCache": use_optimizations, - "UseCached": use_optimizations, - "MoveWorkspace": False} + "UseCached": use_optimizations} # Set the output workspaces set_output_workspaces_on_load_algorithm(load_options, state) -- GitLab