Changeset 2308 for palm/trunk
- Timestamp:
- Jul 10, 2017 12:15:43 PM (7 years ago)
- Location:
- palm/trunk/SCRIPTS
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/palm_gf
r2117 r2308 42 42 import sys 43 43 import os 44 import time 44 45 import palm_gf_files.palm_gf_exec as execute_script 45 46 import palm_gf_files.palm_gf_conf as config_wr … … 47 48 import subprocess as sub 48 49 49 from PyQt4 import QtCore, QtGui, uic 50 51 from PyQt4 import QtCore, QtGui, uic, Qt 52 from PyQt4.QtCore import QCoreApplication 50 53 from palm_gf_files.palm_gf_tools import MyApp3 51 54 … … 67 70 68 71 class MyApp1(QtGui.QMainWindow, Ui_MainWindow): 69 def __init__(self , parent=None):72 def __init__(self): 70 73 71 74 … … 81 84 self.move(frameGm.topLeft()) 82 85 86 87 #centerPoint = str(centerPoint) 88 #xcenter = centerPoint.split('(')[1].split(',')[0] 89 #ycenter = centerPoint.split('(')[1].split(',')[1].split(')')[0] 90 #print xcenter, ycenter 91 #centerPoint = QtCore.QPoint(int(xcenter) - 418, int(ycenter)) 92 #frameGm.moveCenter(centerPoint) 93 #self.move(frameGm.topLeft()) 94 83 95 self.setupUi(self) 84 self.startbutton.clicked.connect(self. run_program) # starts grid_calculation96 self.startbutton.clicked.connect(self.input_check) # starts grid_calculation 85 97 self.psolver_box.currentIndexChanged.connect(self.vis) # triggers visibility of fft_method option 86 98 self.save_button.clicked.connect(self.save_results) # saves .db file under given name … … 89 101 self.result_headline.setVisible(False) 90 102 self.result_label.setVisible(False) 91 self.line_res_up.setVisible(False)103 #self.line_res_up.setVisible(False) 92 104 self.line_res_down.setVisible(False) 93 105 self.view_result_button.setVisible(False) 94 self.tableWidget.setVisible(False)106 #self.tableWidget.setVisible(False) 95 107 self.load_text_label.setVisible(False) 96 108 self.nor_spinbox.setVisible(False) 97 109 self.filename_line.setVisible(False) 98 110 self.save_button.setVisible(False) 111 self.testbar.setVisible(False) 112 self.d_box.setVisible(False) 113 self.tpn_box.setVisible(False) 114 self.tolerance_bar.setVisible(False) 115 self.tolerance_value.setVisible(False) 99 116 self.view_result_button.clicked.connect(self.load_gui) 100 101 #self.startbutton.clicked.connect(self.progress) 102 #self.progressBar.setEnabled(False) 103 #self.progressBar.setVisible(False) 104 105 #def progress(self): 106 # import time 107 # self.progressBar.setVisible(True) 108 # self.progressBar.setDisabled(False) 109 # self.progressBar.setValue(10) 110 # time.sleep(1) 111 # self.progressBar.setValue(50) 112 # time.sleep(1) 113 # self.progressBar.setValue(100) 114 # time.sleep(1) 115 # self.progressBar.setEnabled(False) 117 self.threadclass = Threadclass() 118 self.actionSetting.triggered.connect(self.settings) 119 self.question_box.clicked.connect(self.settings) 120 self.warning_label.setVisible(False) 121 122 123 124 125 def closeEvent(self, QCloseEvent): 126 127 config_wr.closing_cleanup() 128 QCloseEvent.accept() 129 130 131 def input_check(self): 132 133 if int(self.nx_min_box.value()) <= int(self.nx_max_box.value()) and int(self.ny_min_box.value()) <= int(self.nx_max_box.value()) and int(self.nz_min_box.value()) <= int(self.nz_max_box.value()): 134 self.warning_label.setVisible(False) 135 self.run_program() 136 137 else: 138 139 self.warning_label.setStyleSheet('color: red') 140 self.warning_label.setVisible(True) 141 142 143 144 145 146 147 148 def settings(self): 149 150 self.w = MyPopup() 151 #self.w.setGeometry(Qt.QRect(100, 100, 400, 200)) 152 frameGm = self.frameGeometry() 153 screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) 154 centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center() 155 frameGm.moveCenter(centerPoint) 156 self.w.move(frameGm.topLeft()) 157 self.w.show() 158 159 116 160 117 161 def vis(self): … … 126 170 127 171 def load_gui(self): 128 print("not yet possible")129 172 self.child_win = MyApp3() 130 173 self.child_win.show() 131 #self.load_results_2() 132 #MyApp2(self).show() 133 # import filter_script 134 # upt = filter_script.MyApp2() 135 # upt.cur_grid() 136 137 def load_results(self): 138 self.setGeometry(330, 250, 584, 622) 139 self.tableWidget.setVisible(True) 140 conn = sqlite3.connect(".palm_gf_data.db") 141 c = conn.cursor() 142 nor = int(self.nor_spinbox.value()) 143 self.tableWidget.setRowCount(nor) 144 c.execute("SELECT * FROM grid_current") 145 results = c.fetchmany(nor) 146 i = 0 147 j = 0 148 149 while i < nor: 150 line = results[i] 151 while j < 6: 152 var = line[j] 153 154 self.tableWidget.setItem(i, j, QtGui.QTableWidgetItem(str(var))) 155 156 j += 1 157 j = 0 158 i += 1 159 160 c.close() 161 conn.close() 174 175 def run_transfer(self): 176 self.threadclass = Threadclass() 177 self.connect(self.threadclass, QtCore.SIGNAL('finish'), self.behind_run) 178 #self.connect(self.threadclass, QtCore.SIGNAL('progress'), self.up2date) 179 self.connect(self.threadclass, QtCore.SIGNAL('startqmsg'), self.takeoff) 180 self.connect(self.threadclass, QtCore.SIGNAL('check'), self.checkme) 181 self.threadclass.runx() 162 182 163 183 def run_program(self): 164 self.setEnabled(False) 184 185 186 self.result_label.setText('Starting calculation...') 187 #self.QtCore.QCoreApplication.processEvents() 188 QtGui.QApplication.processEvents() 189 #self.setEnabled(False) 165 190 # self.Ui_MainWindow.setDisabled(True) 166 self.qmsg() 191 #self.qmsg_wait(0) 192 #print("bool state ", self.npex_npey_box.checkState()) # XXX 167 193 np_min = str(self.np_min_box.value()) 168 194 np_max = str(self.np_max_box.value()) … … 175 201 tpn = str(self.tpn_box.value()) 176 202 dnpexnpey = str(self.d_box.value()) 203 dnpexnpey_tolerance = str(self.tolerance_value.value()) 177 204 dnxny = str(self.dnxny_box.value()) 205 myobject = MyPopup() 206 ld_thrs = myobject.load_thres.value() 207 rslt_thrs = myobject.result_thres.value() 178 208 179 209 if str(self.psolver_box.currentIndex()) == str(1): … … 199 229 else: 200 230 spctre = False 201 print(poisfft, switch, temperton, mlt_grid, spctre) 202 config_wr.write_config(np_min, np_max, nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, tpn, dnpexnpey, dnxny, 203 str(poisfft), str(switch), str(temperton), str(mlt_grid), str(spctre)) 204 execute_script.grid_executer() 205 #execute_script.grid_maxmin() 231 232 if int(self.strict_box.checkState()) != 2: 233 tpn = 0 234 235 if int(self.npex_npey_box.checkState()) != 2: 236 dnpexnpey = 0 237 dnpexnpey_tolerance = 0 238 239 #print(poisfft, switch, temperton, mlt_grid, spctre) 240 config_wr.write_config(np_min, np_max, nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, tpn, dnpexnpey,dnpexnpey_tolerance, dnxny, 241 str(poisfft), str(switch), str(temperton), str(mlt_grid), str(spctre), rslt_thrs, ld_thrs) 242 #time.sleep(1) 243 # execute_script.grid_executer() temp deactive 244 self.testbar.setVisible(True) 245 QtCore.QCoreApplication.processEvents() 246 self.run_transfer() 247 248 249 def behind_run(self): 250 trigger_bool = False 251 #print("behind_run executed") 206 252 checkfile = open(".palm_gf_tmp", "r") 207 self.result_label.setText(str(checkfile.readline())) 253 #self.result_label.setText(str(checkfile.readline())) 254 res_text = str(checkfile.readline()) # XXX 255 self.result_label.setText(res_text) 256 result_nr = res_text.split(' ')[2] 208 257 if int(checkfile.readline()) == 1: 209 258 self.view_result_button.setVisible(True) 259 trigger_bool = True 210 260 self.result_label.setVisible(True) 211 261 self.result_headline.setVisible(True) 212 262 self.line_res_down.setVisible(True) 213 self.line_res_up.setVisible(True)263 #self.line_res_up.setVisible(True) 214 264 self.load_text_label.setVisible(False) 215 265 self.nor_spinbox.setVisible(False) 216 266 checkfile.close() 217 self.setEnabled(True)267 #self.setEnabled(True) 218 268 self.filename_line.setVisible(True) 219 269 self.save_button.setVisible(True) 220 221 def load_results_2(self): 222 223 database = str(".palm_gf_data.db") 224 print(database) 225 self.tableWidget.setVisible(True) 226 conn = sqlite3.connect(database) # ".palm_gf_data.db" 227 c = conn.cursor() 228 c.execute("SELECT * FROM " + 'grid_current') # "grid_current" database[:-3] 229 # c.execute("SELECT * FROM " + database) 230 results = c.fetchall() 231 232 self.tableWidget.setRowCount(len(results)) 233 234 i = 0 235 j = 0 236 237 while i < len(results): 238 line = results[i] 239 while j < 6: 240 var = line[j] 241 242 self.tableWidget.setItem(i, j, QtGui.QTableWidgetItem(str(var))) 243 244 if i == 0 and j == 0: 245 np_min = line[0] 246 np_max = line[0] 247 npex_min = line[1] 248 npex_max = line[1] 249 npey_min = line[2] 250 npey_max = line[2] 251 nx_min = line[3] 252 nx_max = line[3] 253 ny_min = line[4] 254 ny_max = line[4] 255 nz_min = line[5] 256 nz_max = line[5] 257 else: 258 if line[0] > np_max: 259 np_max = line[0] 260 if line[0] < np_min: 261 np_min = line[0] 262 if line[1] > npex_max: 263 npex_max = line[1] 264 if line[1] < npex_min: 265 npex_min = line[1] 266 if line[2] > npey_max: 267 npey_max = line[2] 268 if line[2] < npey_min: 269 npey_min = line[2] 270 if line[3] > nx_max: 271 nx_max = line[3] 272 if line[3] < nx_min: 273 nx_min = line[3] 274 if line[4] > ny_max: 275 ny_max = line[4] 276 if line[4] < ny_min: 277 ny_min = line[4] 278 if line[5] > nz_max: 279 nz_max = line[5] 280 if line[5] < nz_min: 281 nz_min = line[5] 282 283 j += 1 284 j = 0 285 i += 1 286 287 c.close() 288 conn.close() 289 290 self.np_max.setValue(np_max) 291 292 self.np_min.setValue(np_min) 293 self.npex_max.setValue(npex_max) 294 self.npex_min.setValue(npex_min) 295 self.npey_max.setValue(npey_max) 296 self.npey_min.setValue(npey_min) 297 self.nx_max.setValue(nx_max) 298 self.nx_min.setValue(nx_min) 299 self.ny_max.setValue(ny_max) 300 self.ny_min.setValue(ny_min) 301 self.nz_max.setValue(nz_max) 302 self.nz_min.setValue(nz_min) 303 self.np_max.setMaximum(np_max) 304 self.np_min.setMinimum(np_min) 305 self.npex_max.setMaximum(npex_max) 306 self.npex_min.setMinimum(npex_min) 307 self.npey_max.setMaximum(npey_max) 308 self.npey_min.setMinimum(npey_min) 309 self.nx_max.setMaximum(nx_max) 310 self.nx_min.setMinimum(nx_min) 311 self.ny_max.setMaximum(ny_max) 312 self.ny_min.setMinimum(ny_min) 313 self.nz_max.setMaximum(nz_max) 314 self.nz_min.setMinimum(nz_min) 315 316 self.nr_output_label.setText(str(len(results)) + ' results') 270 parameters = config_wr.read_config() 271 272 273 if trigger_bool is True and int(result_nr) < int(parameters[18]): 274 self.result_label.setText(res_text + 'Loading Ui...') 275 self.load_gui() # XXXX 276 self.result_label.setText(res_text) 277 #self.close() 278 #frameGm = self.frameGeometry() 279 #screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) 280 #centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center() 281 #frameGm = self.frameGeometry() 282 #screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) 283 #centerPoint = str(centerPoint) 284 #xcenter = centerPoint.split('(')[1].split(',')[0] 285 #ycenter = centerPoint.split('(')[1].split(',')[1].split(')')[0] 286 ##print xcenter, ycenter 287 #centerPoint = QtCore.QPoint(int(xcenter) - 292, int(ycenter)) 288 #frameGm.moveCenter(centerPoint) 289 #self.move(frameGm.topLeft()) 290 291 292 293 317 294 318 295 … … 325 302 if dialog.ShowModal() == wx.ID_OK: 326 303 path = dialog.GetPath() 327 print(path) 304 305 print(path, file) 328 306 else: 329 307 path = None … … 357 335 msgbox.exec_() 358 336 337 def tester(self): 338 #print("tester was executed from run method") 339 pass 340 341 def qmsg_wait(self, progress): 342 global msgbox 343 msgbox = QtGui.QMessageBox() 344 layout = msgbox.layout() 345 layout.itemAtPosition(layout.rowCount() - 1, 0).widget().hide() 346 global progressx 347 progressx = QtGui.QProgressBar() 348 layout.addWidget(progressx, layout.rowCount(), 0, 1, layout.columnCount()) 349 350 msgbox.setWindowTitle("Progress") 351 msgbox.Information 352 msgbox.setText("Calculating, please be patient.") 353 354 progressx.setValue(int(progress)) 355 #msgbox.setModal(False) 356 msgbox.exec_() 357 358 def up2date(self, progress): 359 360 progressx.setValue(int(progress)) 361 if progress == 100: 362 msgbox.done(1) 363 364 def takeoff(self): 365 #self.qmsg_wait(0) 366 pass 367 368 def checkme(self, check): 369 #print(check) 370 self.testbar.setValue(int(check)) 371 372 if check == 100: 373 self.testbar.setVisible(False) 374 QtGui.QApplication.processEvents() 375 376 377 378 379 380 class Threadclass(QtCore.QThread): 381 def __init__(self, parent = None): 382 super(Threadclass, self).__init__(parent) 383 384 def runx(self): 385 #print("runx exec.") 386 self.execute() 387 388 389 390 def execute(self): 391 self.emit(QtCore.SIGNAL('startqmsg'), 0) 392 393 parameters = config_wr.read_config() 394 min_procs = int(parameters[0]) 395 max_procs = int(parameters[1]) 396 tpn = int(parameters[2]) 397 dnpexnpey = float(parameters[3]) 398 dnpexnpey_tol = int(parameters[4]) 399 dnxny = float(parameters[5]) 400 nx_min = int(parameters[6]) 401 nx_max = int(parameters[7]) 402 ny_min = int(parameters[8]) 403 ny_max = int(parameters[9]) 404 nz_min = int(parameters[10]) 405 nz_max = int(parameters[11]) 406 poisfft = parameters[12] 407 switch = parameters[13] 408 tempterton = parameters[14] 409 mlt_grid = parameters[15] 410 spectr = parameters[16] 411 result_thrs = parameters[17] 412 413 414 path = "/localdata/.palm_gf_data.db" 415 pathx = parameters[19] + '/.palm_gf_data.db' 416 417 418 conn = sqlite3.connect(pathx) 419 #conn = sqlite3.connect(".palm_gf_data.db") 420 c = conn.cursor() 421 c.execute("DROP TABLE IF EXISTS grid_current") 422 c.execute("DROP TABLE IF EXISTS grid_limits") 423 c.execute( 424 "CREATE TABLE IF NOT EXISTS grid_current(nx INT, ny INT, nz INT, npex INT, npey INT, npxnpy FLOAT, np INT, ngpts INT)") 425 c.execute( 426 "CREATE TABLE IF NOT EXISTS grid_limits(nx INT, ny INT, nz INT, npex INT, npey INT, npxnpy FLOAT, np INT, ngpts INT)") 427 conn.commit() 428 main_bool = True 429 430 431 432 433 if poisfft == str(True): 434 poisfft = True 435 else: 436 poisfft = False 437 438 if switch == str(True): 439 switch = True 440 else: 441 switch = False 442 443 if tempterton == str(True): 444 tempterton = True 445 else: 446 tempterton = False 447 448 if mlt_grid == str(True): 449 mlt_grid = True 450 else: 451 mlt_grid = False 452 453 if spectr == str(True): 454 spectr = True 455 else: 456 spectr = False 457 458 #print(spectr, type(spectr)) 459 #print(poisfft, switch, tempterton, mlt_grid, spectr) 460 461 np_used = min_procs 462 counter = 0 463 464 nx = nx_min 465 ny = ny_min 466 nz = nz_min 467 468 from math import floor 469 470 def factors(n): 471 result = [] 472 for i in range(2, n + 1): # test all integers between 2 and n 473 s = 0 474 while n / i == floor(n / float(i)): # is n/i an integer? 475 n = n / float(i) 476 s += 1 477 if s > 0: 478 for k in range(s): 479 result.append(i) # i is a pf s times 480 if n == 1: 481 return result 482 483 while np_used <= max_procs: 484 a = 1 485 486 while a <= np_used: 487 prcs_var = np_used % a 488 if prcs_var != 0: 489 a += 1 490 elif prcs_var == 0: 491 npex = a 492 npey = int(np_used / npex) 493 494 if tpn != 0: # XXX 495 496 if np_used % tpn != 0: 497 a += 1 498 continue 499 500 if dnpexnpey != 0 and npex / npey != dnpexnpey: 501 a += 1 502 continue 503 504 if dnpexnpey != 0: 505 506 507 if float(npex) / float(npey) < (dnpexnpey - dnpexnpey*dnpexnpey_tol/100): 508 a += 1 509 continue 510 511 if float(npex) / float(npey) > (dnpexnpey + dnpexnpey*dnpexnpey_tol/100): 512 a += 1 513 continue 514 515 while nx <= nx_max: 516 if (nx + 1) % npex != 0: 517 nx += 1 518 continue 519 520 if mlt_grid is True and (nx + 1) % 2 != 0: 521 nx += 1 522 continue 523 524 if switch is True and (nx + 1) % npey != 0: 525 nx += 1 526 continue 527 if npex > nx: 528 nx += 1 529 continue 530 531 while ny <= ny_max: 532 533 if dnxny != 0 and float(nx) / float(ny) != float(dnxny): 534 ny += 1 535 continue 536 if (ny + 1) % npey != 0: 537 ny += 1 538 continue 539 540 #if mlt_grid is True and ny % 2 != 0: mlt and mlt_noOpt have same cond. 541 # ny += 1 542 # continue 543 544 if (ny + 1) % npex != 0 and switch is True: 545 ny += 1 546 continue 547 if npey > ny: 548 ny += 1 549 continue 550 551 while nz <= nz_max: 552 553 if mlt_grid is True and nz % 2 != 0: 554 nz += 1 555 continue 556 557 if poisfft is True and nz % npex != 0: 558 nz += 1 559 continue 560 561 if spectr is True and nz % npey != 0: 562 nz += 1 563 continue 564 565 if tempterton is True and nx > 1 and ny > 1: # and nz < 1: 566 567 nx_list = factors(nx + 1) 568 569 i = 0 570 nx_var = nx_list[i] 571 572 573 while i < len(nx_list): 574 if nx_var != 2 or nx_var != 3 or nx_var != 5: 575 i += 1 576 continue 577 578 i += 1 579 ny_list = factors(ny + 1) 580 i = 0 581 ny_var = ny_list[i] 582 while i < len(ny_list): 583 if ny_var != 2 or ny_var != 3 or ny_var != 5: 584 i += 1 585 continue 586 i += 1 587 588 counter += 1 589 if counter > int(result_thrs): 590 break 591 592 npxnpy = format(float(npex) / float(npey), '.2f') 593 c.execute( 594 """INSERT OR REPLACE INTO grid_current(nx, ny, nz, npex, npey, npxnpy, np, ngpts) VALUES (?, ?, ?, ?, ?, ?, ?, ?)""", 595 (nx, ny, nz, npex, npey, npxnpy, (npex * npey), (nx * ny * nz))) 596 597 nz += 1 598 nz = nz_min 599 ny += 1 600 ny = ny_min 601 nx += 1 602 nx = nx_min 603 a += 1 604 # a += 1 605 np_used += 1 606 progr_act = 100*(float(np_used-1)/float(max_procs)) 607 self.emit(QtCore.SIGNAL('check'), progr_act) 608 #print(np_used, max_procs, progr_act) 609 self.emit(QtCore.SIGNAL('progress'), progr_act) 610 611 conn.commit() 612 613 conn.commit() 614 #c.close() 615 #conn.close() 616 # 617 ## ******************************** 618 # 619 #conn = sqlite3.connect(parameters[19] + '/.palm_gf_data.db') 620 #print parameters[19] + '/.palm_gf_data.db' 621 #c = conn.cursor() 622 try: 623 c.execute("SELECT nx FROM grid_current ORDER BY nx DESC LIMIT 1") 624 mx_nx = c.fetchone()[0] 625 # print(mx_nx) 626 c.execute("SELECT nx FROM grid_current ORDER BY nx LIMIT 1") 627 mn_nx = c.fetchone()[0] 628 # print(mn_nx) 629 c.execute("SELECT ny FROM grid_current ORDER BY ny DESC LIMIT 1") 630 mx_ny = c.fetchone()[0] 631 # print(mx_ny) 632 c.execute("SELECT ny FROM grid_current ORDER BY ny LIMIT 1") 633 mn_ny = c.fetchone()[0] 634 # print(mn_ny) 635 c.execute("SELECT nz FROM grid_current ORDER BY nz DESC LIMIT 1") 636 mx_nz = c.fetchone()[0] 637 # print(mx_nz) 638 c.execute("SELECT nz FROM grid_current ORDER BY nz LIMIT 1") 639 mn_nz = c.fetchone()[0] 640 # print(mn_nz) 641 c.execute("SELECT npex FROM grid_current ORDER BY npex DESC LIMIT 1") 642 mx_npex = c.fetchone()[0] 643 # print(mx_npex) 644 c.execute("SELECT npex FROM grid_current ORDER BY npex LIMIT 1") 645 mn_npex = c.fetchone()[0] 646 # print(mn_npex) 647 c.execute("SELECT npey FROM grid_current ORDER BY npey DESC LIMIT 1") 648 mx_npey = c.fetchone()[0] 649 # print(mx_npey) 650 c.execute("SELECT npey FROM grid_current ORDER BY npey LIMIT 1") 651 mn_npey = c.fetchone()[0] 652 # print(mn_npey) 653 c.execute("SELECT npxnpy FROM grid_current ORDER BY npxnpy DESC LIMIT 1") 654 mx_npxnpy = c.fetchone()[0] 655 # print(mx_npxnpy) 656 c.execute("SELECT npxnpy FROM grid_current ORDER BY npxnpy LIMIT 1") 657 mn_npxnpy = c.fetchone()[0] 658 # print(mn_npxnpy) 659 c.execute("SELECT np FROM grid_current ORDER BY np DESC LIMIT 1") 660 mx_np = c.fetchone()[0] 661 # print(mx_np) 662 c.execute("SELECT np FROM grid_current ORDER BY np LIMIT 1") 663 mn_np = c.fetchone()[0] 664 # print(mn_np) 665 c.execute("SELECT ngpts FROM grid_current ORDER BY ngpts DESC LIMIT 1") 666 mx_ngpts = c.fetchone()[0] 667 # print(mx_ngpts) 668 c.execute("SELECT ngpts FROM grid_current ORDER BY ngpts LIMIT 1") 669 mn_ngpts = c.fetchone()[0] 670 # print(mn_ngpts) 671 672 conn.commit() 673 c.execute( 674 """INSERT OR REPLACE INTO grid_limits(nx, ny, nz, npex, npey, npxnpy, np, ngpts) VALUES (?, ?, ?, ?, ?, ?, ?, ?)""", 675 (mn_nx, mn_ny, mn_nz, mn_npex, mn_npey, mn_npxnpy, mn_np, mn_ngpts)) 676 677 c.execute( 678 """INSERT OR REPLACE INTO grid_limits(nx, ny, nz, npex, npey, npxnpy, np, ngpts) VALUES (?, ?, ?, ?, ?, ?, ?, ?)""", 679 (mx_nx, mx_ny, mx_nz, mx_npex, mx_npey, mx_npxnpy, mx_np, mx_ngpts)) 680 conn.commit() 681 682 c.close() 683 conn.close() 684 except TypeError: 685 686 checkfile = open(".palm_gf_tmp", "w") 687 if counter != 0: 688 checkfile.write("Gridfinder found " + str(counter) + " results.\n1") 689 else: 690 checkfile.write("Check input, no Results found.\n0") 691 checkfile.close() 692 693 checkfile = open(".palm_gf_tmp", "w") 694 if counter != 0: 695 checkfile.write("Gridfinder found " + str(counter) + " results.\n1") 696 else: 697 checkfile.write("Check input, no Results found.\n0") 698 checkfile.close() 699 self.emit(QtCore.SIGNAL('finish'), 1) 700 #print("finished with main execute") 701 702 703 704 705 706 qtpopupFile = palm_bin + '/palm_gf_files/palm_gf_settings.ui' 707 Ui_Pop, QtBaseClass = uic.loadUiType(qtpopupFile) 708 709 710 class MyPopup(QtGui.QWidget, Ui_Pop): 711 712 def __init__(self): 713 Qt.QWidget.__init__(self) 714 Ui_Pop.__init__(self) 715 716 self.setupUi(self) 717 self.show 718 self.savepath.clicked.connect(self.path_to_save) 719 self.begin_check() 720 self.buttonBox.accepted.connect(self.end_check) 721 self.buttonBox.rejected.connect(self.close) 722 723 724 def begin_check(self): 725 file_check = palm_dir + '/trunk/SCRIPTS/.palm_gf_config' 726 if os.path.isfile(file_check) is True: 727 parameters = config_wr.read_config_settings() 728 self.linepath.setText(parameters[0]) 729 self.result_thres.setValue(int(parameters[1])) 730 self.load_thres.setValue(int(parameters[2])) 731 732 def end_check(self): 733 config_wr.write_config_settings(self.linepath.text(), self.result_thres.value(), self.load_thres.value()) 734 735 self.close() 736 737 738 739 740 741 def path_to_save(self, wildcard= None): 742 import wx 743 app = wx.App(None) 744 style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST 745 dialog = wx.DirDialog(None, 'Open') 746 if dialog.ShowModal() == wx.ID_OK: 747 path = str(dialog.GetPath()) 748 749 print(path) 750 self.linepath.setText(path) 751 752 753 754 else: 755 path = None 756 dialog.Destroy() 757 return 758 759 760 761 762 763 764 359 765 360 766 if __name__ == "__main__": -
palm/trunk/SCRIPTS/palm_gf_files/palm_gf.ui
r2116 r2308 6 6 <enum>Qt::WindowModal</enum> 7 7 </property> 8 <property name="enabled"> 9 <bool>true</bool> 10 </property> 8 11 <property name="geometry"> 9 12 <rect> … … 11 14 <y>0</y> 12 15 <width>584</width> 13 <height>3 75</height>16 <height>386</height> 14 17 </rect> 15 18 </property> … … 82 85 <item> 83 86 <widget class="QSpinBox" name="nx_min_box"> 87 <property name="toolTip"> 88 <string><html><head/><body><p>Minimum of number of Gridpoints in X-direction.</p></body></html></string> 89 </property> 84 90 <property name="minimum"> 85 91 <number>1</number> … … 92 98 <item> 93 99 <widget class="QSpinBox" name="ny_min_box"> 100 <property name="toolTip"> 101 <string><html><head/><body><p>Minimum of number of Gridpoints in Y-direction.</p></body></html></string> 102 </property> 94 103 <property name="minimum"> 95 104 <number>1</number> … … 102 111 <item> 103 112 <widget class="QSpinBox" name="nz_min_box"> 113 <property name="toolTip"> 114 <string><html><head/><body><p>Minimum of number of Gridpoints in Z-direction.</p></body></html></string> 115 </property> 104 116 <property name="minimum"> 105 117 <number>1</number> … … 124 136 <item> 125 137 <widget class="QSpinBox" name="nx_max_box"> 138 <property name="toolTip"> 139 <string><html><head/><body><p>Maximum of number of Gridpoints in X-direction.</p></body></html></string> 140 </property> 141 <property name="autoFillBackground"> 142 <bool>false</bool> 143 </property> 144 <property name="styleSheet"> 145 <string notr="true"/> 146 </property> 147 <property name="frame"> 148 <bool>true</bool> 149 </property> 126 150 <property name="minimum"> 127 151 <number>1</number> … … 134 158 <item> 135 159 <widget class="QSpinBox" name="ny_max_box"> 160 <property name="toolTip"> 161 <string><html><head/><body><p>Maxmimum of number of Gridpoints in Y-direction.</p></body></html></string> 162 </property> 136 163 <property name="minimum"> 137 164 <number>1</number> … … 144 171 <item> 145 172 <widget class="QSpinBox" name="nz_max_box"> 173 <property name="toolTip"> 174 <string><html><head/><body><p>Maximum of number of Gridpoints in Z-direction.</p></body></html></string> 175 </property> 146 176 <property name="minimum"> 147 177 <number>1</number> … … 162 192 <height>22</height> 163 193 </rect> 194 </property> 195 <property name="toolTip"> 196 <string><html><head/><body><p>Defines Ratio between the number of Gridpoints in X- and Y-direction.</p><p>If nx/ny = 0 , option is deactivated</p><p><br/></p></body></html></string> 164 197 </property> 165 198 <property name="maximum"> … … 239 272 </property> 240 273 <property name="text"> 241 <string> n y</string>274 <string> nz</string> 242 275 </property> 243 276 <property name="scaledContents"> … … 270 303 </property> 271 304 <property name="text"> 272 <string> n z</string>305 <string> ny</string> 273 306 </property> 274 307 </widget> … … 297 330 <property name="text"> 298 331 <string>Maximum</string> 332 </property> 333 </widget> 334 <widget class="QLabel" name="warning_label"> 335 <property name="geometry"> 336 <rect> 337 <x>230</x> 338 <y>155</y> 339 <width>121</width> 340 <height>31</height> 341 </rect> 342 </property> 343 <property name="autoFillBackground"> 344 <bool>false</bool> 345 </property> 346 <property name="styleSheet"> 347 <string notr="true"/> 348 </property> 349 <property name="text"> 350 <string>Input error! Min > Max</string> 299 351 </property> 300 352 </widget> … … 306 358 <y>0</y> 307 359 <width>211</width> 308 <height>2 01</height>360 <height>221</height> 309 361 </rect> 310 362 </property> … … 399 451 <x>22</x> 400 452 <y>94</y> 401 <width> 51</width>453 <width>61</width> 402 454 <height>21</height> 403 455 </rect> … … 405 457 <property name="text"> 406 458 <string>Maximum</string> 407 </property>408 </widget>409 <widget class="QLabel" name="label_8">410 <property name="geometry">411 <rect>412 <x>16</x>413 <y>130</y>414 <width>89</width>415 <height>27</height>416 </rect>417 </property>418 <property name="toolTip">419 <string><html><head/><body><p>Tasks per node. Default value: 24</p><p>If Tasks / Node = 0 , option is deactivated (not recommended).</p></body></html></string>420 </property>421 <property name="text">422 <string>Tasks / Node</string>423 </property>424 </widget>425 <widget class="QLabel" name="label_10">426 <property name="geometry">427 <rect>428 <x>16</x>429 <y>164</y>430 <width>89</width>431 <height>21</height>432 </rect>433 </property>434 <property name="toolTip">435 <string><html><head/><body><p>Ratio between number of processors in X- and Y-direction.</p><p>If npex / npey = 0,00 , option is deactivated.</p></body></html></string>436 </property>437 <property name="text">438 <string>npex / npey</string>439 459 </property> 440 460 </widget> … … 466 486 </size> 467 487 </property> 488 <property name="toolTip"> 489 <string><html><head/><body><p>Maximum of number of processors used for calculation.</p></body></html></string> 490 </property> 468 491 <property name="minimum"> 469 492 <number>1</number> … … 500 523 </size> 501 524 </property> 525 <property name="toolTip"> 526 <string><html><head/><body><p>Minimum of number of processors used for calculation.</p></body></html></string> 527 </property> 502 528 <property name="minimum"> 503 529 <number>1</number> … … 507 533 </property> 508 534 </widget> 509 <widget class="Q SpinBox" name="tpn_box">510 <property name="geometry"> 511 <rect> 512 <x>1 10</x>535 <widget class="QWidget" name="layoutWidget"> 536 <property name="geometry"> 537 <rect> 538 <x>10</x> 513 539 <y>130</y> 514 <width>72</width> 515 <height>25</height> 516 </rect> 517 </property> 518 <property name="sizePolicy"> 519 <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> 520 <horstretch>0</horstretch> 521 <verstretch>0</verstretch> 522 </sizepolicy> 523 </property> 524 <property name="minimumSize"> 525 <size> 526 <width>72</width> 527 <height>25</height> 528 </size> 529 </property> 530 <property name="maximumSize"> 531 <size> 532 <width>72</width> 533 <height>25</height> 534 </size> 535 </property> 536 <property name="maximum"> 537 <number>10000</number> 540 <width>182</width> 541 <height>27</height> 542 </rect> 543 </property> 544 <layout class="QHBoxLayout" name="horizontalLayout"> 545 <item> 546 <widget class="QCheckBox" name="strict_box"> 547 <property name="toolTip"> 548 <string><html><head/><body><p>Fixed value for the tasks per node</p></body></html></string> 549 </property> 550 <property name="text"> 551 <string>Strict Matching</string> 552 </property> 553 </widget> 554 </item> 555 <item> 556 <widget class="QSpinBox" name="tpn_box"> 557 <property name="enabled"> 558 <bool>true</bool> 559 </property> 560 <property name="sizePolicy"> 561 <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> 562 <horstretch>0</horstretch> 563 <verstretch>0</verstretch> 564 </sizepolicy> 565 </property> 566 <property name="minimumSize"> 567 <size> 568 <width>72</width> 569 <height>25</height> 570 </size> 571 </property> 572 <property name="maximumSize"> 573 <size> 574 <width>72</width> 575 <height>25</height> 576 </size> 577 </property> 578 <property name="toolTip"> 579 <string><html><head/><body><p>Fixed value for the tasks per node</p></body></html></string> 580 </property> 581 <property name="maximum"> 582 <number>10000</number> 583 </property> 584 <property name="value"> 585 <number>24</number> 586 </property> 587 </widget> 588 </item> 589 </layout> 590 </widget> 591 <widget class="QSlider" name="tolerance_bar"> 592 <property name="geometry"> 593 <rect> 594 <x>10</x> 595 <y>190</y> 596 <width>121</width> 597 <height>23</height> 598 </rect> 599 </property> 600 <property name="toolTip"> 601 <string><html><head/><body><p>Tolerance for npex / npey</p></body></html></string> 538 602 </property> 539 603 <property name="value"> 540 <number>24</number> 541 </property> 542 </widget> 543 <widget class="QDoubleSpinBox" name="d_box"> 544 <property name="geometry"> 545 <rect> 546 <x>110</x> 547 <y>162</y> 548 <width>72</width> 549 <height>25</height> 550 </rect> 551 </property> 552 <property name="sizePolicy"> 553 <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> 554 <horstretch>0</horstretch> 555 <verstretch>0</verstretch> 556 </sizepolicy> 557 </property> 558 <property name="minimumSize"> 559 <size> 560 <width>72</width> 561 <height>25</height> 562 </size> 563 </property> 564 <property name="maximumSize"> 565 <size> 566 <width>72</width> 567 <height>25</height> 568 </size> 569 </property> 570 <property name="maximum"> 571 <double>1000.000000000000000</double> 572 </property> 604 <number>10</number> 605 </property> 606 <property name="orientation"> 607 <enum>Qt::Horizontal</enum> 608 </property> 609 </widget> 610 <widget class="QSpinBox" name="tolerance_value"> 611 <property name="geometry"> 612 <rect> 613 <x>131</x> 614 <y>190</y> 615 <width>61</width> 616 <height>22</height> 617 </rect> 618 </property> 619 <property name="toolTip"> 620 <string><html><head/><body><p>Tolerance for npex / npey in percent</p><p><br/></p><p><br/></p></body></html></string> 621 </property> 622 <property name="value"> 623 <number>10</number> 624 </property> 625 </widget> 626 <widget class="QWidget" name="layoutWidget"> 627 <property name="geometry"> 628 <rect> 629 <x>10</x> 630 <y>160</y> 631 <width>181</width> 632 <height>27</height> 633 </rect> 634 </property> 635 <layout class="QHBoxLayout" name="horizontalLayout_4"> 636 <item> 637 <widget class="QCheckBox" name="npex_npey_box"> 638 <property name="text"> 639 <string>npex / npey</string> 640 </property> 641 </widget> 642 </item> 643 <item> 644 <widget class="QDoubleSpinBox" name="d_box"> 645 <property name="sizePolicy"> 646 <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> 647 <horstretch>0</horstretch> 648 <verstretch>0</verstretch> 649 </sizepolicy> 650 </property> 651 <property name="minimumSize"> 652 <size> 653 <width>72</width> 654 <height>25</height> 655 </size> 656 </property> 657 <property name="maximumSize"> 658 <size> 659 <width>72</width> 660 <height>25</height> 661 </size> 662 </property> 663 <property name="maximum"> 664 <double>1000.000000000000000</double> 665 </property> 666 </widget> 667 </item> 668 </layout> 573 669 </widget> 574 670 </widget> … … 665 761 <item> 666 762 <property name="text"> 667 <string>multigrid </string>763 <string>multigrid_noopt</string> 668 764 </property> 669 765 </item> 670 766 <item> 671 767 <property name="text"> 672 <string>multigrid _fast</string>768 <string>multigrid</string> 673 769 </property> 674 770 </item> … … 846 942 <rect> 847 943 <x>380</x> 848 <y>2 20</y>944 <y>240</y> 849 945 <width>197</width> 850 946 <height>31</height> … … 865 961 <rect> 866 962 <x>370</x> 867 <y> 180</y>963 <y>218</y> 868 964 <width>179</width> 869 <height> 59</height>965 <height>20</height> 870 966 </rect> 871 967 </property> … … 876 972 </font> 877 973 </property> 974 <property name="toolTip"> 975 <string><html><head/><body><p>tolerance for npex / npey</p></body></html></string> 976 </property> 878 977 <property name="text"> 879 978 <string>Results</string> 880 </property>881 </widget>882 <widget class="Line" name="line_res_up">883 <property name="geometry">884 <rect>885 <x>360</x>886 <y>190</y>887 <width>201</width>888 <height>20</height>889 </rect>890 </property>891 <property name="orientation">892 <enum>Qt::Horizontal</enum>893 979 </property> 894 980 </widget> … … 897 983 <rect> 898 984 <x>360</x> 899 <y> 280</y>985 <y>300</y> 900 986 <width>201</width> 901 987 <height>20</height> … … 910 996 <rect> 911 997 <x>490</x> 912 <y>2 61</y>998 <y>281</y> 913 999 <width>75</width> 914 1000 <height>23</height> … … 925 1011 </property> 926 1012 </widget> 927 <widget class="QTableWidget" name="tableWidget">928 <property name="geometry">929 <rect>930 <x>10</x>931 <y>340</y>932 <width>491</width>933 <height>241</height>934 </rect>935 </property>936 <property name="sizePolicy">937 <sizepolicy hsizetype="Maximum" vsizetype="Expanding">938 <horstretch>0</horstretch>939 <verstretch>0</verstretch>940 </sizepolicy>941 </property>942 <property name="maximumSize">943 <size>944 <width>900</width>945 <height>16777215</height>946 </size>947 </property>948 <property name="layoutDirection">949 <enum>Qt::LeftToRight</enum>950 </property>951 <property name="frameShape">952 <enum>QFrame::Box</enum>953 </property>954 <property name="frameShadow">955 <enum>QFrame::Sunken</enum>956 </property>957 <property name="lineWidth">958 <number>1</number>959 </property>960 <property name="horizontalScrollBarPolicy">961 <enum>Qt::ScrollBarAlwaysOff</enum>962 </property>963 <property name="showGrid">964 <bool>true</bool>965 </property>966 <property name="sortingEnabled">967 <bool>true</bool>968 </property>969 <attribute name="horizontalHeaderVisible">970 <bool>true</bool>971 </attribute>972 <attribute name="horizontalHeaderCascadingSectionResizes">973 <bool>false</bool>974 </attribute>975 <attribute name="horizontalHeaderDefaultSectionSize">976 <number>80</number>977 </attribute>978 <column>979 <property name="text">980 <string>np</string>981 </property>982 </column>983 <column>984 <property name="text">985 <string>npex</string>986 </property>987 </column>988 <column>989 <property name="text">990 <string>npey</string>991 </property>992 </column>993 <column>994 <property name="text">995 <string>nx</string>996 </property>997 </column>998 <column>999 <property name="text">1000 <string>ny</string>1001 </property>1002 </column>1003 <column>1004 <property name="text">1005 <string>nz</string>1006 </property>1007 </column>1008 </widget>1009 1013 <widget class="QLabel" name="load_text_label"> 1010 1014 <property name="geometry"> 1011 1015 <rect> 1012 1016 <x>379</x> 1013 <y>2 61</y>1017 <y>281</y> 1014 1018 <width>42</width> 1015 1019 <height>23</height> … … 1042 1046 <rect> 1043 1047 <x>420</x> 1044 <y>2 61</y>1048 <y>281</y> 1045 1049 <width>61</width> 1046 1050 <height>23</height> … … 1067 1071 <rect> 1068 1072 <x>490</x> 1069 <y>3 04</y>1073 <y>324</y> 1070 1074 <width>75</width> 1071 1075 <height>23</height> … … 1101 1105 <rect> 1102 1106 <x>415</x> 1103 <y>3 04</y>1107 <y>324</y> 1104 1108 <width>75</width> 1105 1109 <height>23</height> … … 1120 1124 <height>18</height> 1121 1125 </size> 1126 </property> 1127 </widget> 1128 <widget class="QProgressBar" name="testbar"> 1129 <property name="geometry"> 1130 <rect> 1131 <x>364</x> 1132 <y>239</y> 1133 <width>206</width> 1134 <height>23</height> 1135 </rect> 1136 </property> 1137 <property name="value"> 1138 <number>0</number> 1139 </property> 1140 </widget> 1141 <widget class="QPushButton" name="question_box"> 1142 <property name="geometry"> 1143 <rect> 1144 <x>395</x> 1145 <y>324</y> 1146 <width>21</width> 1147 <height>23</height> 1148 </rect> 1149 </property> 1150 <property name="text"> 1151 <string>?</string> 1122 1152 </property> 1123 1153 </widget> … … 1129 1159 <y>0</y> 1130 1160 <width>584</width> 1131 <height>2 1</height>1161 <height>20</height> 1132 1162 </rect> 1133 1163 </property> … … 1136 1166 <string>Gridfinder</string> 1137 1167 </property> 1168 <addaction name="actionSetting"/> 1138 1169 <addaction name="actionSchlie_en"/> 1139 1170 </widget> … … 1144 1175 <property name="text"> 1145 1176 <string>SchlieÃen</string> 1177 </property> 1178 </action> 1179 <action name="actionSetting"> 1180 <property name="text"> 1181 <string>Settings</string> 1146 1182 </property> 1147 1183 </action> … … 1167 1203 <tabstop>quitbutton</tabstop> 1168 1204 <tabstop>filename_line</tabstop> 1169 <tabstop>tableWidget</tabstop>1170 1205 <tabstop>Oos_checkbox</tabstop> 1171 1206 </tabstops> … … 1188 1223 </hints> 1189 1224 </connection> 1225 <connection> 1226 <sender>strict_box</sender> 1227 <signal>clicked(bool)</signal> 1228 <receiver>tpn_box</receiver> 1229 <slot>setVisible(bool)</slot> 1230 <hints> 1231 <hint type="sourcelabel"> 1232 <x>422</x> 1233 <y>193</y> 1234 </hint> 1235 <hint type="destinationlabel"> 1236 <x>514</x> 1237 <y>193</y> 1238 </hint> 1239 </hints> 1240 </connection> 1241 <connection> 1242 <sender>npex_npey_box</sender> 1243 <signal>clicked(bool)</signal> 1244 <receiver>d_box</receiver> 1245 <slot>setVisible(bool)</slot> 1246 <hints> 1247 <hint type="sourcelabel"> 1248 <x>422</x> 1249 <y>193</y> 1250 </hint> 1251 <hint type="destinationlabel"> 1252 <x>513</x> 1253 <y>193</y> 1254 </hint> 1255 </hints> 1256 </connection> 1257 <connection> 1258 <sender>tolerance_bar</sender> 1259 <signal>valueChanged(int)</signal> 1260 <receiver>tolerance_value</receiver> 1261 <slot>setValue(int)</slot> 1262 <hints> 1263 <hint type="sourcelabel"> 1264 <x>430</x> 1265 <y>221</y> 1266 </hint> 1267 <hint type="destinationlabel"> 1268 <x>521</x> 1269 <y>220</y> 1270 </hint> 1271 </hints> 1272 </connection> 1273 <connection> 1274 <sender>npex_npey_box</sender> 1275 <signal>clicked(bool)</signal> 1276 <receiver>tolerance_bar</receiver> 1277 <slot>setVisible(bool)</slot> 1278 <hints> 1279 <hint type="sourcelabel"> 1280 <x>422</x> 1281 <y>193</y> 1282 </hint> 1283 <hint type="destinationlabel"> 1284 <x>430</x> 1285 <y>221</y> 1286 </hint> 1287 </hints> 1288 </connection> 1289 <connection> 1290 <sender>npex_npey_box</sender> 1291 <signal>clicked(bool)</signal> 1292 <receiver>tolerance_value</receiver> 1293 <slot>setVisible(bool)</slot> 1294 <hints> 1295 <hint type="sourcelabel"> 1296 <x>422</x> 1297 <y>193</y> 1298 </hint> 1299 <hint type="destinationlabel"> 1300 <x>521</x> 1301 <y>220</y> 1302 </hint> 1303 </hints> 1304 </connection> 1305 <connection> 1306 <sender>tolerance_value</sender> 1307 <signal>valueChanged(int)</signal> 1308 <receiver>tolerance_bar</receiver> 1309 <slot>setValue(int)</slot> 1310 <hints> 1311 <hint type="sourcelabel"> 1312 <x>521</x> 1313 <y>220</y> 1314 </hint> 1315 <hint type="destinationlabel"> 1316 <x>430</x> 1317 <y>221</y> 1318 </hint> 1319 </hints> 1320 </connection> 1190 1321 </connections> 1191 1322 </ui> -
palm/trunk/SCRIPTS/palm_gf_files/palm_gf_conf.py
r2116 r2308 1 def write_config(np_min, np_max, nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, tpn, dnpexnpey, dn xny, poisfft, switch,2 temperton, mlt_grid, spectr ):1 def write_config(np_min, np_max, nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, tpn, dnpexnpey, dnpexnpey_tolerance, dnxny, poisfft, switch, 2 temperton, mlt_grid, spectr, rslt_thrs, ld_thrs): 3 3 #from configparser import ConfigParser # windows 4 4 from ConfigParser import ConfigParser # Linux … … 7 7 cfg = ConfigParser() 8 8 9 cfg.add_section("processor_topology") 9 import os.path 10 if os.path.exists('.palm_gf_conf') is False: 11 cfg.add_section("processor_topology") 12 cfg.add_section("numerical_grid") 13 cfg.add_section("method") 14 15 #cfg.add_section("processor_topology") 10 16 cfg.set("processor_topology", "np_min", np_min) 11 17 cfg.set("processor_topology", "np_max", np_max) 12 18 cfg.set("processor_topology", "tasks_per_node", tpn) 13 19 cfg.set("processor_topology", "dnpexnpey", dnpexnpey) 20 cfg.set("processor_topology", "dnpexnpey_tolerance", dnpexnpey_tolerance) 14 21 cfg.set("processor_topology", "dnxny", dnxny) 15 22 16 cfg.add_section("numerical_grid")23 #cfgadd_section("numerical_grid"). 17 24 cfg.set("numerical_grid", "nx_min", nx_min) 18 25 cfg.set("numerical_grid", "nx_max", nx_max) … … 22 29 cfg.set("numerical_grid", "nz_max", nz_max) 23 30 24 cfg.add_section("method")31 #cfg.add_section("method") 25 32 cfg.set("method", "poisfft", poisfft) 26 33 cfg.set("method", "switch", switch) … … 29 36 cfg.set("method", "spectr", spectr) 30 37 31 with open(".palm_gf_config", "w") as configfile: 38 #cfg.add_section("settings") 39 #cfg.set("settings", "path", path) 40 #cfg.set("settings", "result_threshold", rslt_thrs) 41 #cfg.set("settings", "load_threshold", ld_thrs) 42 43 44 with open(".palm_gf_config", "a") as configfile: 32 45 cfg.write(configfile) 33 46 … … 36 49 #from configparser import ConfigParser # windows 37 50 from ConfigParser import ConfigParser # Linux 51 38 52 39 53 cfg = ConfigParser() … … 44 58 tpn = cfg.get("processor_topology", "tasks_per_node") 45 59 dnpexnpey = cfg.get("processor_topology", "dnpexnpey") 60 dnpexnpey_tolerance = cfg.get("processor_topology", "dnpexnpey_tolerance") 46 61 dnxny = cfg.get("processor_topology", "dnxny") 47 62 … … 59 74 spectr = cfg.get("method", "spectr") 60 75 61 return np_min, np_max, tpn, dnpexnpey, dnxny, nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, poisfft, switch, temperton, mlt_grid, spectr 76 import ConfigParser as conf 77 try: 78 result_threshold = cfg.get("settings", "result_threshold") 79 load_threshold = cfg.get("settings", "load_threshold") 80 path = cfg.get("settings", 'path') 81 82 except conf.NoSectionError: 83 84 path = '/localdata/' 85 result_threshold = 250000 86 load_threshold = 100000 87 88 return np_min, np_max, tpn, dnpexnpey, dnpexnpey_tolerance, dnxny, nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, poisfft, switch, temperton, mlt_grid, spectr, result_threshold, load_threshold, path 89 90 91 def write_config_settings(path, rslt_thrs, ld_thrs): 92 93 from ConfigParser import ConfigParser 94 95 cfg = ConfigParser() 96 97 cfg.add_section('settings') 98 99 cfg.set('settings', 'path', path) 100 cfg.set('settings', "result_threshold", rslt_thrs) 101 cfg.set('settings', "load_threshold", ld_thrs) 102 103 with open(".palm_gf_config", "a") as configfile: 104 cfg.write(configfile) 105 106 107 def read_config_settings(): 108 109 from ConfigParser import ConfigParser 110 import ConfigParser as con 111 112 cfg = ConfigParser() 113 cfg.read(".palm_gf_config") 114 115 try: 116 path = cfg.get("settings", "path") 117 result_thrs = cfg.get("settings", "result_threshold") 118 load_thrs = cfg.get("settings", "load_threshold") 119 120 except con.NoSectionError: 121 122 path = '/localdata/' 123 result_thrs = 250000 124 load_thrs = 100000 125 126 except con.NoOptionError: 127 128 path = '/localdata/' 129 result_thrs = 250000 130 load_thrs = 100000 131 132 #print path, result_thrs, load_thrs 133 134 return path, result_thrs, load_thrs 135 136 137 # *********************************************** 138 139 140 def closing_cleanup(): 141 from ConfigParser import ConfigParser # Linux 142 import ConfigParser as conf 143 import os, shutil, time 144 145 cfg = ConfigParser() 146 147 try: 148 149 cfg.read(".palm_gf_config") 150 np_min = cfg.get("processor_topology", "np_min") 151 np_max = cfg.get("processor_topology", "np_max") 152 tpn = cfg.get("processor_topology", "tasks_per_node") 153 dnpexnpey = cfg.get("processor_topology", "dnpexnpey") 154 dnpexnpey_tolerance = cfg.get("processor_topology", "dnpexnpey_tolerance") 155 dnxny = cfg.get("processor_topology", "dnxny") 156 157 nx_min = cfg.get("numerical_grid", "nx_min") 158 nx_max = cfg.get("numerical_grid", "nx_max") 159 ny_min = cfg.get("numerical_grid", "ny_min") 160 ny_max = cfg.get("numerical_grid", "ny_max") 161 nz_min = cfg.get("numerical_grid", "nz_min") 162 nz_max = cfg.get("numerical_grid", "nz_max") 163 164 poisfft = cfg.get("method", "poisfft") 165 switch = cfg.get("method", "switch") 166 temperton = cfg.get("method", "temperton") 167 mlt_grid = cfg.get("method", "mlt_grid") 168 spectr = cfg.get("method", "spectr") 169 170 var1_bool = True 171 172 except conf.NoSectionError: 173 np_min = 0 174 np_max = 0 175 tpn = 0 176 dnpexnpey = 0 177 dnpexnpey_tolerance = 0 178 dnxny = 0 179 180 nx_min = 0 181 nx_max = 0 182 ny_min = 0 183 ny_max = 0 184 nz_min = 0 185 nz_max = 0 186 187 poisfft = False 188 switch = False 189 temperton = False 190 mlt_grid = False 191 spectr = False 192 var1_bool = False 193 194 with open(".palm_gf_config", "w") as configfile: 195 cfg.write(configfile) 196 197 try: 198 cfg.read(".palm_gf_config") 199 rslt_thrs = cfg.get("settings", "result_threshold") 200 ld_thrs = cfg.get("settings", "load_threshold") 201 path = cfg.get("settings", 'path') 202 203 var2_bool = True 204 205 except conf.NoSectionError: 206 207 path = '/localdata/' 208 rslt_thrs = 250000 209 ld_thrs = 100000 210 211 var2_bool = False 212 213 214 215 with open(".palm_gf_config", "w") as configfile: 216 cfg.write(configfile) 217 218 219 220 #os.remove('.palm_gf_config') 221 222 223 224 try: 225 cfg.set("processor_topology", "np_min", np_min) 226 cfg.set("processor_topology", "np_max", np_max) 227 cfg.set("processor_topology", "tasks_per_node", tpn) 228 cfg.set("processor_topology", "dnpexnpey", dnpexnpey) 229 cfg.set("processor_topology", "dnpexnpey_tolerance", dnpexnpey_tolerance) 230 cfg.set("processor_topology", "dnxny", dnxny) 231 232 233 cfg.set("numerical_grid", "nx_min", nx_min) 234 cfg.set("numerical_grid", "nx_max", nx_max) 235 cfg.set("numerical_grid", "ny_min", ny_min) 236 cfg.set("numerical_grid", "ny_max", ny_max) 237 cfg.set("numerical_grid", "nz_min", nz_min) 238 cfg.set("numerical_grid", "nz_max", nz_max) 239 240 241 cfg.set("method", "poisfft", poisfft) 242 cfg.set("method", "switch", switch) 243 cfg.set("method", "temperton", temperton) 244 cfg.set("method", "mlt_grid", mlt_grid) 245 cfg.set("method", "spectr", spectr) 246 247 except conf.NoSectionError: 248 cfg.add_section("processor_topology") 249 cfg.set("processor_topology", "np_min", np_min) 250 cfg.set("processor_topology", "np_max", np_max) 251 cfg.set("processor_topology", "tasks_per_node", tpn) 252 cfg.set("processor_topology", "dnpexnpey", dnpexnpey) 253 cfg.set("processor_topology", "dnpexnpey_tolerance", dnpexnpey_tolerance) 254 cfg.set("processor_topology", "dnxny", dnxny) 255 256 cfg.add_section("numerical_grid") 257 cfg.set("numerical_grid", "nx_min", nx_min) 258 cfg.set("numerical_grid", "nx_max", nx_max) 259 cfg.set("numerical_grid", "ny_min", ny_min) 260 cfg.set("numerical_grid", "ny_max", ny_max) 261 cfg.set("numerical_grid", "nz_min", nz_min) 262 cfg.set("numerical_grid", "nz_max", nz_max) 263 264 cfg.add_section("method") 265 cfg.set("method", "poisfft", poisfft) 266 cfg.set("method", "switch", switch) 267 cfg.set("method", "temperton", temperton) 268 cfg.set("method", "mlt_grid", mlt_grid) 269 cfg.set("method", "spectr", spectr) 270 271 272 try: 273 cfg.set("settings", "path", path) 274 cfg.set("settings", "result_threshold", rslt_thrs) 275 cfg.set("settings", "load_threshold", ld_thrs) 276 277 except conf.NoSectionError: 278 cfg.add_section("settings") 279 cfg.set("settings", "path", path) 280 cfg.set("settings", "result_threshold", rslt_thrs) 281 cfg.set("settings", "load_threshold", ld_thrs) 282 283 284 285 286 287 288 with open(".palm_gf_config", "w") as configfile: 289 cfg.write(configfile) 290 -
palm/trunk/SCRIPTS/palm_gf_files/palm_gf_exec.py
r2116 r2308 6 6 c.execute("DROP TABLE IF EXISTS grid_current") 7 7 c.execute("DROP TABLE IF EXISTS grid_limits") 8 #c.execute("CREATE TABLE IF NOT EXISTS grid_current(np INT, npex INT, npey INT, nx INT, ny INT, nz INT)")9 8 c.execute("CREATE TABLE IF NOT EXISTS grid_current(nx INT, ny INT, nz INT, npex INT, npey INT, npxnpy FLOAT, np INT, ngpts INT)") 10 9 c.execute("CREATE TABLE IF NOT EXISTS grid_limits(nx INT, ny INT, nz INT, npex INT, npey INT, npxnpy FLOAT, np INT, ngpts INT)") … … 56 55 57 56 print(spectr, type(spectr)) 58 results = open(".palm_gf_results", "w")59 57 print(poisfft, switch, tempterton, mlt_grid, spectr) 60 58 … … 177 175 178 176 npxnpy = format(float(npex)/float(npey), '.2f') 179 results.write(180 str(" npex: ") + str(npex) + str(" npey: ") + str(npey) + str(" nx: ") + str(nx) + str(181 " ny: ") + str(ny) + str(" nz: ") + str(nz) + "\n")182 177 c.execute("""INSERT OR REPLACE INTO grid_current(nx, ny, nz, npex, npey, npxnpy, np, ngpts) VALUES (?, ?, ?, ?, ?, ?, ?, ?)""", 183 178 (nx, ny, nz, npex, npey, npxnpy, (npex * npey), (nx*ny*nz))) 184 #print(npxnpy) 185 186 nz += 1 179 180 nz += 11 187 181 nz = nz_min 188 182 ny += 1 … … 198 192 199 193 200 results.close()201 194 conn.commit() 202 195 c.close() -
palm/trunk/SCRIPTS/palm_gf_files/palm_gf_table.ui
r2116 r2308 7 7 <x>0</x> 8 8 <y>0</y> 9 <width>8 22</width>10 <height>4 83</height>9 <width>817</width> 10 <height>439</height> 11 11 </rect> 12 12 </property> … … 14 14 <string>Dialog</string> 15 15 </property> 16 <widget class="QPushButton" name="pushButton">17 <property name="geometry">18 <rect>19 <x>19</x>20 <y>79</y>21 <width>80</width>22 <height>27</height>23 </rect>24 </property>25 <property name="text">26 <string>Execute filter</string>27 </property>28 </widget>29 <widget class="QPushButton" name="pushButton_2">30 <property name="geometry">31 <rect>32 <x>19</x>33 <y>107</y>34 <width>80</width>35 <height>27</height>36 </rect>37 </property>38 <property name="text">39 <string>Reset limits</string>40 </property>41 </widget>42 16 <widget class="QTableWidget" name="tableWidget"> 43 17 <property name="geometry"> 44 18 <rect> 45 <x> 2</x>46 <y>1 71</y>19 <x>5</x> 20 <y>166</y> 47 21 <width>805</width> 48 22 <height>266</height> … … 61 35 <enum>Qt::ScrollBarAlwaysOff</enum> 62 36 </property> 37 <property name="autoScroll"> 38 <bool>true</bool> 39 </property> 63 40 <property name="dragEnabled"> 64 41 <bool>false</bool> … … 67 44 <bool>false</bool> 68 45 </property> 46 <property name="selectionMode"> 47 <enum>QAbstractItemView::MultiSelection</enum> 48 </property> 69 49 <property name="selectionBehavior"> 70 <enum>QAbstractItemView::Select Rows</enum>50 <enum>QAbstractItemView::SelectItems</enum> 71 51 </property> 72 52 <property name="sortingEnabled"> … … 76 56 <number>8</number> 77 57 </property> 58 <attribute name="horizontalHeaderVisible"> 59 <bool>false</bool> 60 </attribute> 61 <attribute name="horizontalHeaderShowSortIndicator" stdset="0"> 62 <bool>true</bool> 63 </attribute> 78 64 <attribute name="verticalHeaderVisible"> 79 65 <bool>false</bool> … … 117 103 <column> 118 104 <property name="text"> 119 <string >nx</string>105 <string/> 120 106 </property> 121 107 </column> 122 108 <column> 123 109 <property name="text"> 124 <string >ny</string>110 <string/> 125 111 </property> 126 112 </column> 127 113 <column> 128 114 <property name="text"> 129 <string >nz</string>115 <string/> 130 116 </property> 131 117 </column> 132 118 <column> 133 119 <property name="text"> 134 <string >npex</string>120 <string/> 135 121 </property> 136 122 </column> 137 123 <column> 138 124 <property name="text"> 139 <string >npey</string>125 <string/> 140 126 </property> 141 127 </column> 142 128 <column> 143 129 <property name="text"> 144 <string >npex/npey</string>130 <string/> 145 131 </property> 146 132 </column> 147 133 <column> 148 134 <property name="text"> 149 <string >np</string>135 <string/> 150 136 </property> 151 137 </column> 152 138 <column> 153 139 <property name="text"> 154 <string >ngpts</string>140 <string/> 155 141 </property> 156 142 </column> 157 <item row="0" column="0">158 <property name="text">159 <string/>160 </property>161 </item>162 <item row="1" column="0">163 <property name="text">164 <string/>165 </property>166 </item>167 <item row="2" column="0">168 <property name="text">169 <string/>170 </property>171 </item>172 <item row="3" column="0">173 <property name="text">174 <string/>175 </property>176 </item>177 <item row="4" column="0">178 <property name="text">179 <string/>180 </property>181 </item>182 <item row="5" column="0">183 <property name="text">184 <string/>185 </property>186 </item>187 <item row="6" column="0">188 <property name="text">189 <string/>190 </property>191 </item>192 </widget>193 <widget class="QPushButton" name="pushButton_3">194 <property name="geometry">195 <rect>196 <x>19</x>197 <y>51</y>198 <width>80</width>199 <height>27</height>200 </rect>201 </property>202 <property name="text">203 <string>Load all</string>204 </property>205 143 </widget> 206 144 <widget class="Line" name="line"> … … 848 786 </property> 849 787 </widget> 850 <widget class="QComboBox" name="Sortvariable_box">851 <property name="geometry">852 <rect>853 <x>146</x>854 <y>140</y>855 <width>111</width>856 <height>23</height>857 </rect>858 </property>859 <item>860 <property name="text">861 <string>Sorting...</string>862 </property>863 </item>864 <item>865 <property name="text">866 <string>nx</string>867 </property>868 </item>869 <item>870 <property name="text">871 <string>ny</string>872 </property>873 </item>874 <item>875 <property name="text">876 <string>nz</string>877 </property>878 </item>879 <item>880 <property name="text">881 <string>npex</string>882 </property>883 </item>884 <item>885 <property name="text">886 <string>npey</string>887 </property>888 </item>889 <item>890 <property name="text">891 <string>npex/npey</string>892 </property>893 </item>894 <item>895 <property name="text">896 <string>np</string>897 </property>898 </item>899 <item>900 <property name="text">901 <string>ngpts</string>902 </property>903 </item>904 </widget>905 <widget class="QComboBox" name="Sortorder_box">906 <property name="geometry">907 <rect>908 <x>260</x>909 <y>140</y>910 <width>101</width>911 <height>23</height>912 </rect>913 </property>914 <item>915 <property name="text">916 <string>Order...</string>917 </property>918 </item>919 <item>920 <property name="text">921 <string>Ascending</string>922 </property>923 </item>924 <item>925 <property name="text">926 <string>Descending</string>927 </property>928 </item>929 </widget>930 <widget class="QPushButton" name="Sortnow_button">931 <property name="geometry">932 <rect>933 <x>365</x>934 <y>140</y>935 <width>90</width>936 <height>23</height>937 </rect>938 </property>939 <property name="text">940 <string>Sort now</string>941 </property>942 </widget>943 788 <widget class="QLabel" name="label_3"> 944 789 <property name="geometry"> … … 1191 1036 <string> ngpts</string> 1192 1037 </property> 1038 </widget> 1039 <widget class="QPushButton" name="nx_table"> 1040 <property name="geometry"> 1041 <rect> 1042 <x>6</x> 1043 <y>149</y> 1044 <width>102</width> 1045 <height>23</height> 1046 </rect> 1047 </property> 1048 <property name="text"> 1049 <string>nx</string> 1050 </property> 1051 <property name="checkable"> 1052 <bool>true</bool> 1053 </property> 1054 <property name="autoRepeat"> 1055 <bool>false</bool> 1056 </property> 1057 <property name="autoDefault"> 1058 <bool>true</bool> 1059 </property> 1060 <property name="default"> 1061 <bool>false</bool> 1062 </property> 1063 <property name="flat"> 1064 <bool>false</bool> 1065 </property> 1066 </widget> 1067 <widget class="QPushButton" name="ny_table"> 1068 <property name="geometry"> 1069 <rect> 1070 <x>105</x> 1071 <y>149</y> 1072 <width>104</width> 1073 <height>23</height> 1074 </rect> 1075 </property> 1076 <property name="text"> 1077 <string>ny</string> 1078 </property> 1079 <property name="checkable"> 1080 <bool>true</bool> 1081 </property> 1082 </widget> 1083 <widget class="QPushButton" name="nz_table"> 1084 <property name="geometry"> 1085 <rect> 1086 <x>206</x> 1087 <y>149</y> 1088 <width>102</width> 1089 <height>23</height> 1090 </rect> 1091 </property> 1092 <property name="text"> 1093 <string>nz</string> 1094 </property> 1095 <property name="checkable"> 1096 <bool>true</bool> 1097 </property> 1098 </widget> 1099 <widget class="QPushButton" name="npex_table"> 1100 <property name="geometry"> 1101 <rect> 1102 <x>305</x> 1103 <y>149</y> 1104 <width>103</width> 1105 <height>23</height> 1106 </rect> 1107 </property> 1108 <property name="text"> 1109 <string>npex</string> 1110 </property> 1111 <property name="checkable"> 1112 <bool>true</bool> 1113 </property> 1114 <property name="autoRepeat"> 1115 <bool>false</bool> 1116 </property> 1117 </widget> 1118 <widget class="QPushButton" name="npey_table"> 1119 <property name="geometry"> 1120 <rect> 1121 <x>405</x> 1122 <y>149</y> 1123 <width>104</width> 1124 <height>23</height> 1125 </rect> 1126 </property> 1127 <property name="text"> 1128 <string>npey</string> 1129 </property> 1130 <property name="checkable"> 1131 <bool>true</bool> 1132 </property> 1133 </widget> 1134 <widget class="QPushButton" name="npexnpey_table"> 1135 <property name="geometry"> 1136 <rect> 1137 <x>506</x> 1138 <y>149</y> 1139 <width>102</width> 1140 <height>23</height> 1141 </rect> 1142 </property> 1143 <property name="text"> 1144 <string>npex/npey</string> 1145 </property> 1146 <property name="checkable"> 1147 <bool>true</bool> 1148 </property> 1149 </widget> 1150 <widget class="QPushButton" name="np_table"> 1151 <property name="geometry"> 1152 <rect> 1153 <x>605</x> 1154 <y>149</y> 1155 <width>103</width> 1156 <height>23</height> 1157 </rect> 1158 </property> 1159 <property name="text"> 1160 <string>np</string> 1161 </property> 1162 <property name="checkable"> 1163 <bool>true</bool> 1164 </property> 1165 </widget> 1166 <widget class="QPushButton" name="ngpts_table"> 1167 <property name="geometry"> 1168 <rect> 1169 <x>705</x> 1170 <y>149</y> 1171 <width>104</width> 1172 <height>23</height> 1173 </rect> 1174 </property> 1175 <property name="text"> 1176 <string>ngpts</string> 1177 </property> 1178 <property name="checkable"> 1179 <bool>true</bool> 1180 </property> 1181 </widget> 1182 <widget class="QWidget" name="layoutWidget"> 1183 <property name="geometry"> 1184 <rect> 1185 <x>5</x> 1186 <y>25</y> 1187 <width>97</width> 1188 <height>106</height> 1189 </rect> 1190 </property> 1191 <layout class="QVBoxLayout" name="verticalLayout"> 1192 <item> 1193 <widget class="QPushButton" name="save_to_file_button"> 1194 <property name="enabled"> 1195 <bool>false</bool> 1196 </property> 1197 <property name="toolTip"> 1198 <string><html><head/><body><p>Currently Disabled</p></body></html></string> 1199 </property> 1200 <property name="text"> 1201 <string>Save to file</string> 1202 </property> 1203 </widget> 1204 </item> 1205 <item> 1206 <widget class="QPushButton" name="pushButton_3"> 1207 <property name="toolTip"> 1208 <string><html><head/><body><p>Loads all calculated results. </p></body></html></string> 1209 </property> 1210 <property name="text"> 1211 <string>Load all</string> 1212 </property> 1213 </widget> 1214 </item> 1215 <item> 1216 <widget class="QPushButton" name="pushButton"> 1217 <property name="text"> 1218 <string>Execute filter</string> 1219 </property> 1220 </widget> 1221 </item> 1222 <item> 1223 <widget class="QPushButton" name="pushButton_2"> 1224 <property name="text"> 1225 <string>Reset limits</string> 1226 </property> 1227 </widget> 1228 </item> 1229 </layout> 1193 1230 </widget> 1194 1231 </widget> … … 1212 1249 <tabstop>ngpts_max</tabstop> 1213 1250 <tabstop>pushButton</tabstop> 1214 <tabstop>Sortvariable_box</tabstop>1215 <tabstop>Sortorder_box</tabstop>1216 <tabstop>Sortnow_button</tabstop>1217 1251 <tabstop>pushButton_2</tabstop> 1218 1252 <tabstop>tableWidget</tabstop> -
palm/trunk/SCRIPTS/palm_gf_files/palm_gf_tools.py
r2116 r2308 4 4 from PyQt4 import QtCore, QtGui, uic 5 5 import subprocess as sub 6 import palm_gf_conf as configwr 6 7 7 8 out = sub.check_output("echo $PALM_BIN", shell=True, stderr=sub.STDOUT) … … 22 23 return self.sortKey < other.sortKey 23 24 24 25 25 def __init__(self): # def __init__(self, parent=None): 26 26 QtGui.QMainWindow.__init__(self) … … 31 31 centerpoint = QtGui.QApplication.desktop().screenGeometry(screen).center() 32 32 framegm.moveCenter(centerpoint) 33 34 #centerpoint = str(centerpoint) 35 #xcenter = centerpoint.split('(')[1].split(',')[0] 36 #ycenter = centerpoint.split('(')[1].split(',')[1].split(')')[0] 37 ##print xcenter, ycenter 38 #centerpoint = QtCore.QPoint(int(xcenter) + 418, int(ycenter)) 39 #framegm.moveCenter(centerpoint) 33 40 self.move(framegm.topLeft()) 41 42 43 34 44 self.setupUi(self) 35 45 self.pushButton_3.clicked.connect(self.load_result) … … 37 47 self.load_trigger() 38 48 self.pushButton.clicked.connect(self.filter_results) 39 self.Sortnow_button.clicked.connect(self.sort_order)49 #self.Sortnow_button.clicked.connect(self.sort_order) 40 50 self.pushButton_2.clicked.connect(self.load_trigger) 51 self.tableWidget.horizontalHeader().setClickable(True) 52 53 54 self.nx_table.clicked.connect(lambda: self.sort_table(str("nx"))) 55 self.ny_table.clicked.connect(lambda: self.sort_table(str("ny"))) 56 self.nz_table.clicked.connect(lambda: self.sort_table(str("nz"))) 57 self.npex_table.clicked.connect(lambda: self.sort_table(str("npex"))) 58 self.npey_table.clicked.connect(lambda: self.sort_table(str("npey"))) 59 self.npexnpey_table.clicked.connect(lambda: self.sort_table(str("npexnpey"))) 60 self.np_table.clicked.connect(lambda: self.sort_table(str("np"))) 61 self.ngpts_table.clicked.connect(lambda: self.sort_table(str("ngpts"))) 62 63 self.instant() 64 65 self.save_to_file_button.clicked.connect(self.get_path) 66 67 def instant(self): 68 checkfile = open(".palm_gf_tmp", "r") 69 # self.result_label.setText(str(checkfile.readline())) 70 res_text = str(checkfile.readline()) # XXX 71 result_nr = res_text.split(' ')[2] 72 checkfile.close() 73 if int(result_nr) < 100000: 74 self.load_result() 41 75 42 76 43 77 44 78 def load_trigger(self): 79 pathx = configwr.read_config() 80 pathx = pathx[19] 81 82 45 83 dtb = str('.palm_gf_data.db') 46 con = sqlite3.connect(dtb) 84 #con = sqlite3.connect("/localdata/.palm_gf_data.db") 85 con = sqlite3.connect(pathx + '.palm_gf_data.db') 47 86 c = con.cursor() 48 87 c.execute("SELECT * FROM " + 'grid_limits') … … 96 135 def check(self): 97 136 dtb = str('.palm_gf_data.db') 98 con = sqlite3.connect( dtb)137 con = sqlite3.connect("/localdata/.palm_gf_data.db") 99 138 c = con.cursor() 100 139 c.execute("SELECT * FROM " + 'grid_limits') … … 113 152 114 153 def load_result(self): 154 #print("LOADED!!!") 155 import decimal 115 156 self.setEnabled(False) 116 157 QtGui.QApplication.processEvents() … … 118 159 self.process1() 119 160 database = str('.palm_gf_data.db') 120 conn = sqlite3.connect( database)161 conn = sqlite3.connect("/localdata/.palm_gf_data.db") 121 162 c = conn.cursor() 122 163 c.execute("SELECT * FROM " + 'grid_current') … … 134 175 var = line[j] 135 176 136 self.tableWidget.setItem(i, j, self.MyTableWidgetItem(str(var), j+i)) 177 if j == 7: 178 self.tableWidget.setItem(i, j, self.MyTableWidgetItem(str("%.1e" % var), j + i)) 179 #print("%.2e" % int(var), "%.4e" % int(1782)) 180 181 else: 182 self.tableWidget.setItem(i, j, self.MyTableWidgetItem(str(var), j+i)) 137 183 #item = self.MyTableWidgetItem(str(var), k) 138 184 #self.tableWidget.setItem(i, j, item) … … 155 201 156 202 def filter_results(self): 203 157 204 self.setEnabled(False) 158 205 self.calc_label.setText('calculating...') 159 206 QtGui.QApplication.processEvents() 160 207 database = str('.palm_gf_data.db') 161 conn = sqlite3.connect( database)208 conn = sqlite3.connect("/localdata/.palm_gf_data.db") 162 209 c = conn.cursor() 163 210 c.execute("SELECT * FROM " + "grid_current") … … 208 255 while j < 8: 209 256 var = line[j] 210 self.tableWidget.setItem(row_cnt, j, self.MyTableWidgetItem(str(var), i)) 257 258 if j == 7: 259 self.tableWidget.setItem(row_cnt, j, self.MyTableWidgetItem(str("%.1e" % var), i)) 260 261 else: 262 self.tableWidget.setItem(row_cnt, j, self.MyTableWidgetItem(str(var), i)) 211 263 212 264 j += 1 … … 224 276 225 277 278 279 def sort_table(self, column): 280 281 fnx_mn = self.nx_min.value() 282 fnx_mx = self.nx_max.value() 283 fny_mn = self.ny_min.value() 284 fny_mx = self.ny_max.value() 285 fnz_mn = self.nz_min.value() 286 fnz_mx = self.nz_max.value() 287 fnpex_mn = self.npex_min.value() 288 fnpex_mx = self.npex_max.value() 289 fnpey_mn = self.npex_min.value() 290 fnpey_mx = self.npey_max.value() 291 fnpxnpy_mn = self.npxnpy_min.value() 292 fnpxnpy_mx = self.npxnpy_max.value() 293 fnp_mn = self.np_min.value() 294 fnp_mx = self.np_max.value() 295 fngpts_mn = self.ngpts_min.value() 296 fngpts_mx = self.ngpts_max.value() 297 298 if column == str("nx"): 299 sorted_col = "nx" 300 301 if self.nx_table.isChecked() is True: 302 order = " DESC" 303 304 else: 305 306 order = " ASC" 307 308 self.ny_table.setChecked(False) 309 self.nz_table.setChecked(False) 310 self.npex_table.setChecked(False) 311 self.npey_table.setChecked(False) 312 self.npexnpey_table.setChecked(False) 313 self.np_table.setChecked(False) 314 self.ngpts_table.setChecked(False) 315 316 if column == str("ny"): 317 sorted_col = "ny" 318 319 if self.ny_table.isChecked() is True: 320 order = " DESC" 321 322 else: 323 324 order = " ASC" 325 326 self.nx_table.setChecked(False) 327 self.nz_table.setChecked(False) 328 self.npex_table.setChecked(False) 329 self.npey_table.setChecked(False) 330 self.npexnpey_table.setChecked(False) 331 self.np_table.setChecked(False) 332 self.ngpts_table.setChecked(False) 333 334 if column == str("nz"): 335 sorted_col = "nz" 336 337 if self.nz_table.isChecked() is True: 338 order = " DESC" 339 340 else: 341 342 order = " ASC" 343 344 self.nx_table.setChecked(False) 345 self.ny_table.setChecked(False) 346 self.npex_table.setChecked(False) 347 self.npey_table.setChecked(False) 348 self.npexnpey_table.setChecked(False) 349 self.np_table.setChecked(False) 350 self.ngpts_table.setChecked(False) 351 352 if column == str("npex"): 353 sorted_col = "npex" 354 355 if self.npex_table.isChecked() is True: 356 order = " DESC" 357 358 else: 359 360 order = " ASC" 361 362 self.ny_table.setChecked(False) 363 self.nz_table.setChecked(False) 364 self.nx_table.setChecked(False) 365 self.npey_table.setChecked(False) 366 self.npexnpey_table.setChecked(False) 367 self.np_table.setChecked(False) 368 self.ngpts_table.setChecked(False) 369 370 if column == str("npey"): 371 sorted_col = "npey" 372 373 if self.npey_table.isChecked() is True: 374 order = " DESC" 375 376 else: 377 378 order = " ASC" 379 380 381 self.ny_table.setChecked(False) 382 self.nz_table.setChecked(False) 383 self.npex_table.setChecked(False) 384 self.nx_table.setChecked(False) 385 self.npexnpey_table.setChecked(False) 386 self.np_table.setChecked(False) 387 self.ngpts_table.setChecked(False) 388 389 if column == str("npexnpey"): 390 sorted_col = "npxnpy" 391 392 if self.npexnpey_table.isChecked() is True: 393 order = " DESC" 394 395 else: 396 397 order = " ASC" 398 399 self.ny_table.setChecked(False) 400 self.nz_table.setChecked(False) 401 self.npex_table.setChecked(False) 402 self.npey_table.setChecked(False) 403 self.nx_table.setChecked(False) 404 self.np_table.setChecked(False) 405 self.ngpts_table.setChecked(False) 406 407 if column == str("np"): 408 sorted_col = "np" 409 410 if self.np_table.isChecked() is True: 411 order = " DESC" 412 413 else: 414 415 order = " ASC" 416 417 self.ny_table.setChecked(False) 418 self.nz_table.setChecked(False) 419 self.npex_table.setChecked(False) 420 self.npey_table.setChecked(False) 421 self.npexnpey_table.setChecked(False) 422 self.nx_table.setChecked(False) 423 self.ngpts_table.setChecked(False) 424 425 if column == str("ngpts"): 426 sorted_col = "ngpts" 427 428 if self.ngpts_table.isChecked() is True: 429 order = " DESC" 430 431 else: 432 433 order = " ASC" 434 435 self.ny_table.setChecked(False) 436 self.nz_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.nx_table.setChecked(False) 442 443 444 445 conn = sqlite3.connect("/localdata/.palm_gf_data.db") 446 c = conn.cursor() 447 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) + 448 " AND nz >= " + str(fnz_mn) + " AND npex <= " + str(fnpex_mx) + " AND npex >= " + 449 str(fnpex_mn) + " AND npey <= " + str(fnpey_mx) + " AND npey >= " + str(fnpey_mn) + " AND " 450 "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) + 451 " ORDER BY " + str(sorted_col) + str(order)) 452 453 454 455 sorted = c.fetchall() 456 457 c.close() 458 conn.close() 459 self.tableWidget.setRowCount(len(sorted)) 460 461 for row_indx in range(0,len(sorted)): 462 463 for col_indx in range(0,8): 464 row = sorted[row_indx] 465 value = row[col_indx] 466 if col_indx == 7: 467 self.tableWidget.setItem(row_indx, col_indx, QtGui.QTableWidgetItem(str("%.1e" % value))) 468 else: 469 self.tableWidget.setItem(row_indx, col_indx, QtGui.QTableWidgetItem(str(value))) 226 470 227 471 … … 273 517 sorted_col = "ngpts" 274 518 275 print(self.Sortvariable_box.currentIndex())519 #print(self.Sortvariable_box.currentIndex()) 276 520 277 521 if str(self.Sortorder_box.currentIndex()) == str(1): … … 285 529 286 530 287 288 289 290 291 292 conn = sqlite3.connect(".palm_gf_data.db") 531 conn = sqlite3.connect("/localdata/.palm_gf_data.db") 293 532 c = conn.cursor() 294 533 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) + … … 311 550 row = sorted[row_indx] 312 551 value = row[col_indx] 313 self.tableWidget.setItem(row_indx, col_indx, QtGui.QTableWidgetItem(str(va lue)))314 315 316 317 318 319 320 print(len(sorted))552 self.tableWidget.setItem(row_indx, col_indx, QtGui.QTableWidgetItem(str(var))) 553 554 555 556 557 558 559 #print(len(sorted)) 321 560 #print(sorted) 561 562 def get_path(wildcard): 563 import wx 564 app = wx.App(None) 565 style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST 566 dialog = wx.FileDialog(None, 'Open', wildcard='*.db') 567 if dialog.ShowModal() == wx.ID_OK: 568 path = dialog.GetPath() 569 570 print(path, file) 571 else: 572 path = None 573 dialog.Destroy() 574 return 575 576 577 578 579 580 581 322 582 323 583
Note: See TracChangeset
for help on using the changeset viewer.