1 | import numpy as np |
---|
2 | # We create a fake workspace around the original extents of Test22Mev |
---|
3 | CreateMDWorkspace(Dimensions=3, Extents='-0.25,1.45,-0.55,0.55,-0.95,0.65', Names='A,B,C', Units='U,U,U', OutputWorkspace='c') |
---|
4 | # Put peaks in place to mark the edges in the original coordinate systemFakeMDEventData(InputWorkspace='c', PeakParams='10000,-0.25,-0.55,-0.95,0.1') |
---|
5 | FakeMDEventData(InputWorkspace='c', PeakParams='10000,1.45,-0.55,-0.95,0.1') |
---|
6 | FakeMDEventData(InputWorkspace='c', PeakParams='10000,-0.25,0.55,-0.95,0.1') |
---|
7 | FakeMDEventData(InputWorkspace='c', PeakParams='10000,1.45,0.55,-0.95,0.1') |
---|
8 | FakeMDEventData(InputWorkspace='c', PeakParams='10000,-0.25,-0.55,0.65,0.1') |
---|
9 | FakeMDEventData(InputWorkspace='c', PeakParams='10000,1.45,-0.55,0.65,0.1') |
---|
10 | FakeMDEventData(InputWorkspace='c', PeakParams='10000,-0.25,0.55,0.65,0.1') |
---|
11 | FakeMDEventData(InputWorkspace='c', PeakParams='10000,1.45,0.55,0.65,0.1') |
---|
12 | # Normalize NormalizeBasisVectors = False is important! |
---|
13 | u = np.array([1,1,0])v = np.array([0,0,1]) |
---|
14 | w = np.cross(v,u)c = mtd['c'] |
---|
15 | |
---|
16 | def calculate_extents(v, u, w, ws): |
---|
17 | M=np.array([u,v,w]) Minv=np.linalg.inv(M) # We are assuming that the workspace has dimensions H, K, L in that order. The workspace MUST have 3 dimensions at least for the following to work. |
---|
18 | Hrange=[ws.getDimension(0).getMinimum(), ws.getDimension(0).getMaximum()] Krange=[ws.getDimension(1).getMinimum(), ws.getDimension(1).getMaximum()] Lrange=[ws.getDimension(2).getMinimum(), ws.getDimension(2).getMaximum()] new_coords = np.empty([8, 3]) counter = 0 for h in Hrange: for k in Krange: for l in Lrange: originalCorner=np.array([h,k,l]) new_coords[counter]=originalCorner.dot(Minv) counter += 1 extents = list() print new_coords for i in range(0,3): extents.append(np.amin(new_coords[:,i])) extents.append(np.amax(new_coords[:,i])) # Copy extents for non crystallographic dimensions non_crystallographic_dimensions = ws.getNumDims() - 3 if non_crystallographic_dimensions > 0: for i in range(0, non_crystallographic_dimensions): extents.append(ws.getDimension(i + 3).getMinimum()) extents.append(ws.getDimension(i + 3).getMaximum()) return extents extents = calculate_extents(u,v,w,c)print 'x1,t,' + ','.join(map(str, u.tolist()))BinMD(InputWorkspace='c', NormalizeBasisVectors=False, AxisAligned=False, BasisVector0='x1,t,' + ','.join(map(str, u.tolist())), BasisVector1='x2,t,' + ','.join(map(str, v.tolist())), BasisVector2='x3,t,' + ','.join(map(str, w.tolist())), OutputExtents=','.join(map(str, extents)), OutputBins='100,100,100', OutputWorkspace='demo_histo')plotSlice('demo_histo')print np.identity(3)[0, :] |
---|