~gcg/splithopkinsontools/trunk

« back to all changes in this revision

Viewing changes to LineScanAnalysis.py

  • Committer: gcg
  • Date: 2017-10-06 12:29:59 UTC
  • Revision ID: gcg-20171006122959-ppqs0y22z341ezbb
shtb tools

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
from pyqtgraph.parametertree import Parameter, ParameterTree
15
15
 
16
16
# only edit lines below:
17
 
path = "/home/gcg/SHTB/20170804_Puls_Flash/1"
 
17
path = "/home/gcg/SHTB/20171005_PP"
18
18
 
19
 
params = [{'name': 'px2mm', 'type': 'float', 'value': 0.01325, 'step': 1.0e-3, 'siPrefix': False, 'suffix': 'mm/px'},
 
19
params = [{'name': 'px2mm', 'type': 'float', 'value':  0.02439, 'step': 1.0e-3, 'siPrefix': False, 'suffix': 'mm/px'},
20
20
          {'name': 'scan rate', 'type': 'float', 'value': 200, 'step': 1, 'suffix': 'kHz'},
21
21
          {'name': 'width ROI 1 in px', 'type': 'float', 'value': 1, 'suffix': ' px'},
22
22
          {'name': 'width ROI 1 in mm', 'type': 'float', 'value': 1, 'suffix': ' mm'},
43
43
    image_data = misc.imread(os.path.join(path,files[0]), flatten=1)
44
44
    print np.shape(image_data)
45
45
    
46
 
    return image_data
 
46
    # average every two subsequent lines
 
47
    nx, ny = np.shape(image_data)
 
48
    new_data = np.zeros((nx/2, ny))
 
49
    for i in xrange(nx/2 - 1):
 
50
        j = 2*i
 
51
        k = j + 1
 
52
        new_data[i,:] = 0.5 * (image_data[j,:] + image_data[k,:])
 
53
        
 
54
    print "*** AVERAGED EVERY TWO LINES ***"
 
55
    
 
56
    #return image_data
 
57
    return new_data
47
58
 
48
59
def updatePlot():
49
60
    global x
127
138
    strain = (y2 - y1) / L0  
128
139
    
129
140
    header = "linescan frequency = %f kHz\npixel length = %f mm\ngauge length = %f\ntime [msec], ROI1 displacement [mm], ROI2 displacement [mm], relative displacement [mm],  strain [-]" % (p["scan rate"], p["px2mm"], L0*p["px2mm"])
130
 
    np.savetxt(os.path.join(path, "linescan_analysis.dat"), np.column_stack((x, y1, y2, y3, strain)),
 
141
    np.savetxt(os.path.join(path, "linescan_analysis.dat"), np.column_stack((2*x, y1, y2, y3, strain)),
131
142
                header=header)
132
143
    print "wrote output file linescan_analysis.dat to directory [%s]" % (path)
133
144