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.

 1import matplotlib.pyplot as plt
 2from DMCpy import DataSet,DataFile,_tools
 3import numpy as np
 4import os
 5
 6# Give file number and folder the file is stored in.
 7scanNumbers = '12105-12106'
 8folder = 'data/SC'
 9year = 2022
10
11filePath = _tools.fileListGenerator(scanNumbers,folder,year=year)
12
13unitCell = np.array([ 7.218, 7.218, 18.183, 90.0, 90.0, 120.0])
14
15# # # load dataFiles
16dataFiles = [DataFile.loadDataFile(dFP,unitCell = unitCell) for dFP in filePath]
17
18# load data files and make data set
19ds = DataSet.DataSet(dataFiles)
20
21# Define Q coordinates and HKL for the coordinates.
22q2 = [-1.2240,-1.6901,-0.0175]
23q1 = [-1.4275,1.0299,-0.0055]
24HKL2 = [0,0,6]
25HKL1 = [1,1,0]
26
27# this function uses two coordinates in Q space and align them to corrdinates in HKL space
28ds.alignToRefs(q1=q1,q2=q2,HKL1=HKL1,HKL2=HKL2)
29
30# Here we do a cut over the (440) reflection by the cut1D function.
31# cut1D takes start and end point as lists.
32
33kwargs = {
34          'width' : 0.1,
35          'widthZ' : 0.5,
36          'stepSize' : 0.005,
37          'rlu' : True,
38          'optimize' : False,
39          'marker' : 'o',
40          'color' : 'green',
41          'markersize' : 8,
42          'mew' : 1.5,
43          'linewidth' : 1.5,
44          'capsize' : 3,
45          'linestyle' : (0, (1, 1)),
46          'mfc' : 'white',
47          }
48
49positionVector,I,err,ax = ds.plotCut1D([1.333,1.333,-0.5],[1.333,1.333,0.5],**kwargs)
50fig = ax.get_figure()
51fig.savefig('figure0.png',format='png')
52
53#export of cut to text file
54if False:
55   path = os.path.join(os.getcwd(),folder)
56   saveData = np.column_stack([positionVector[0],positionVector[1],positionVector[2],I,err])
57   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

../_images/Cut1.png