|
@@ -17,6 +17,7 @@ from ruamel import yaml
|
17
|
17
|
from akvo.gui.main_ui import Ui_MainWindow
|
18
|
18
|
from akvo.gui.addCircularLoop_ui import Ui_circularLoopAdd
|
19
|
19
|
from akvo.gui.addFigure8Loop_ui import Ui_figure8LoopAdd
|
|
20
|
+from akvo.gui.addPolygonalLoop_ui import Ui_polygonalLoopAdd
|
20
|
21
|
from akvo.tressel import mrsurvey
|
21
|
22
|
|
22
|
23
|
from pyLemma import LemmaCore
|
|
@@ -205,31 +206,6 @@ class ApplicationWindow(QtWidgets.QMainWindow):
|
205
|
206
|
self.ui.mplwidget_navigator.setCanvas(self.ui.mplwidget)
|
206
|
207
|
#self.ui.mplwidget_navigator_2.setCanvas(self.ui.mplwidget)
|
207
|
208
|
|
208
|
|
-
|
209
|
|
- ##########################################################################
|
210
|
|
- # Loop Table
|
211
|
|
- self.ui.loopTableWidget.setRowCount(80)
|
212
|
|
- self.ui.loopTableWidget.setColumnCount(6)
|
213
|
|
- self.ui.loopTableWidget.setHorizontalHeaderLabels( ["ch. tag", \
|
214
|
|
- "Northing [m]","Easting [m]","Height [m]", "Radius","Tx"] )
|
215
|
|
-
|
216
|
|
- for ir in range(0, self.ui.loopTableWidget.rowCount() ):
|
217
|
|
- for ic in range(1, self.ui.loopTableWidget.columnCount() ):
|
218
|
|
- pCell = QtWidgets.QTableWidgetItem()
|
219
|
|
- #pCell.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
|
220
|
|
- pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable
|
221
|
|
- pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
|
222
|
|
- self.ui.loopTableWidget.setItem(ir, ic, pCell)
|
223
|
|
-
|
224
|
|
- self.ui.loopTableWidget.cellChanged.connect(self.loopCellChanged)
|
225
|
|
- #self.ui.loopTableWidget.cellPressed.connect(self.loopCellChanged)
|
226
|
|
- self.ui.loopTableWidget.itemClicked.connect(self.loopCellClicked)
|
227
|
|
- #self.ui.loopTableWidget.cellPressed.connect(self.loopCellClicked)
|
228
|
|
-
|
229
|
|
- self.ui.loopTableWidget.setDragDropOverwriteMode(False)
|
230
|
|
- self.ui.loopTableWidget.setDragEnabled(False)
|
231
|
|
- #self.ui.loopTableWidget.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
|
232
|
|
-
|
233
|
209
|
self.ui.txRxTable.setColumnCount(4)
|
234
|
210
|
self.ui.txRxTable.setRowCount(0)
|
235
|
211
|
self.ui.txRxTable.setHorizontalHeaderLabels( ["Label", "Geom.","Turns","Tx/Rx"] )
|
|
@@ -388,9 +364,71 @@ class ApplicationWindow(QtWidgets.QMainWindow):
|
388
|
364
|
ns = dialog.ui.segments.value()
|
389
|
365
|
#cwise = dialog.ui.cwiseBox.currentIndex()
|
390
|
366
|
print(cn1, ce1, cn2, ce2, ht, rad, turns, ns)
|
|
367
|
+
|
|
368
|
+ if self.ui.loopGeom.currentText() == "polygon":
|
|
369
|
+
|
|
370
|
+ dialog = QtWidgets.QDialog()
|
|
371
|
+ dialog.ui = Ui_polygonalLoopAdd()
|
|
372
|
+ dialog.ui.setupUi(dialog)
|
|
373
|
+
|
|
374
|
+ ##########################################################################
|
|
375
|
+ # Loop Table
|
|
376
|
+ dialog.ui.loopTableWidget.setRowCount(80)
|
|
377
|
+ dialog.ui.loopTableWidget.setColumnCount(3)
|
|
378
|
+ #dialog.ui.loopTableWidget.horizontalHeader().setSectionResizeMode(0, QtGui.Qt.QHeaderView.Stretch)
|
|
379
|
+ dialog.ui.loopTableWidget.setHorizontalHeaderLabels( \
|
|
380
|
+ ["Northing [m]","Easting [m]","Height [m]"])
|
|
381
|
+
|
391
|
382
|
|
|
383
|
+ for ir in range(0, dialog.ui.loopTableWidget.rowCount() ):
|
|
384
|
+ for ic in range(0, 3): #dialog.ui.loopTableWidget.columnCount() ):
|
|
385
|
+ pCell = QtWidgets.QTableWidgetItem()
|
|
386
|
+ #pCell.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
|
|
387
|
+ #pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable
|
|
388
|
+ #pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
|
|
389
|
+ dialog.ui.loopTableWidget.setItem(ir, ic, pCell)
|
|
390
|
+
|
|
391
|
+ #dialog.ui.loopTableWidget.cellChanged.connect(self.loopCellChanged)
|
|
392
|
+ #dialog.ui.loopTableWidget.itemClicked.connect(self.loopCellClicked)
|
|
393
|
+
|
|
394
|
+ #self.ui.loopTableWidget.cellPressed.connect(self.loopCellChanged)
|
|
395
|
+ #self.ui.loopTableWidget.cellPressed.connect(self.loopCellClicked)
|
|
396
|
+
|
|
397
|
+ dialog.ui.loopTableWidget.setDragDropOverwriteMode(False)
|
|
398
|
+ dialog.ui.loopTableWidget.setDragEnabled(False)
|
|
399
|
+ #self.ui.loopTableWidget.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
|
|
400
|
+
|
|
401
|
+ dialog.ui.loopTableWidget.resizeColumnsToContents()
|
|
402
|
+ dialog.exec_()
|
|
403
|
+ dialog.show()
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+ if dialog.result():
|
|
407
|
+ self.loops[self.ui.loopLabel.text()] = FDEM1D.PolygonalWireAntenna()
|
|
408
|
+ self.loops[self.ui.loopLabel.text()].SetNumberOfTurns( dialog.ui.loopTurns.value() )
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+ npts = 0
|
|
412
|
+ for ir in range(0, dialog.ui.loopTableWidget.rowCount() ):
|
|
413
|
+ if len(dialog.ui.loopTableWidget.item(ir, 0).text()) == 0:
|
|
414
|
+ break
|
|
415
|
+ npts += 1
|
|
416
|
+ self.loops[self.ui.loopLabel.text()].SetNumberOfPoints( npts )
|
|
417
|
+ for ir in range( 0, npts ):
|
|
418
|
+ self.loops[self.ui.loopLabel.text()].SetPoint(ir, eval(dialog.ui.loopTableWidget.item(ir, 0).text()), \
|
|
419
|
+ eval(dialog.ui.loopTableWidget.item(ir, 1).text()), \
|
|
420
|
+ eval(dialog.ui.loopTableWidget.item(ir, 2).text()) \
|
|
421
|
+ )
|
|
422
|
+ self.loops[self.ui.loopLabel.text()].SetNumberOfFrequencies(1)
|
|
423
|
+ self.loops[self.ui.loopLabel.text()].SetCurrent(1.)
|
|
424
|
+
|
|
425
|
+
|
392
|
426
|
# general across all types
|
393
|
427
|
if dialog.result():
|
|
428
|
+
|
|
429
|
+ yml = open( self.ui.loopLabel.text() + ".yml", 'w' )
|
|
430
|
+ print( self.loops[self.ui.loopLabel.text()], file=yml)
|
|
431
|
+
|
394
|
432
|
# update the table
|
395
|
433
|
self.ui.txRxTable.setRowCount( len(self.loops.keys()) )
|
396
|
434
|
|
|
@@ -495,74 +533,6 @@ class ApplicationWindow(QtWidgets.QMainWindow):
|
495
|
533
|
|
496
|
534
|
self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged)
|
497
|
535
|
|
498
|
|
- def loopCellClicked(self, item):
|
499
|
|
- print("checkstate", item.checkState(),item.row())
|
500
|
|
-
|
501
|
|
- #self.ui.loopTableWidget.itemClicked.disconnect(self.loopCellClicked)
|
502
|
|
- jj = item.column()
|
503
|
|
- ii = item.row()
|
504
|
|
- tp = type(self.ui.loopTableWidget.item(ii, 0))
|
505
|
|
- print("tp", tp, ii, jj)
|
506
|
|
- if str(tp) == "<class 'NoneType'>":
|
507
|
|
- return
|
508
|
|
- #print("Clicked", ii, jj)
|
509
|
|
- if jj == 5 and self.ui.loopTableWidget.item(ii, 0).text() in self.loops.keys():
|
510
|
|
- #print("jj=5")
|
511
|
|
- self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["Tx"] = self.ui.loopTableWidget.item(ii, 5).checkState()
|
512
|
|
- # update surrogates
|
513
|
|
- print("updating surrogates")
|
514
|
|
- for point in self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["points"][1:]:
|
515
|
|
- pCell = self.ui.loopTableWidget.item(point, 5)
|
516
|
|
- if self.ui.loopTableWidget.item(ii, 5).checkState():
|
517
|
|
- pCell.setCheckState(QtCore.Qt.Checked);
|
518
|
|
- else:
|
519
|
|
- pCell.setCheckState(QtCore.Qt.Unchecked);
|
520
|
|
-
|
521
|
|
- #print( "loops", self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["Tx"])
|
522
|
|
-
|
523
|
|
- #self.ui.loopTableWidget.itemClicked.connect(self.loopCellClicked)
|
524
|
|
-
|
525
|
|
- def loopCellChanged(self):
|
526
|
|
-
|
527
|
|
- self.ui.loopTableWidget.cellChanged.disconnect(self.loopCellChanged)
|
528
|
|
- jj = self.ui.loopTableWidget.currentColumn()
|
529
|
|
- ii = self.ui.loopTableWidget.currentRow()
|
530
|
|
-
|
531
|
|
- if jj == 0 and len( self.ui.loopTableWidget.item(ii, jj).text().strip()) == 0:
|
532
|
|
- for jjj in range(jj+1,jj+6):
|
533
|
|
- pCell = self.ui.loopTableWidget.item(ii, jjj)
|
534
|
|
- pCell.setBackground( QtGui.QColor("white") )
|
535
|
|
- pCell.setFlags( QtCore.Qt.NoItemFlags | QtCore.Qt.ItemIsUserCheckable ) # not selectable
|
536
|
|
- elif jj == 0 and len( self.ui.loopTableWidget.item(ii, jj).text().strip() ): # ch. tag modified
|
537
|
|
- for jjj in range(jj+1,jj+5):
|
538
|
|
- pCell = self.ui.loopTableWidget.item(ii, jjj)
|
539
|
|
- pCell.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
|
540
|
|
- pCell.setBackground( QtGui.QColor("lightblue") )
|
541
|
|
- if self.ui.loopTableWidget.item(ii, jj).text() not in self.loops.keys():
|
542
|
|
- # This is a new loop ID
|
543
|
|
- self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ] = {}
|
544
|
|
- self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ]["Tx"] = self.ui.loopTableWidget.item(ii, 5).checkState()
|
545
|
|
- self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ]["points"] = [ii]
|
546
|
|
- # Transmitter cell
|
547
|
|
- pCell = self.ui.loopTableWidget.item(ii, jj+5)
|
548
|
|
- pCell.setCheckState(QtCore.Qt.Unchecked)
|
549
|
|
- pCell.setFlags( QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled )
|
550
|
|
- pCell.setBackground( QtGui.QColor("lightblue") )
|
551
|
|
- else:
|
552
|
|
- # This is an existing loop ID
|
553
|
|
- self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ]["points"].append( ii )
|
554
|
|
- pCell = self.ui.loopTableWidget.item(ii, jj+5)
|
555
|
|
- pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable
|
556
|
|
- if self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["Tx"]:
|
557
|
|
- pCell.setCheckState(QtCore.Qt.Checked);
|
558
|
|
- else:
|
559
|
|
- pCell.setCheckState(QtCore.Qt.Unchecked);
|
560
|
|
- #pCell.setFlags( )
|
561
|
|
- pCell.setBackground( QtGui.QColor("lightblue") )
|
562
|
|
-
|
563
|
|
- self.plotLoops()
|
564
|
|
- self.ui.loopTableWidget.cellChanged.connect(self.loopCellChanged)
|
565
|
|
-
|
566
|
536
|
def plotLoops2(self):
|
567
|
537
|
self.ui.mplwidget.reAxH(1)
|
568
|
538
|
|
|
@@ -582,52 +552,6 @@ class ApplicationWindow(QtWidgets.QMainWindow):
|
582
|
552
|
del self.loops[ self.ui.txRxTable.item( self.ui.txRxTable.currentRow(), 0).text() ]
|
583
|
553
|
self.ui.txRxTable.removeRow(self.ui.txRxTable.currentRow())
|
584
|
554
|
|
585
|
|
- def plotLoops(self):
|
586
|
|
-
|
587
|
|
- self.ui.mplwidget.reAxH(1)
|
588
|
|
- #self.ui.mplwidget.ax1.clear()
|
589
|
|
- #self.ui.mplwidget.ax2.clear()
|
590
|
|
- nor = dict()
|
591
|
|
- eas = dict()
|
592
|
|
- dep = dict()
|
593
|
|
- for ii in range( self.ui.loopTableWidget.rowCount() ):
|
594
|
|
- for jj in range( self.ui.loopTableWidget.columnCount() ):
|
595
|
|
- tp = type(self.ui.loopTableWidget.item(ii, jj))
|
596
|
|
- if str(tp) == "<class 'NoneType'>":
|
597
|
|
- pass
|
598
|
|
- elif not len(self.ui.loopTableWidget.item(ii, jj).text()):
|
599
|
|
- pass
|
600
|
|
- else:
|
601
|
|
- if jj == 0:
|
602
|
|
- idx = self.ui.loopTableWidget.item(ii, 0).text()
|
603
|
|
- if idx not in nor.keys():
|
604
|
|
- nor[idx] = list()
|
605
|
|
- eas[idx] = list()
|
606
|
|
- dep[idx] = list()
|
607
|
|
- if jj == 4:
|
608
|
|
- # circular loop
|
609
|
|
- m2pi = np.linspace(0,2*np.pi,10)
|
610
|
|
- rad = 30.
|
611
|
|
- nor[idx] = np.concatenate((np.array(nor[idx]), rad * np.sin(m2pi)))
|
612
|
|
- eas[idx] = np.concatenate((np.array(eas[idx]), rad * np.cos(m2pi)))
|
613
|
|
- dep[idx] = np.concatenate((np.array(dep[idx]), np.ones(len(m2pi))))
|
614
|
|
- print("nor", nor[idx])
|
615
|
|
- if jj == 1:
|
616
|
|
- nor[idx].append( eval(self.ui.loopTableWidget.item(ii, 1).text()) )
|
617
|
|
- elif jj == 2:
|
618
|
|
- eas[idx].append( eval(self.ui.loopTableWidget.item(ii, 2).text()) )
|
619
|
|
- elif jj == 3:
|
620
|
|
- dep[idx].append( eval(self.ui.loopTableWidget.item(ii, 3).text()) )
|
621
|
|
-
|
622
|
|
- for ii in nor.keys():
|
623
|
|
- try:
|
624
|
|
- self.ui.mplwidget.ax1.plot( np.array(nor[ii]), np.array(eas[ii]) )
|
625
|
|
- except:
|
626
|
|
- pass
|
627
|
|
- #self.ui.mplwidget.figure.axes().set
|
628
|
|
- self.ui.mplwidget.ax1.set_aspect('equal') #, adjustable='box')
|
629
|
|
- self.ui.mplwidget.draw()
|
630
|
|
-
|
631
|
555
|
def about(self):
|
632
|
556
|
# TODO proper popup with info
|
633
|
557
|
#self.w = MyPopup("""About Akvo \n
|
|
@@ -635,9 +559,10 @@ class ApplicationWindow(QtWidgets.QMainWindow):
|
635
|
559
|
#""")
|
636
|
560
|
#self.w.setGeometry(100, 100, 400, 200)
|
637
|
561
|
#self.w.show()
|
|
562
|
+ #print("ABOUT")
|
638
|
563
|
|
639
|
564
|
# Just a splash screen for now
|
640
|
|
- logo = pkg_resources.resource_filename(__name__, 'akvo_about.png')
|
|
565
|
+ logo = pkg_resources.resource_filename(__name__, 'akvo-about.png')
|
641
|
566
|
pixmap = QtGui.QPixmap(logo)
|
642
|
567
|
self.splash = QtWidgets.QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint)
|
643
|
568
|
self.splash.show()
|
|
@@ -1406,6 +1331,11 @@ class ApplicationWindow(QtWidgets.QMainWindow):
|
1406
|
1331
|
self.YamlNode.META["B_0"]["intensity"] = self.ui.intensitySpinBox.value()
|
1407
|
1332
|
self.YamlNode.META["Field Notes"] = self.ui.txtComments.toPlainText()
|
1408
|
1333
|
|
|
1334
|
+ self.YamlNode.META["Loops"] = OrderedDict()
|
|
1335
|
+ for loop in self.loops:
|
|
1336
|
+ print(self.loops[loop])
|
|
1337
|
+ self.YamlNode.META["Loops"][loop] = loop + ".yml"
|
|
1338
|
+
|
1409
|
1339
|
self.Log()
|
1410
|
1340
|
|
1411
|
1341
|
def bandPassFilter(self):
|