/
IndirectDiffScanTest.py
74 lines (54 loc) · 2.45 KB
/
IndirectDiffScanTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
from __future__ import (absolute_import, division, print_function)
import unittest
from mantid.simpleapi import *
from mantid.api import *
class IndirectDiffScanTest(unittest.TestCase):
def test_basic_reduction_completes(self):
"""
Sanity test to ensure the most basic reduction actually completes.
"""
IndirectDiffScan(InputFiles=['IRS26176.RAW'],
Instrument='IRIS',
SpectraRange=[105, 112])
wks = mtd['Output']
self.assertTrue(isinstance(wks, WorkspaceGroup), 'Result workspace should be a workspace group.')
self.assertEqual(len(wks), 1)
self.assertEqual(wks.getNames()[0], 'iris26176_diffspec_red')
red_ws = wks[0]
self.assertEqual(red_ws.getAxis(0).getUnit().unitID(), 'dSpacing')
self.assertEqual(red_ws.getNumberHistograms(), 1)
scan_ws = mtd['Output_scan']
self.assertEqual(round(scan_ws.readY(0)[0], 7), 6.6324986)
def test_multi_files(self):
"""
Test reducing multiple files.
"""
IndirectDiffScan(InputFiles=['IRS26176.RAW', 'IRS26173.RAW'],
Instrument='IRIS',
SpectraRange=[105, 112])
wks = mtd['Output']
self.assertTrue(isinstance(wks, WorkspaceGroup), 'Result workspace should be a workspace group.')
self.assertEqual(len(wks), 2)
self.assertEqual(wks.getNames()[0], 'iris26176_diffspec_red')
self.assertEqual(wks.getNames()[1], 'iris26173_diffspec_red')
red_ws = wks[0]
self.assertEqual(red_ws.getAxis(0).getUnit().unitID(), 'dSpacing')
self.assertEqual(red_ws.getNumberHistograms(), 1)
scan_ws = mtd['Output_scan']
self.assertEqual(round(scan_ws.readY(0)[0], 7), 6.6324986)
def test_osiris(self):
"""
Test with OSIRIS
"""
IndirectDiffScan(InputFiles=['osi89813.raw'],
Instrument='OSIRIS',
SpectraRange=[100, 150])
wks = mtd['Output']
self.assertTrue(isinstance(wks, WorkspaceGroup), 'Result workspace should be a workspace group.')
self.assertEqual(len(wks), 1)
self.assertEqual(wks.getNames()[0], 'osiris89813_diffspec_red')
red_ws = wks[0]
self.assertEqual(red_ws.getAxis(0).getUnit().unitID(), 'dSpacing')
self.assertEqual(red_ws.getNumberHistograms(), 1)
if __name__ == '__main__':
unittest.main()