Ticket #8395: create_larmor_data2.2.py

File create_larmor_data2.2.py, 1.6 KB (added by Gesner Passos, 7 years ago)
Line 
1import numpy as np
2
3
4def getLarmorRowColumn(index): 
5        return index%512,index/512
6
7def getSansIndexFromLarmor(index):
8        row, column = getLarmorRowColumn(index)
9        row_sans = int((row * 192) / 512)
10        column_sans = int( (column * 192) / 80)
11        return column_sans * 192 + row_sans
12
13def createLarmorData(sansrun, larmorfile):
14  larmor = LoadEmptyInstrument('/apps/mantid/mantid_develop2/Code/Mantid/instrument/LARMOR_Definition.xml')
15  larmor = larmor.rebin('5.0, 200, 100000')
16 
17  sans2d = LoadNexus(sansrun)
18  sans2d = sans2d.rebin('5.0, 200, 100000')
19
20  for i in [0,1]:
21    larmor.getAxis(i).setUnit(sans2d.getAxis(i).getUnit().unitID())
22 
23  for i in range(8):
24    larmor.setY(i, sans2d.readY(i))
25    larmor.setE(i, sans2d.readE(i))
26       
27  for i in range(40960):
28    t_index = getSansIndexFromLarmor(i) + 8
29    larmor.setY(i+10, sans2d.readY(t_index))
30    larmor.setE(i+10, sans2d.readE(t_index))
31
32
33  cloned_sans = CropWorkspace(sans2d,EndWorkspaceIndex=40969)
34
35  for i in range(40970):
36    cloned_sans.setY(i, larmor.readY(i))
37    cloned_sans.setE(i, larmor.readE(i))
38
39  LoadInstrument(cloned_sans, InstrumentName='LARMOR')
40
41  #SaveNexus(cloned_sans, larmorfile)
42  SaveNexus(larmor, larmorfile)
43
44
45
46createLarmorData('SANS2D14273','LARMOR00000073.nxs')
47createLarmorData('SANS2D14253', 'LARMOR00000053.nxs')
48createLarmorData('SANS2D14270', 'LARMOR00000070.nxs')
49createLarmorData('SANS2D14272', 'LARMOR00000072.nxs')
50
51full_path = FileFinder.getFullPath('LARMOR00000073.nxs')
52import h5py
53h5f = h5py.File(full_path, 'r+')
54sample = h5f['mantid_workspace_1/sample']
55sample['geom_height'][:] = 8.0
56sample['geom_id'][:] = 3
57sample['geom_thickness'][:] = 2.0
58sample['geom_width'] [:]= 8.0
59h5f.close()
60
61