def test_that_unknown_reduction_mode_raises(self): # Arrange state = SANSFunctionsTest._get_state() # Act + Assert try: get_standard_output_workspace_name(state, ISISReductionMode.All) did_raise = False except RuntimeError: did_raise = True self.assertTrue(did_raise)
def test_that_creates_correct_workspace_name_for_1D(self): # Arrange state = SANSFunctionsTest._get_state() # Act output_workspace, _ = get_standard_output_workspace_name(state, ISISReductionMode.LAB) # Assert self.assertTrue("12345rear_1D_12.0_34.0Phi12.0_56.0_t4.57_T12.37" == output_workspace)
def test_that_creates_correct_transmission_workspace_name(self): # Arrange state = SANSFunctionsTest._get_state() # Act output_workspace, _ = get_standard_output_workspace_name(state, ISISReductionMode.LAB, data_type = 'Sample', transmission = True) # Assert self.assertTrue("12345_trans_Sample_12.0_34.0Phi12.0_56.0_t4.57_T12.37" == output_workspace)
def test_that_creates_correct_workspace_name_for_1D(self): # Arrange state = SANSFunctionsTest._get_state() # Act wav_range = state.wavelength.wavelength_interval.wavelength_full_range output_workspace, _ = get_standard_output_workspace_name(state, ReductionMode.LAB, wav_range=wav_range) # Assert self.assertEqual("12345_rear_1D_12.0_34.0Phi12.0_56.0_t4.57_T12.37", output_workspace)
def test_that_can_switch_off_including_slice_limits_in_standard_output_workspace_name(self): # Arrange state = SANSFunctionsTest._get_state() # Act output_workspace, _ = get_standard_output_workspace_name(state, ReductionMode.LAB, include_slice_limits=False) # Assert self.assertTrue("12345_rear_1D_12.0_34.0Phi12.0_56.0" == output_workspace)
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 monitor normalization workspace # -------------------------------------- monitor_normalization_workspace = self._get_monitor_normalization_workspace( state) # -------------------------------------- # Get the calculated transmission # -------------------------------------- calculated_transmission_workspace, unfitted_transmission_workspace =\ self._get_calculated_transmission_workspace(state) # -------------------------------------- # Get the wide angle correction workspace # -------------------------------------- wave_length_and_pixel_adjustment_workspace = self._get_wide_angle_correction_workspace( state, calculated_transmission_workspace) # noqa # -------------------------------------------- # Get the full wavelength and pixel adjustment # -------------------------------------------- wave_length_adjustment_workspace, \ pixel_length_adjustment_workspace = self._get_wavelength_and_pixel_adjustment_workspaces(state, monitor_normalization_workspace, # noqa calculated_transmission_workspace) # noqa if wave_length_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAdjustment", wave_length_adjustment_workspace) if pixel_length_adjustment_workspace: self.setProperty("OutputWorkspacePixelAdjustment", pixel_length_adjustment_workspace) if wave_length_and_pixel_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAndPixelAdjustment", wave_length_and_pixel_adjustment_workspace) if calculated_transmission_workspace and unfitted_transmission_workspace and state.adjustment.show_transmission: data_type = self.getProperty("DataType").value output_workspace_name, output_workspace_base_name = get_standard_output_workspace_name( state, state.reduction.reduction_mode, transmission=True, data_type=data_type) AnalysisDataService.addOrReplace( output_workspace_base_name, calculated_transmission_workspace) AnalysisDataService.addOrReplace( output_workspace_base_name + '_unfitted', unfitted_transmission_workspace)
def test_that_creates_correct_transmission_workspace_name(self): # Arrange state = SANSFunctionsTest._get_state() # Act output_workspace, _ = get_standard_output_workspace_name( state, ISISReductionMode.LAB, data_type='Sample', transmission=True) # Assert self.assertTrue("12345_trans_Sample_12.0_34.0Phi12.0_56.0_t4.57_T12.37" == output_workspace)
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 monitor normalization workspace # -------------------------------------- monitor_normalization_workspace = self._get_monitor_normalization_workspace(state) # -------------------------------------- # Get the calculated transmission # -------------------------------------- calculated_transmission_workspace, unfitted_transmission_workspace =\ self._get_calculated_transmission_workspace(state) # -------------------------------------- # Get the wide angle correction workspace # -------------------------------------- wave_length_and_pixel_adjustment_workspace = self._get_wide_angle_correction_workspace(state, calculated_transmission_workspace) # noqa # -------------------------------------------- # Get the full wavelength and pixel adjustment # -------------------------------------------- wave_length_adjustment_workspace, \ pixel_length_adjustment_workspace = self._get_wavelength_and_pixel_adjustment_workspaces(state, monitor_normalization_workspace, # noqa calculated_transmission_workspace) # noqa if wave_length_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAdjustment", wave_length_adjustment_workspace) if pixel_length_adjustment_workspace: self.setProperty("OutputWorkspacePixelAdjustment", pixel_length_adjustment_workspace) if wave_length_and_pixel_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAndPixelAdjustment", wave_length_and_pixel_adjustment_workspace) if calculated_transmission_workspace and unfitted_transmission_workspace and state.adjustment.show_transmission: data_type = self.getProperty("DataType").value output_workspace_name, output_workspace_base_name = get_standard_output_workspace_name(state, state.reduction.reduction_mode , transmission = True, data_type = data_type) AnalysisDataService.addOrReplace(output_workspace_base_name, calculated_transmission_workspace) AnalysisDataService.addOrReplace(output_workspace_base_name + '_unfitted', unfitted_transmission_workspace)
def test_that_unknown_reduction_mode_raises(self): state = SANSFunctionsTest._get_state() with self.assertRaises(RuntimeError): get_standard_output_workspace_name(state, ReductionMode.ALL, wav_range=(0., 0.))