Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -9,8 +9,8 @@ from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, InstrumentVali ...@@ -9,8 +9,8 @@ from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, InstrumentVali
WorkspaceProperty, WorkspaceUnitValidator) WorkspaceProperty, WorkspaceUnitValidator)
from mantid.kernel import (CompositeValidator, Direction, FloatBoundedValidator, IntArrayBoundedValidator, from mantid.kernel import (CompositeValidator, Direction, FloatBoundedValidator, IntArrayBoundedValidator,
IntArrayProperty, Property, StringArrayProperty, StringListValidator) IntArrayProperty, Property, StringArrayProperty, StringListValidator)
from mantid.simpleapi import (ClearMaskFlag, CloneWorkspace, CreateEmptyTableWorkspace, Divide, from mantid.simpleapi import (ClearMaskFlag, CloneWorkspace, CreateEmptyTableWorkspace, CreateSingleValuedWorkspace, Divide,
ExtractMask, Integration, LoadMask, MaskDetectors, MedianDetectorTest, Plus, SolidAngle) ExtractMask, Integration, LoadMask, MaskDetectors, MedianDetectorTest, Multiply, Plus, SolidAngle)
import numpy import numpy
import os.path import os.path
...@@ -83,10 +83,17 @@ def _createDiagnosticsReportTable(reportWSName, numberHistograms, algorithmLoggi ...@@ -83,10 +83,17 @@ def _createDiagnosticsReportTable(reportWSName, numberHistograms, algorithmLoggi
def _createMaskWS(ws, name, algorithmLogging): def _createMaskWS(ws, name, algorithmLogging):
"""Return a single bin workspace with same number of histograms as ws.""" """Return a single bin workspace with same number of histograms as ws."""
maskWS, detList = ExtractMask(InputWorkspace=ws, extractResult = ExtractMask(InputWorkspace=ws,
OutputWorkspace=name, OutputWorkspace=name,
EnableLogging=algorithmLogging) EnableLogging=algorithmLogging)
maskWS *= 0.0 zeroWS = CreateSingleValuedWorkspace(DataValue=0.,
ErrorValue=0.,
EnableLogging=algorithmLogging,
StoreInADS=False)
maskWS = Multiply(LHSWorkspace=extractResult.OutputWorkspace,
RHSWorkspace=zeroWS,
OutputWorkspace=name,
EnableLogging=algorithmLogging)
return maskWS return maskWS
...@@ -793,10 +800,10 @@ class DirectILLDiagnostics(DataProcessorAlgorithm): ...@@ -793,10 +800,10 @@ class DirectILLDiagnostics(DataProcessorAlgorithm):
DetectorList=userMask, DetectorList=userMask,
ComponentList=maskComponents, ComponentList=maskComponents,
EnableLogging=algorithmLogging) EnableLogging=algorithmLogging)
maskWS, detectorList = ExtractMask(InputWorkspace=maskWS, extractResult = ExtractMask(InputWorkspace=maskWS,
OutputWorkspace=maskWSName, OutputWorkspace=maskWSName,
EnableLogging=algorithmLogging) EnableLogging=algorithmLogging)
return maskWS return extractResult.OutputWorkspace
def _value(self, ws, propertyName, instrumentParameterName, defaultValue): def _value(self, ws, propertyName, instrumentParameterName, defaultValue):
"""Return a suitable value either from a property, the IPF or the supplied defaultValue.""" """Return a suitable value either from a property, the IPF or the supplied defaultValue."""
......
...@@ -181,6 +181,34 @@ class DirectILLDiagnosticsTest(unittest.TestCase): ...@@ -181,6 +181,34 @@ class DirectILLDiagnosticsTest(unittest.TestCase):
else: else:
self.assertEquals(ys[0], 0) 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): def testOutputIsUsable(self):
inWS = mtd[self._RAW_WS_NAME] inWS = mtd[self._RAW_WS_NAME]
spectraCount = inWS.getNumberHistograms() spectraCount = inWS.getNumberHistograms()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment