1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
| import sys
import math as m
import numpy as np
from PyQt4 import QtGui, QtCore, uic
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
form_class = uic.loadUiType("GUI.ui")[0]
class Window(QtGui.QMainWindow, form_class):
fig = Figure()
def __init__(self):
super(Window, self).__init__()
self.setupUi(self)
self.procedure()
self.show()
def procedure(self):
self.axes = self.fig.add_axes([0.05, 0.05, 0.87, 0.87], polar=True)
self.axes.set_theta_direction(-1)
self.axes.set_theta_offset(m.pi / 2.0)
self.canvas = FigureCanvas(self.fig)
self.grph.addWidget(self.canvas)
self.canvas.draw()
self.toolbar = NavigationToolbar(self.canvas, self, coordinates=True)
self.addToolBar(self.toolbar)
self.EnterButton.clicked.connect(self.ClickEnter)
self.ClearButton.clicked.connect(self.ClickClear)
def show_modal_window(self):
self.modalWindow = QtGui.QWidget()
modalWindow.setWindowTitle("Error, empty enter variables")
modalWindow.resize(200, 50)
button = QtGui.QPushButton("Ok", modalWindow)
button.setFixedSize(150, 30)
button.move(75, 20)
QtCore.QObject.connect(button, QtCore.SIGNAL("clicked()"), modalWindow, QtCore.SLOT("close()"))
modalWindow.setWindowModality(QtCore.Qt.WindowModal)
modalWindow.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
modalWindow.show()
def ClickEnter(self):
RadEarth = 8500
HeightCentreDish = int(self.lineEdit_HCD.text())
EffectReflectSurface = int(self.lineEdit_ER.text())
if HeightCentreDish and EffectReflectSurface == 0:
show_modal_window(self)
flag = self.CheckBoxGround.isChecked()
TargetHeight = int(self.BoxHeight.currentText())
lag = m.pi / 36.
angles = np.arange(0, 2 * m.pi, lag)
AllAng = []
fang = open("angles.txt", mode='r')
for LineFileFang in fang.readlines():
angRadians = m.radians(int(LineFileFang) / 60)
AllAng.append(angRadians)
AllTrouble = []
file_height_trouble = open("height_trouble.txt", mode='r')
for LineFileHeightTrouble in file_height_trouble.readlines():
AllTrouble.append(int(LineFileHeightTrouble))
AllDist = []
AB = m.asin(RadEarth / (RadEarth + HeightCentreDish * 0.001)) - m.pi / 2
for i in range(len(angles)):
if flag:
if AllTrouble[i] != 0:
AA = m.atan((AllTrouble[i] * m.tan(AllAng[i]) - HeightCentreDish) / AllTrouble[i])
else:
AA = m.atan((100 * m.tan(AllAng[i]) - HeightCentreDish) / 100)
else:
AA = AllAng[i]
if AA < AB:
TemporaryLvalue = AB + m.pi / 2
else:
TemporaryLvalue = AA + m.pi / 2
temp1 = RadEarth + HeightCentreDish * 0.001
temp2 = RadEarth + TargetHeight * 0.001
D = m.floor(m.sqrt(temp1 ** 2 + temp2 ** 2 - 2 * temp1 * temp2 * m.cos(
m.pi - m.asin(temp1 * m.sin(TemporaryLvalue) / temp2) - TemporaryLvalue)) * 0.9 * EffectReflectSurface ** (1 / 4))
AllDist.append(D)
self.axes.set_theta_direction(-1)
self.axes.set_theta_offset(m.pi / 2.0)
self.axes.set_xticks(np.arange(0, 2 * m.pi, m.pi / 36))
temp_color = np.random.rand(3,1)
temp = self.axes.plot(angles, AllDist, color=temp_color, linewidth=1)
self.axes.plot((angles[-1], angles[0]), (AllDist[-1], AllDist[0]), color=temp_color, linewidth=1.)
self.canvas.draw()
def ClickClear(self):
self.axes.cla()
self.canvas.draw()
def run():
app = QtGui.QApplication(sys.argv)
GUI = Window()
app.exec_()
if __name__ == "__main__":
run() |