1 | from mantid import config, logger, mtd |
---|
2 | # this section not needed - ws already there when gui is opened |
---|
3 | instr = 'IRIS' |
---|
4 | ana = 'graphite' |
---|
5 | refl = '002' |
---|
6 | mt_ws = '_empty'+instr |
---|
7 | idf_dir = config['instrumentDefinition.directory'] |
---|
8 | idf = idf_dir + instr + '_Definition.xml' |
---|
9 | LoadEmptyInstrument(Filename=idf, OutputWorkspace=mt_ws) |
---|
10 | ipf = idf_dir + instr + '_' + ana + '_' + refl + '_Parameters.xml' |
---|
11 | LoadParameterFile(Workspace=mt_ws, Filename=ipf) |
---|
12 | # except for mt_ws |
---|
13 | instrument = mtd[mt_ws].getInstrument() |
---|
14 | analyser = instrument.getStringParameter('analyser')[0] |
---|
15 | resolution = instrument.getComponentByName(analyser).getNumberParameter('resolution')[0] |
---|
16 | x = [-6*resolution, -5*resolution, -2*resolution, 0.0, 2*resolution] |
---|
17 | # BgdMin, BgdMax, PeakMin, PeakZero, PeakMax |
---|
18 | y = [1,2,3,4] |
---|
19 | e = [0,0,0,0] |
---|
20 | CreateWorkspace(OutputWorkspace='energy', DataX=x, DataY=y, DataE=e, |
---|
21 | Nspec=1, UnitX='DeltaE') |
---|
22 | ConvertToHistogram(InputWorkspace='energy', OutputWorkspace='energy') |
---|
23 | LoadInstrument(Workspace='energy', InstrumentName=instr) |
---|
24 | LoadParameterFile(Workspace='energy', Filename=ipf) |
---|
25 | efixed = mtd['energy'].getInstrument().getNumberParameter('efixed-val')[0] |
---|
26 | print 'efixed = '+str(efixed) |
---|
27 | # Reset det IDs |
---|
28 | spectrum = mtd['energy'].getSpectrum(0) |
---|
29 | spectrum.setSpectrumNo(3) |
---|
30 | spectrum.clearDetectorIDs() |
---|
31 | spectrum.addDetectorID(3) |
---|
32 | ConvertUnits(InputWorkspace='energy', OutputWorkspace='tof', Target='TOF', |
---|
33 | EMode='Indirect', EFixed=efixed) |
---|
34 | tof = mtd['tof'].readX(0) |
---|
35 | # energy increasing on converting becomes time decreasing |
---|
36 | # so the parameter order is reversed |
---|
37 | # these are the default values |
---|
38 | PeakMin = tof[0] |
---|
39 | PeakMax = tof[2] |
---|
40 | BgdMin = tof[3] |
---|
41 | BgdMax = tof[4] |
---|