plt.plot(time,amplitude) plt.title('amplitude over time') plt.show() #Plot smooth amplitude over time plt.plot(time,smoothamplitude) plt.title('Smooth amplitude over time') plt.show() #Plot deltaAmplitude over time plt.plot(time,deltaA) plt.title('delta Amplitude over time') plt.show() #Autocorrelate smooth amplitude ac = PhyPraKit.autocorrelate(smoothamplitude) #Plot Maximumarray plt.plot(ac) plt.title("Autocorrelate") plt.show() #Find minimums and maximums of autocorrelate and take differences maxac = maximumfinder(ac) minac = minimumfinder(ac) print(maxac) print(minac) plt.plot(ac) plt.title("Autocorrelate")
' processing file ' + fname) # read data from PicoScope units, data = ppk.readPicoScope(fname, prlevel=2) t = data[0] a = data[1] print("** Fourier Spectrum") freq, amp = ppk.FourierSpectrum(t, a, fmax=20) # freq, amp = ppk.Fourier_fft(t, a) # use fast algorithm frequency = freq[np.where(amp == max(amp))] print(" --> Frequenz mit max. Amplitude: ", frequency) # calculate autocorrelation function print("** Autocorrelation Function") ac_a = ppk.autocorrelate(a) ac_t = t - t[0] # run peak finder width = 80 # use convoluted template filter pidx = ppk.convolutionPeakfinder(ac_a, width, th=0.4) if len(pidx) > 3: print(" --> %i auto-correlation peaks found" % (len(pidx))) pidx[0] = 0 # first peak is at 0 by construction tp, ap = np.array(ac_t[pidx]), np.array(ac_a[pidx]) else: print("*!!* not enough peaks found - tune peakfinder parameters!") sys.exit(1) # Filter peaks and dips: keep only largest ones
M = 0.14174 #Angaben in kg M_F = 0.0154 o_me = 0.1 * 10**-3 #Fehler von der Wage me, o_me = (M + 1. / 3. * M_F), o_me + 1 / 3 * o_me #Bestimmung von T ___________________________________________________________________________ hlines, data = ppk.readCSV('HandyPendel.csv') t = data[0] a = data[2] #Glätten der Funktion a_smooth = ppk.meanFilter(a, 7) # calculate autocorrelation function ac_a = ppk.autocorrelate(a_smooth) ac_t = t # find maxima and minima using convolution peak finder width = 3 pidxac = ppk.convolutionPeakfinder(ac_a, width, th=0.66) didxac = ppk.convolutionPeakfinder(-ac_a, width, th=0.66) if len(pidxac) > 1: print(" --> %i auto-correlation peaks found" % (len(pidxac))) pidxac[0] = 0 # first peak is at 0 by construction ac_tp, ac_ap = np.array(ac_t[pidxac]), np.array(ac_a[pidxac]) ac_td, ac_ad = np.array(ac_t[didxac]), np.array(ac_a[didxac]) else: print("*!!* not enough correlation peaks found") #Plot erstellen