SANSILLAutoProcessTest.py 5.38 KB
Newer Older
1
2
3
4
5
6
7
8
9
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI,
#   NScD Oak Ridge National Laboratory, European Spallation Source,
#   Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +

import unittest
from mantid.simpleapi import SANSILLAutoProcess, config, mtd
10
from mantid.api import WorkspaceGroup, MatrixWorkspace
11
12
13
14


class SANSILLAutoProcessTest(unittest.TestCase):

gvardany's avatar
gvardany committed
15
16
17
18
19
    @classmethod
    def setUpClass(cls):
        cls._facility = config["default.facility"]
        cls._instrument = config["default.instrument"]
        cls._dirs = config["datasearch.directories"]
gvardany's avatar
gvardany committed
20
21
        config.appendDataSearchSubDir("ILL/D11/")
        config.appendDataSearchSubDir("ILL/D16/")
22
23
24
        config["default.facility"] = "ILL"
        config["default.instrument"] = "D11"

gvardany's avatar
gvardany committed
25
26
27
28
29
30
    @classmethod
    def tearDownClass(cls):
        config["default.facility"] = cls._facility
        config["default.instrument"] = cls._instrument
        config["datasearch.directories"] = cls._dirs

31
32
33
    def tearDown(self):
        mtd.clear()

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
    def test_noSampleRun(self):
        self.assertRaises(RuntimeError, SANSILLAutoProcess)

    def test_noOutputWs(self):
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462")

    def test_wrongAbsorberDim(self):
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462",
                          AbsorberRuns="010462,010462",
                          OutputWorkspace="ws")

    def test_wrongBeamDim(self):
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462",
                          BeamRuns="010462,010462",
                          OutputWorkspace="ws")

    def test_wrongContainerDim(self):
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462",
                          ContainerRuns="010462,010462",
                          OutputWorkspace="ws")

    def test_wrongMaskDim(self):
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462",
                          MaskFiles="010462,010462",
                          OutputWorkspace="ws")

    def test_wrongReferenceDim(self):
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462",
                          ReferenceFiles="010462,010462",
                          OutputWorkspace="ws")

    def test_wrongSensivityDim(self):
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462",
                          SensitivityMaps="010462,010462",
                          OutputWorkspace="ws")

    def test_wrongFluxDim(self):
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462",
                          FluxRuns="010462,010462",
                          OutputWorkspace="ws")

    def test_wrongParametersDim(self):
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462",
                          MaxQxy="1,1",
                          OutputWorkspace="ws")
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462",
                          DeltaQ="1,1",
                          OutputWorkspace="ws")
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462",
                          BeamRadius="1,1",
                          OutputWorkspace="ws")

    def test_wrongTransmissionDim(self):
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462,010462",
                          SampleTransmissionRuns="010462,010462",
                          OutputWorkspace="ws")
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462,010462",
                          ContainerTransmissionRuns="010462,010462",
                          OutputWorkspace="ws")
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462,010462",
                          TransmissionBeamRuns="010462,010462",
                          OutputWorkspace="ws")
        self.assertRaises(RuntimeError, SANSILLAutoProcess,
                          SampleRuns="010462,010462",
                          TransmissionAbsorberRuns="010462,010462",
                          OutputWorkspace="ws")

115
116
117
118
119
120
    def test_flux(self):
        ws = SANSILLAutoProcess(SampleRuns="010462",
                                FluxRuns='010462')

        self.assertTrue(isinstance(ws, WorkspaceGroup))

gvardany's avatar
gvardany committed
121
122
123
124
    def test_one_q_binning_params(self):
        ws = SANSILLAutoProcess(SampleRuns="3674, 3677, 3680", OutputBinning='0.01')
        self.assertTrue(ws)

125
    def test_minimalProcessing(self):
126
        ws = SANSILLAutoProcess(SampleRuns="010462")
127

128
129
130
131
132
133
        self.assertTrue(isinstance(ws, WorkspaceGroup))
        self.assertEqual(ws.getNumberOfEntries(), 1)
        item = ws.getItem(0)
        self.assertTrue(isinstance(item, MatrixWorkspace))
        self.assertEqual(item.getAxis(0).getUnit().unitID(), "MomentumTransfer")
        self.assertEquals(item.getNumberHistograms(), 1)
134
135
136
137


if __name__ == "__main__":
    unittest.main()