1 | #import mantid |
---|
2 | from mantid.simpleapi import * |
---|
3 | #sys.path.append("/Users/spu92482/Documents/mantid/systemtests/StressTestFramework") |
---|
4 | |
---|
5 | #import stresstesting |
---|
6 | |
---|
7 | import datetime |
---|
8 | from time import localtime, strftime |
---|
9 | import os |
---|
10 | |
---|
11 | def _skip_test(): |
---|
12 | """Helper function to determine if we run the test""" |
---|
13 | import platform |
---|
14 | # Only runs on RHEL6 at the moment |
---|
15 | if "Linux" not in platform.platform(): |
---|
16 | return True |
---|
17 | flavour = platform.linux_distribution()[2] |
---|
18 | if flavour == 'Santiago': # Codename for RHEL6 |
---|
19 | return False # Do not skip |
---|
20 | else: |
---|
21 | return True |
---|
22 | |
---|
23 | class PG3Calibration(object): |
---|
24 | |
---|
25 | def skipTests(self): |
---|
26 | return _skip_test() |
---|
27 | |
---|
28 | def requiredFiles(self): |
---|
29 | files = ["PG3_2538_event.nxs"] |
---|
30 | return files |
---|
31 | |
---|
32 | def requiredMemoryMB(self): |
---|
33 | """Requires 3Gb""" |
---|
34 | return 3000 |
---|
35 | |
---|
36 | def runTest(self): |
---|
37 | # determine where to save |
---|
38 | import os |
---|
39 | savedir = os.path.abspath(os.path.curdir) |
---|
40 | |
---|
41 | # run the actual code |
---|
42 | CalibrateRectangularDetectors(OutputDirectory = savedir, SaveAs = 'calibration', FilterBadPulses = True, |
---|
43 | GroupDetectorsBy = 'All', DiffractionFocusWorkspace = False, Binning = '0.5, -0.0004, 2.5', |
---|
44 | MaxOffset=0.01, PeakPositions = '2.0592,1.2610,1.0754,0.7280', |
---|
45 | CrossCorrelation = False, Instrument = 'PG3', RunNumber = '2538', Extension = '_event.nxs') |
---|
46 | |
---|
47 | # load saved cal file |
---|
48 | self.saved_cal_file = savedir+"/PG3_calibrate_d2538"+strftime("_%Y_%m_%d.cal") |
---|
49 | LoadCalFile(InputWorkspace="PG3_2538_calibrated", CalFileName=self.saved_cal_file, WorkspaceName="PG3_2538", |
---|
50 | MakeGroupingWorkspace=False) |
---|
51 | MaskDetectors(Workspace="PG3_2538_offsets",MaskedWorkspace="PG3_2538_mask") |
---|
52 | # load golden cal file |
---|
53 | LoadCalFile(InputWorkspace="PG3_2538_calibrated", CalFileName="PG3_golden.cal", WorkspaceName="PG3_2538_golden", |
---|
54 | MakeGroupingWorkspace=False) |
---|
55 | MaskDetectors(Workspace="PG3_2538_golden_offsets",MaskedWorkspace="PG3_2538_golden_mask") |
---|
56 | |
---|
57 | def validateMethod(self): |
---|
58 | return "ValidateWorkspaceToWorkspace" |
---|
59 | |
---|
60 | def validate(self): |
---|
61 | self.tolerance = 1.0e-4 |
---|
62 | return ('PG3_2538_offsets','PG3_2538_golden_offsets') |
---|
63 | |
---|
64 | class PG3CCCalibration(object): |
---|
65 | |
---|
66 | def skipTests(self): |
---|
67 | return _skip_test() |
---|
68 | |
---|
69 | def requiredFiles(self): |
---|
70 | files = ["PG3_2538_event.nxs"] |
---|
71 | return files |
---|
72 | |
---|
73 | def requiredMemoryMB(self): |
---|
74 | """Requires 3Gb""" |
---|
75 | return 3000 |
---|
76 | |
---|
77 | def runTest(self): |
---|
78 | # determine where to save |
---|
79 | import os |
---|
80 | savedir = os.path.abspath(os.path.curdir) |
---|
81 | |
---|
82 | # run the actual code |
---|
83 | |
---|
84 | CalibrateRectangularDetectors(OutputDirectory = savedir, SaveAs = 'calibration', FilterBadPulses = True, |
---|
85 | GroupDetectorsBy = 'All', DiffractionFocusWorkspace = False, Binning = '0.5, -0.0004, 2.5', |
---|
86 | MaxOffset=0.01, PeakPositions = '0.7282933,1.261441',DetectorsPeaks = '17,6', |
---|
87 | CrossCorrelation = True, Instrument = 'PG3', RunNumber = '2538', Extension = '_event.nxs') |
---|
88 | |
---|
89 | # load saved cal file |
---|
90 | self.saved_cal_file = savedir+"/PG3_calibrate_d2538"+strftime("_%Y_%m_%d.cal") |
---|
91 | LoadCalFile(InputWorkspace="PG3_2538_calibrated", CalFileName=self.saved_cal_file, WorkspaceName="PG3_2538", |
---|
92 | MakeGroupingWorkspace=False) |
---|
93 | MaskDetectors(Workspace="PG3_2538_offsets",MaskedWorkspace="PG3_2538_mask") |
---|
94 | # load golden cal file |
---|
95 | LoadCalFile(InputWorkspace="PG3_2538_calibrated", CalFileName="PG3_goldenCC.cal", WorkspaceName="PG3_2538_golden", |
---|
96 | MakeGroupingWorkspace=False) |
---|
97 | MaskDetectors(Workspace="PG3_2538_golden_offsets",MaskedWorkspace="PG3_2538_golden_mask") |
---|
98 | |
---|
99 | def validateMethod(self): |
---|
100 | return "ValidateWorkspaceToWorkspace" |
---|
101 | |
---|
102 | def validate(self): |
---|
103 | self.tolerance = 1.0e-4 |
---|
104 | return ('PG3_2538_offsets','PG3_2538_golden_offsets') |
---|
105 | |
---|
106 | test = PG3Calibration() |
---|
107 | test.runTest() |
---|