Viewer 3D align with new prjection vectors¶
This tutorial illustrate that somethimes 3Dviewer can calculate different projector vectors than we prefer. This can be corrected by overwriting the projection vectors as done in the code below.
1from DMCpy import DataSet,DataFile,_tools
2import numpy as np
3
4# Give file number and folder the file is stored in.
5scanNumbers = '12105-12106'
6folder = 'data/SC'
7year = 2022
8
9filePath = _tools.fileListGenerator(scanNumbers,folder,year=year)
10
11unitCell = np.array([ 7.218, 7.218, 18.183, 90.0, 90.0, 120.0])
12
13# # # load dataFiles
14dataFiles = [DataFile.loadDataFile(dFP,unitCell = unitCell) for dFP in filePath]
15
16# load data files and make data set
17ds = DataSet.DataSet(dataFiles)
18
19# Define Q coordinates and HKL for the coordinates.
20q2 = [-1.2240,-1.6901,-0.0175]
21q1 = [-1.4275,1.0299,-0.0055]
22HKL2 = [0,0,6]
23HKL1 = [1,1,0]
24
25# this function uses two coordinates in Q space and align them to corrdinates in HKL space
26ds.alignToRefs(q1=q1,q2=q2,HKL1=HKL1,HKL2=HKL2)
27
28Viewer = ds.Viewer3D(0.01,0.01,0.02,rlu=True)
29
30Viewer.set_clim(0,0.001)
31
32zSteps = Viewer.Z.shape[-1]
33Viewer.setPlane(int(zSteps/2)-1)
34
35fig = Viewer.ax.get_figure()
36fig.savefig('figure0.png',format='png')
37
38# we can enforce new projection vectors by this command:
39p1 = np.array([1,1,0])
40p2 = np.array([0,0,1])
41ds.setProjectionVectors(p1,p2,p3=None)
42
43Viewer2 = ds.Viewer3D(0.01,0.01,0.02,rlu=True)
44
45Viewer2.set_clim(0,0.001)
46
47zSteps = Viewer2.Z.shape[-1]
48Viewer2.setPlane(int(zSteps/2)-1)
49
50fig = Viewer2.ax.get_figure()
51fig.savefig('figure1.png',format='png')
The above code takes the data from the A3 scan files 12105-12106 from 2022 and generates the Viewer 3D utilizing a voxel size of 0.01 x 0.01 x 0.01 in Q-space. By default, the viewer starts out in projection 2, i.e. but the projection is strange. This is because 3Dviewer allways use 100, 010 or 001 as one of the projected axis. We can overwrite this and get 3Dviewer to plot what we want.
3DViewer with default projection vectors
3DViewer with new projection vectors