Cut1D¶
After inspecting the scattering plane, we want to perform cuts along certain directions. In this tutorial, we demonstrate the cut1D function. Cuts can be made given by hkl or Qx, Qy, Qz. The width of the cut can be adjusted by the keywords width and widthZ. The unit of width and widthZ is AA-1.
1from DMCpy import DataSet,DataFile,_tools
2import numpy as np
3import os
4
5# Give file number and folder the file is stored in.
6scanNumbers = '12105-12106'
7folder = 'data/SC'
8year = 2022
9
10filePath = _tools.fileListGenerator(scanNumbers,folder,year=year)
11
12unitCell = np.array([ 7.218, 7.218, 18.183, 90.0, 90.0, 120.0])
13
14# # # load dataFiles
15dataFiles = [DataFile.loadDataFile(dFP,unitCell = unitCell) for dFP in filePath]
16
17# load data files and make data set
18ds = DataSet.DataSet(dataFiles)
19
20# Define Q coordinates and HKL for the coordinates.
21q2 = [-1.2240,-1.6901,-0.0175]
22q1 = [-1.4275,1.0299,-0.0055]
23HKL2 = [0,0,6]
24HKL1 = [1,1,0]
25
26# this function uses two coordinates in Q space and align them to corrdinates in HKL space
27ds.alignToRefs(q1=q1,q2=q2,HKL1=HKL1,HKL2=HKL2)
28
29# Here we do a cut over a reflection by the cut1D function.
30# cut1D takes start and end point as lists.
31
32kwargs = {
33 'width' : 0.1,
34 'widthZ' : 0.5,
35 'stepSize' : 0.005,
36 'rlu' : True,
37 'optimize' : True,
38 'marker' : 'o',
39 'color' : 'green',
40 'markersize' : 8,
41 'mew' : 1.5,
42 'linewidth' : 1.5,
43 'capsize' : 3,
44 'linestyle' : (0, (1, 1)),
45 'mfc' : 'white',
46 }
47
48positionVector,I,err,ax = ds.plotCut1D([1.333,1.333,-0.5],[1.333,1.333,0.5],**kwargs)
49fig = ax.get_figure()
50fig.savefig('figure0.png',format='png')
51
52#export of cut to text file
53if False:
54 path = os.path.join(os.getcwd(),folder)
55 saveData = np.column_stack([positionVector[0],positionVector[1],positionVector[2],I,err])
56 np.savetxt(os.path.join(path,'cut.txt'),saveData,header='h,k,l,I,err',delimiter=',')
The above code takes the data from a A3 scan, and align it by the alignToRefs function.Then one cuts across the 4/3,4/3,l direction. The example also demonstrate how kwargs can be given to the functions to adjust the apperance of the figure.
The cut is diplayed below