Repository navigation
Expand file tree
/
Copy pathreader.py
More file actions
43 lines (35 loc) · 1.78 KB
/
Copy pathreader.py
File metadata and controls
43 lines (35 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import numpy as np
import pandas as pd
def parse_vulcan_vdrive(fname,skip_lines,nslice,nrow,ncol,hkl='211',det_bank=1):
'''
Function to read VULCAN beam-line generated V-drive files and re-shape them into numpy arrays of strain maps.
This is useful for strain mapping experiments
Input: fname: Full path to file (txt)
skip_lines : Number of lines corresponding to test scans or those used to determine d0
nslice : Number of "X" slices to image - usually the 3rd dimension
nrow : Number of vertical measurements i.e. y axis
ncol : Number of horizontal measurments i.e. z axis
hkl : The hkl peak of interest (string)
det_bank : Detector bank number
Output: tot_counts : Total counts at each point
fit_quality : Quality of fit for each point
strain : Estimated d-spacing by fitting
x,y,z : x, y and z coordinates of each measurement
'''
delimiter='\t'
count_col = 'TotalCounts'
temp_str = hkl+'_'+str(det_bank)
strain_comp='d_'+ temp_str
quality_flag = 'GoodFit_'+temp_str
data = pd.read_csv(fname,sep=delimiter)
#Read strain pattern
strain = data[strain_comp][skip_lines-1:].to_numpy().reshape(nslice,nrow,ncol)
#Read corresponding quality flag
fit_quality = data[quality_flag][skip_lines-1:].to_numpy().reshape(nslice,nrow,ncol)
#Read counts
tot_counts = data[count_col][skip_lines-1:].to_numpy().reshape(nslice,nrow,ncol)
#Read coordinates for each measurement
x = data['X'][skip_lines-1:].to_numpy().reshape(nslice,nrow,ncol)
y = data['Y'][skip_lines-1:].to_numpy().reshape(nslice,nrow,ncol)
z = data['Z'][skip_lines-1:].to_numpy().reshape(nslice,nrow,ncol)
return x,y,z, tot_counts,fit_quality, strain