Alignment

A UB matrix is needed to convert the measured data into hkl-space. UB matrices is stored in the sample object in DMCpy and can be saved and loaded as binary files. DMC only measure one scattering plane and conventional indexing will not work as information in one direction will be missing. DMCpy therefore has a few alternative methods for generating UB matrices. alignToRefs is the recommended method for alignment. It is a method that takes two QxQyQz coordinates, which is used to tilt and rotate the data.

alignToRef is a method which takes one spesific QxQyQz coordinates, which is used to tilt and rotate the data.

 1from DMCpy import DataSet,DataFile,_tools
 2import numpy as np
 3
 4# Give file number and folder the file is stored in.
 5scanNumbers = '12153-12154'
 6folder = 'data/SC'
 7year = 2022
 8
 9filePath = _tools.fileListGenerator(scanNumbers,folder,year=year)
10
11# we can add the unit cell to the data files or directly to DMCpy when we load the data
12unitCell = np.array([ 7.218, 7.218, 18.183, 90.0, 90.0, 120.0])
13
14# Alternative to add unit cell to files
15if False:
16   _tools.giveUnitCellToHDF(filePath,unitCell)
17
18# # # load dataFiles with unit cell
19dataFiles = [DataFile.loadDataFile(dFP,unitCell = unitCell) for dFP in filePath]
20
21# load data files and make data set
22ds = DataSet.DataSet(dataFiles)
23
24# The recommended function for alignment is alignToRefs, which takes two coordinates in Q and the corresponding hkl vectors
25q1 = [-0.447,-0.914,-0.003]
26q2 = [-1.02,-0.067,-0.02]
27HKL1 = [1,0,0]
28HKL2 = [0,1,0]
29
30# this function uses two coordinates in Q space and align them to corrdinates in HKL space
31ds.alignToRefs(q1=q1,q2=q2,HKL1=HKL1,HKL2=HKL2)
32
33# To find the A3, A4 and z values of a reflection, we can use calcualteHKLToA3A4Z
34# The function work on both DataSet and DataFile level
35ds.calcualteHKLToA3A4Z(1,1,0)
36
37# save UB to file
38if False:
39   _tools.saveSampleToDesk(ds[0].sample,r'UB.bin')
40
41# # # load UB from file
42if False:
43   rlu = True
44   ds.loadSample(r'UB.bin')