Ticket #11691: Bilby_through_reduction_framework_Anders.2.py

File Bilby_through_reduction_framework_Anders.2.py, 1.7 KB (added by Anton Piccardo-Selg, 5 years ago)
Line 
1from mantid.simpleapi import *
2import ISISCommandInterface as ici
3import isis_instrument
4
5# create a dummy instrument setup, here starting up with LARMOR
6# the values below are probably somewhat ga ga
7class BILBY(isis_instrument.LARMOR):
8        WAV_RANGE_MIN = 2.5
9        WAV_RANGE_MAX = 12.0
10
11        def on_load_sample(self, ws_name, beamcentre, isSample):
12                print ws_name
13                ws = mtd[ws_name]
14                out = Rebin(ws, '30500,500,38500', False)
15                RenameWorkspace(out, OutputWorkspace=ws_name)
16        def setDetector(self, name):
17                bank = self.get_low_angle_detector()
18                bank._shape = bank._DectShape(20, 3072, True, 61440)
19                bank.set_first_spec_num(0)
20                return self.setDefaultDetector()
21        def get_TOFs(self, nm):
22                return 30500, 38500
23        def move_components(self, ws, bx, by):
24                return [0,0], [-bx, -by]
25       
26        def curr_detector_position(self, ws_name):
27                return [0,0]
28       
29ici.ReductionSingleton().set_instrument(BILBY())
30
31# load a random mask file
32ici.MaskFile('MaskSANS2DReductionGUI.txt')
33
34# load mcstas event data
35ici.AssignSample('BBY0000014.tar')
36
37# set detector. PLEASE NOTE IT WOULD BE BETTER IF LoadBBY ASSSIGNED SOME
38# UNIQUE NAME FOR EACH BANK
39ici.Detector('bank')
40
41# manual set sample info since this is not set in this nexus file
42# This is NOT PRETTY. BETTER IF THE LoadBBY add sample information
43# Here just done as below for testing
44ici.ReductionSingleton().get_sample().geometry.height = 1.0
45ici.ReductionSingleton().get_sample().geometry.width = 1.0
46ici.ReductionSingleton().get_sample().geometry.thickness = 1.0
47print ici.ReductionSingleton().get_sample().geometry.shape
48print ici.ReductionSingleton().get_sample().geometry.height
49print ici.ReductionSingleton().get_sample().geometry.width
50print ici.ReductionSingleton().get_sample().geometry.thickness
51
52ici.WavRangeReduction(2.2, 12   )