Commit f65bb605 authored by Whitfield, Ross's avatar Whitfield, Ross
Browse files

Cleanup temp workspaces

parent a196b517
...@@ -10,7 +10,7 @@ from mantid.simpleapi import (ConvertUnits, ExtractSpectra, ...@@ -10,7 +10,7 @@ from mantid.simpleapi import (ConvertUnits, ExtractSpectra,
ApplyDiffCal, DiffractionFocussing, ApplyDiffCal, DiffractionFocussing,
PDCalibration, Load, LoadMask, PDCalibration, Load, LoadMask,
LoadDiffCal, LoadDetectorsGroupingFile, LoadDiffCal, LoadDetectorsGroupingFile,
SaveDiffCal) SaveDiffCal, DeleteWorkspace)
# Diamond peak positions in d-space # Diamond peak positions in d-space
DIAMOND = (0.3117,0.3257,0.3499,0.4205,0.4645, DIAMOND = (0.3117,0.3257,0.3499,0.4205,0.4645,
...@@ -59,28 +59,29 @@ def cc_calibrate_groups(data_ws, ...@@ -59,28 +59,29 @@ def cc_calibrate_groups(data_ws,
for group in group_list: for group in group_list:
indexes = np.where(group_ws.extractY().flatten() == group)[0] indexes = np.where(group_ws.extractY().flatten() == group)[0]
ExtractSpectra(data_d, WorkspaceIndexList=indexes, OutputWorkspace=f'_tmp_group_{group}') ExtractSpectra(data_d, WorkspaceIndexList=indexes, OutputWorkspace='_tmp_group_cc')
ExtractUnmaskedSpectra(f'_tmp_group_{group}', OutputWorkspace=f'_tmp_group_{group}') ExtractUnmaskedSpectra('_tmp_group_cc', OutputWorkspace='_tmp_group_cc')
if mtd[f'_tmp_group_{group}'].getNumberHistograms() < 2: if mtd['_tmp_group_cc'].getNumberHistograms() < 2:
continue continue
Rebin(f'_tmp_group_{group}', Params=f'{Xmin},{Step},{Xmax}', OutputWorkspace=f'_tmp_group_{group}') Rebin('_tmp_group_cc', Params=f'{Xmin},{Step},{Xmax}', OutputWorkspace='_tmp_group_cc')
CrossCorrelate(f'_tmp_group_{group}', CrossCorrelate('_tmp_group_cc',
Xmin=Xmin, XMax=Xmax, Xmin=Xmin, XMax=Xmax,
MaxDSpaceShift=MaxDSpaceShift, MaxDSpaceShift=MaxDSpaceShift,
WorkspaceIndexMin=0, WorkspaceIndexMin=0,
WorkspaceIndexMax=mtd[f'_tmp_group_{group}'].getNumberHistograms()-1, WorkspaceIndexMax=mtd['_tmp_group_cc'].getNumberHistograms()-1,
OutputWorkspace=f'_tmp_group_{group}_cc') OutputWorkspace='_tmp_group_cc')
bin_range = (Xmax-Xmin)/Step bin_range = (Xmax-Xmin)/Step
GetDetectorOffsets(InputWorkspace=f'_tmp_group_{group}_cc', GetDetectorOffsets(InputWorkspace='_tmp_group_cc',
Step=Step, Step=Step,
Xmin=-bin_range, XMax=bin_range, Xmin=-bin_range, XMax=bin_range,
DReference=DReference, DReference=DReference,
MaxOffset=1, MaxOffset=1,
OutputWorkspace=f'{output_basename}_offsets_{group}') OutputWorkspace='_tmp_group_cc')
previous_calibration = ConvertDiffCal(f'{output_basename}_offsets_{group}', previous_calibration = ConvertDiffCal('_tmp_group_cc',
PreviousCalibration=previous_calibration, PreviousCalibration=previous_calibration,
OutputWorkspace=f'{output_basename}_cc_diffcal') OutputWorkspace=f'{output_basename}_cc_diffcal')
DeleteWorkspace('_tmp_group_cc')
return mtd[f'{output_basename}_cc_diffcal'] return mtd[f'{output_basename}_cc_diffcal']
...@@ -124,14 +125,14 @@ def pdcalibration_groups(data_ws, ...@@ -124,14 +125,14 @@ def pdcalibration_groups(data_ws,
ApplyDiffCal(data_ws, CalibrationWorkspace=cc_diffcal) ApplyDiffCal(data_ws, CalibrationWorkspace=cc_diffcal)
ConvertUnits(data_ws, Target='dSpacing', OutputWorkspace='_tmp_data_aligned') ConvertUnits(data_ws, Target='dSpacing', OutputWorkspace='_tmp_data_aligned')
DiffractionFocussing('_tmp_data_aligned', GroupingWorkspace=group_ws, OutputWorkspace='_tmp_data_aligned_focussed') DiffractionFocussing('_tmp_data_aligned', GroupingWorkspace=group_ws, OutputWorkspace='_tmp_data_aligned')
# Remove the following line after new CombineDiffCal algorithm is implemented as that will use the calibrated difc # Remove the following line after new CombineDiffCal algorithm is implemented as that will use the calibrated difc
ApplyDiffCal('_tmp_data_aligned_focussed', ClearCalibration=True) ApplyDiffCal('_tmp_data_aligned', ClearCalibration=True)
ConvertUnits('_tmp_data_aligned_focussed', Target='TOF', OutputWorkspace='_tmp_data_aligned_focussed') ConvertUnits('_tmp_data_aligned', Target='TOF', OutputWorkspace='_tmp_data_aligned')
PDCalibration(InputWorkspace='_tmp_data_aligned_focussed', PDCalibration(InputWorkspace='_tmp_data_aligned',
TofBinning=TofBinning, TofBinning=TofBinning,
PreviousCalibrationTable=previous_calibration, PreviousCalibrationTable=previous_calibration,
PeakFunction=PeakFunction, PeakFunction=PeakFunction,
...@@ -148,7 +149,7 @@ def pdcalibration_groups(data_ws, ...@@ -148,7 +149,7 @@ def pdcalibration_groups(data_ws,
cc_det_to_difc = dict(zip(cc_diffcal.column('detid'), cc_diffcal.column('difc'))) cc_det_to_difc = dict(zip(cc_diffcal.column('detid'), cc_diffcal.column('difc')))
grouped = mtd['_tmp_data_aligned_focussed'] grouped = mtd['_tmp_data_aligned']
specInfo = grouped.spectrumInfo() specInfo = grouped.spectrumInfo()
grouped_det_to_difc = {} grouped_det_to_difc = {}
...@@ -164,6 +165,8 @@ def pdcalibration_groups(data_ws, ...@@ -164,6 +165,8 @@ def pdcalibration_groups(data_ws,
* cc_det_to_difc[detid] * cc_det_to_difc[detid]
/ grouped_det_to_difc[detid]) / grouped_det_to_difc[detid])
DeleteWorkspace('_tmp_data_aligned')
return mtd[f'{output_basename}_cc_pd_diffcal'] return mtd[f'{output_basename}_cc_pd_diffcal']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment