Unverified Commit 0afb8979 authored by Gagik Vardanyan's avatar Gagik Vardanyan Committed by GitHub
Browse files

Merge pull request #23618 from mantidproject/23597_DirectILLDiagnostics_logging

Quiet down DirectILLDiagnostics
parents 3712c0a5 507349d4
......@@ -9,8 +9,8 @@ from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, InstrumentVali
WorkspaceProperty, WorkspaceUnitValidator)
from mantid.kernel import (CompositeValidator, Direction, FloatBoundedValidator, IntArrayBoundedValidator,
IntArrayProperty, Property, StringArrayProperty, StringListValidator)
from mantid.simpleapi import (ClearMaskFlag, CloneWorkspace, CreateEmptyTableWorkspace, Divide,
ExtractMask, Integration, LoadMask, MaskDetectors, MedianDetectorTest, Plus, SolidAngle)
from mantid.simpleapi import (ClearMaskFlag, CloneWorkspace, CreateEmptyTableWorkspace, CreateSingleValuedWorkspace, Divide,
ExtractMask, Integration, LoadMask, MaskDetectors, MedianDetectorTest, Multiply, Plus, SolidAngle)
import numpy
import os.path
......@@ -83,10 +83,17 @@ def _createDiagnosticsReportTable(reportWSName, numberHistograms, algorithmLoggi
def _createMaskWS(ws, name, algorithmLogging):
"""Return a single bin workspace with same number of histograms as ws."""
maskWS, detList = ExtractMask(InputWorkspace=ws,
OutputWorkspace=name,
EnableLogging=algorithmLogging)
maskWS *= 0.0
extractResult = ExtractMask(InputWorkspace=ws,
OutputWorkspace=name,
EnableLogging=algorithmLogging)
zeroWS = CreateSingleValuedWorkspace(DataValue=0.,
ErrorValue=0.,
EnableLogging=algorithmLogging,
StoreInADS=False)
maskWS = Multiply(LHSWorkspace=extractResult.OutputWorkspace,
RHSWorkspace=zeroWS,
OutputWorkspace=name,
EnableLogging=algorithmLogging)
return maskWS
......@@ -793,10 +800,10 @@ class DirectILLDiagnostics(DataProcessorAlgorithm):
DetectorList=userMask,
ComponentList=maskComponents,
EnableLogging=algorithmLogging)
maskWS, detectorList = ExtractMask(InputWorkspace=maskWS,
OutputWorkspace=maskWSName,
EnableLogging=algorithmLogging)
return maskWS
extractResult = ExtractMask(InputWorkspace=maskWS,
OutputWorkspace=maskWSName,
EnableLogging=algorithmLogging)
return extractResult.OutputWorkspace
def _value(self, ws, propertyName, instrumentParameterName, defaultValue):
"""Return a suitable value either from a property, the IPF or the supplied defaultValue."""
......
......@@ -181,6 +181,34 @@ class DirectILLDiagnosticsTest(unittest.TestCase):
else:
self.assertEquals(ys[0], 0)
def testMaskedComponents(self):
inWS = mtd[self._RAW_WS_NAME]
spectraCount = inWS.getNumberHistograms()
outWSName = 'diagnosticsWS'
kwargs = {
'InputWorkspace': self._RAW_WS_NAME,
'OutputWorkspace': outWSName,
'ElasticPeakDiagnostics': 'Peak Diagnostics OFF',
'BkgDiagnostics': 'Bkg Diagnostics OFF',
'BeamStopDiagnostics': 'Beam Stop Diagnostics OFF',
'DefaultMask': 'Default Mask OFF',
'MaskedComponents': 'tube_1',
'rethrow': True
}
run_algorithm('DirectILLDiagnostics', **kwargs)
self.assertTrue(mtd.doesExist(outWSName))
outWS = mtd[outWSName]
self.assertEquals(outWS.getNumberHistograms(), spectraCount)
self.assertEquals(outWS.blocksize(), 1)
for i in range(spectraCount):
Ys = outWS.readY(i)
detector = outWS.getDetector(i)
componentName = detector.getFullName()
if 'tube_1' in componentName:
self.assertEquals(Ys[0], 1)
else:
self.assertEquals(Ys[0], 0)
def testOutputIsUsable(self):
inWS = mtd[self._RAW_WS_NAME]
spectraCount = inWS.getNumberHistograms()
......
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