def _do_test(self, file_name, mover_type):
     # Arrange
     workspace = load_workspace(file_name)
     move_factory = SANSMoveFactory()
     # Act
     mover = move_factory.create_mover(workspace)
     # Assert
     self.assertTrue(isinstance(mover, mover_type))
Exemple #2
0
    def PyExec(self):
        # Read the state
        state_property_manager = self.getProperty("SANSState").value
        state = create_deserialized_sans_state_from_property_manager(
            state_property_manager)

        # Get the correct SANS move strategy from the SANSMoveFactory
        workspace = self.getProperty("Workspace").value
        move_factory = SANSMoveFactory()
        mover = move_factory.create_mover(workspace)

        # Get the selected component and the beam coordinates
        move_info = state.move
        full_component_name = self._get_full_component_name(move_info)
        coordinates = self._get_coordinates(move_info, full_component_name)

        # Get which move operation the user wants to perform on the workspace. This can be:
        # 1. Initial move: Suitable when a workspace has been freshly loaded.
        # 2. Elementary displacement: Takes the degrees of freedom of the detector into account. This is normally used
        #    for beam center finding
        # 3. Set to zero: Set the component to its zero position
        progress = Progress(self, start=0.0, end=1.0, nreports=2)
        selected_move_type = self._get_move_type()

        if selected_move_type is MoveType.ElementaryDisplacement:
            progress.report("Starting elementary displacement")
            mover.move_with_elementary_displacement(move_info, workspace,
                                                    coordinates,
                                                    full_component_name)
        elif selected_move_type is MoveType.InitialMove:
            is_transmission_workspace = self.getProperty(
                "IsTransmissionWorkspace").value
            progress.report("Starting initial move.")
            mover.move_initial(move_info, workspace, coordinates,
                               full_component_name, is_transmission_workspace)
        elif selected_move_type is MoveType.SetToZero:
            progress.report("Starting set to zero.")
            mover.set_to_zero(move_info, workspace, full_component_name)
        else:
            raise ValueError("SANSMove: The selection {0} for the  move type "
                             "is unknown".format(str(selected_move_type)))
        progress.report("Completed move.")
Exemple #3
0
    def PyExec(self):
        # Read the state
        state_property_manager = self.getProperty("SANSState").value
        state = create_deserialized_sans_state_from_property_manager(state_property_manager)

        # Get the correct SANS move strategy from the SANSMoveFactory
        workspace = self.getProperty("Workspace").value
        move_factory = SANSMoveFactory()
        mover = move_factory.create_mover(workspace)

        # Get the selected component and the beam coordinates
        move_info = state.move
        full_component_name = self._get_full_component_name(move_info)
        coordinates = self._get_coordinates(move_info, full_component_name)

        # Get which move operation the user wants to perform on the workspace. This can be:
        # 1. Initial move: Suitable when a workspace has been freshly loaded.
        # 2. Elementary displacement: Takes the degrees of freedom of the detector into account. This is normally used
        #    for beam center finding
        # 3. Set to zero: Set the component to its zero position
        progress = Progress(self, start=0.0, end=1.0, nreports=2)
        selected_move_type = self._get_move_type()

        if selected_move_type is MoveType.ElementaryDisplacement:
            progress.report("Starting elementary displacement")
            mover.move_with_elementary_displacement(move_info, workspace, coordinates, full_component_name)
        elif selected_move_type is MoveType.InitialMove:
            is_transmission_workspace = self.getProperty("IsTransmissionWorkspace").value
            progress.report("Starting initial move.")
            mover.move_initial(move_info, workspace, coordinates, full_component_name, is_transmission_workspace)
        elif selected_move_type is MoveType.SetToZero:
            progress.report("Starting set to zero.")
            mover.set_to_zero(move_info, workspace, full_component_name)
        else:
            raise ValueError("SANSMove: The selection {0} for the  move type "
                             "is unknown".format(str(selected_move_type)))
        progress.report("Completed move.")
 def _provide_mover(workspace):
     move_factory = SANSMoveFactory()
     return move_factory.create_mover(workspace)