def test_subtract_summed_runs(self): # Load a vanadium workspace for this test sample_empty_number = "100" ws_file_name = "POL" + sample_empty_number original_ws = mantid.Load(ws_file_name) mantid.AddSampleLog(Workspace=original_ws, LogName='gd_prtn_chrg', LogText="10.0", LogType='Number') no_scale_ws = mantid.CloneWorkspace(InputWorkspace=original_ws, OutputWorkspace="test_subtract_sample_empty_ws") # Subtracting from self should equal 0 returned_ws = common.subtract_summed_runs(ws_to_correct=no_scale_ws, instrument=ISISPowderMockInst(), empty_sample_ws_string=sample_empty_number) y_values = returned_ws.readY(0) for i in range(returned_ws.blocksize()): self.assertAlmostEqual(y_values[i], 0) # Check what happens when we specify scale as a half scaled_ws = common.subtract_summed_runs(ws_to_correct=original_ws, instrument=ISISPowderMockInst(), scale_factor=0.75, empty_sample_ws_string=sample_empty_number) scaled_y_values = scaled_ws.readY(0) self.assertAlmostEqual(scaled_y_values[2], 0.20257424) self.assertAlmostEqual(scaled_y_values[4], 0.31700152) self.assertAlmostEqual(scaled_y_values[7], 0.35193970) mantid.DeleteWorkspace(returned_ws) mantid.DeleteWorkspace(scaled_ws)
def test_subtract_summed_runs(self): # Load a vanadium workspace for this test sample_empty_number = "100" ws_file_name = "POL" + sample_empty_number original_ws = mantid.Load(ws_file_name) mantid.AddSampleLog(Workspace=original_ws, LogName='gd_prtn_chrg', LogText="10.0", LogType='Number') no_scale_ws = mantid.CloneWorkspace( InputWorkspace=original_ws, OutputWorkspace="test_subtract_sample_empty_ws") # Subtracting from self should equal 0 returned_ws = common.subtract_summed_runs( ws_to_correct=no_scale_ws, instrument=ISISPowderMockInst(), empty_sample_ws_string=sample_empty_number) y_values = returned_ws.readY(0) for i in range(returned_ws.blocksize()): self.assertAlmostEqual(y_values[i], 0) # Check what happens when we specify scale as a half scaled_ws = common.subtract_summed_runs( ws_to_correct=original_ws, instrument=ISISPowderMockInst(), scale_factor=0.75, empty_sample_ws_string=sample_empty_number) scaled_y_values = scaled_ws.readY(0) self.assertAlmostEqual(scaled_y_values[2], 0.20257424) self.assertAlmostEqual(scaled_y_values[4], 0.31700152) self.assertAlmostEqual(scaled_y_values[7], 0.35193970) mantid.DeleteWorkspace(returned_ws) mantid.DeleteWorkspace(scaled_ws)
def test_subtract_summed_runs_throw_on_tof_mismatch(self): # Create a sample workspace which will have mismatched TOF range sample_ws = mantid.CreateSampleWorkspace() ws_file_name = "100" # Load POL100 # This should throw as the TOF ranges do not match with assertRaisesRegex(self, ValueError, "specified for this file do not have matching binning. Do the "): common.subtract_summed_runs(ws_to_correct=sample_ws, instrument=ISISPowderMockInst(), empty_sample_ws_string=ws_file_name) mantid.DeleteWorkspace(sample_ws)
def test_subtract_summed_runs_throw_on_tof_mismatch(self): # Create a sample workspace which will have mismatched TOF range sample_ws = mantid.CreateSampleWorkspace() mantid.AddSampleLog(Workspace=sample_ws, LogName='gd_prtn_chrg', LogText="10.0", LogType='Number') ws_file_name = "100" # Load POL100 # This should throw as the TOF ranges do not match with assertRaisesRegex(self, ValueError, "specified for this file do not have matching binning. Do the "): common.subtract_summed_runs(ws_to_correct=sample_ws, instrument=ISISPowderMockInst(), empty_sample_ws_string=ws_file_name) mantid.DeleteWorkspace(sample_ws)
def create_van(instrument, run_details, absorb): """ Creates a splined vanadium run for the following instrument. Requires the run_details for the vanadium workspace we will process and whether to apply absorption corrections. :param instrument: The instrument object that will be used to supply various instrument specific methods :param run_details: The run details associated with this vanadium run :param absorb: Boolean flag whether to apply absorption corrections :return: Processed workspace group in dSpacing (but not splined) """ van = run_details.vanadium_run_numbers # Always sum a range of inputs as its a vanadium run over multiple captures input_van_ws_list = common.load_current_normalised_ws_list( run_number_string=van, instrument=instrument, input_batching=INPUT_BATCHING.Summed) input_van_ws = input_van_ws_list[ 0] # As we asked for a summed ws there should only be one returned corrected_van_ws = common.subtract_summed_runs( ws_to_correct=input_van_ws, empty_sample_ws_string=run_details.empty_runs, instrument=instrument) # Crop the tail end of the data on PEARL if they are not capturing slow neutrons corrected_van_ws = instrument._crop_raw_to_expected_tof_range( ws_to_crop=corrected_van_ws) if absorb: corrected_van_ws = instrument._apply_absorb_corrections( run_details=run_details, ws_to_correct=corrected_van_ws) aligned_ws = mantid.AlignDetectors( InputWorkspace=corrected_van_ws, CalibrationFile=run_details.offset_file_path) focused_vanadium = mantid.DiffractionFocussing( InputWorkspace=aligned_ws, GroupingFileName=run_details.grouping_file_path) focused_spectra = common.extract_ws_spectra(focused_vanadium) focused_spectra = instrument._crop_van_to_expected_tof_range( focused_spectra) d_spacing_group, tof_group = instrument._output_focused_ws( processed_spectra=focused_spectra, run_details=run_details, output_mode="mods") _create_vanadium_splines(focused_spectra, instrument, run_details) common.keep_single_ws_unit(d_spacing_group=d_spacing_group, tof_group=tof_group, unit_to_keep=instrument._get_unit_to_keep()) common.remove_intermediate_workspace(corrected_van_ws) common.remove_intermediate_workspace(aligned_ws) common.remove_intermediate_workspace(focused_vanadium) common.remove_intermediate_workspace(focused_spectra) return d_spacing_group
def test_subtract_summed_runs_throw_on_tof_mismatch(self): # Create a sample workspace which will have mismatched TOF range sample_ws = mantid.CreateSampleWorkspace() mantid.AddSampleLog(Workspace=sample_ws, LogName='gd_prtn_chrg', LogText="10.0", LogType='Number') ws_file_name = "POL100" # Load POL100 empty_ws = mantid.Load(ws_file_name) # This should throw as the TOF ranges do not match with self.assertRaisesRegex( ValueError, "specified for this file do not have matching binning. Do the " ): common.subtract_summed_runs(ws_to_correct=sample_ws, empty_sample=empty_ws) mantid.DeleteWorkspace(sample_ws)
def create_van(instrument, run_details, absorb): """ Creates a splined vanadium run for the following instrument. Requires the run_details for the vanadium workspace we will process and whether to apply absorption corrections. :param instrument: The instrument object that will be used to supply various instrument specific methods :param run_details: The run details associated with this vanadium run :param absorb: Boolean flag whether to apply absorption corrections :return: Processed workspace group in dSpacing (but not splined) """ van = run_details.vanadium_run_numbers # Always sum a range of inputs as its a vanadium run over multiple captures input_van_ws_list = common.load_current_normalised_ws_list(run_number_string=van, instrument=instrument, input_batching=INPUT_BATCHING.Summed) input_van_ws = input_van_ws_list[0] # As we asked for a summed ws there should only be one returned corrected_van_ws = common.subtract_summed_runs(ws_to_correct=input_van_ws, empty_sample_ws_string=run_details.empty_runs, instrument=instrument) # Crop the tail end of the data on PEARL if they are not capturing slow neutrons corrected_van_ws = instrument._crop_raw_to_expected_tof_range(ws_to_crop=corrected_van_ws) if absorb: corrected_van_ws = instrument._apply_absorb_corrections(run_details=run_details, ws_to_correct=corrected_van_ws) else: # Assume that create_van only uses Vanadium runs mantid.SetSampleMaterial(InputWorkspace=corrected_van_ws, ChemicalFormula='V') aligned_ws = mantid.AlignDetectors(InputWorkspace=corrected_van_ws, CalibrationFile=run_details.offset_file_path) focused_vanadium = mantid.DiffractionFocussing(InputWorkspace=aligned_ws, GroupingFileName=run_details.grouping_file_path) focused_spectra = common.extract_ws_spectra(focused_vanadium) focused_spectra = instrument._crop_van_to_expected_tof_range(focused_spectra) d_spacing_group, tof_group = instrument._output_focused_ws(processed_spectra=focused_spectra, run_details=run_details) _create_vanadium_splines(focused_spectra, instrument, run_details) common.keep_single_ws_unit(d_spacing_group=d_spacing_group, tof_group=tof_group, unit_to_keep=instrument._get_unit_to_keep()) common.remove_intermediate_workspace(corrected_van_ws) common.remove_intermediate_workspace(aligned_ws) common.remove_intermediate_workspace(focused_vanadium) common.remove_intermediate_workspace(focused_spectra) return d_spacing_group
def test_subtract_summed_runs_no_current(self): # Load a vanadium workspace for this test sample_empty_number = "100" ws_file_name = "POL" + sample_empty_number original_ws = mantid.Load(ws_file_name) ws_to_correct = mantid.CloneWorkspace(InputWorkspace=original_ws) empty_ws = mantid.CloneWorkspace(InputWorkspace=original_ws) empty_ws = empty_ws * 0.3 returned_ws = common.subtract_summed_runs(ws_to_correct=ws_to_correct, empty_sample=empty_ws) y_values = returned_ws.readY(0) original_y_values = original_ws.readY(0) # subtraction should be skipped leaving original values for i in range(returned_ws.blocksize()): self.assertAlmostEqual(y_values[i], original_y_values[i]) mantid.DeleteWorkspace(ws_to_correct) mantid.DeleteWorkspace(empty_ws) mantid.DeleteWorkspace(returned_ws)
def test_subtract_summed_runs(self): # Load a vanadium workspace for this test sample_empty_number = "100" ws_file_name = "POL" + sample_empty_number original_ws = mantid.Load(ws_file_name) # add a current to ensure subtract_summed_runs gets past initial check mantid.AddSampleLog(Workspace=original_ws, LogName='gd_prtn_chrg', LogText="10.0", LogType='Number') no_scale_ws = mantid.CloneWorkspace(InputWorkspace=original_ws) empty_ws = mantid.CloneWorkspace(InputWorkspace=original_ws) empty_ws = empty_ws * 0.3 returned_ws = common.subtract_summed_runs(ws_to_correct=no_scale_ws, empty_sample=empty_ws) y_values = returned_ws.readY(0) original_y_values = original_ws.readY(0) for i in range(returned_ws.blocksize()): self.assertAlmostEqual(y_values[i], original_y_values[i] * 0.7) mantid.DeleteWorkspace(no_scale_ws) mantid.DeleteWorkspace(empty_ws) mantid.DeleteWorkspace(returned_ws)
def _focus_one_ws(input_workspace, run_number, instrument, perform_vanadium_norm, absorb, sample_details, vanadium_path): run_details = instrument._get_run_details(run_number_string=run_number) if perform_vanadium_norm: _test_splined_vanadium_exists(instrument, run_details) # Subtract empty instrument runs, as long as this run isn't an empty and user hasn't turned empty subtraction off if not common.runs_overlap(run_number, run_details.empty_runs ) and instrument.should_subtract_empty_inst(): input_workspace = common.subtract_summed_runs( ws_to_correct=input_workspace, instrument=instrument, empty_sample_ws_string=run_details.empty_runs) # Subtract a sample empty if specified if run_details.sample_empty: input_workspace = common.subtract_summed_runs( ws_to_correct=input_workspace, instrument=instrument, empty_sample_ws_string=run_details.sample_empty, scale_factor=instrument._inst_settings.sample_empty_scale) # Crop to largest acceptable TOF range input_workspace = instrument._crop_raw_to_expected_tof_range( ws_to_crop=input_workspace) # Correct for absorption / multiple scattering if required if absorb: input_workspace = instrument._apply_absorb_corrections( run_details=run_details, ws_to_correct=input_workspace) else: # Set sample material if specified by the user if sample_details is not None: mantid.SetSample( InputWorkspace=input_workspace, Geometry=common.generate_sample_geometry(sample_details), Material=common.generate_sample_material(sample_details)) # Align aligned_ws = mantid.AlignDetectors( InputWorkspace=input_workspace, CalibrationFile=run_details.offset_file_path) # Focus the spectra into banks focused_ws = mantid.DiffractionFocussing( InputWorkspace=aligned_ws, GroupingFileName=run_details.grouping_file_path) calibrated_spectra = _apply_vanadium_corrections( instrument=instrument, input_workspace=focused_ws, perform_vanadium_norm=perform_vanadium_norm, vanadium_splines=vanadium_path) output_spectra = instrument._crop_banks_to_user_tof(calibrated_spectra) bin_widths = instrument._get_instrument_bin_widths() if bin_widths: # Reduce the bin width if required on this instrument output_spectra = common.rebin_workspace_list( workspace_list=output_spectra, bin_width_list=bin_widths) # Output d_spacing_group, tof_group = instrument._output_focused_ws( output_spectra, run_details=run_details) common.keep_single_ws_unit(d_spacing_group=d_spacing_group, tof_group=tof_group, unit_to_keep=instrument._get_unit_to_keep()) # Tidy workspaces from Mantid common.remove_intermediate_workspace(input_workspace) common.remove_intermediate_workspace(aligned_ws) common.remove_intermediate_workspace(focused_ws) common.remove_intermediate_workspace(output_spectra) return d_spacing_group
def _focus_one_ws(ws, run_number, instrument, perform_vanadium_norm, absorb): run_details = instrument._get_run_details(run_number_string=run_number) if perform_vanadium_norm: _test_splined_vanadium_exists(instrument, run_details) # Subtract empty instrument runs input_workspace = common.subtract_summed_runs( ws_to_correct=ws, instrument=instrument, empty_sample_ws_string=run_details.empty_runs) # Subtract a sample empty if specified if run_details.sample_empty: input_workspace = common.subtract_summed_runs( ws_to_correct=input_workspace, instrument=instrument, empty_sample_ws_string=run_details.sample_empty, scale_factor=instrument._inst_settings.sample_empty_scale) # Crop to largest acceptable TOF range input_workspace = instrument._crop_raw_to_expected_tof_range( ws_to_crop=input_workspace) # Correct for absorption / multiple scattering if required if absorb: input_workspace = instrument._apply_absorb_corrections( run_details=run_details, ws_to_correct=input_workspace) # Align aligned_ws = mantid.AlignDetectors( InputWorkspace=input_workspace, CalibrationFile=run_details.offset_file_path) # Focus the spectra into banks focused_ws = mantid.DiffractionFocussing( InputWorkspace=aligned_ws, GroupingFileName=run_details.grouping_file_path) calibrated_spectra = _apply_vanadium_corrections( instrument=instrument, run_number=run_number, input_workspace=focused_ws, perform_vanadium_norm=perform_vanadium_norm) output_spectra = instrument._crop_banks_to_user_tof(calibrated_spectra) bin_widths = instrument._get_instrument_bin_widths() if bin_widths: # Reduce the bin width if required on this instrument output_spectra = common.rebin_workspace_list( workspace_list=output_spectra, bin_width_list=bin_widths) # Output d_spacing_group, tof_group = instrument._output_focused_ws( output_spectra, run_details=run_details) common.keep_single_ws_unit(d_spacing_group=d_spacing_group, tof_group=tof_group, unit_to_keep=instrument._get_unit_to_keep()) # Tidy workspaces from Mantid common.remove_intermediate_workspace(input_workspace) common.remove_intermediate_workspace(aligned_ws) common.remove_intermediate_workspace(focused_ws) common.remove_intermediate_workspace(output_spectra) return d_spacing_group
def _focus_one_ws(input_workspace, run_number, instrument, perform_vanadium_norm, absorb, sample_details, vanadium_path, empty_can_subtraction_method, paalman_pings_events_per_point=None): run_details = instrument._get_run_details(run_number_string=run_number) if perform_vanadium_norm: _test_splined_vanadium_exists(instrument, run_details) # Subtract empty instrument runs, as long as this run isn't an empty, user hasn't turned empty subtraction off, or # The user has not supplied a sample empty is_run_empty = common.runs_overlap(run_number, run_details.empty_inst_runs) summed_empty = None if not is_run_empty and instrument.should_subtract_empty_inst( ) and not run_details.sample_empty: if os.path.isfile(run_details.summed_empty_inst_file_path): logger.warning('Pre-summed empty instrument workspace found at ' + run_details.summed_empty_inst_file_path) summed_empty = mantid.LoadNexus( Filename=run_details.summed_empty_inst_file_path) else: summed_empty = common.generate_summed_runs( empty_sample_ws_string=run_details.empty_inst_runs, instrument=instrument) elif run_details.sample_empty: scale_factor = 1.0 if empty_can_subtraction_method != 'PaalmanPings': scale_factor = instrument._inst_settings.sample_empty_scale # Subtract a sample empty if specified ie empty can summed_empty = common.generate_summed_runs( empty_sample_ws_string=run_details.sample_empty, instrument=instrument, scale_factor=scale_factor) if absorb and empty_can_subtraction_method == 'PaalmanPings': if run_details.sample_empty: # need summed_empty including container input_workspace = instrument._apply_paalmanpings_absorb_and_subtract_empty( workspace=input_workspace, summed_empty=summed_empty, sample_details=sample_details, paalman_pings_events_per_point=paalman_pings_events_per_point) # Crop to largest acceptable TOF range input_workspace = instrument._crop_raw_to_expected_tof_range( ws_to_crop=input_workspace) else: raise TypeError( "The PaalmanPings absorption method requires 'sample_empty' to be supplied." ) else: if summed_empty: input_workspace = common.subtract_summed_runs( ws_to_correct=input_workspace, empty_sample=summed_empty) # Crop to largest acceptable TOF range input_workspace = instrument._crop_raw_to_expected_tof_range( ws_to_crop=input_workspace) if absorb: input_workspace = instrument._apply_absorb_corrections( run_details=run_details, ws_to_correct=input_workspace) else: # Set sample material if specified by the user if sample_details is not None: mantid.SetSample( InputWorkspace=input_workspace, Geometry=sample_details.generate_sample_geometry(), Material=sample_details.generate_sample_material()) # Align mantid.ApplyDiffCal(InstrumentWorkspace=input_workspace, CalibrationFile=run_details.offset_file_path) aligned_ws = mantid.ConvertUnits(InputWorkspace=input_workspace, Target="dSpacing") solid_angle = instrument.get_solid_angle_corrections( run_details.vanadium_run_numbers, run_details) if solid_angle: aligned_ws = mantid.Divide(LHSWorkspace=aligned_ws, RHSWorkspace=solid_angle) mantid.DeleteWorkspace(solid_angle) # Focus the spectra into banks focused_ws = mantid.DiffractionFocussing( InputWorkspace=aligned_ws, GroupingFileName=run_details.grouping_file_path) instrument.apply_calibration_to_focused_data(focused_ws) calibrated_spectra = _apply_vanadium_corrections( instrument=instrument, input_workspace=focused_ws, perform_vanadium_norm=perform_vanadium_norm, vanadium_splines=vanadium_path) output_spectra = instrument._crop_banks_to_user_tof(calibrated_spectra) bin_widths = instrument._get_instrument_bin_widths() if bin_widths: # Reduce the bin width if required on this instrument output_spectra = common.rebin_workspace_list( workspace_list=output_spectra, bin_width_list=bin_widths) # Output d_spacing_group, tof_group = instrument._output_focused_ws( output_spectra, run_details=run_details) common.keep_single_ws_unit(d_spacing_group=d_spacing_group, tof_group=tof_group, unit_to_keep=instrument._get_unit_to_keep()) # Tidy workspaces from Mantid common.remove_intermediate_workspace(input_workspace) common.remove_intermediate_workspace(aligned_ws) common.remove_intermediate_workspace(focused_ws) common.remove_intermediate_workspace(output_spectra) return d_spacing_group
def create_van(instrument, run_details, absorb): """ Creates a splined vanadium run for the following instrument. Requires the run_details for the vanadium workspace we will process and whether to apply absorption corrections. :param instrument: The instrument object that will be used to supply various instrument specific methods :param run_details: The run details associated with this vanadium run :param absorb: Boolean flag whether to apply absorption corrections :return: Processed workspace group in dSpacing (but not splined) """ van = run_details.vanadium_run_numbers # Always sum a range of inputs as its a vanadium run over multiple captures input_van_ws_list = common.load_current_normalised_ws_list( run_number_string=van, instrument=instrument, input_batching=INPUT_BATCHING.Summed) input_van_ws = input_van_ws_list[ 0] # As we asked for a summed ws there should only be one returned instrument.create_solid_angle_corrections(input_van_ws, run_details) if not (run_details.empty_runs is None): summed_empty = common.generate_summed_runs( empty_sample_ws_string=run_details.empty_runs, instrument=instrument) mantid.SaveNexus(Filename=run_details.summed_empty_file_path, InputWorkspace=summed_empty) corrected_van_ws = common.subtract_summed_runs( ws_to_correct=input_van_ws, empty_sample=summed_empty) # Crop the tail end of the data on PEARL if they are not capturing slow neutrons corrected_van_ws = instrument._crop_raw_to_expected_tof_range( ws_to_crop=corrected_van_ws) if absorb: corrected_van_ws = instrument._apply_absorb_corrections( run_details=run_details, ws_to_correct=corrected_van_ws) else: # Assume that create_van only uses Vanadium runs mantid.SetSampleMaterial(InputWorkspace=corrected_van_ws, ChemicalFormula='V') mantid.ApplyDiffCal(InstrumentWorkspace=corrected_van_ws, CalibrationFile=run_details.offset_file_path) aligned_ws = mantid.ConvertUnits(InputWorkspace=corrected_van_ws, Target="dSpacing") solid_angle = instrument.get_solid_angle_corrections( run_details.run_number, run_details) if solid_angle: aligned_ws = mantid.Divide(LHSWorkspace=aligned_ws, RHSWorkspace=solid_angle) mantid.DeleteWorkspace(solid_angle) focused_vanadium = mantid.DiffractionFocussing( InputWorkspace=aligned_ws, GroupingFileName=run_details.grouping_file_path) # convert back to TOF based on engineered detector positions mantid.ApplyDiffCal(InstrumentWorkspace=focused_vanadium, ClearCalibration=True) focused_spectra = common.extract_ws_spectra(focused_vanadium) focused_spectra = instrument._crop_van_to_expected_tof_range( focused_spectra) d_spacing_group, tof_group = instrument._output_focused_ws( processed_spectra=focused_spectra, run_details=run_details) _create_vanadium_splines(focused_spectra, instrument, run_details) common.keep_single_ws_unit(d_spacing_group=d_spacing_group, tof_group=tof_group, unit_to_keep=instrument._get_unit_to_keep()) common.remove_intermediate_workspace(corrected_van_ws) common.remove_intermediate_workspace(aligned_ws) common.remove_intermediate_workspace(focused_vanadium) common.remove_intermediate_workspace(focused_spectra) return d_spacing_group
def _focus_one_ws(input_workspace, run_number, instrument, perform_vanadium_norm, absorb, sample_details, vanadium_path): run_details = instrument._get_run_details(run_number_string=run_number) if perform_vanadium_norm: _test_splined_vanadium_exists(instrument, run_details) # Subtract empty instrument runs, as long as this run isn't an empty and user hasn't turned empty subtraction off if not common.runs_overlap(run_number, run_details.empty_runs) and instrument.should_subtract_empty_inst(): input_workspace = common.subtract_summed_runs(ws_to_correct=input_workspace, instrument=instrument, empty_sample_ws_string=run_details.empty_runs) # Subtract a sample empty if specified if run_details.sample_empty: input_workspace = common.subtract_summed_runs(ws_to_correct=input_workspace, instrument=instrument, empty_sample_ws_string=run_details.sample_empty, scale_factor=instrument._inst_settings.sample_empty_scale) # Crop to largest acceptable TOF range input_workspace = instrument._crop_raw_to_expected_tof_range(ws_to_crop=input_workspace) # Correct for absorption / multiple scattering if required if absorb: input_workspace = instrument._apply_absorb_corrections(run_details=run_details, ws_to_correct=input_workspace) else: # Set sample material if specified by the user if sample_details is not None: mantid.SetSample(InputWorkspace=input_workspace, Geometry=common.generate_sample_geometry(sample_details), Material=common.generate_sample_material(sample_details)) # Align aligned_ws = mantid.AlignDetectors(InputWorkspace=input_workspace, CalibrationFile=run_details.offset_file_path) # Focus the spectra into banks focused_ws = mantid.DiffractionFocussing(InputWorkspace=aligned_ws, GroupingFileName=run_details.grouping_file_path) calibrated_spectra = _apply_vanadium_corrections(instrument=instrument, input_workspace=focused_ws, perform_vanadium_norm=perform_vanadium_norm, vanadium_splines=vanadium_path) output_spectra = instrument._crop_banks_to_user_tof(calibrated_spectra) bin_widths = instrument._get_instrument_bin_widths() if bin_widths: # Reduce the bin width if required on this instrument output_spectra = common.rebin_workspace_list(workspace_list=output_spectra, bin_width_list=bin_widths) # Output d_spacing_group, tof_group = instrument._output_focused_ws(output_spectra, run_details=run_details) common.keep_single_ws_unit(d_spacing_group=d_spacing_group, tof_group=tof_group, unit_to_keep=instrument._get_unit_to_keep()) # Tidy workspaces from Mantid common.remove_intermediate_workspace(input_workspace) common.remove_intermediate_workspace(aligned_ws) common.remove_intermediate_workspace(focused_ws) common.remove_intermediate_workspace(output_spectra) return d_spacing_group