1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | #--------------------------------------------------------------------------------# |
---|
4 | # This file is part of the PALM model system. |
---|
5 | # |
---|
6 | # PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | # of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | # either version 3 of the License, or (at your option) any later version. |
---|
9 | # |
---|
10 | # PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | # |
---|
14 | # You should have received a copy of the GNU General Public License along with |
---|
15 | # PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | # |
---|
17 | # Copyright 1997-2021 Leibniz Universitaet Hannover |
---|
18 | #--------------------------------------------------------------------------------# |
---|
19 | # |
---|
20 | # Current revisions: |
---|
21 | # ----------------- |
---|
22 | # |
---|
23 | # |
---|
24 | # Former revisions: |
---|
25 | # ----------------- |
---|
26 | # $Id: palm_gf_tools.py 4843 2021-01-15 15:22:11Z suehring $ |
---|
27 | # Initial revision |
---|
28 | # |
---|
29 | # |
---|
30 | # |
---|
31 | # |
---|
32 | # |
---|
33 | # Description: |
---|
34 | # ------------ |
---|
35 | # |
---|
36 | # |
---|
37 | # Instructions: |
---|
38 | # ------------- |
---|
39 | # |
---|
40 | #------------------------------------------------------------------------------! |
---|
41 | |
---|
42 | import sys |
---|
43 | import os |
---|
44 | import sqlite3 |
---|
45 | from PyQt4 import QtCore, QtGui, uic |
---|
46 | import subprocess as sub |
---|
47 | import palm_gf_conf as configwr |
---|
48 | |
---|
49 | palm_dir = os.getcwd() |
---|
50 | palm_bin = palm_dir + '/trunk/SCRIPTS' |
---|
51 | |
---|
52 | qtCreatorFile = palm_bin + '/palm_gf_files/palm_gf_table.ui' |
---|
53 | |
---|
54 | Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile) |
---|
55 | |
---|
56 | class MyApp3(QtGui.QMainWindow, Ui_MainWindow): |
---|
57 | |
---|
58 | class MyTableWidgetItem(QtGui.QTableWidgetItem): |
---|
59 | def __init__(self, text, sortKey): |
---|
60 | QtGui.QTableWidgetItem.__init__(self, text, QtGui.QTableWidgetItem.UserType) |
---|
61 | self.sortKey = sortKey |
---|
62 | |
---|
63 | def __lt__(self, other): |
---|
64 | return self.sortKey < other.sortKey |
---|
65 | |
---|
66 | def __init__(self): # def __init__(self, parent=None): |
---|
67 | QtGui.QMainWindow.__init__(self) |
---|
68 | Ui_MainWindow.__init__(self) |
---|
69 | |
---|
70 | framegm = self.frameGeometry() |
---|
71 | screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) |
---|
72 | centerpoint = QtGui.QApplication.desktop().screenGeometry(screen).center() |
---|
73 | framegm.moveCenter(centerpoint) |
---|
74 | |
---|
75 | #centerpoint = str(centerpoint) |
---|
76 | #xcenter = centerpoint.split('(')[1].split(',')[0] |
---|
77 | #ycenter = centerpoint.split('(')[1].split(',')[1].split(')')[0] |
---|
78 | ##print xcenter, ycenter |
---|
79 | #centerpoint = QtCore.QPoint(int(xcenter) + 418, int(ycenter)) |
---|
80 | #framegm.moveCenter(centerpoint) |
---|
81 | self.move(framegm.topLeft()) |
---|
82 | |
---|
83 | |
---|
84 | |
---|
85 | self.setupUi(self) |
---|
86 | self.pushButton_3.clicked.connect(self.load_result) |
---|
87 | #self.nx_min.valueChanged.connect(self.check) |
---|
88 | self.load_trigger() |
---|
89 | self.pushButton.clicked.connect(self.filter_results) |
---|
90 | #self.Sortnow_button.clicked.connect(self.sort_order) |
---|
91 | self.pushButton_2.clicked.connect(self.load_trigger) |
---|
92 | self.tableWidget.horizontalHeader().setClickable(True) |
---|
93 | |
---|
94 | |
---|
95 | self.nx_table.clicked.connect(lambda: self.sort_table(str("nx"))) |
---|
96 | self.ny_table.clicked.connect(lambda: self.sort_table(str("ny"))) |
---|
97 | self.nz_table.clicked.connect(lambda: self.sort_table(str("nz"))) |
---|
98 | self.npex_table.clicked.connect(lambda: self.sort_table(str("npex"))) |
---|
99 | self.npey_table.clicked.connect(lambda: self.sort_table(str("npey"))) |
---|
100 | self.npexnpey_table.clicked.connect(lambda: self.sort_table(str("npexnpey"))) |
---|
101 | self.np_table.clicked.connect(lambda: self.sort_table(str("np"))) |
---|
102 | self.ngpts_table.clicked.connect(lambda: self.sort_table(str("ngpts"))) |
---|
103 | self.nxpex_table.clicked.connect(lambda: self.sort_table(str("nxnpex"))) |
---|
104 | self.nypey_table.clicked.connect(lambda: self.sort_table(str("nynpey"))) |
---|
105 | |
---|
106 | self.instant() |
---|
107 | |
---|
108 | self.save_to_file_button.clicked.connect(self.get_path) |
---|
109 | |
---|
110 | def instant(self): |
---|
111 | checkfile = open(".palm_gf_tmp", "r") |
---|
112 | # self.result_label.setText(str(checkfile.readline())) |
---|
113 | res_text = str(checkfile.readline()) # XXX |
---|
114 | result_nr = res_text.split(' ')[2] |
---|
115 | checkfile.close() |
---|
116 | if int(result_nr) < 100000: |
---|
117 | self.load_result() |
---|
118 | |
---|
119 | |
---|
120 | |
---|
121 | def load_trigger(self): |
---|
122 | pathx = configwr.read_config() |
---|
123 | pathx = pathx[19] |
---|
124 | |
---|
125 | |
---|
126 | dtb = str('.palm_gf_data.db') |
---|
127 | #con = sqlite3.connect("/localdata/.palm_gf_data.db") |
---|
128 | |
---|
129 | pathx = pathx + '/.palm_gf_data.db' |
---|
130 | con = sqlite3.connect(pathx) |
---|
131 | c = con.cursor() |
---|
132 | c.execute("SELECT * FROM " + 'grid_limits') |
---|
133 | mini = c.fetchone() |
---|
134 | max = c.fetchone() |
---|
135 | self.nx_min.setValue(mini[0]) |
---|
136 | self.nx_max.setValue(max[0]) |
---|
137 | |
---|
138 | self.ny_min.setValue(mini[1]) |
---|
139 | self.ny_max.setValue(max[1]) |
---|
140 | self.nz_min.setValue(mini[2]) |
---|
141 | self.nz_max.setValue(max[2]) |
---|
142 | self.npex_min.setValue(mini[3]) |
---|
143 | self.npex_max.setValue(max[3]) |
---|
144 | self.npey_min.setValue(mini[4]) |
---|
145 | self.npey_max.setValue(max[4]) |
---|
146 | self.npxnpy_min.setValue(mini[5]) |
---|
147 | self.npxnpy_max.setValue(max[5]) |
---|
148 | self.np_min.setValue(mini[6]) |
---|
149 | self.np_max.setValue(max[6]) |
---|
150 | self.ngpts_min.setValue(mini[7]) |
---|
151 | self.ngpts_max.setValue(max[7]) |
---|
152 | self.nxpex_min.setValue(mini[8]) |
---|
153 | self.nxpex_max.setValue(max[8]) |
---|
154 | self.nypey_min.setValue(mini[9]) |
---|
155 | self.nypey_max.setValue(max[9]) |
---|
156 | |
---|
157 | self.nx_min.setMinimum(mini[0]) |
---|
158 | self.nx_max.setMaximum(max[0]) |
---|
159 | self.ny_min.setMinimum(mini[1]) |
---|
160 | self.ny_max.setMaximum(max[1]) |
---|
161 | self.nz_min.setMinimum(mini[2]) |
---|
162 | self.nz_max.setMaximum(max[2]) |
---|
163 | self.npex_min.setMinimum(mini[3]) |
---|
164 | self.npex_max.setMaximum(max[3]) |
---|
165 | self.npey_min.setMinimum(mini[4]) |
---|
166 | self.npey_max.setMaximum(max[4]) |
---|
167 | self.npxnpy_min.setMinimum(mini[5]) |
---|
168 | self.npxnpy_max.setMaximum(max[5]) |
---|
169 | self.np_min.setMinimum(mini[6]) |
---|
170 | self.np_max.setMaximum(max[6]) |
---|
171 | |
---|
172 | self.ngpts_min.setMinimum(mini[7]) |
---|
173 | self.ngpts_max.setMaximum(max[7]) |
---|
174 | self.ngpts_min.setMaximum(max[7]) |
---|
175 | self.ngpts_max.setMinimum(mini[7]) |
---|
176 | |
---|
177 | self.nxpex_min.setMinimum(mini[8]) |
---|
178 | self.nxpex_max.setMaximum(max[8]) |
---|
179 | self.nxpex_min.setMaximum(max[8]) |
---|
180 | self.nxpex_max.setMinimum(mini[8]) |
---|
181 | |
---|
182 | self.nypey_min.setMinimum(mini[9]) |
---|
183 | self.nypey_max.setMaximum(max[9]) |
---|
184 | self.nypey_min.setMaximum(max[9]) |
---|
185 | self.nypey_max.setMinimum(mini[9]) |
---|
186 | |
---|
187 | |
---|
188 | |
---|
189 | |
---|
190 | |
---|
191 | con.commit() |
---|
192 | c.close() |
---|
193 | con.close() |
---|
194 | |
---|
195 | |
---|
196 | |
---|
197 | |
---|
198 | def check(self): |
---|
199 | pathx = configwr.read_config() |
---|
200 | pathx = pathx[19] |
---|
201 | |
---|
202 | dtb = str('.palm_gf_data.db') |
---|
203 | #con = sqlite3.connect("/localdata/.palm_gf_data.db") |
---|
204 | con = sqlite3.connect(pathx + '/.palm_gf_data.db') |
---|
205 | c = con.cursor() |
---|
206 | c.execute("SELECT * FROM " + 'grid_limits') |
---|
207 | mini = c.fetchone() |
---|
208 | max = c.fetchone() |
---|
209 | if self.nx_min.value() < mini[0]: |
---|
210 | |
---|
211 | self.nx_min.setValue(mini[0]) |
---|
212 | |
---|
213 | |
---|
214 | def process1(self): |
---|
215 | self.calc_label.setText('loading...') |
---|
216 | QtGui.QApplication.processEvents() |
---|
217 | |
---|
218 | |
---|
219 | |
---|
220 | def load_result(self): |
---|
221 | #print("LOADED!!!") |
---|
222 | import decimal |
---|
223 | |
---|
224 | pathx = configwr.read_config() |
---|
225 | pathx = pathx[19] |
---|
226 | |
---|
227 | self.setEnabled(False) |
---|
228 | QtGui.QApplication.processEvents() |
---|
229 | self.load_trigger() |
---|
230 | self.process1() |
---|
231 | database = str('.palm_gf_data.db') |
---|
232 | conn = sqlite3.connect(pathx + '/.palm_gf_data.db') |
---|
233 | c = conn.cursor() |
---|
234 | c.execute("SELECT * FROM " + 'grid_current') |
---|
235 | results = c.fetchall() |
---|
236 | |
---|
237 | self.tableWidget.setRowCount(len(results)) |
---|
238 | |
---|
239 | i = 0 |
---|
240 | j = 0 |
---|
241 | k = 0 |
---|
242 | |
---|
243 | while i < len(results): |
---|
244 | line = results[i] |
---|
245 | while j < 10: |
---|
246 | var = line[j] |
---|
247 | |
---|
248 | if j == 7: |
---|
249 | self.tableWidget.setItem(i, j, self.MyTableWidgetItem(str("%.1e" % var), j + i)) |
---|
250 | #print("%.2e" % int(var), "%.4e" % int(1782)) |
---|
251 | |
---|
252 | else: |
---|
253 | self.tableWidget.setItem(i, j, self.MyTableWidgetItem(str(var), j+i)) |
---|
254 | #item = self.MyTableWidgetItem(str(var), k) |
---|
255 | #self.tableWidget.setItem(i, j, item) |
---|
256 | |
---|
257 | j += 1 |
---|
258 | #if j == 3: |
---|
259 | #print(k) |
---|
260 | #k += 1 |
---|
261 | #k -= 7 |
---|
262 | k += 1 |
---|
263 | j = 0 |
---|
264 | i += 1 |
---|
265 | |
---|
266 | c.close() |
---|
267 | conn.close() |
---|
268 | self.calc_label.setText('loading completed') |
---|
269 | self.label_11.setText(str(len(results)) + ' results ') |
---|
270 | self.setEnabled(True) |
---|
271 | QtGui.QApplication.processEvents() |
---|
272 | |
---|
273 | def filter_results(self): |
---|
274 | |
---|
275 | pathx = configwr.read_config() |
---|
276 | pathx = pathx[19] |
---|
277 | |
---|
278 | self.setEnabled(False) |
---|
279 | self.calc_label.setText('calculating...') |
---|
280 | QtGui.QApplication.processEvents() |
---|
281 | database = str('.palm_gf_data.db') |
---|
282 | conn = sqlite3.connect(pathx + '/.palm_gf_data.db') |
---|
283 | c = conn.cursor() |
---|
284 | c.execute("SELECT * FROM " + "grid_current") |
---|
285 | results = c.fetchall() |
---|
286 | #print(results) |
---|
287 | |
---|
288 | self.tableWidget.setRowCount(len(results)) |
---|
289 | |
---|
290 | i = 0 |
---|
291 | j = 0 |
---|
292 | row_cnt = -1 |
---|
293 | while i < len(results): |
---|
294 | line = results[i] |
---|
295 | |
---|
296 | if line[0] <= self.nx_max.value(): |
---|
297 | |
---|
298 | if line[0] >= self.nx_min.value(): |
---|
299 | |
---|
300 | if line[1] <= self.ny_max.value(): |
---|
301 | |
---|
302 | if line[1] >= self.ny_min.value(): |
---|
303 | |
---|
304 | if line[2] <= self.nz_max.value(): |
---|
305 | |
---|
306 | if line[2] >= self.nz_min.value(): |
---|
307 | |
---|
308 | if line[3] <= self.npex_max.value(): |
---|
309 | |
---|
310 | if line[3] >= self.npex_min.value(): |
---|
311 | |
---|
312 | if line[4] <= self.npey_max.value(): |
---|
313 | |
---|
314 | if line[4] >= self.npey_min.value(): |
---|
315 | |
---|
316 | if line[5] <= self.npxnpy_max.value(): |
---|
317 | |
---|
318 | if line[5] >= self.npxnpy_min.value(): |
---|
319 | |
---|
320 | if line[6] <= self.np_max.value(): |
---|
321 | |
---|
322 | if line[6] >= self.np_min.value(): |
---|
323 | |
---|
324 | if line[7] <= self.ngpts_max.value(): |
---|
325 | |
---|
326 | if line[7] >= self.ngpts_min.value(): |
---|
327 | |
---|
328 | if line[8] <= self.nxpex_max.value(): |
---|
329 | |
---|
330 | if line[8] >= self.nxpex_min.value(): |
---|
331 | |
---|
332 | if line[9] <= self.nypey_max.value(): |
---|
333 | |
---|
334 | if line[9] >= self.nypey_min.value(): |
---|
335 | |
---|
336 | row_cnt += 1 |
---|
337 | while j < 10: |
---|
338 | var = line[j] |
---|
339 | |
---|
340 | if j == 7: |
---|
341 | self.tableWidget.setItem(row_cnt, j, self.MyTableWidgetItem(str("%.1e" % var), i)) |
---|
342 | |
---|
343 | else: |
---|
344 | self.tableWidget.setItem(row_cnt, j, self.MyTableWidgetItem(str(var), i)) |
---|
345 | |
---|
346 | j += 1 |
---|
347 | |
---|
348 | j = 0 |
---|
349 | i += 1 |
---|
350 | |
---|
351 | c.close() |
---|
352 | conn.close() |
---|
353 | self.tableWidget.setRowCount(row_cnt + 1) |
---|
354 | self.setEnabled(True) |
---|
355 | self.calc_label.setText('calculation completed') |
---|
356 | self.label_11.setText(str(row_cnt + 1) + ' results') |
---|
357 | QtGui.QApplication.processEvents() |
---|
358 | |
---|
359 | |
---|
360 | |
---|
361 | def sort_table(self, column): |
---|
362 | |
---|
363 | fnx_mn = self.nx_min.value() |
---|
364 | fnx_mx = self.nx_max.value() |
---|
365 | fny_mn = self.ny_min.value() |
---|
366 | fny_mx = self.ny_max.value() |
---|
367 | fnz_mn = self.nz_min.value() |
---|
368 | fnz_mx = self.nz_max.value() |
---|
369 | fnpex_mn = self.npex_min.value() |
---|
370 | fnpex_mx = self.npex_max.value() |
---|
371 | fnpey_mn = self.npex_min.value() |
---|
372 | fnpey_mx = self.npey_max.value() |
---|
373 | fnpxnpy_mn = self.npxnpy_min.value() |
---|
374 | fnpxnpy_mx = self.npxnpy_max.value() |
---|
375 | fnp_mn = self.np_min.value() |
---|
376 | fnp_mx = self.np_max.value() |
---|
377 | fngpts_mn = self.ngpts_min.value() |
---|
378 | fngpts_mx = self.ngpts_max.value() |
---|
379 | nxpex_mn = self.nxpex_min.value() |
---|
380 | nxpex_mx = self.nxpex_max.value() |
---|
381 | nypey_mn = self.nypey_min.value() |
---|
382 | nypey_mx = self.nypey_max.value() |
---|
383 | |
---|
384 | |
---|
385 | if column == str("nx"): |
---|
386 | sorted_col = "nx" |
---|
387 | |
---|
388 | if self.nx_table.isChecked() is True: |
---|
389 | order = " DESC" |
---|
390 | |
---|
391 | else: |
---|
392 | |
---|
393 | order = " ASC" |
---|
394 | |
---|
395 | self.ny_table.setChecked(False) |
---|
396 | self.nz_table.setChecked(False) |
---|
397 | self.npex_table.setChecked(False) |
---|
398 | self.npey_table.setChecked(False) |
---|
399 | self.npexnpey_table.setChecked(False) |
---|
400 | self.np_table.setChecked(False) |
---|
401 | self.ngpts_table.setChecked(False) |
---|
402 | self.nxpex_table.setChecked(False) |
---|
403 | self.nypey_table.setChecked(False) |
---|
404 | |
---|
405 | if column == str("ny"): |
---|
406 | sorted_col = "ny" |
---|
407 | |
---|
408 | if self.ny_table.isChecked() is True: |
---|
409 | order = " DESC" |
---|
410 | |
---|
411 | else: |
---|
412 | |
---|
413 | order = " ASC" |
---|
414 | |
---|
415 | self.nx_table.setChecked(False) |
---|
416 | self.nz_table.setChecked(False) |
---|
417 | self.npex_table.setChecked(False) |
---|
418 | self.npey_table.setChecked(False) |
---|
419 | self.npexnpey_table.setChecked(False) |
---|
420 | self.np_table.setChecked(False) |
---|
421 | self.ngpts_table.setChecked(False) |
---|
422 | self.nxpex_table.setChecked(False) |
---|
423 | self.nypey_table.setChecked(False) |
---|
424 | |
---|
425 | if column == str("nz"): |
---|
426 | sorted_col = "nz" |
---|
427 | |
---|
428 | if self.nz_table.isChecked() is True: |
---|
429 | order = " DESC" |
---|
430 | |
---|
431 | else: |
---|
432 | |
---|
433 | order = " ASC" |
---|
434 | |
---|
435 | self.nx_table.setChecked(False) |
---|
436 | self.ny_table.setChecked(False) |
---|
437 | self.npex_table.setChecked(False) |
---|
438 | self.npey_table.setChecked(False) |
---|
439 | self.npexnpey_table.setChecked(False) |
---|
440 | self.np_table.setChecked(False) |
---|
441 | self.ngpts_table.setChecked(False) |
---|
442 | self.nxpex_table.setChecked(False) |
---|
443 | self.nypey_table.setChecked(False) |
---|
444 | |
---|
445 | if column == str("npex"): |
---|
446 | sorted_col = "npex" |
---|
447 | |
---|
448 | if self.npex_table.isChecked() is True: |
---|
449 | order = " DESC" |
---|
450 | |
---|
451 | else: |
---|
452 | |
---|
453 | order = " ASC" |
---|
454 | |
---|
455 | self.ny_table.setChecked(False) |
---|
456 | self.nz_table.setChecked(False) |
---|
457 | self.nx_table.setChecked(False) |
---|
458 | self.npey_table.setChecked(False) |
---|
459 | self.npexnpey_table.setChecked(False) |
---|
460 | self.np_table.setChecked(False) |
---|
461 | self.ngpts_table.setChecked(False) |
---|
462 | self.nxpex_table.setChecked(False) |
---|
463 | self.nypey_table.setChecked(False) |
---|
464 | |
---|
465 | if column == str("npey"): |
---|
466 | sorted_col = "npey" |
---|
467 | |
---|
468 | if self.npey_table.isChecked() is True: |
---|
469 | order = " DESC" |
---|
470 | |
---|
471 | else: |
---|
472 | |
---|
473 | order = " ASC" |
---|
474 | |
---|
475 | |
---|
476 | self.ny_table.setChecked(False) |
---|
477 | self.nz_table.setChecked(False) |
---|
478 | self.npex_table.setChecked(False) |
---|
479 | self.nx_table.setChecked(False) |
---|
480 | self.npexnpey_table.setChecked(False) |
---|
481 | self.np_table.setChecked(False) |
---|
482 | self.ngpts_table.setChecked(False) |
---|
483 | self.nxpex_table.setChecked(False) |
---|
484 | self.nypey_table.setChecked(False) |
---|
485 | |
---|
486 | if column == str("npexnpey"): |
---|
487 | sorted_col = "npxnpy" |
---|
488 | |
---|
489 | if self.npexnpey_table.isChecked() is True: |
---|
490 | order = " DESC" |
---|
491 | |
---|
492 | else: |
---|
493 | |
---|
494 | order = " ASC" |
---|
495 | |
---|
496 | self.ny_table.setChecked(False) |
---|
497 | self.nz_table.setChecked(False) |
---|
498 | self.npex_table.setChecked(False) |
---|
499 | self.npey_table.setChecked(False) |
---|
500 | self.nx_table.setChecked(False) |
---|
501 | self.np_table.setChecked(False) |
---|
502 | self.ngpts_table.setChecked(False) |
---|
503 | self.nxpex_table.setChecked(False) |
---|
504 | self.nypey_table.setChecked(False) |
---|
505 | |
---|
506 | if column == str("np"): |
---|
507 | sorted_col = "np" |
---|
508 | |
---|
509 | if self.np_table.isChecked() is True: |
---|
510 | order = " DESC" |
---|
511 | |
---|
512 | else: |
---|
513 | |
---|
514 | order = " ASC" |
---|
515 | |
---|
516 | self.ny_table.setChecked(False) |
---|
517 | self.nz_table.setChecked(False) |
---|
518 | self.npex_table.setChecked(False) |
---|
519 | self.npey_table.setChecked(False) |
---|
520 | self.npexnpey_table.setChecked(False) |
---|
521 | self.nx_table.setChecked(False) |
---|
522 | self.ngpts_table.setChecked(False) |
---|
523 | self.nxpex_table.setChecked(False) |
---|
524 | self.nypey_table.setChecked(False) |
---|
525 | |
---|
526 | if column == str("ngpts"): |
---|
527 | sorted_col = "ngpts" |
---|
528 | |
---|
529 | if self.ngpts_table.isChecked() is True: |
---|
530 | order = " DESC" |
---|
531 | |
---|
532 | else: |
---|
533 | |
---|
534 | order = " ASC" |
---|
535 | |
---|
536 | self.ny_table.setChecked(False) |
---|
537 | self.nz_table.setChecked(False) |
---|
538 | self.npex_table.setChecked(False) |
---|
539 | self.npey_table.setChecked(False) |
---|
540 | self.npexnpey_table.setChecked(False) |
---|
541 | self.np_table.setChecked(False) |
---|
542 | self.nx_table.setChecked(False) |
---|
543 | self.nxpex_table.setChecked(False) |
---|
544 | self.nypey_table.setChecked(False) |
---|
545 | |
---|
546 | if column == str("nxnpex"): |
---|
547 | sorted_col = "nxnpex" |
---|
548 | |
---|
549 | if self.nxpex_table.isChecked() is True: |
---|
550 | order = " DESC" |
---|
551 | |
---|
552 | else: |
---|
553 | |
---|
554 | order = " ASC" |
---|
555 | |
---|
556 | self.ny_table.setChecked(False) |
---|
557 | self.nz_table.setChecked(False) |
---|
558 | self.npex_table.setChecked(False) |
---|
559 | self.npey_table.setChecked(False) |
---|
560 | self.npexnpey_table.setChecked(False) |
---|
561 | self.np_table.setChecked(False) |
---|
562 | self.nx_table.setChecked(False) |
---|
563 | self.ngpts_table.setChecked(False) |
---|
564 | self.nypey_table.setChecked(False) |
---|
565 | |
---|
566 | if column == str("nynpey"): |
---|
567 | sorted_col = "nynpey" |
---|
568 | |
---|
569 | if self.nypey_table.isChecked() is True: |
---|
570 | order = " DESC" |
---|
571 | |
---|
572 | else: |
---|
573 | |
---|
574 | order = " ASC" |
---|
575 | |
---|
576 | self.ny_table.setChecked(False) |
---|
577 | self.nz_table.setChecked(False) |
---|
578 | self.npex_table.setChecked(False) |
---|
579 | self.npey_table.setChecked(False) |
---|
580 | self.npexnpey_table.setChecked(False) |
---|
581 | self.np_table.setChecked(False) |
---|
582 | self.nx_table.setChecked(False) |
---|
583 | self.ngpts_table.setChecked(False) |
---|
584 | self.nxpex_table.setChecked(False) |
---|
585 | |
---|
586 | else: |
---|
587 | pass |
---|
588 | |
---|
589 | pathx = configwr.read_config() |
---|
590 | pathx = pathx[19] |
---|
591 | |
---|
592 | |
---|
593 | conn = sqlite3.connect(pathx + "/.palm_gf_data.db") |
---|
594 | c = conn.cursor() |
---|
595 | c.execute("SELECT * FROM grid_current WHERE nx <= " + str(fnx_mx) + " AND nx >= " + str(fnx_mn) + " AND ny <= " + str(fny_mx) + " AND ny >= " + str(fny_mn) + " AND nz <= " + str(fnz_mx) + |
---|
596 | " AND nz >= " + str(fnz_mn) + " AND npex <= " + str(fnpex_mx) + " AND npex >= " + |
---|
597 | str(fnpex_mn) + " AND npey <= " + str(fnpey_mx) + " AND npey >= " + str(fnpey_mn) + " AND " |
---|
598 | "npxnpy <= " + str(fnpxnpy_mx) + " AND npxnpy >= " + str(fnpxnpy_mn) + " AND np <= " + str(fnp_mx) + " AND np >= " + str(fnp_mn) + " AND ngpts <= " + str(fngpts_mx) + " AND ngpts >= " + str(fngpts_mn) + |
---|
599 | " AND nxnpex <= " + str(nxpex_mx) + " AND nxnpex >= " + str(nxpex_mn) + " AND nynpey <= " + str(nypey_mx) + " AND nynpey >= " + str(nypey_mn) + |
---|
600 | " ORDER BY " + str(sorted_col) + str(order)) |
---|
601 | |
---|
602 | |
---|
603 | |
---|
604 | sorted = c.fetchall() |
---|
605 | |
---|
606 | |
---|
607 | c.close() |
---|
608 | conn.close() |
---|
609 | self.tableWidget.setRowCount(len(sorted)) |
---|
610 | |
---|
611 | for row_indx in range(0,len(sorted)): |
---|
612 | |
---|
613 | for col_indx in range(0,10): |
---|
614 | row = sorted[row_indx] |
---|
615 | value = row[col_indx] |
---|
616 | if col_indx == 7: |
---|
617 | self.tableWidget.setItem(row_indx, col_indx, QtGui.QTableWidgetItem(str("%.1e" % value))) |
---|
618 | else: |
---|
619 | self.tableWidget.setItem(row_indx, col_indx, QtGui.QTableWidgetItem(str(value))) |
---|
620 | |
---|
621 | |
---|
622 | |
---|
623 | def sort_order(self): |
---|
624 | |
---|
625 | sorted = 0 |
---|
626 | fnx_mn = self.nx_min.value() |
---|
627 | fnx_mx = self.nx_max.value() |
---|
628 | fny_mn = self.ny_min.value() |
---|
629 | fny_mx = self.ny_max.value() |
---|
630 | fnz_mn = self.nz_min.value() |
---|
631 | fnz_mx = self.nz_max.value() |
---|
632 | fnpex_mn = self.npex_min.value() |
---|
633 | fnpex_mx = self.npex_max.value() |
---|
634 | fnpey_mn = self.npex_min.value() |
---|
635 | fnpey_mx = self.npey_max.value() |
---|
636 | fnpxnpy_mn = self.npxnpy_min.value() |
---|
637 | fnpxnpy_mx = self.npxnpy_max.value() |
---|
638 | fnp_mn = self.np_min.value() |
---|
639 | fnp_mx = self.np_max.value() |
---|
640 | fngpts_mn = self.ngpts_min.value() |
---|
641 | fngpts_mx = self.ngpts_max.value() |
---|
642 | |
---|
643 | if str(self.Sortvariable_box.currentIndex()) == str(1): |
---|
644 | |
---|
645 | |
---|
646 | sorted_col = "nx" |
---|
647 | if str(self.Sortvariable_box.currentIndex()) == str(2): |
---|
648 | |
---|
649 | sorted_col = "ny" |
---|
650 | if str(self.Sortvariable_box.currentIndex()) == str(3): |
---|
651 | |
---|
652 | sorted_col = "nz" |
---|
653 | if str(self.Sortvariable_box.currentIndex()) == str(4): |
---|
654 | |
---|
655 | sorted_col = "npex" |
---|
656 | if str(self.Sortvariable_box.currentIndex()) == str(5): |
---|
657 | |
---|
658 | sorted_col = "npey" |
---|
659 | if str(self.Sortvariable_box.currentIndex()) == str(6): |
---|
660 | |
---|
661 | sorted_col = "npxnpy" |
---|
662 | if str(self.Sortvariable_box.currentIndex()) == str(7): |
---|
663 | |
---|
664 | sorted_col = "np" |
---|
665 | if str(self.Sortvariable_box.currentIndex()) == str(8): |
---|
666 | |
---|
667 | sorted_col = "ngpts" |
---|
668 | |
---|
669 | #print(self.Sortvariable_box.currentIndex()) |
---|
670 | |
---|
671 | if str(self.Sortorder_box.currentIndex()) == str(1): |
---|
672 | |
---|
673 | order = " ASC" |
---|
674 | |
---|
675 | if str(self.Sortorder_box.currentIndex()) == str(2): |
---|
676 | |
---|
677 | order = " DESC" |
---|
678 | |
---|
679 | |
---|
680 | |
---|
681 | conn = sqlite3.connect("/localdata/.palm_gf_data.db") |
---|
682 | c = conn.cursor() |
---|
683 | c.execute("SELECT * FROM grid_current WHERE nx <= " + str(fnx_mx) + " AND nx >= " + str(fnx_mn) + " AND ny <= " + str(fny_mx) + " AND ny >= " + str(fny_mn) + " AND nz <= " + str(fnz_mx) + |
---|
684 | " AND nz >= " + str(fnz_mn) + " AND npex <= " + str(fnpex_mx) + " AND npex >= " + |
---|
685 | str(fnpex_mn) + " AND npey <= " + str(fnpey_mx) + " AND npey >= " + str(fnpey_mn) + " AND " |
---|
686 | "npxnpy <= " + str(fnpxnpy_mx) + " AND npxnpy >= " + str(fnpxnpy_mn) + " AND np <= " + str(fnp_mx) + " AND np >= " + str(fnp_mn) + " AND ngpts <= " + str(fngpts_mx) + " AND ngpts >= " + str(fngpts_mn) + |
---|
687 | " ORDER BY " + str(sorted_col) + str(order)) |
---|
688 | |
---|
689 | |
---|
690 | |
---|
691 | sorted = c.fetchall() |
---|
692 | |
---|
693 | c.close() |
---|
694 | conn.close() |
---|
695 | self.tableWidget.setRowCount(len(sorted)) |
---|
696 | |
---|
697 | for row_indx in range(0,len(sorted)): |
---|
698 | |
---|
699 | for col_indx in range(0,8): |
---|
700 | row = sorted[row_indx] |
---|
701 | value = row[col_indx] |
---|
702 | self.tableWidget.setItem(row_indx, col_indx, QtGui.QTableWidgetItem(str(var))) |
---|
703 | |
---|
704 | |
---|
705 | |
---|
706 | |
---|
707 | |
---|
708 | |
---|
709 | #print(len(sorted)) |
---|
710 | #print(sorted) |
---|
711 | |
---|
712 | def get_path(wildcard): |
---|
713 | import wx |
---|
714 | app = wx.App(None) |
---|
715 | style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST |
---|
716 | dialog = wx.FileDialog(None, 'Open', wildcard='*.db') |
---|
717 | if dialog.ShowModal() == wx.ID_OK: |
---|
718 | path = dialog.GetPath() |
---|
719 | |
---|
720 | print(path, file) |
---|
721 | else: |
---|
722 | path = None |
---|
723 | dialog.Destroy() |
---|
724 | return |
---|
725 | |
---|
726 | |
---|
727 | |
---|
728 | |
---|
729 | |
---|
730 | |
---|
731 | |
---|
732 | |
---|
733 | |
---|
734 | |
---|
735 | |
---|
736 | if __name__ == "__main__": |
---|
737 | app = QtGui.QApplication(sys.argv) |
---|
738 | window = MyApp3() |
---|
739 | window.setWindowTitle('Gridfilter') |
---|
740 | window.show() |
---|
741 | sys.exit(app.exec_()) |
---|
742 | |
---|