Make a DataFile and DataSet

In this tutorial we demonstrate how to make DataFiles and DataSets in DMCpy. You create a DataFile by the loadDataFile function. The input for loadDataFile is file name and path as a string. In addition, can arguments that act on the DataFile be give, e.g. twoThetaPosition. The _tools.fileListGenerator is a useful tool to create a list of DataFiles with complete path. The input is the short number of the Datafile and path. Several DataFiles can be added into one DataSet. This is done by giving DataSet a list of DataFiles: DataSet(dataFiles)

 1from DMCpy import DataFile,DataSet, _tools
 2import numpy as np
 3
 4# Create a DataFile and DataSet for 565
 5file = r'data\dmc2021n000565.hdf'
 6
 7df = DataFile.loadDataFile(file)
 8ds = DataSet.DataSet(df)
 9
10
11# Create a DataFile and DataSet for 565 with correct twoTheta
12twoThetaOffset = 1.0
13
14df = DataFile.loadDataFile(file,twoThetaPosition=twoThetaOffset)
15ds = DataSet.DataSet(df)
16
17# Create a DataFile and DataSet with _tools.fileListGenerator
18scanNumbers = '578'
19folder = 'data'
20
21# Create complete filepath
22file = os.path.join(os.getcwd(),_tools.fileListGenerator(scanNumbers,folder)[0])
23
24df = DataFile.loadDataFile(file,twoThetaPosition=twoThetaOffset)
25ds = DataSet.DataSet(df)
26
27# If we want to load several DataFiles in the DataSet
28dataFiles = [DataFile.loadDataFile(dFP,twoThetaPosition=twoThetaOffset) for dFP in _tools.fileListGenerator(scanNumbers,folder)]
29
30ds = DataSet.DataSet(dataFiles)
31
32
33# We can also add a unit cell to the dataFiles when loaded:
34scanNumbers = '12153'
35folder = 'data/SC'
36year = 2022
37
38filePath = _tools.fileListGenerator(scanNumbers,folder,year=year)
39
40unitCell = np.array([ 7.218, 7.218, 18.183, 90.0, 90.0, 120.0])
41
42# # # load dataFiles
43dataFiles = [DataFile.loadDataFile(dFP,unitCell = unitCell) for dFP in filePath]