Viewer 3D

In a single crystal experiment, the first step is to gain an overview of the system. This is most often done by performing an A3 scan with the sample in a specific scattering plane. Due to the 2D detector of DMC, such an A3 scan produces a 3D set of measured data points. In the frame of reference of the instrument, the majority of the covered volume is in the Qx-Qy plane, i.e. with Qz close to zero. A single A3 slices corresponds to a curved line in th Qx-Qy together with a symmetrically curved line in Qz. This sheet is then rotated around the origin with each A3 step. Without an UB matrix, we can first look at the data in Q-space. This is done by having rlu=False.

Interactivity

The Viewer 3D is an interactive plotting function which allows a look through the data in steps along the three major axes. In the current build, these are along Qx, Qy, and Qz, and once can change between them by clicking keys on the keyboard as tabulated below

Key press

Effect

0

Change plotting such that Qx is constant

1

Change plotting such that Qy is constant

2

Change plotting such that Qz is constant

+ or UpArrow

Increment step along constant axis

Page Up

Increment 10 steps along constant axis

- or DownArrow

Decrement step along constant axis

Page Down

Decrement 10 steps along constant axis

s

Save current figure

End

Skip to the end of allowed stop in this projection

Home

Skip to the start of allowed stop in this projection

 1from DMCpy import DataSet,DataFile,_tools
 2
 3# Give file number and folder the file is stored in.
 4scanNumbers = '12153-12154'
 5folder = 'data/SC'
 6year = 2022
 7
 8filePath = _tools.fileListGenerator(scanNumbers,folder,year=year)
 9
10# # # load dataFiles
11dataFiles = [DataFile.loadDataFile(dFP) for dFP in filePath]
12
13# load data files and make data set
14ds = DataSet.DataSet(dataFiles)
15
16# plot the data with 3D Viewer
17Viewer = ds.Viewer3D(0.01,0.01,0.01,rlu=False)
18
19# Set the color bar limits to 0 and 0.001
20Viewer.set_clim(0,0.001)
21
22# set axes to be equal
23Viewer.ax.axis('equal')
24
25# Find the number of steps and set viewer to middel value
26# This can also be done interactively in the viewer by pressing up or down,
27# or by scrolling the mouse wheel or clicking the sliding bar.
28zSteps = Viewer.Z.shape[-1]
29Viewer.setPlane(int(zSteps/2)-1)
30
31fig = Viewer.ax.get_figure()
32fig.savefig('figure0.png',format='png')
33
34#  Change programatically to the next plane
35Viewer.setPlane(int(zSteps/2))
36fig2 = Viewer.ax.get_figure()
37fig2.savefig('figure1.png',format='png')
38
39
40# Instead of only stepping through the data with the Qx and Qy in the plane
41# one can flip the view by clicking 0, 1, or 2 in the interactive view,
42# or do it programmatically by
43
44Viewer.changeAxis(0)
45xSteps = Viewer.X.shape[-1]
46
47# Notice that the shape of X, Y, and Z changes when the axis is flipped!
48# The last dimension is alway 'orthogonal' to the view.
49Viewer.setPlane(int(xSteps/2)-1)
50
51fig3 = Viewer.ax.get_figure()
52fig3.savefig('figure2.png',format='png')
53
54# data from 3D Viewer can be saved as a mat file. The generated files are large, in the order of several GB.
55if False:
56   savedata = {'data':V.Data, 'bins':V.bins}
57   savemat("matlab_matrix.mat", savedata)

The above code takes the data from a A3 scan and generates the Viewer 3D utilizing a voxel size of 0.01 x 0.01 x 0.01 A:math:^{-3}. By default, the viewer starts out in projection 2, i.e. with Qz being the axis stepped through. When handling the data directly it is more convenient to utilize the keyboard shortcuts but in a scripting interface these are not available. Instead one can utilize the .setPlane and .changeAxis methods. In addition, the color scale has been tweaked such that weaker peaks are visible. It is possible to slightly tweak the color scale directly in the Viewer 3D by using the sliders to the right of the color bar. Notice: When saving the figure these slides are rendered invisible. The end results are shown below:

First data overview with Qz slightly positive and Qx and Qy in the plane

../../_images/CenterMiddel.png

One step ‘higher’ up along Qz in the same scattering plane

../../_images/CenterAboveMiddel.png

Flipping of the scattering plane axis to 0, i.e. with Qx being constant

../../_images/CenterQx.png