-
Notifications
You must be signed in to change notification settings - Fork 0
/
VPM_Gui_V3.py
237 lines (198 loc) · 10.4 KB
/
VPM_Gui_V3.py
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#V3: working version from aaron but with comments, print statements, etc.
import sys
import os
import time
from PyQt5.Qt import QApplication, QMainWindow
from PyQt5.uic import loadUiType
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
qtCreatorFile = r"VPM_Config_evan.ui"
Ui_MainWindow, QtBaseClass = loadUiType(qtCreatorFile)
path = r"/users/esmith/VPMgui/"
os.chdir(path)
Config_Commands = open("Config_commands.txt")
Command = Config_Commands.readlines()
class App(QMainWindow, Ui_MainWindow):
def __init__(self):
# Do QMainWindow stuff
QMainWindow.__init__(self)
# Set up the UI file
self.setupUi(self)
self.Band_Width.activated.connect(self.Combo_Box_Bw_Nchan)
self.Nchan.activated.connect(self.Auto_Select_Nchan_Tint)
self.Nchan.activated.connect(self.Auto_Select_Tint_Scale)
#self.Create_Script.clicked.connect(self.Create_Name)
self.Create_Script.clicked.connect(self.Generate_Script)
self.Observation_Mode.activated.connect(self.Polarization_Mode)
def Combo_Box_Bw_Nchan(self):
Count_Nchan = self.Nchan.count()
print(type(self.Nchan))
for contents in range(Count_Nchan):
self.Nchan.model().item(contents).setEnabled(True)
self.Tint.model().item(contents).setEnabled(True)
#gray out nchan and tint items based on bandwidth selection
#range_gray_out: how many items to disable
#start_gray_out: where on the list of items to start graying out
def Gray_Out_Bw_Nchan(Range_Gray_Out,Start_Gray_Out,Band_Width_Item):
Band_Width_Selected_Item = self.Band_Width.currentText()
if Band_Width_Selected_Item == Band_Width_Item:
self.Nchan.model().item(1).setEnabled(False)
self.Tint.model().item(1).setEnabled(False)
for i in range(Range_Gray_Out):
print(self.Nchan.model().item(i + Start_Gray_Out))
self.Nchan.model().item(i + Start_Gray_Out).setEnabled(False)
self.Tint.model().item(i + Start_Gray_Out).setEnabled(False)
if self.Dispersion_Mode.currentText() == "Coherent":
Gray_Out_Bw_Nchan(4, 6, "100")
Gray_Out_Bw_Nchan(3, 7, "200")
Gray_Out_Bw_Nchan(2, 8, "1500")
elif self.Dispersion_Mode.currentText() == "Incoherent":
Gray_Out_Bw_Nchan(4, 1, "100")
Gray_Out_Bw_Nchan(5, 1, "200")
def Auto_Select_Nchan_Tint(self):
Tint_Count = self.Tint.count()
Item = self.Nchan.currentIndex()
self.Tint.setCurrentIndex(Item)
for j in range(Tint_Count):
if j == Item:
None
else:
self.Tint.model().item(j).setEnabled(False)
def Auto_Select_Tint_Scale(self):
Band_Width_Item = self.Band_Width.currentText()
Count_Scale = self.Scale.count()
def Auto_select_Scale(Scale_Range,Item_Tint,Selected_Scale):
if self.Tint.currentText() == Item_Tint:
Scale_Item_Index = self.Scale.findText(Selected_Scale)
self.Scale.setCurrentIndex(Scale_Item_Index)
for k in range(Scale_Range):
if k == Scale_Item_Index:
None
else:
self.Scale.model().item(k).setEnabled(False)
if self.Dispersion_Mode.currentText() == "Coherent":
if Band_Width_Item == "100":
Auto_select_Scale(Count_Scale,"64" ,"1500")
Auto_select_Scale(Count_Scale,"128" ,"1000")
Auto_select_Scale(Count_Scale,"256" ,"2500")
Auto_select_Scale(Count_Scale,"512" ,"3750")
elif Band_Width_Item == "200":
Auto_select_Scale(Count_Scale, "64", "1000")
Auto_select_Scale(Count_Scale, "128", "1500")
Auto_select_Scale(Count_Scale, "256", "1000")
Auto_select_Scale(Count_Scale, "512", "2500")
Auto_select_Scale(Count_Scale, "1024", "3750")
elif Band_Width_Item == "800":
Auto_select_Scale(Count_Scale, "32", "300")
Auto_select_Scale(Count_Scale, "64", "450")
Auto_select_Scale(Count_Scale, "128", "675")
Auto_select_Scale(Count_Scale, "256", "1000")
Auto_select_Scale(Count_Scale, "512", "1500")
Auto_select_Scale(Count_Scale, "1024", "1000")
Auto_select_Scale(Count_Scale, "2048", "2500")
Auto_select_Scale(Count_Scale, "4096", "3750")
elif Band_Width_Item == "1500":
Auto_select_Scale(Count_Scale, "32", "300")
Auto_select_Scale(Count_Scale, "64", "500")
Auto_select_Scale(Count_Scale, "128", "700")
Auto_select_Scale(Count_Scale, "256", "1000")
Auto_select_Scale(Count_Scale, "512", "1375")
Auto_select_Scale(Count_Scale, "1024", "1000")
Auto_select_Scale(Count_Scale, "2048", "2800")
elif self.Dispersion_Mode.currentText() == "Incoherent":
if Band_Width_Item == "100":
Auto_select_Scale(Count_Scale, "512", "4000")
Auto_select_Scale(Count_Scale, "1024", "4000")
Auto_select_Scale(Count_Scale, "2048", "4000")
Auto_select_Scale(Count_Scale, "4096", "4000")
Auto_select_Scale(Count_Scale, "8192", "600")
elif Band_Width_Item == "200":
Auto_select_Scale(Count_Scale, "1024", "1000")
Auto_select_Scale(Count_Scale, "2048", "1300")
Auto_select_Scale(Count_Scale, "4096", "500")
Auto_select_Scale(Count_Scale, "8192", "1000")
elif Band_Width_Item == "800":
Auto_select_Scale(Count_Scale, "32", "10000")
Auto_select_Scale(Count_Scale, "64", "10000")
Auto_select_Scale(Count_Scale, "128", "12500")
Auto_select_Scale(Count_Scale, "256", "5000")
Auto_select_Scale(Count_Scale, "512", "10000")
Auto_select_Scale(Count_Scale, "1024", "5000")
Auto_select_Scale(Count_Scale, "2048", "10000")
Auto_select_Scale(Count_Scale, "4096", "5000")
Auto_select_Scale(Count_Scale, "8192", "10000")
elif Band_Width_Item == "1500":
Auto_select_Scale(Count_Scale, "32", "13500")
Auto_select_Scale(Count_Scale, "64", "65000")
Auto_select_Scale(Count_Scale, "128", "13500")
Auto_select_Scale(Count_Scale, "256", "6500")
Auto_select_Scale(Count_Scale, "512", "13500")
Auto_select_Scale(Count_Scale, "1024", "6500")
Auto_select_Scale(Count_Scale, "2048", "13500")
Auto_select_Scale(Count_Scale, "4096", "6500")
Auto_select_Scale(Count_Scale, "8192", "13500")
def Create_Name(self):
Rcvr_Dict = {"L-Band (Rcvr1_2)": "Rcvr1_2", "S-Band (Rcvr2_3)": "Rcvr2_3",
"C-Band (Rcvr4_6)": "Rcvr4_6", "X-Band (Rcvr8_10)": "Rcvr8_10"}
rcvr = self.Receiver_Names.currentText()
ddmode = self.Dispersion_Mode.currentText()
bw = self.Band_Width.currentText()
nchan = self.Nchan.currentText()
nwin = 1
obsmode = self.Observation_Mode.currentText()
Config_Name = "config_vpm_{}_{}{}x{}x{}_{}".format(Rcvr_Dict[rcvr],ddmode,bw,nchan,nwin,obsmode)
self.Display_Script.append(Config_Name)
def Generate_Script(self):
self.Display_Script.clear()
Command_List = [self.Observation_Mode.currentText(),
self.Receiver_Names.currentText(),
self.Rest_Frequency.text(),
self.Noise_Diode_State.currentText(),
self.Polarization.currentText(),
self.Band_Width.currentText(),
self.Tint.currentText(),
self.Nchan.currentText(),
self.Scale.currentText(),
self.Polarization_Products.currentText(),
self.Parfile.text(),
self.Fold_Time.text(),
self.Dispersion_Mode.currentText(),
self.Fold_Bins.text()
]
def Generate_Command(Widget_Input, Widget_List):
Full_Command_Statement = Command[Widget_List].replace("null", Widget_Input)
return self.Display_Script.append(Full_Command_Statement)
Rcvr_Dict = {"L-Band (Rcvr1_2)": "Rcvr1_2", "S-Band (Rcvr2_3)": "Rcvr2_3",
"C-Band (Rcvr4_6)": "Rcvr4_6", "X-Band (Rcvr8_10)": "Rcvr8_10"}
rcvr = self.Receiver_Names.currentText()
ddmode = self.Dispersion_Mode.currentText()
bw = self.Band_Width.currentText()
nchan = self.Nchan.currentText()
nwin = 1
obsmode = self.Observation_Mode.currentText()
Config_Name = "config_vpm_{}_{}{}x{}x{}_{}".format(Rcvr_Dict[rcvr], ddmode, bw, nchan, nwin, obsmode)
self.Display_Script.append(Config_Name)
for Command_List_Index, Widget_Text in enumerate(Command_List):
Generate_Command(Widget_Text, Command_List_Index)
#print(Widget_Text, Command - List)
def Polarization_Mode(self):
ObsMode_Search = ["Total Intensity","Full Stokes"]
ObsMode_Other = ["Full Stokes", "Total Intensity"]
DdMode = self.Dispersion_Mode.currentText()
ObsMode = self.Observation_Mode.currentText()
if ObsMode == "Search":
if DdMode == "Inchoherent":
self.Polarization_Products.clear()
self.Polarization_Products.addItems(ObsMode_Search)
else:
None
else:
self.Polarization_Products.clear()
self.Polarization_Products.addItems(ObsMode_Other)
self.Polarization_Products.model().item(1).setEnabled(False)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = App()
window.show()
sys.exit(app.exec_())