~gcg/splithopkinsontools/trunk

« back to all changes in this revision

Viewing changes to SynchronizeStrain_force.py

  • Committer: gcg
  • Date: 2018-03-16 16:21:26 UTC
  • Revision ID: gcg-20180316162126-uwdmokuwqfljive0
switched LineScanAnalysis to OpenCV

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
        # first resample using linear interpolation and very fine grid
112
112
        # this makes the data monotonix in x
113
113
        xmin, xmax = x[0], x[-1]
114
 
        xs_fine = np.linspace(xmin, xmax, 100000)
 
114
        xs_fine = np.linspace(xmin, xmax, 10000)
115
115
        from scipy.interpolate import UnivariateSpline, interp1d
116
116
        f = interp1d(x, y)
117
117
        ys1 = f(xs_fine)
118
118
        
119
119
        # now fit a spline to the data
120
 
        spl_smooth = UnivariateSpline(xs_fine, ys1, k=3, s=0.1)
 
120
        spl_smooth = UnivariateSpline(xs_fine, ys1, k=3, s=0.01)
121
121
        spl_raw = UnivariateSpline(xs_fine, ys1, k=3, s=0.0)
122
122
        xs = np.linspace(xmin, xmax, 2000)
123
123
        
143
143
        
144
144
        # plot stress/strain
145
145
        
146
 
        self.strain, self.raw_stress, self.smooth_stress = self.generate_smooth_stress_strain(1.0)
 
146
        #self.strain, self.raw_stress, self.smooth_stress = self.generate_smooth_stress_strain(1.0)
 
147
        self.strain, self.raw_stress, self.smooth_stress = self.correlated_strain, self.correlated_force / self.A, self.correlated_force / self.A
147
148
        
148
149
        self.axarr[1].cla()
149
150
        self.axarr[1].plot(self.strain, self.raw_stress, label="raw data", linewidth=1, color="gray")
217
218
        """
218
219
        force_data = np.genfromtxt(self.forceFile, delimiter=" ", skip_header = 0)
219
220
        self.fx = force_data[:,0]
220
 
        self.fy = force_data[:,2]
 
221
        self.fy = force_data[:,1]
221
222
        self.dtForce = self.fx[1] - self.fx[0]
222
223
        numPtsForce = len(self.fx)
223
224
        print numPtsForce
251
252
    def readStrainData(self):
252
253
        strain_data = np.genfromtxt(self.strainFile, delimiter=" ", skip_header = 0)
253
254
        self.sx0 = strain_data[:,0]
254
 
        self.sy0 = strain_data[:,3] # this is relative displacement, nedd to convert to strain
255
 
        self.sy0 /= L0
 
255
        self.sy0 = strain_data[:,4] # this is relative displacement, nedd to convert to strain
 
256
        #self.sy0 /= L0
256
257
        self.dtstrain = self.sx0[1] - self.sx0[0]
257
258
        #numPtsstrain = len(self.sx0)
258
259
        
267
268
        #self.sx0 -= START_TIME
268
269
        print "strain time axis: [%g -- %g], sampling interval is %g" % (self.sx0[0], self.sx0[-1], self.dtstrain)
269
270
        
270
 
        #window_len = 2
271
 
        #print "smoothing strain data with window length %g" % (window_len*self.dtstrain)
272
 
        #self.sy0 = smooth.smooth(self.sy0, window_len, window="blackman")
 
271
        window_len = 10
 
272
        print "smoothing strain data with window length %g" % (window_len*self.dtstrain)
 
273
        self.sy0 = smooth.smooth(self.sy0, window_len, window="blackman")
273
274
 
274
 
START_TIME = 37.0        
275
 
FAILURE_TIME = 37.92 # use this to cut off force data after failure -- makes for a nicer plot 
276
 
L0 = 16        
277
 
A = 18
 
275
START_TIME = 0.25        
 
276
FAILURE_TIME = 1.36 # use this to cut off force data after failure -- makes for a nicer plot 
 
277
L0 = 1        
 
278
A = 24
278
279
NSAMPLES = 2000
279
280
E = 210
280
281
Erange = 0.002
281
282
SPECIMEN_TITLE = "PP / Cordenka"      
282
283
        
283
 
directory = "/home/gcg/SHTB/20171005_PP"
 
284
directory = "/home/gcg/SHTB/testData"
284
285
strain_file = os.path.join(directory, "linescan_analysis.dat")
285
 
#force_file = os.path.join(directory, "SHTB_time_strain_force.dat")
286
286
force_file = os.path.join(directory, "time_force_nonshifted.txt")
287
287
SyncStrainForce(strain_file, force_file, L0, A, E, Erange)