def read_data(self): self.iunit = int(self.Lb1.curselection()[0]) if (self.iunit == 0): # common array self.t, self.c, self.num = read_two_columns_from_dialog( 'Select Input File', self.master) else: self.t, self.a, self.num = read_two_columns_from_dialog( 'Select Force Input File', self.master) self.tb, self.b, self.num = read_two_columns_from_dialog( 'Select Response File', self.master) La = len(self.a) Lb = len(self.b) if (La != Lb): tkMessageBox.showinfo("Warning", " Vector length error", parent=self.button_read_data) return if (abs(self.t[0] - self.tb[0]) > 0.0005): tkMessageBox.showinfo("Warning", " Vector synch error", parent=self.button_read_data) return self.c = zeros([La, 2], 'f') for i in range(0, La): self.c[i, 0] = self.a[i] self.c[i, 1] = self.b[i]
def read_data_two(self): self.a1,self.b1,self.num1=read_two_columns_from_dialog('Select First Input File',self.master) self.a1=array(self.a1) self.b1=array(self.b1) dur1=self.a1[self.num1-1]-self.a1[0] self.dt1=dur1/float(self.num1) self.sr1=1./self.dt1 self.sr1,self.dt1=sample_rate_check(self.a1,self.b1,self.num1,self.sr1,self.dt1) ### self.a2,self.b2,self.num2=read_two_columns_from_dialog('Select Second Input File',self.master) self.a2=array(self.a2) self.b2=array(self.b2) dur2=self.a2[self.num2-1]-self.a2[0] self.dt2=dur2/float(self.num2) self.sr2=1./self.dt2 self.sr2,self.dt2=sample_rate_check(self.a2,self.b2,self.num2,self.sr2,self.dt2) ### plt.clf() plt.figure(1) plt.plot(self.a1, self.b1, linewidth=1.0,color='b') # disregard error plt.grid(True) plt.xlabel('Time (sec)') plt.ylabel(self.y_string.get()) plt.title('First Input Time History') plt.draw() plt.figure(2) plt.plot(self.a2, self.b2, linewidth=1.0,color='b') # disregard error plt.grid(True) plt.xlabel('Time (sec)') plt.ylabel(self.y_string.get()) plt.title('Second Input Time History') plt.draw() print ("\n file 1: samples = %d " % self.num1) print ("\n file 2: samples = %d " % self.num2) self.button_calculate.config(state = 'normal')
def read_data(self): self.a, self.b, self.num = read_two_columns_from_dialog( 'Select Input File', self.master) ref = 20.e-06 oaspl = 0 for i in range(0, self.num): oaspl += ref * (10**(self.b[i] / 20.)) p_rms = 20 * log10(oaspl / ref) out1 = 'Sound Pressure Level OASPL=%7.4g dB ref 20 micro Pa' % p_rms print('\n OASPL=%9.5g dB ref 20 micro Pa' % p_rms) plt.ion() plt.close(1) plt.figure(1) plt.plot(self.a, self.b, linewidth=1.0, color='b') # disregard error plt.grid(True) plt.xlabel('Frequency (Hz)') plt.ylabel('Sound Pressure (dB)') plt.title(out1) plt.xscale('log') plt.draw()
def read_data(self): self.ttime,self.y,self.num=read_two_columns_from_dialog('Select Input File',self.master) self.ns=self.num dur=self.ttime[self.num-1]-self.ttime[0] self.dt=dur/float(self.num) self.sr=1./self.dt self.sr,self.dt=sample_rate_check(self.ttime,self.y,self.num,self.sr,self.dt) plt.ion() plt.clf() plt.figure(1) plt.plot(self.ttime, self.y, linewidth=1.0,color='b') # disregard error plt.grid(True) plt.xlabel('Time (sec)') plt.ylabel(self.y_string.get()) plt.title('Time History') plt.draw() print ("\n Input Signal ") print ("\n samples = %d " % self.num) sr,self.dt,ave,sd,rms,skewness,kurtosis,dur=signal_stats(self.ttime, self.y,self.num) self.button_calculate.config(state = 'normal')
def read_data(self): self.a,self.b,self.num=read_two_columns_from_dialog('Select Input File',self.master) dur=self.a[self.num-1]-self.a[0] self.dt=dur/float(self.num) self.sr=1./self.dt self.sr,self.dt=sample_rate_check(self.a,self.b,self.num,self.sr,self.dt) plt.ion() plt.clf() plt.figure(1) plt.plot(self.a, self.b, linewidth=1.0,color='b') # disregard error plt.grid(True) plt.xlabel('Time (sec)') plt.ylabel(self.y_string.get()) plt.title('Time History') plt.draw() print ("\n samples = %d " % self.num) self.button_process.config(state = 'normal') out1=str('%8.4g' %self.a[0]) out2=str('%8.4g' %self.a[self.num-1]) self.tmir.set(out1) self.tmer.set(out2)
def read_data(self): self.a,self.b,self.num=\ read_two_columns_from_dialog('Select Acceleration File',self.master) dur = self.a[self.num - 1] - self.a[0] self.dt = dur / float(self.num) self.sr = 1. / self.dt self.sr, self.dt = sample_rate_check(self.a, self.b, self.num, self.sr, self.dt) plt.ion() plt.clf() plt.figure(1) plt.plot(self.a, self.b, linewidth=1.0, color='b') # disregard error plt.grid(True) plt.xlabel('Time (sec)') plt.ylabel('Accel (G)') plt.title('Base Input Time History') plt.draw() print("\n samples = %d " % self.num) self.button_calculate.config(state='normal') self.button_tripartite.config(state='disabled')
def read_data(self): n=1+int(self.Lb1.curselection()[0]) if(n==1): self.a,self.b,self.num=read_two_columns_from_dialog('Select Input File',self.master) else: self.a,self.b,self.c,self.num=read_three_columns_from_dialog('Select Input File',self.master) plt.ion() plt.close(1) plt.figure(1) if(n==1): plt.plot(self.a, self.b, linewidth=1.0,color='b') # disregard error else: plt.plot(self.a, self.b, label="positive") plt.plot(self.a, self.c, label="negative") plt.legend(loc="upper right") plt.grid(True) plt.xlabel(self.x_string.get()) plt.ylabel(self.y_string.get()) plt.title(self.t_string.get()) plt.xscale('log') plt.yscale('log') plt.draw()
def read_data(self): self.a, self.b, self.num = read_two_columns_from_dialog( 'Select Input File', self.master) sr, dt, mean, sd, rms, skew, kurtosis, dur = signal_stats( self.a, self.b, self.num) print("\n") print(" sr=%8.4g samples/sec" % sr) print(" mean=%8.4g" % mean) print(" std dev=%8.4g" % sd) print(" rms=%8.4g" % rms) print("\n %d points \n" % self.num) plt.close(1) plt.figure(1) plt.plot(self.a, self.b, linewidth=1.0, color='b') # disregard error plt.grid(True) plt.xlabel(self.x_string.get()) plt.ylabel(self.y_string.get()) plt.title(self.t_string.get()) plt.draw() self.button_extract.config(height=2, width=15, state='normal')
def read_data(self): self.a,self.b,self.num=read_two_columns_from_dialog('Select Input File',self.master) self.a=array(self.a) self.b=array(self.b) dur=self.a[self.num-1]-self.a[0] self.dt=dur/float(self.num) self.sr=1./self.dt self.sr,self.dt=sample_rate_check(self.a,self.b,self.num,self.sr,self.dt) plt.ion() plt.clf() plt.figure(1) plt.plot(self.a, self.b, linewidth=1.0,color='b') # disregard error plt.grid(True) plt.xlabel('Time (sec)') plt.ylabel(self.y_string.get()) plt.title('Input Time History') plt.draw() plt.show() print ("\n samples = %d " % self.num) self.button_calculate.config(state = 'normal')
def read_data(self): unit = 1 + int(self.Lbu.curselection()[0]) if (unit == 1): self.ff, self.zr, self.zi, self.num = read_three_columns_from_dialog( 'Select Input File', self.master) else: self.ff, self.zc, self.num = read_two_columns_from_dialog( 'Select Input File', self.master) self.zi = zeros(self.num, 'f') self.zr = zeros(self.num, 'f') for i in range(0, self.num): arg = self.ph[i] * (pi / 180) self.zi[i] = self.zc[i].real self.zr[i] = self.zc[i].imag self.zz = zeros(self.num, 'f') self.ph = zeros(self.num, 'f') for i in range(0, self.num): self.zz[i] = sqrt(self.zr[i]**2 + self.zi[i]**2) self.ph[i] = arctan2(self.zi[i], self.zr[i]) * 180 / pi self.button_replot.config(state='normal') self.plotd(self)
def read_data2(self): self.a2, self.b2, self.num2 = read_two_columns_from_dialog( 'Select Input File 2', self.master) if (self.num2 >= 1): tl2 = self.topp tkMessageBox.showinfo(" ", "Data File 2 Read", parent=tl2)
def read_data4(self): self.a4, self.b4, self.num4 = read_two_columns_from_dialog( 'Select Input File 4', self.master) if (self.num4 >= 1): tl2 = self.topp tkMessageBox.showinfo(" ", "Data File 4 Read", parent=tl2)
def read_data3(self): self.a3, self.b3, self.num3 = read_two_columns_from_dialog( 'Select Input File 3', self.master) if (self.num3 >= 1): tl2 = self.topp tkMessageBox.showinfo(" ", "Data File 3 Read", parent=tl2)
def read_data1(self): self.a1, self.b1, self.num1 = read_two_columns_from_dialog( 'Select Input File 1', self.master) if (self.num1 >= 1): tl2 = self.topp tkMessageBox.showinfo(" ", "Data File 1 Read", parent=tl2)
def read_data_1(self): self.a1, self.b1, self.num1 = read_two_columns_from_dialog( 'Select Input File', self.master) tl2 = self.topp if (self.num1 >= 1): tkMessageBox.showinfo(" ", "Data file 1 read", parent=tl2) else: tkMessageBox.showinfo(" ", "Data file 1 not read", parent=tl2)
def read_data_2(self): self.a2, self.b2, self.num2 = read_two_columns_from_dialog( 'Select Input File', self.master) tl2 = self.topp if (self.num2 >= 1): tkMessageBox.showinfo(" ", "Data file 2 read", parent=tl2) else: tkMessageBox.showinfo(" ", "Data file 2 not read", parent=tl2) self.button_plot.config(state='normal')
def read_data(self): self.a,self.b,self.num=read_two_columns_from_dialog('Select Input File',self.master) sr,dt,mean,sd,rms,skew,kurtosis,dur=signal_stats(self.a,self.b,self.num) print("\n") print(" sr=%8.4g samples/sec" %sr) print(" mean=%8.4g" %mean) print(" std dev=%8.4g" %sd) print(" rms=%8.4g" %rms) print("\n %d points \n" %self.num)
def read_data(self): self.a, self.b, self.num = read_two_columns_from_dialog( 'Select Input File', self.master) dur = self.a[self.num - 1] - self.a[0] self.dt = dur / float(self.num) self.sr = 1. / self.dt self.sr, self.dt = sample_rate_check(self.a, self.b, self.num, self.sr, self.dt) plt.ion() plt.clf() plt.figure(1) plt.plot(self.a, self.b, linewidth=1.0, color='b') # disregard error plt.grid(True) plt.xlabel('Time (sec)') ## plt.ylabel(self.y_string.get()) plt.title('Input Time History') nat = int(self.Lbat.curselection()[0]) str = self.iur.get() if (nat == 0): out1 = 'Accel (' + str + ')' if (nat == 1): out1 = 'Velocity (' + str + ')' if (nat == 2): out1 = 'Disp (' + str + ')' if (nat == 3): out1 = 'Force (' + str + ')' if (nat == 4): out1 = 'Pressure (' + str + ')' if (nat == 5): out1 = 'Stress (' + str + ')' plt.ylabel(out1) plt.draw() print("\n samples = %d " % self.num) self.button_calculate.config(state='normal') self.advise(self)
def read_data(self): self.t, self.b, self.num = read_two_columns_from_dialog( 'Select Input File', self.master) dur = self.t[self.num - 1] - self.t[0] self.dt = dur / float(self.num) self.sr = 1. / self.dt self.sr, self.dt = sample_rate_check(self.t, self.b, self.num, self.sr, self.dt) self.button_calculate.config(state='normal')
def read_data(self): self.button_calculate.config(state = 'normal') self.ttime,self.y,self.num=read_two_columns_from_dialog('Select Input File',self.master) self.y_original=self.y self.ns=self.num dur=self.ttime[self.num-1]-self.ttime[0] self.dt=dur/float(self.num) self.sr=1./self.dt self.sr,self.dt=sample_rate_check(self.ttime,self.y,self.num,self.sr,self.dt) plt.ion() plt.clf() plt.figure(1) plt.plot(self.ttime, self.y, linewidth=1.0,color='b') # disregard error plt.grid(True) plt.xlabel('Time (sec)') plt.ylabel(self.y_string.get()) plt.title('Time History') nn=len(self.ttime) if(nn>=1000000): ymin, ymax = plt.ylim() ymin=2*ymin ymax=2*ymax plt.ylim( ymin, ymax ) plt.draw() print ("\n samples = %d " % self.num)
def read_data(self): self.a, self.b, self.num = read_two_columns_from_dialog( 'Select Input File', self.master) self.dur = self.a[self.num - 1] - self.a[0] self.dt = self.dur / float(self.num) self.sr = 1. / self.dt self.sr, self.dt = sample_rate_check(self.a, self.b, self.num, self.sr, self.dt) plt.ion() plt.clf() self.plot_input(self) print("\n samples = %d " % self.num) self.button_calculate.config(state='normal')
def read_data(self): icf = int(self.Lb1.curselection()[0]) plt.ion() plt.clf() if (icf == 1): # single column self.b, self.num = read_one_column_from_dialog( 'Select Input File', self.master) plt.figure(1) plt.plot(self.b, linewidth=1.0, color='b') else: # two columns self.a, self.b, self.num = read_two_columns_from_dialog( 'Select Input File', self.master) plt.figure(1) plt.plot(self.a, self.b, linewidth=1.0, color='b') plt.xlabel('Time (sec)') plt.grid(True) plt.ylabel('Amplitude') plt.title('Time History') plt.draw() print("\n samples = %d " % self.num) self.button_calculate.config(state='normal') self.tree.heading('A', text='') self.tree.heading('B', text='') self.tree.heading('C', text='') self.tree.heading('D', text='') self.tree.heading('E', text='') self.tree.heading('F', text='') self.tree.heading('G', text='') self.hwtextext_exrf.config(state='disabled') self.button_rt.config(state='disabled') self.button_ac.config(state='disabled') self.button_rc.config(state='disabled')
def read_data(self): """ a = frequency column b = PSD column num = number of coordinates slope = slope between coordinate pairs """ print(" ") print( " The input file must have two columns: freq(Hz) & psd(unit^2/Hz)") a, b, num = read_two_columns_from_dialog('Select Input File', self.master) print("\n samples = %d " % num) a = array(a) b = array(b) if (a[0] < 1.0e-20 or b[0] < 1.0e-20): a = delete(a, 0) b = delete(b, 0) num = num - 1 nm1 = num - 1 slope = zeros(nm1, 'f') ra = 0 for i in range(0, int(nm1)): # s = log(b[i + 1] / b[i]) / log(a[i + 1] / a[i]) slope[i] = s # if s < -1.0001 or s > -0.9999: ra += (b[i + 1] * a[i + 1] - b[i] * a[i]) / (s + 1.) else: ra += b[i] * a[i] * log(a[i + 1] / a[i]) rms = sqrt(ra) three_rms = 3 * rms na = 1 + int(self.Lb1.curselection()[0]) print(" ") print(" *** Input PSD *** ") print(" ") print(" Overall = %10.3g RMS" % rms) print(" = %10.3g 3-sigma" % three_rms) ############################################################################### print(" ") print(" view plot ") s1 = (self.aur.get()) plt.ion() plt.close(1) plt.figure(1) plt.plot(a, b) title_string = 'Power Spectral Density ' + str( "%6.3g %s" % (rms, s1)) + ' RMS Overall ' plt.title(title_string) if (na == 1): out1 = "Accel (%s^2/Hz)" % s1 if (na == 2): out1 = "Vel (%s^2/Hz)" % s1 if (na == 3): out1 = "Disp (%s^2/Hz)" % s1 if (na == 4): out1 = "Force (%s^2/Hz)" % s1 if (na == 5): out1 = "Pressure (%s^2/Hz)" % s1 if (na == 6): out1 = "PSD (%s^2/Hz)" % s1 plt.ylabel(out1) plt.xlabel(' Frequency (Hz) ') plt.grid(which='both') plt.savefig('power_spectral_density') plt.xscale('log') plt.yscale('log') plt.show() ############################################################################### return a, b, rms, num, slope
def read_data(self): if not self.durr.get(): #do something tkMessageBox.showinfo("Warning", "Enter duration", parent=self.button_read) return self.tmax = float(self.durr.get()) """ f = frequency column a = PSD column num = number of coordinates slope = slope between coordinate pairs """ print(" ") print( " The input file must have two columns: freq(Hz) & accel(G^2/Hz)") f, a, num = read_two_columns_from_dialog('Select Input File', self.master) print("\n samples = %d " % num) f = array(f) a = array(a) self.maxf = max(f) nm1 = num - 1 slope = zeros(nm1, 'f') ra = 0 for i in range(0, int(nm1)): # s = log(a[i + 1] / a[i]) / log(f[i + 1] / f[i]) slope[i] = s # if s < -1.0001 or s > -0.9999: ra += (a[i + 1] * f[i + 1] - a[i] * f[i]) / (s + 1.) else: ra += a[i] * f[i] * log(f[i + 1] / f[i]) omega = 2 * pi * a av = zeros(num, 'f') ad = zeros(num, 'f') for i in range(0, int(num)): av[i] = a[i] / omega[i]**2 rv = 0 for i in range(0, int(nm1)): # s = log(av[i + 1] / av[i]) / log(f[i + 1] / f[i]) # if s < -1.0001 or s > -0.9999: rv += (av[i + 1] * f[i + 1] - av[i] * f[i]) / (s + 1.) else: rv += av[i] * f[i] * log(f[i + 1] / f[i]) for i in range(0, int(num)): ad[i] = av[i] / omega[i]**2 rd = 0 for i in range(0, int(nm1)): # s = log(ad[i + 1] / ad[i]) / log(f[i + 1] / f[i]) # if s < -1.0001 or s > -0.9999: rd += (ad[i + 1] * f[i + 1] - ad[i] * f[i]) / (s + 1.) else: rd += ad[i] * f[i] * log(f[i + 1] / f[i]) rms = sqrt(ra) three_rms = 3 * rms print(" ") print(" *** Input PSD *** ") print(" ") print(" Acceleration ") print(" Overall = %10.3g GRMS" % rms) print(" = %10.3g 3-sigma" % three_rms) self.grms_in = rms self.f = f self.a = a self.rms = rms self.freq_spec = f self.amp_spec = a self.num = num self.slope = slope self.button_calculate.config(state='normal') self.spec_grms = rms plt.ion() plt.clf() plt.figure(self.fig_num) self.fig_num += 1 plt.plot(f, a) title_string = 'Power Spectral Density ' + str( "%6.3g" % rms) + ' GRMS Overall ' plt.title(title_string) plt.ylabel(' Accel (G^2/Hz)') plt.xlabel(' Frequency (Hz) ') plt.grid(which='both') plt.savefig('power_spectral_density') plt.xscale('log') plt.yscale('log') plt.show() self.advise(self) self.white_noise(self) self.calculate_fft(self) self.apply_spec(self) self.calculate_invfft(self) self.button_calculate.config(state='normal')
def read_data(self): """ a = frequency column b = PSD column num = number of coordinates slope = slope between coordinate pairs """ print (" ") print (" The input file must have two columns: freq(Hz) & psd(unit^2/Hz)") a,b,num =read_two_columns_from_dialog('Select Input File',self.master) print ("\n samples = %d " % num) a=array(a) b=array(b) if(a[0]<1.0e-20 or b[0]<1.0e-20): a = delete(a, 0) b = delete(b, 0) num=num-1 self.nm1=num-1 self.num=num self.a=a self.b=b self.s1=(self.aur.get()) na=1+int(self.Lb1.curselection()[0]) if(na==1): self.out1="Accel (%s^2/Hz)" %self.s1 if(na==2): self.out1="Vel (%s^2/Hz)" %self.s1 if(na==3): self.out1="Disp (%s^2/Hz)" %self.s1 if(na==4): self.out1="Force (%s^2/Hz)" %self.s1 if(na==5): self.out1="Pressure (%s^2/Hz)" %self.s1 if(na==6): self.out1="PSD (%s^2/Hz)" %self.s1 ############################################################################### slope =zeros(self.nm1,'f') ra=0 for i in range (0,int(self.nm1)): # s=log(self.b[i+1]/self.b[i])/log(self.a[i+1]/self.a[i]) slope[i]=s # if s < -1.0001 or s > -0.9999: ra+= ( self.b[i+1] * self.a[i+1]- self.b[i]*self.a[i])/( s+1.) else: ra+= self.b[i]*self.a[i]*log( self.a[i+1]/self.a[i]) rms=sqrt(ra) plt.ion() plt.clf() plt.figure(self.fig_num) self.fig_num+=1 plt.plot(self.a,self.b) title_string='Power Spectral Density '+str("%6.3g %s" %(rms,self.s1))+' RMS Overall ' plt.title(title_string) plt.ylabel(self.out1) plt.xlabel(' Frequency (Hz) ') plt.grid(which='both') plt.savefig('power_spectral_density') plt.xscale('log') plt.yscale('log') if (self.f1r.get() and self.f2r.get()): f1=float(self.f1r.get()) f2=float(self.f2r.get()) plt.xlim([f1,f2]) plt.show() self.button_calculate.config(state = 'normal') self.convert_octave_band(self)
def read_data(self): self.a,self.b,self.num=\ read_two_columns_from_dialog('Select FRF File',self.master) self.button_plot.config(state='normal')
def read_data(self): """ f = frequency column a = PSD column num = number of coordinates slope = slope between coordinate pairs """ print(" ") print( " The input file must have two columns: freq(Hz) & accel(G^2/Hz)") f, a, num = read_two_columns_from_dialog('Select Input File', self.master) print("\n samples = %d " % num) f = array(f) a = array(a) nm1 = num - 1 slope = zeros(nm1, 'f') ra = 0 for i in range(0, int(nm1)): # s = log(a[i + 1] / a[i]) / log(f[i + 1] / f[i]) slope[i] = s # if s < -1.0001 or s > -0.9999: ra += (a[i + 1] * f[i + 1] - a[i] * f[i]) / (s + 1.) else: ra += a[i] * f[i] * log(f[i + 1] / f[i]) omega = 2 * pi * a av = zeros(num, 'f') ad = zeros(num, 'f') for i in range(0, int(num)): av[i] = a[i] / omega[i]**2 av = av * 386**2 rv = 0 for i in range(0, int(nm1)): # s = log(av[i + 1] / av[i]) / log(f[i + 1] / f[i]) # if s < -1.0001 or s > -0.9999: rv += (av[i + 1] * f[i + 1] - av[i] * f[i]) / (s + 1.) else: rv += av[i] * f[i] * log(f[i + 1] / f[i]) for i in range(0, int(num)): ad[i] = av[i] / omega[i]**2 rd = 0 for i in range(0, int(nm1)): # s = log(ad[i + 1] / ad[i]) / log(f[i + 1] / f[i]) # if s < -1.0001 or s > -0.9999: rd += (ad[i + 1] * f[i + 1] - ad[i] * f[i]) / (s + 1.) else: rd += ad[i] * f[i] * log(f[i + 1] / f[i]) rms = sqrt(ra) three_rms = 3 * rms print(" ") print(" *** Input PSD *** ") print(" ") print(" Acceleration ") print(" Overall = %10.3g GRMS" % rms) print(" = %10.3g 3-sigma" % three_rms) self.grms_in = rms self.f = f self.a = a self.slope = slope self.button_calculate.config(state='normal') plt.ion() plt.clf() plt.close(1) plt.figure(1) plt.plot(f, a) title_string = 'Power Spectral Density ' + str( "%6.3g" % rms) + ' GRMS Overall ' plt.title(title_string) plt.ylabel(' Accel (G^2/Hz)') plt.xlabel(' Frequency (Hz) ') plt.grid(which='both') plt.savefig('power_spectral_density') plt.xscale('log') plt.yscale('log') plt.show()
def read_data(self): """ f = frequency column a = PSD column num = number of coordinates slope = slope between coordinate pairs """ print(" ") print( " The input file must have two columns: freq(Hz) & accel(G^2/Hz)") f, a, num = read_two_columns_from_dialog('Select Input File', self.master) print("\n samples = %d " % num) f = array(f) a = array(a) nm1 = num - 1 slope = zeros(nm1, 'f') ra = 0 for i in range(0, int(nm1)): # s = log(a[i + 1] / a[i]) / log(f[i + 1] / f[i]) slope[i] = s # if s < -1.0001 or s > -0.9999: ra += (a[i + 1] * f[i + 1] - a[i] * f[i]) / (s + 1.) else: ra += a[i] * f[i] * log(f[i + 1] / f[i]) omega = 2 * pi * a av = zeros(num, 'f') ad = zeros(num, 'f') for i in range(0, int(num)): av[i] = a[i] / omega[i]**2 av = av * 386**2 rv = 0 for i in range(0, int(nm1)): # s = log(av[i + 1] / av[i]) / log(f[i + 1] / f[i]) # if s < -1.0001 or s > -0.9999: rv += (av[i + 1] * f[i + 1] - av[i] * f[i]) / (s + 1.) else: rv += av[i] * f[i] * log(f[i + 1] / f[i]) for i in range(0, int(num)): ad[i] = av[i] / omega[i]**2 rd = 0 for i in range(0, int(nm1)): # s = log(ad[i + 1] / ad[i]) / log(f[i + 1] / f[i]) # if s < -1.0001 or s > -0.9999: rd += (ad[i + 1] * f[i + 1] - ad[i] * f[i]) / (s + 1.) else: rd += ad[i] * f[i] * log(f[i + 1] / f[i]) rms = sqrt(ra) three_rms = 3 * rms print(" ") print(" *** Input PSD *** ") print(" ") print(" Acceleration ") print(" Overall = %10.3g GRMS" % rms) print(" = %10.3g 3-sigma" % three_rms) self.grms_in = rms self.f = f self.a = a self.slope = slope self.button_calculate.config(state='normal')
def read_data(self): """ f = frequency column a = PSD column num = number of coordinates slope = slope between coordinate pairs """ print(" ") n1 = int(self.Lb1.curselection()[0]) if (n1 == 0): out1 = 'The input file must have two columns: freq(Hz) & force(lbf^2/Hz)' else: out1 = 'The input file must have two columns: freq(Hz) & force(N^2/Hz)' f, a, num = read_two_columns_from_dialog(out1, self.master) print("\n samples = %d " % num) f = array(f) a = array(a) nm1 = num - 1 slope = zeros(nm1, 'f') ra = 0 for i in range(0, int(nm1)): # s = log(a[i + 1] / a[i]) / log(f[i + 1] / f[i]) slope[i] = s # if s < -1.0001 or s > -0.9999: ra += (a[i + 1] * f[i + 1] - a[i] * f[i]) / (s + 1.) else: ra += a[i] * f[i] * log(f[i + 1] / f[i]) rms = sqrt(ra) three_rms = 3 * rms self.rms = rms print(" ") print(" *** Applied Force PSD *** ") print(" ") if (n1 == 0): print(" Overall = %10.3g lbf RMS" % rms) print(" = %10.3g 3-sigma" % three_rms) else: print(" Overall = %10.3g N RMS" % rms) print(" = %10.3g 3-sigma" % three_rms) self.force_rms_in = rms self.f = f self.a = a self.slope = slope self.button_calculate.config(state='normal') plt.ion() plt.clf() plt.close(1) plt.figure(1) plt.plot(f, a) y1 = 10**int(floor(log10(min(a)))) y2 = 10**int(ceil(log10(max(a)))) if (y2 == y1): y2 = 10 * y1 y1 = y1 / 10 plt.ylim([y1, y2]) nu = int(self.Lb1.curselection()[0]) if (nu == 0): title_string = 'Power Spectral Density ' + str( "%6.3g" % rms) + ' lbf RMS Overall ' plt.ylabel(' Force (lbf^2/Hz)') else: title_string = 'Power Spectral Density ' + str( "%6.3g" % rms) + ' N RMS Overall ' plt.ylabel(' Force (N^2/Hz)') plt.title(title_string) plt.xlabel(' Frequency (Hz) ') plt.grid(which='both') plt.savefig('power_spectral_density') plt.xscale('log') plt.yscale('log') plt.show()
def read_data(self): self.iunit = int(self.Lb1.curselection()[0]) if (self.iunit == 0): self.ypsd_string = 'Force (lbf^2/Hz)' self.yth_string = 'Force (lbf)' if (self.iunit == 1): self.ypsd_string = 'Force (N^2/Hz)' self.yth_string = 'Force (N)' if (self.iunit == 2): self.ypsd_string = 'Pressure (psi^2/Hz)' self.yth_string = 'Pressure (psi)' if (self.iunit == 3): self.ypsd_string = 'Pressure (Pa^2/Hz)' self.yth_string = 'Pressure (Pa)' if (self.iunit == 4): self.ypsd_string = 'unit^2/Hz' self.yth_string = 'Amplitude' if not self.durr.get(): #do something tkMessageBox.showinfo("Warning", "Enter duration", parent=self.button_read) return self.tmax = float(self.durr.get()) """ f = frequency column a = PSD column num = number of coordinates slope = slope between coordinate pairs """ print(" ") print( " The input file must have two columns: freq(Hz) & psd(unit^2/Hz)") f, a, num = read_two_columns_from_dialog('Select Input File', self.master) print("\n samples = %d " % num) f = array(f) a = array(a) nm1 = num - 1 slope = zeros(nm1, 'f') ra = 0 for i in range(0, int(nm1)): # s = log(a[i + 1] / a[i]) / log(f[i + 1] / f[i]) slope[i] = s # if s < -1.0001 or s > -0.9999: ra += (a[i + 1] * f[i + 1] - a[i] * f[i]) / (s + 1.) else: ra += a[i] * f[i] * log(f[i + 1] / f[i]) rms = sqrt(ra) three_rms = 3 * rms print(" ") print(" *** Input PSD *** ") print(" ") print(" Overall = %10.3g RMS" % rms) print(" = %10.3g 3-sigma" % three_rms) self.RMS_in = rms self.f = f self.a = a self.rms = rms self.freq_spec = f self.amp_spec = a self.num = num self.slope = slope self.button_calculate.config(state='normal') self.spec_RMS = rms plt.ion() plt.clf() plt.close(self.fig_num) plt.figure(self.fig_num) self.fig_num += 1 plt.plot(f, a) title_string = 'Power Spectral Density ' + str( "%6.3g" % rms) + ' RMS Overall ' plt.title(title_string) plt.ylabel(self.ypsd_string) plt.xlabel(' Frequency (Hz) ') plt.grid(which='both') plt.savefig('power_spectral_density') plt.xscale('log') plt.yscale('log') plt.show() self.white_noise(self) self.calculate_fft(self) self.apply_spec(self) self.calculate_invfft(self) self.advise(self) self.button_calculate.config(state='normal')