Пример #1
0
    def window2(self):  # <===
        self.w = Window2()
        std_val, mean_val, max_val, min_val = data_import_func.stats(
            self.df[self.content])
        layout = QtWidgets.QGridLayout()

        self.heading1 = QtWidgets.QLabel(self)
        self.heading1.setText('Actual')
        self.heading2 = QtWidgets.QLabel(self)
        self.heading2.setText('Normalised')

        #display statistical information about the signal
        self.avg_label = QtWidgets.QLabel(self)
        self.avg_label.setText('Average')
        self.avg_lineedit = QtWidgets.QLineEdit(self)
        self.avg_lineedit.setText('%.5s' % str(mean_val))
        self.avg_norm_lineedit = QtWidgets.QLineEdit(self)
        self.avg_norm_lineedit.setText('-')

        self.std_label = QtWidgets.QLabel(self)
        self.std_label.setText('Standard Deviation')
        self.std_lineedit = QtWidgets.QLineEdit(self)
        self.std_lineedit.setText('%.5s' % str(std_val))
        self.std_norm_lineedit = QtWidgets.QLineEdit(self)
        self.std_norm_lineedit.setText('%.4s' % str(std_val / mean_val))

        self.max_label = QtWidgets.QLabel(self)
        self.max_label.setText('Max')
        self.max_lineedit = QtWidgets.QLineEdit(self)
        self.max_lineedit.setText('%.5s' % str(max_val))
        self.max_norm_lineedit = QtWidgets.QLineEdit(self)
        self.max_norm_lineedit.setText('%.4s' % str(max_val / mean_val))

        self.min_label = QtWidgets.QLabel(self)
        self.min_label.setText('Min ')
        self.min_lineedit = QtWidgets.QLineEdit(self)
        self.min_lineedit.setText('%.5s' % str(min_val))
        self.min_norm_lineedit = QtWidgets.QLineEdit(self)
        self.min_norm_lineedit.setText('%.4s' % str(min_val / mean_val))

        layout.addWidget(self.heading1, 0, 1)
        layout.addWidget(self.heading2, 0, 2)
        layout.addWidget(self.avg_label, 1, 0)
        layout.addWidget(self.avg_lineedit, 1, 1)
        layout.addWidget(self.avg_norm_lineedit, 1, 2)
        layout.addWidget(self.std_label, 2, 0)
        layout.addWidget(self.std_lineedit, 2, 1)
        layout.addWidget(self.std_norm_lineedit, 2, 2)
        layout.addWidget(self.max_label, 3, 0)
        layout.addWidget(self.max_lineedit, 3, 1)
        layout.addWidget(self.max_norm_lineedit, 3, 2)
        layout.addWidget(self.min_label, 4, 0)
        layout.addWidget(self.min_lineedit, 4, 1)
        layout.addWidget(self.min_norm_lineedit, 4, 2)
        self.w.setLayout(layout)

        self.w.show()
    def plot(self):
        #Figure 1 is used to plot the time series.

        self.ax1.clear()
        self.content = self.combo_box.currentText()
        std_val, mean_val, max_val, min_val = data_import_func.stats(
            self.df[self.content])
        self.l3_output.setText('%.5s' % str(mean_val))
        #Add Normalisation to the statistical parameters
        self.l4_output.setText('%.5s' % str(std_val) + '/' +
                               '%.4s' % str(std_val / mean_val))
        self.l5_output.setText('%.5s' % str(max_val) + '/' +
                               '%.4s' % str(max_val / mean_val))
        self.l6_output.setText('%.5s' % str(min_val) + '/' +
                               '%.4s' % str(min_val / mean_val))
        mean_array = [mean_val] * len(self.df[self.content])
        self.ax1.plot(self.df[self.content], label='Data')
        self.ax1.plot(self.df.index, mean_array, label='Mean', linestyle='--')
        self.ax1.set_ylabel('Force [N]')
        self.ax1.set_xlabel('Time [s]')
        self.ax1.set_title('Time Signal')
        self.ax1.grid()
        self.ax1.legend()
        self.canvas1.draw()

        #Figure 2 will be used to plot the fft
        #read the bins provided for the fft operation
        if self.l9_input.text() == 'Default':
            self.l9_get_text = 'Default'
        else:
            self.l9_get_text = float(self.l9_input.text())

        #allow for normalisation using the checkbox
        spec, freq = data_import_func.spectral_analysis(
            self.df, self.content, self.l7_get_text, self.l8_get_text,
            self.l9_get_text)
        self.ax2.clear()

        if self.l10_checkbox.isChecked() == True:
            rotor_freq = data_import_func.rotor_freq(self.df['RPM'])
            freq = freq / rotor_freq
            self.ax2.loglog(freq[1:int(len(freq) / 2)], spec[1:])
            self.ax2.set_xlabel(r'$\frac{F}{f_0}$ [Hz/Hz]')
            self.ax2.set_title('Normalised FFT')

        else:
            self.ax2.loglog(freq[1:int(len(freq) / 2)], spec[1:])
            self.ax2.set_xlabel('Frequency [s]')
            self.ax2.set_title('FFT')

        self.ax2.set_ylabel('Force [N]')
        self.ax2.grid(True, which='both', ls='--')
        self.canvas2.draw()

        #read the bins for the histogram first
        self.l11_get_text = int(self.l11_input.text())
        #Figure 3 will be used to plot a normal distribution of normalised loads
        self.ax3.clear()
        self.ax3.hist(self.df[self.content],
                      bins=self.l11_get_text,
                      density=True)
        self.ax3.set_xlabel('Force [N]')
        self.ax3.set_ylabel('PDF')
        sorted_array = self.df.sort_values(by=self.content)[self.content]
        self.ax3.plot(sorted_array, norm.pdf(sorted_array, mean_val, std_val))
        self.ax3.set_title('Probability density Function')
        self.ax3.grid()
        self.canvas3.draw()

        #Plot the polar chart with
        #pass values to the function angle_turbine
        t = self.df.index.to_numpy()
        Fy1 = self.df['Fy1'].to_numpy()
        Fy2 = self.df['Fy2'].to_numpy()
        Fy3 = self.df['Fy3'].to_numpy()
        fr = data_import_func.rotor_freq(self.df['RPM'])
        self.theta = data_import_func.angle_turbine(t, Fy1, Fy2, Fy3, fr)
        self.ax4.clear()
        #half the samples are plotted to avoid clutter
        self.ax4.scatter(self.theta[0:(int(len(self.theta) / 2))],
                         self.df[self.content][0:(int(self.l7_get_text / 2))],
                         s=0.01,
                         alpha=0.75)
        self.canvas4.draw()
