Commit 7fa68223 authored by Whitfield, Ross's avatar Whitfield, Ross
Browse files

Remove masked PDCalibration output from final diffcal

parent 98f2d7fc
......@@ -10,7 +10,7 @@ from mantid.simpleapi import (ConvertUnits, ExtractSpectra,
ApplyDiffCal, DiffractionFocussing,
PDCalibration, Load, LoadMask,
LoadDiffCal, LoadDetectorsGroupingFile,
SaveDiffCal, DeleteWorkspace)
SaveDiffCal, DeleteWorkspace, DeleteTableRows)
# Diamond peak positions in d-space
DIAMOND = (0.3117,0.3257,0.3499,0.4205,0.4645,
......@@ -149,10 +149,23 @@ def pdcalibration_groups(data_ws,
DiagnosticWorkspaces=f'{output_basename}_pd_diag')
# Everything below will all be replaced by be the new CombineDiffCal algorithm
pd_diffcal = mtd[f'{output_basename}_pd_diffcal']
cc_and_pd_diffcal = CloneWorkspace(f'{output_basename}_pd_diffcal', OutputWorkspace=f'{output_basename}_cc_pd_diffcal')
# remove masked detectors
mask_ws = mtd[f'{output_basename}_pd_diffcal_mask']
rows_to_remove = []
detid_list = cc_and_pd_diffcal.column('detid')
for n in range(mask_ws.getNumberHistograms()):
if mask_ws.readY(n)[0] == 1:
try:
rows_to_remove.append(detid_list.index(mask_ws.getSpectrum(n).getDetectorIDs()[0]))
except ValueError:
pass
if rows_to_remove:
DeleteTableRows(cc_and_pd_diffcal, Rows=rows_to_remove)
cc_det_to_difc = dict(zip(cc_diffcal.column('detid'), cc_diffcal.column('difc')))
grouped = mtd['_tmp_data_aligned']
......@@ -167,7 +180,7 @@ def pdcalibration_groups(data_ws,
for n, detid in enumerate(cc_and_pd_diffcal.column('detid')):
if detid in cc_det_to_difc and detid in grouped_det_to_difc:
cc_and_pd_diffcal.setCell(n, 1,
pd_diffcal.cell(n, 1)
cc_and_pd_diffcal.cell(n, 1)
* cc_det_to_difc[detid]
/ grouped_det_to_difc[detid])
......
......@@ -87,11 +87,9 @@ class TestGroupCalibration(unittest.TestCase):
[starting_difc[0],
starting_difc[1]/0.95,
starting_difc[2]/1.05,
0,
starting_difc[4]/0.95,
starting_difc[5]/(0.95*0.98),
starting_difc[6]/(0.95*1.02),
0], rtol=0.005)
starting_difc[6]/(0.95*1.02)], rtol=0.005)
def test_from_prev_cal(self):
......@@ -148,11 +146,9 @@ class TestGroupCalibration(unittest.TestCase):
[starting_difc[0],
starting_difc[1]/0.95,
starting_difc[2]/1.05,
starting_difc[3]*1.01,
starting_difc[4]/0.95,
starting_difc[5]/(0.95*0.98),
starting_difc[6]/(0.95*1.02),
starting_difc[7]*1.01], rtol=0.005)
starting_difc[6]/(0.95*1.02)], rtol=0.005)
def test_di_group_calibration(self):
ws, groups = create_test_ws_and_group()
......@@ -195,11 +191,9 @@ class TestGroupCalibration(unittest.TestCase):
[starting_difc[0],
starting_difc[1]/0.95,
starting_difc[2]/1.05,
starting_difc[3]*1.01,
starting_difc[4]/0.95,
starting_difc[5]/(0.95*0.98),
starting_difc[6]/(0.95*1.02),
starting_difc[7]*1.01], rtol=0.005)
starting_difc[6]/(0.95*1.02)], rtol=0.005)
if __name__ == '__main__':
......
Supports Markdown
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