From d00188f0bffe69b67fa69ff93d91714554b47d8a Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 6 Mar 2019 15:20:01 +0100 Subject: [PATCH] Version 1 --- filtre.ui | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ gui.ui | 56 ++++++++++++++++++++++ projet.py | 57 ++++++++++++++++++++++ projet.ui | 31 ++++++++++++ test.py | 115 ++++++++++++++++++++++++++++++++++++++++++++ test2.py | 126 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 524 insertions(+) create mode 100644 filtre.ui create mode 100644 gui.ui create mode 100644 projet.py create mode 100644 projet.ui create mode 100755 test.py create mode 100644 test2.py diff --git a/filtre.ui b/filtre.ui new file mode 100644 index 0000000..80838f6 --- /dev/null +++ b/filtre.ui @@ -0,0 +1,139 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + 560 + 450 + 90 + 35 + + + + Calculer + + + + + + 230 + 60 + 411 + 152 + + + + + + + + + + + + + + + + + + + + + 32 + 60 + 201 + 151 + + + + + + + Fréquence de coupure + + + + + + + Amplitude + + + + + + + Impédance d'entrée + + + + + + + Ordre + + + + + + + + + 460 + 450 + 90 + 35 + + + + Reset + + + + + + 230 + 220 + 411 + 191 + + + + pushButton + verticalLayoutWidget + verticalLayoutWidget_2 + label_2 + spinBox + pushButton_2 + tableWidget + + + + + 0 + 0 + 800 + 31 + + + + + + + + diff --git a/gui.ui b/gui.ui new file mode 100644 index 0000000..627a114 --- /dev/null +++ b/gui.ui @@ -0,0 +1,56 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + 500 + 430 + 90 + 35 + + + + PushButton + + + + + + 80 + 10 + 271 + 251 + + + + + + + + + 0 + 0 + 800 + 31 + + + + + + + + diff --git a/projet.py b/projet.py new file mode 100644 index 0000000..981b040 --- /dev/null +++ b/projet.py @@ -0,0 +1,57 @@ + # -*-coding:Latin-1 -* +from math import * +print("Entrez la fréquence de coupure:") +frequence = input() +#print(f) +print("Entrez l'impédance d'entrée:") +impedance=input() +print("Entrez l'amplitude max:") +amplitude=input() +print("Entrez l'ordre du filtre:") +ordre=input() +#Calcul des paramètres +#Calcule de wc +wc=2*pi*frequence +#Calcul de b +b=log(cosh(amplitude/17.37)/sinh(amplitude/17.37)) +#Calcul de gamma +gamma=sinh(b/(2*ordre)) +#initialisation i +i=1 +ak=[0]*ordre +bk=[0]*ordre +gk=[0]*ordre +#Cacule de ak +for i in range(ordre): + ak[i-1]=sin((2*(i-1)*pi)/(2*ordre)) +#Calcul de bk +for i in range(ordre): + bk[i-1]=pow(gamma,2)+(sin(i*pi)/ordre) +print("test") +print(bk) +#Calcul de gk + +gk[0] = ((2*ak[1])/gamma) +print(ak) +print(gk[0]) +print(bk[0]) +for i in range(ordre): + gk[i]=((4*ak[i-1]*ak[i])/(bk[i-1]*gk[i-1])) +#Calcul de ck et lk +if (ordre%2)==0: + for i in range(ordre): + lk[i]=(impedance/wc)*gk[i] + for i in range(ordre): + ck[i]=(1/impedance)*(1/wc)*gk[i-1] + else: + for i in range(ordre): + lk[i]=(impedance/wc)*gk[i-1] + for i in range(ordre): + ck[i]=(1/impedance)*(1/wc)*gk[i] + #Calcul de Rn +if ordre==1: + rn=1*impedance +else: + rn=pow((tanh(b/4)),2) + +print(ck) diff --git a/projet.ui b/projet.ui new file mode 100644 index 0000000..bf901c7 --- /dev/null +++ b/projet.ui @@ -0,0 +1,31 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + 0 + 0 + 800 + 31 + + + + + + + + diff --git a/test.py b/test.py new file mode 100755 index 0000000..43d3ce0 --- /dev/null +++ b/test.py @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'filtre.ui' +# +# Created by: PyQt4 UI code generator 4.12.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + def _fromUtf8(s): + return s + +try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig, _encoding) +except AttributeError: + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig) + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName(_fromUtf8("MainWindow")) + MainWindow.resize(800, 600) + self.centralwidget = QtGui.QWidget(MainWindow) + self.centralwidget.setObjectName(_fromUtf8("centralwidget")) + self.pushButton = QtGui.QPushButton(self.centralwidget) + self.pushButton.setGeometry(QtCore.QRect(560, 450, 90, 35)) + self.pushButton.setObjectName(_fromUtf8("pushButton")) + self.verticalLayoutWidget = QtGui.QWidget(self.centralwidget) + self.verticalLayoutWidget.setGeometry(QtCore.QRect(230, 60, 411, 152)) + self.verticalLayoutWidget.setObjectName(_fromUtf8("verticalLayoutWidget")) + self.verticalLayout = QtGui.QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout.setMargin(0) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.lineEdit = QtGui.QLineEdit(self.verticalLayoutWidget) + self.lineEdit.setObjectName(_fromUtf8("lineEdit")) + self.verticalLayout.addWidget(self.lineEdit) + self.lineEdit_2 = QtGui.QLineEdit(self.verticalLayoutWidget) + self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2")) + self.verticalLayout.addWidget(self.lineEdit_2) + self.lineEdit_3 = QtGui.QLineEdit(self.verticalLayoutWidget) + self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3")) + self.verticalLayout.addWidget(self.lineEdit_3) + self.spinBox = QtGui.QSpinBox(self.verticalLayoutWidget) + self.spinBox.setObjectName(_fromUtf8("spinBox")) + self.verticalLayout.addWidget(self.spinBox) + self.verticalLayoutWidget_2 = QtGui.QWidget(self.centralwidget) + self.verticalLayoutWidget_2.setGeometry(QtCore.QRect(32, 60, 201, 151)) + self.verticalLayoutWidget_2.setObjectName(_fromUtf8("verticalLayoutWidget_2")) + self.verticalLayout_2 = QtGui.QVBoxLayout(self.verticalLayoutWidget_2) + self.verticalLayout_2.setMargin(0) + self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.label_2 = QtGui.QLabel(self.verticalLayoutWidget_2) + self.label_2.setObjectName(_fromUtf8("label_2")) + self.verticalLayout_2.addWidget(self.label_2) + self.label_3 = QtGui.QLabel(self.verticalLayoutWidget_2) + self.label_3.setObjectName(_fromUtf8("label_3")) + self.verticalLayout_2.addWidget(self.label_3) + self.label_4 = QtGui.QLabel(self.verticalLayoutWidget_2) + self.label_4.setObjectName(_fromUtf8("label_4")) + self.verticalLayout_2.addWidget(self.label_4) + self.label = QtGui.QLabel(self.verticalLayoutWidget_2) + self.label.setObjectName(_fromUtf8("label")) + self.verticalLayout_2.addWidget(self.label) + self.pushButton_2 = QtGui.QPushButton(self.centralwidget) + self.pushButton_2.setGeometry(QtCore.QRect(460, 450, 90, 35)) + self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) + self.tableWidget = QtGui.QTableWidget(self.centralwidget) + self.tableWidget.setGeometry(QtCore.QRect(230, 220, 411, 191)) + self.tableWidget.setObjectName(_fromUtf8("tableWidget")) + self.tableWidget.setColumnCount(0) + self.tableWidget.setRowCount(0) + self.pushButton.raise_() + self.verticalLayoutWidget.raise_() + self.verticalLayoutWidget_2.raise_() + self.label_2.raise_() + self.spinBox.raise_() + self.pushButton_2.raise_() + self.tableWidget.raise_() + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtGui.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 31)) + self.menubar.setObjectName(_fromUtf8("menubar")) + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtGui.QStatusBar(MainWindow) + self.statusbar.setObjectName(_fromUtf8("statusbar")) + MainWindow.setStatusBar(self.statusbar) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) + self.pushButton.setText(_translate("MainWindow", "Calculer", None)) + self.label_2.setText(_translate("MainWindow", "Fréquence de coupure", None)) + self.label_3.setText(_translate("MainWindow", "Amplitude", None)) + self.label_4.setText(_translate("MainWindow", "Impédance d\'entrée", None)) + self.label.setText(_translate("MainWindow", "Ordre", None)) + self.pushButton_2.setText(_translate("MainWindow", "Reset", None)) + + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + MainWindow = QtGui.QMainWindow() + ui = Ui_MainWindow() + ui.setupUi(MainWindow) + MainWindow.show() + sys.exit(app.exec_()) + diff --git a/test2.py b/test2.py new file mode 100644 index 0000000..3a57ac5 --- /dev/null +++ b/test2.py @@ -0,0 +1,126 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'filtre2.ui' +# +# Created by: PyQt4 UI code generator 4.12.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + def _fromUtf8(s): + return s + +try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig, _encoding) +except AttributeError: + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig) + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName(_fromUtf8("MainWindow")) + MainWindow.resize(800, 600) + self.centralwidget = QtGui.QWidget(MainWindow) + self.centralwidget.setObjectName(_fromUtf8("centralwidget")) + self.Calculer = QtGui.QPushButton(self.centralwidget) + self.Calculer.setGeometry(QtCore.QRect(560, 450, 90, 35)) + self.Calculer.setObjectName(_fromUtf8("Calculer")) + self.verticalLayoutWidget = QtGui.QWidget(self.centralwidget) + self.verticalLayoutWidget.setGeometry(QtCore.QRect(230, 60, 411, 152)) + self.verticalLayoutWidget.setObjectName(_fromUtf8("verticalLayoutWidget")) + self.verticalLayout = QtGui.QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout.setMargin(0) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.frequence = QtGui.QLineEdit(self.verticalLayoutWidget) + self.frequence.setObjectName(_fromUtf8("frequence")) + self.verticalLayout.addWidget(self.frequence) + self.amplitude = QtGui.QLineEdit(self.verticalLayoutWidget) + self.amplitude.setObjectName(_fromUtf8("amplitude")) + self.verticalLayout.addWidget(self.amplitude) + self.imdance = QtGui.QLineEdit(self.verticalLayoutWidget) + self.imdance.setObjectName(_fromUtf8("imdance")) + self.verticalLayout.addWidget(self.imdance) + self.ordre = QtGui.QSpinBox(self.verticalLayoutWidget) + self.ordre.setObjectName(_fromUtf8("ordre")) + self.verticalLayout.addWidget(self.ordre) + self.verticalLayoutWidget_2 = QtGui.QWidget(self.centralwidget) + self.verticalLayoutWidget_2.setGeometry(QtCore.QRect(32, 60, 201, 151)) + self.verticalLayoutWidget_2.setObjectName(_fromUtf8("verticalLayoutWidget_2")) + self.verticalLayout_2 = QtGui.QVBoxLayout(self.verticalLayoutWidget_2) + self.verticalLayout_2.setMargin(0) + self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.label_2 = QtGui.QLabel(self.verticalLayoutWidget_2) + self.label_2.setObjectName(_fromUtf8("label_2")) + self.verticalLayout_2.addWidget(self.label_2) + self.label_3 = QtGui.QLabel(self.verticalLayoutWidget_2) + self.label_3.setObjectName(_fromUtf8("label_3")) + self.verticalLayout_2.addWidget(self.label_3) + self.label_4 = QtGui.QLabel(self.verticalLayoutWidget_2) + self.label_4.setObjectName(_fromUtf8("label_4")) + self.verticalLayout_2.addWidget(self.label_4) + self.label = QtGui.QLabel(self.verticalLayoutWidget_2) + self.label.setObjectName(_fromUtf8("label")) + self.verticalLayout_2.addWidget(self.label) + self.reset = QtGui.QPushButton(self.centralwidget) + self.reset.setGeometry(QtCore.QRect(460, 450, 90, 35)) + self.reset.setObjectName(_fromUtf8("reset")) + self.lineEdit = QtGui.QLineEdit(self.centralwidget) + self.lineEdit.setGeometry(QtCore.QRect(370, 20, 113, 33)) + self.lineEdit.setObjectName(_fromUtf8("lineEdit")) + self.tableView = QtGui.QTableView(self.centralwidget) + self.tableView.setGeometry(QtCore.QRect(230, 230, 421, 192)) + self.tableView.setObjectName(_fromUtf8("tableView")) + self.Calculer.raise_() + self.verticalLayoutWidget.raise_() + self.verticalLayoutWidget_2.raise_() + self.label_2.raise_() + self.ordre.raise_() + self.reset.raise_() + self.lineEdit.raise_() + self.tableView.raise_() + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtGui.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 31)) + self.menubar.setObjectName(_fromUtf8("menubar")) + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtGui.QStatusBar(MainWindow) + self.statusbar.setObjectName(_fromUtf8("statusbar")) + MainWindow.setStatusBar(self.statusbar) + self.actionCalculer = QtGui.QAction(MainWindow) + self.actionCalculer.setObjectName(_fromUtf8("actionCalculer")) + + self.retranslateUi(MainWindow) + QtCore.QObject.connect(self.reset, QtCore.SIGNAL(_fromUtf8("clicked()")), MainWindow.show) + QtCore.QObject.connect(self.reset, QtCore.SIGNAL(_fromUtf8("clicked()")), self.frequence.clear) + QtCore.QObject.connect(self.reset, QtCore.SIGNAL(_fromUtf8("clicked()")), self.amplitude.clear) + QtCore.QObject.connect(self.reset, QtCore.SIGNAL(_fromUtf8("clicked()")), self.imdance.clear) + QtCore.QObject.connect(self.reset, QtCore.SIGNAL(_fromUtf8("clicked()")), self.ordre.clear) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) + self.Calculer.setText(_translate("MainWindow", "Calculer", None)) + self.label_2.setText(_translate("MainWindow", "Fréquence de coupure", None)) + self.label_3.setText(_translate("MainWindow", "Amplitude", None)) + self.label_4.setText(_translate("MainWindow", "Impédance d\'entrée", None)) + self.label.setText(_translate("MainWindow", "Ordre", None)) + self.reset.setText(_translate("MainWindow", "Reset", None)) + self.lineEdit.setText(_translate("MainWindow", "Filtres", None)) + self.actionCalculer.setText(_translate("MainWindow", "calculer", None)) + +import test_rc + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + MainWindow = QtGui.QMainWindow() + ui = Ui_MainWindow() + ui.setupUi(MainWindow) + MainWindow.show() + sys.exit(app.exec_())