Пример #3
0
    def plot(self):
        #Figure 1 is used to plot the time series.

        self.ax1.clear()
        self.content = self.combo_box.currentText()
        std_val, mean_val, max_val, min_val = data_import_func.stats(
            self.df[self.content])
        #self.l3_output.setText('%.5s' % str(mean_val))
        #Add Normalisation to the statistical parameters
        #self.l4_output.setText('%.5s' % str(std_val) + '/' + '%.4s' % str(std_val/mean_val))
        #self.l5_output.setText('%.5s' % str(max_val) + '/' + '%.4s' % str(max_val/mean_val))
        #self.l6_output.setText('%.5s' % str(min_val) + '/' + '%.4s' % str(min_val/mean_val))
        mean_array = [mean_val] * len(self.df[self.content])
        upper_std = [(mean_val + std_val)] * len(self.df[self.content])
        lower_std = [(mean_val - std_val)] * len(self.df[self.content])
        self.ax1.plot(self.df[self.content], label='Data')
        self.ax1.plot(self.df.index, mean_array, label='Mean', linestyle='--')
        self.ax1.plot(self.df.index,
                      upper_std,
                      label='Upper Standard Deviation',
                      linestyle='--')
        self.ax1.plot(self.df.index,
                      lower_std,
                      label='Lower Standard Deviation',
                      linestyle='--')
        self.ax1.set_ylabel('Force [N]')
        self.ax1.set_xlabel('Time [s]')
        self.ax1.set_title('Time Signal')
        self.ax1.grid()
        self.ax1.legend()
        self.canvas1.draw()

        #Figure 2 will be used to plot the fft
        #read the bins provided for the fft operation
        if self.fft_input.text() == 'Default':
            self.fft_get_text = 'Default'
        else:
            self.fft_get_text = float(self.fft_input.text())

        #allow for normalisation using the checkbox
        spec, freq = data_import_func.spectral_analysis(
            self.df, self.content, self.fft_get_text)
        self.ax2.clear()

        if self.fft_checkbox.isChecked() == True:
            rotor_freq = data_import_func.rotor_freq(self.df['RPM'])
            freq = freq / rotor_freq
            self.ax2.loglog(freq[1:int(len(freq) / 2)], spec[1:])
            self.ax2.set_xlabel(r'$\frac{F}{f_0}$ [Hz/Hz]')
            self.ax2.set_title('Normalised FFT')

        else:
            self.ax2.loglog(freq[1:int(len(freq) / 2)], spec[1:])
            self.ax2.set_xlabel('Frequency [Hz]')
            self.ax2.set_title('FFT')

        self.ax2.set_ylabel('Force [N]')
        self.ax2.grid(True, which='both', ls='--')
        self.canvas2.draw()

        #read the bins for the histogram first
        self.bin_input = int(self.bin_lineedit.text())
        #Figure 3 will be used to plot a normal distribution of normalised loads
        self.ax3.clear()
        self.ax3.hist(self.df[self.content], bins=self.bin_input, density=True)
        self.ax3.set_xlabel('Force [N]')
        self.ax3.set_ylabel('PDF')
        sorted_array = self.df.sort_values(by=self.content)[self.content]
        self.ax3.plot(sorted_array, norm.pdf(sorted_array, mean_val, std_val))
        self.ax3.set_title('Probability density Function')
        self.ax3.grid()
        self.canvas3.draw()

        #Plot the polar chart with
        self.ax4.clear()
        plt.autoscale(axis='both', tight='bool')
        self.ax4.set_rlabel_position(90)
        self.ax4.set_theta_zero_location("N")  # theta=0 at the top
        self.ax4.set_theta_direction(-1)  # theta increasing clockwise
        self.ax4.yaxis.set_major_locator(plt.MaxNLocator(3))
        #pass values to the function angle_turbine
        angle, fit = data_import_func.angle_theta(self.df, self.content)
        self.ax4.scatter(angle['theta'], angle['signal'], s=0.01)
        self.ax4.plot(fit['theta_s'], fit['Average'], color='red')

        #half the samples are plotted to avoid clutter

        #self.ax4.scatter(self.theta, self.y_new, s = 0.5, alpha = 1)
        self.ax4.set_title('Varation against Blade Angle')
        self.canvas4.draw()