Browse Source

All kernel params from GUI

tags/1.6.1
Trevor Irons 5 years ago
parent
commit
76da3dbe24
5 changed files with 464 additions and 233 deletions
  1. 68
    11
      akvo/gui/akvoGUI.py
  2. 2
    2
      akvo/gui/callScript.py
  3. 341
    200
      akvo/gui/main.ui
  4. 1
    1
      akvo/gui/redirect.ui
  5. 52
    19
      akvo/tressel/calcAkvoKernel.py

+ 68
- 11
akvo/gui/akvoGUI.py View File

@@ -228,16 +228,26 @@ class ApplicationWindow(QtWidgets.QMainWindow):
228 228
         self.ui.layerTableWidget.setDragEnabled(True)
229 229
         self.ui.layerTableWidget.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
230 230
         
231
-        pCell = QtWidgets.QTableWidgetItem()
232
-        pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable 
233
-        pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
234
-        self.ui.layerTableWidget.setItem(0, 1, pCell)
231
+        pCell0 = QtWidgets.QTableWidgetItem()
232
+        pCell0.setFlags(QtCore.Qt.NoItemFlags) # not selectable 
233
+        pCell0.setBackground( QtGui.QColor("lightgrey").lighter(110) )
234
+        pCell0.setText(str("0"))
235
+        self.ui.layerTableWidget.setItem(0, 0, pCell0)
236
+        
237
+        pCell1 = QtWidgets.QTableWidgetItem()
238
+        #pCell1.setFlags(QtCore.Qt.NoItemFlags) # not selectable 
239
+        pCell1.setBackground( QtGui.QColor("lightgrey").lighter(110) )
240
+        pCell1.setForeground( QtGui.QColor("black").lighter(110) )
241
+        self.ui.layerTableWidget.setItem(0, 1, pCell1)
242
+
243
+
235 244
         for ir in range(1, self.ui.layerTableWidget.rowCount() ):
236 245
             for ic in range(0, self.ui.layerTableWidget.columnCount() ):
237 246
                 pCell = QtWidgets.QTableWidgetItem()
238 247
                 #pCell.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
239 248
                 pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable 
240 249
                 pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
250
+                pCell.setForeground( QtGui.QColor("black"))
241 251
                 self.ui.layerTableWidget.setItem(ir, ic, pCell)
242 252
         self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged) 
243 253
 
@@ -315,15 +325,60 @@ class ApplicationWindow(QtWidgets.QMainWindow):
315 325
         except IOError as e:
316 326
             fpath = '.'
317 327
 
318
-        akvoData = QtWidgets.QFileDialog.getOpenFileName(self, 'Open Datafile File', fpath, r"Akvo datafiles (*.yaml)")[0] # arg2 = File Type 'All Files (*)'
319
-        txCoil = QtWidgets.QFileDialog.getOpenFileName(self, 'Open Tx File', fpath, r"Akvo datafiles (*.yaml, *.yml)")[0] # arg2 = File Type 'All Files (*)'
320
-        saveStr = QtWidgets.QFileDialog.getSaveFileName(self, "Save kernel as", fpath, r"Merlin KernelV0 (*.yml)")[0] #[0]
328
+        akvoData = QtWidgets.QFileDialog.getOpenFileName(self, 'Open Datafile File', fpath, r"Akvo datafiles (*.yaml)")[0]
329
+        txCoil = QtWidgets.QFileDialog.getOpenFileName(self, 'Open Tx File', fpath, r"Akvo datafiles (*.yaml, *.yml)")[0] 
330
+        saveStr = QtWidgets.QFileDialog.getSaveFileName(self, "Save kernel as", fpath, r"Merlin KernelV0 (*.yml)")[0] 
331
+
332
+        intDict = dict()
333
+        intDict["origin_n"] = self.ui.originN.value()
334
+        intDict["origin_e"] = self.ui.originE.value()
335
+        intDict["origin_d"] = self.ui.originD.value()
336
+        intDict["size_n"] = self.ui.sizeN.value()
337
+        intDict["size_e"] = self.ui.sizeE.value()
338
+        intDict["size_d"] = self.ui.sizeD.value()
339
+        intDict["nLay"] = self.ui.NLayers.value()
340
+        intDict["thick1"] = self.ui.thick1.value()
341
+        intDict["thickN"] = self.ui.thickN.value()
342
+        intDict["Lspacing"] = self.ui.layerSpacing.currentText()
343
+        intDict["minLevel"] = self.ui.minLevel.value()
344
+        intDict["maxLevel"] = self.ui.maxLevel.value()
345
+        intDict["branchTol"] = self.ui.branchTol.value()
346
+
347
+        # conductivity model... 
348
+        #tops = self.ui.layerTableWidget.col(0)
349
+        #print("Tops", tops)
350
+        tops = []
351
+        itop = 0
352
+        while self.ui.layerTableWidget.item(itop, 0).text(): 
353
+            tops.append( float(self.ui.layerTableWidget.item(itop,0).text()) ) 
354
+            itop += 1
355
+
356
+        bots = []
357
+        ibot = 0
358
+        while self.ui.layerTableWidget.item(ibot, 1).text(): 
359
+            bots.append( float(self.ui.layerTableWidget.item(ibot, 1).text()) ) 
360
+            ibot += 1
361
+        
362
+        sigs = []
363
+        isig = 0
364
+        while self.ui.layerTableWidget.item(isig, 2).text(): 
365
+            sigs.append( 1./float(self.ui.layerTableWidget.item(isig, 2).text()) ) 
366
+            isig += 1
367
+
368
+        intDict["tops"] = tops
369
+        intDict["bots"] = bots
370
+        intDict["sigs"] = sigs
371
+
372
+        node = yaml.YAML()
373
+        kpo = open( "kparams.yml", 'w' )
374
+        node.dump(intDict, kpo)
375
+
321 376
 
322 377
         callBox = callScript(  ) #QtWidgets.QDialog() 
323 378
         
324 379
         callBox.ui = Ui_callScript()
325 380
         callBox.ui.setupUi( callBox )
326
-        callBox.setupCB( akvoData, txCoil, saveStr  )
381
+        callBox.setupCB( akvoData, txCoil, "kparams.yml", saveStr  )
327 382
         
328 383
         callBox.exec_()
329 384
         callBox.show()
@@ -495,7 +550,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
495 550
         # do that. Would require instead dist of T2 I guess.
496 551
         jj = self.ui.layerTableWidget.currentColumn()
497 552
         ii = self.ui.layerTableWidget.currentRow()
498
-        val = "class 'NoneType'>" 
553
+        val = "class 'NoneType'>"
499 554
         try:
500 555
             val = eval (str( self.ui.layerTableWidget.item(ii, jj).text() ))
501 556
         except:
@@ -546,16 +601,18 @@ class ApplicationWindow(QtWidgets.QMainWindow):
546 601
             # enable next layer
547 602
             pCell4 = self.ui.layerTableWidget.item(ii+1, jj)
548 603
             pCell4.setBackground( QtGui.QColor("lightblue") ) #.lighter(110))
604
+            pCell4.setForeground( QtGui.QColor("black"))
549 605
             pCell4.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
550 606
             
551 607
             pCell5 = self.ui.layerTableWidget.item(ii+1, jj+1)
552 608
             pCell5.setBackground( QtGui.QColor("white"))
609
+            pCell5.setForeground( QtGui.QColor("black"))
553 610
             pCell5.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
554 611
             
555
-        print("ii", ii, "jj", jj)
556 612
         if ii == 0 and jj == 0:
557 613
             pCell = self.ui.layerTableWidget.item(0, 1)
558
-            pCell.setBackground( QtGui.QColor("lightblue")) #.lighter(110) )
614
+            pCell.setBackground(QtGui.QColor("lightblue")) #.lighter(110) )
615
+            pCell.setForeground( QtGui.QColor("black"))
559 616
             pCell.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
560 617
 
561 618
         self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged) 

+ 2
- 2
akvo/gui/callScript.py View File

@@ -10,7 +10,7 @@ class callScript(QDialog):
10 10
     #def __init__(self):
11 11
     #    super().__init__()
12 12
     
13
-    def setupCB(self, akvoData, TxCoil, SaveStr):
13
+    def setupCB(self, akvoData, TxCoil, kernelParams, SaveStr):
14 14
 
15 15
         #QtGui.QWidget.__init__(self)
16 16
         #uic.loadUi('redirect.ui', self)
@@ -24,7 +24,7 @@ class callScript(QDialog):
24 24
 
25 25
         #print ('Starting process')
26 26
         #self.process.start('python', ['calcAkvoKernel.py', akvoData, TxCoil, SaveStr])
27
-        self.process.start('akvoK0', [ akvoData, TxCoil, SaveStr])
27
+        self.process.start('akvoK0', [ akvoData, TxCoil, kernelParams, SaveStr])
28 28
 
29 29
     def append(self, text):
30 30
         cursor = self.ui.textEdit.textCursor()

+ 341
- 200
akvo/gui/main.ui View File

@@ -709,7 +709,7 @@ background: dark grey;
709 709
        <property name="geometry">
710 710
         <rect>
711 711
          <x>0</x>
712
-         <y>0</y>
712
+         <y>-201</y>
713 713
          <width>537</width>
714 714
          <height>982</height>
715 715
         </rect>
@@ -760,7 +760,7 @@ background: dark grey;
760 760
            <enum>Qt::LeftToRight</enum>
761 761
           </property>
762 762
           <property name="currentIndex">
763
-           <number>0</number>
763
+           <number>4</number>
764 764
           </property>
765 765
           <property name="elideMode">
766 766
            <enum>Qt::ElideLeft</enum>
@@ -3533,6 +3533,15 @@ background: dark grey;
3533 3533
               <layout class="QGridLayout" name="gridLayout_2">
3534 3534
                <item row="2" column="2">
3535 3535
                 <widget class="QPushButton" name="removeLoopButton">
3536
+                 <property name="styleSheet">
3537
+                  <string notr="true">#removeLoopButton {
3538
+    background: red;
3539
+}
3540
+
3541
+#removeLoopButton:disabled {
3542
+    background: black;
3543
+}</string>
3544
+                 </property>
3536 3545
                  <property name="text">
3537 3546
                   <string>Remove</string>
3538 3547
                  </property>
@@ -3564,6 +3573,15 @@ background: dark grey;
3564 3573
                </item>
3565 3574
                <item row="0" column="0">
3566 3575
                 <widget class="QPushButton" name="addLoopButton">
3576
+                 <property name="styleSheet">
3577
+                  <string notr="true">#addLoopButton {
3578
+    background: green;
3579
+}
3580
+
3581
+#addLoopButton:disabled {
3582
+    background: black;
3583
+}</string>
3584
+                 </property>
3567 3585
                  <property name="text">
3568 3586
                   <string>Add </string>
3569 3587
                  </property>
@@ -3593,6 +3611,15 @@ background: dark grey;
3593 3611
                </item>
3594 3612
                <item row="2" column="3">
3595 3613
                 <widget class="QPushButton" name="plotLoops">
3614
+                 <property name="styleSheet">
3615
+                  <string notr="true">#plotLoops {
3616
+    background: green;
3617
+}
3618
+
3619
+#plotLoops:disabled {
3620
+    background: black;
3621
+}</string>
3622
+                 </property>
3596 3623
                  <property name="text">
3597 3624
                   <string>Plot loops</string>
3598 3625
                  </property>
@@ -3649,206 +3676,320 @@ background: dark grey;
3649 3676
           </widget>
3650 3677
           <widget class="QWidget" name="KernTab">
3651 3678
            <attribute name="title">
3652
-            <string>Kern</string>
3679
+            <string>Kernel</string>
3653 3680
            </attribute>
3654
-           <widget class="QGroupBox" name="groupBox_2">
3655
-            <property name="geometry">
3656
-             <rect>
3657
-              <x>30</x>
3658
-              <y>10</y>
3659
-              <width>371</width>
3660
-              <height>301</height>
3661
-             </rect>
3662
-            </property>
3663
-            <property name="title">
3664
-             <string>Integration Parameters</string>
3665
-            </property>
3666
-            <widget class="QSpinBox" name="spinBox">
3667
-             <property name="geometry">
3668
-              <rect>
3669
-               <x>120</x>
3670
-               <y>30</y>
3671
-               <width>49</width>
3672
-               <height>29</height>
3673
-              </rect>
3674
-             </property>
3675
-            </widget>
3676
-            <widget class="QSpinBox" name="spinBox_2">
3677
-             <property name="geometry">
3678
-              <rect>
3679
-               <x>120</x>
3680
-               <y>70</y>
3681
-               <width>49</width>
3682
-               <height>29</height>
3683
-              </rect>
3684
-             </property>
3685
-            </widget>
3686
-            <widget class="QDoubleSpinBox" name="doubleSpinBox_7">
3687
-             <property name="geometry">
3688
-              <rect>
3689
-               <x>280</x>
3690
-               <y>70</y>
3691
-               <width>70</width>
3692
-               <height>29</height>
3693
-              </rect>
3694
-             </property>
3695
-            </widget>
3696
-            <widget class="QLabel" name="label_70">
3697
-             <property name="geometry">
3698
-              <rect>
3699
-               <x>21</x>
3700
-               <y>34</y>
3701
-               <width>81</width>
3702
-               <height>20</height>
3703
-              </rect>
3704
-             </property>
3705
-             <property name="text">
3706
-              <string>min. level</string>
3707
-             </property>
3708
-            </widget>
3709
-            <widget class="QLabel" name="label_71">
3710
-             <property name="geometry">
3711
-              <rect>
3712
-               <x>20</x>
3713
-               <y>75</y>
3714
-               <width>81</width>
3715
-               <height>20</height>
3716
-              </rect>
3717
-             </property>
3718
-             <property name="text">
3719
-              <string>max. level</string>
3720
-             </property>
3721
-            </widget>
3722
-            <widget class="QLabel" name="label_72">
3723
-             <property name="geometry">
3724
-              <rect>
3725
-               <x>187</x>
3726
-               <y>75</y>
3727
-               <width>81</width>
3728
-               <height>20</height>
3729
-              </rect>
3730
-             </property>
3731
-             <property name="text">
3732
-              <string>branch tol</string>
3733
-             </property>
3734
-            </widget>
3735
-            <widget class="QDoubleSpinBox" name="doubleSpinBox_6">
3736
-             <property name="geometry">
3737
-              <rect>
3738
-               <x>210</x>
3739
-               <y>260</y>
3740
-               <width>141</width>
3741
-               <height>29</height>
3742
-              </rect>
3743
-             </property>
3744
-            </widget>
3745
-            <widget class="QDoubleSpinBox" name="doubleSpinBox">
3746
-             <property name="geometry">
3747
-              <rect>
3748
-               <x>10</x>
3749
-               <y>160</y>
3750
-               <width>171</width>
3751
-               <height>29</height>
3752
-              </rect>
3753
-             </property>
3754
-            </widget>
3755
-            <widget class="QDoubleSpinBox" name="doubleSpinBox_3">
3756
-             <property name="geometry">
3757
-              <rect>
3758
-               <x>10</x>
3759
-               <y>210</y>
3760
-               <width>171</width>
3761
-               <height>31</height>
3762
-              </rect>
3763
-             </property>
3764
-            </widget>
3765
-            <widget class="QDoubleSpinBox" name="doubleSpinBox_5">
3766
-             <property name="geometry">
3767
-              <rect>
3768
-               <x>210</x>
3769
-               <y>210</y>
3770
-               <width>141</width>
3771
-               <height>29</height>
3772
-              </rect>
3773
-             </property>
3774
-            </widget>
3775
-            <widget class="QDoubleSpinBox" name="doubleSpinBox_4">
3776
-             <property name="geometry">
3777
-              <rect>
3778
-               <x>210</x>
3779
-               <y>160</y>
3780
-               <width>141</width>
3781
-               <height>29</height>
3782
-              </rect>
3783
-             </property>
3784
-            </widget>
3785
-            <widget class="QDoubleSpinBox" name="doubleSpinBox_2">
3786
-             <property name="geometry">
3787
-              <rect>
3788
-               <x>10</x>
3789
-               <y>260</y>
3790
-               <width>171</width>
3791
-               <height>29</height>
3792
-              </rect>
3793
-             </property>
3794
-            </widget>
3795
-            <widget class="QLabel" name="label_2">
3796
-             <property name="geometry">
3797
-              <rect>
3798
-               <x>10</x>
3799
-               <y>130</y>
3800
-               <width>63</width>
3801
-               <height>20</height>
3802
-              </rect>
3803
-             </property>
3804
-             <property name="text">
3805
-              <string>Origin</string>
3806
-             </property>
3807
-            </widget>
3808
-            <widget class="QLabel" name="label_73">
3809
-             <property name="geometry">
3810
-              <rect>
3811
-               <x>210</x>
3812
-               <y>130</y>
3813
-               <width>63</width>
3814
-               <height>20</height>
3815
-              </rect>
3816
-             </property>
3817
-             <property name="text">
3818
-              <string>Size</string>
3819
-             </property>
3820
-            </widget>
3821
-           </widget>
3822
-           <widget class="QTableWidget" name="layerTableWidget">
3823
-            <property name="geometry">
3824
-             <rect>
3825
-              <x>30</x>
3826
-              <y>320</y>
3827
-              <width>351</width>
3828
-              <height>431</height>
3829
-             </rect>
3830
-            </property>
3831
-            <property name="toolTip">
3832
-             <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This table is used to enter coil geometries the format is as follows: each row specifies a single point on a coil. The first column is the coil index (using the GMR channel is useful), the next three colums specify the point in Northing, Easting, and Elevation. These can either be local coordinates or global ones. The final column specifies the loop radius if it is a circle or figure 8, for non circular or figure 8 loops leave this column blank. For figure-8 loops the coils do not need to be touching (see Irons and Kass, 2017). If a given index has 1 row it will be a circular loop, two rows will be a figure 8, and more than that will be a polygonal representation of the points, linearlly interpolated between them. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
3833
-            </property>
3834
-           </widget>
3835
-           <widget class="QPushButton" name="calcK0">
3836
-            <property name="geometry">
3837
-             <rect>
3838
-              <x>400</x>
3839
-              <y>330</y>
3840
-              <width>105</width>
3841
-              <height>39</height>
3842
-             </rect>
3843
-            </property>
3844
-            <property name="text">
3845
-             <string>Calc Kernel</string>
3846
-            </property>
3847
-           </widget>
3681
+           <layout class="QVBoxLayout" name="verticalLayout_11">
3682
+            <item>
3683
+             <widget class="QGroupBox" name="groupBox">
3684
+              <property name="title">
3685
+               <string>Conductivty model</string>
3686
+              </property>
3687
+              <layout class="QVBoxLayout" name="verticalLayout_10">
3688
+               <item>
3689
+                <widget class="QTableWidget" name="layerTableWidget">
3690
+                 <property name="toolTip">
3691
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This table is used to enter coil geometries the format is as follows: each row specifies a single point on a coil. The first column is the coil index (using the GMR channel is useful), the next three colums specify the point in Northing, Easting, and Elevation. These can either be local coordinates or global ones. The final column specifies the loop radius if it is a circle or figure 8, for non circular or figure 8 loops leave this column blank. For figure-8 loops the coils do not need to be touching (see Irons and Kass, 2017). If a given index has 1 row it will be a circular loop, two rows will be a figure 8, and more than that will be a polygonal representation of the points, linearlly interpolated between them. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
3692
+                 </property>
3693
+                </widget>
3694
+               </item>
3695
+              </layout>
3696
+             </widget>
3697
+            </item>
3698
+            <item>
3699
+             <widget class="QGroupBox" name="integrationBox">
3700
+              <property name="sizePolicy">
3701
+               <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
3702
+                <horstretch>0</horstretch>
3703
+                <verstretch>0</verstretch>
3704
+               </sizepolicy>
3705
+              </property>
3706
+              <property name="minimumSize">
3707
+               <size>
3708
+                <width>480</width>
3709
+                <height>300</height>
3710
+               </size>
3711
+              </property>
3712
+              <property name="title">
3713
+               <string>Integration Parameters</string>
3714
+              </property>
3715
+              <layout class="QGridLayout" name="gridLayout_17">
3716
+               <item row="5" column="1" colspan="2">
3717
+                <widget class="QDoubleSpinBox" name="originD">
3718
+                 <property name="minimum">
3719
+                  <double>0.010000000000000</double>
3720
+                 </property>
3721
+                 <property name="value">
3722
+                  <double>0.100000000000000</double>
3723
+                 </property>
3724
+                </widget>
3725
+               </item>
3726
+               <item row="5" column="3" colspan="2">
3727
+                <widget class="QDoubleSpinBox" name="sizeD">
3728
+                 <property name="minimum">
3729
+                  <double>1.000000000000000</double>
3730
+                 </property>
3731
+                 <property name="maximum">
3732
+                  <double>300.000000000000000</double>
3733
+                 </property>
3734
+                 <property name="value">
3735
+                  <double>125.000000000000000</double>
3736
+                 </property>
3737
+                </widget>
3738
+               </item>
3739
+               <item row="0" column="0">
3740
+                <widget class="QLabel" name="label_70">
3741
+                 <property name="text">
3742
+                  <string>min. level</string>
3743
+                 </property>
3744
+                </widget>
3745
+               </item>
3746
+               <item row="4" column="1" colspan="2">
3747
+                <widget class="QDoubleSpinBox" name="originE"/>
3748
+               </item>
3749
+               <item row="1" column="3">
3750
+                <widget class="QLabel" name="label_72">
3751
+                 <property name="text">
3752
+                  <string>branch tol [nT]</string>
3753
+                 </property>
3754
+                </widget>
3755
+               </item>
3756
+               <item row="0" column="4">
3757
+                <widget class="QSpinBox" name="maxLevel">
3758
+                 <property name="minimum">
3759
+                  <number>1</number>
3760
+                 </property>
3761
+                 <property name="maximum">
3762
+                  <number>14</number>
3763
+                 </property>
3764
+                 <property name="value">
3765
+                  <number>3</number>
3766
+                 </property>
3767
+                </widget>
3768
+               </item>
3769
+               <item row="7" column="0">
3770
+                <widget class="QLabel" name="label_65">
3771
+                 <property name="text">
3772
+                  <string>Layers</string>
3773
+                 </property>
3774
+                </widget>
3775
+               </item>
3776
+               <item row="2" column="1">
3777
+                <widget class="QLabel" name="label_2">
3778
+                 <property name="text">
3779
+                  <string>Origin</string>
3780
+                 </property>
3781
+                </widget>
3782
+               </item>
3783
+               <item row="1" column="4">
3784
+                <widget class="QDoubleSpinBox" name="branchTol">
3785
+                 <property name="decimals">
3786
+                  <number>3</number>
3787
+                 </property>
3788
+                 <property name="minimum">
3789
+                  <double>0.001000000000000</double>
3790
+                 </property>
3791
+                 <property name="value">
3792
+                  <double>1.000000000000000</double>
3793
+                 </property>
3794
+                </widget>
3795
+               </item>
3796
+               <item row="2" column="3">
3797
+                <widget class="QLabel" name="label_73">
3798
+                 <property name="text">
3799
+                  <string>Size</string>
3800
+                 </property>
3801
+                </widget>
3802
+               </item>
3803
+               <item row="4" column="0">
3804
+                <widget class="QLabel" name="label_58">
3805
+                 <property name="text">
3806
+                  <string>easting</string>
3807
+                 </property>
3808
+                </widget>
3809
+               </item>
3810
+               <item row="4" column="3" colspan="2">
3811
+                <widget class="QDoubleSpinBox" name="sizeE">
3812
+                 <property name="minimum">
3813
+                  <double>1.000000000000000</double>
3814
+                 </property>
3815
+                 <property name="maximum">
3816
+                  <double>500.000000000000000</double>
3817
+                 </property>
3818
+                 <property name="value">
3819
+                  <double>200.000000000000000</double>
3820
+                 </property>
3821
+                </widget>
3822
+               </item>
3823
+               <item row="0" column="3">
3824
+                <widget class="QLabel" name="label_71">
3825
+                 <property name="text">
3826
+                  <string>max. level</string>
3827
+                 </property>
3828
+                </widget>
3829
+               </item>
3830
+               <item row="3" column="0">
3831
+                <widget class="QLabel" name="label_54">
3832
+                 <property name="text">
3833
+                  <string>northing</string>
3834
+                 </property>
3835
+                </widget>
3836
+               </item>
3837
+               <item row="3" column="3" colspan="2">
3838
+                <widget class="QDoubleSpinBox" name="sizeN">
3839
+                 <property name="minimum">
3840
+                  <double>1.000000000000000</double>
3841
+                 </property>
3842
+                 <property name="maximum">
3843
+                  <double>500.000000000000000</double>
3844
+                 </property>
3845
+                 <property name="value">
3846
+                  <double>200.000000000000000</double>
3847
+                 </property>
3848
+                </widget>
3849
+               </item>
3850
+               <item row="3" column="1" colspan="2">
3851
+                <widget class="QDoubleSpinBox" name="originN"/>
3852
+               </item>
3853
+               <item row="0" column="1">
3854
+                <widget class="QSpinBox" name="minLevel">
3855
+                 <property name="minimum">
3856
+                  <number>1</number>
3857
+                 </property>
3858
+                 <property name="maximum">
3859
+                  <number>10</number>
3860
+                 </property>
3861
+                </widget>
3862
+               </item>
3863
+               <item row="5" column="0">
3864
+                <widget class="QLabel" name="label_60">
3865
+                 <property name="text">
3866
+                  <string>depth</string>
3867
+                 </property>
3868
+                </widget>
3869
+               </item>
3870
+               <item row="7" column="2">
3871
+                <widget class="QSpinBox" name="NLayers">
3872
+                 <property name="minimum">
3873
+                  <number>1</number>
3874
+                 </property>
3875
+                 <property name="maximum">
3876
+                  <number>200</number>
3877
+                 </property>
3878
+                 <property name="value">
3879
+                  <number>50</number>
3880
+                 </property>
3881
+                </widget>
3882
+               </item>
3883
+               <item row="7" column="1">
3884
+                <widget class="QLabel" name="label_66">
3885
+                 <property name="text">
3886
+                  <string>N Layers</string>
3887
+                 </property>
3888
+                </widget>
3889
+               </item>
3890
+               <item row="7" column="4">
3891
+                <widget class="QComboBox" name="layerSpacing">
3892
+                 <property name="minimumSize">
3893
+                  <size>
3894
+                   <width>100</width>
3895
+                   <height>0</height>
3896
+                  </size>
3897
+                 </property>
3898
+                 <item>
3899
+                  <property name="text">
3900
+                   <string>Geometric</string>
3901
+                  </property>
3902
+                 </item>
3903
+                 <item>
3904
+                  <property name="text">
3905
+                   <string>Log</string>
3906
+                  </property>
3907
+                 </item>
3908
+                 <item>
3909
+                  <property name="text">
3910
+                   <string>Linear</string>
3911
+                  </property>
3912
+                 </item>
3913
+                </widget>
3914
+               </item>
3915
+               <item row="7" column="3">
3916
+                <widget class="QLabel" name="label_68">
3917
+                 <property name="text">
3918
+                  <string>spacing</string>
3919
+                 </property>
3920
+                </widget>
3921
+               </item>
3922
+               <item row="6" column="0" colspan="5">
3923
+                <widget class="Line" name="line_14">
3924
+                 <property name="orientation">
3925
+                  <enum>Qt::Horizontal</enum>
3926
+                 </property>
3927
+                </widget>
3928
+               </item>
3929
+               <item row="8" column="1">
3930
+                <widget class="QLabel" name="label_69">
3931
+                 <property name="text">
3932
+                  <string>Thick 1</string>
3933
+                 </property>
3934
+                </widget>
3935
+               </item>
3936
+               <item row="8" column="3">
3937
+                <widget class="QLabel" name="label_75">
3938
+                 <property name="text">
3939
+                  <string>Thick N</string>
3940
+                 </property>
3941
+                </widget>
3942
+               </item>
3943
+               <item row="8" column="2">
3944
+                <widget class="QDoubleSpinBox" name="thick1">
3945
+                 <property name="minimum">
3946
+                  <double>0.010000000000000</double>
3947
+                 </property>
3948
+                 <property name="value">
3949
+                  <double>0.500000000000000</double>
3950
+                 </property>
3951
+                </widget>
3952
+               </item>
3953
+               <item row="8" column="4">
3954
+                <widget class="QDoubleSpinBox" name="thickN">
3955
+                 <property name="minimum">
3956
+                  <double>0.010000000000000</double>
3957
+                 </property>
3958
+                 <property name="value">
3959
+                  <double>10.000000000000000</double>
3960
+                 </property>
3961
+                </widget>
3962
+               </item>
3963
+              </layout>
3964
+             </widget>
3965
+            </item>
3966
+            <item>
3967
+             <widget class="QPushButton" name="calcK0">
3968
+              <property name="minimumSize">
3969
+               <size>
3970
+                <width>100</width>
3971
+                <height>40</height>
3972
+               </size>
3973
+              </property>
3974
+              <property name="styleSheet">
3975
+               <string notr="true">#calcK0{
3976
+    background: green;
3977
+}
3978
+
3979
+#calcK0:disabled {
3980
+    background: black;
3981
+}</string>
3982
+              </property>
3983
+              <property name="text">
3984
+               <string>Calc Kernel</string>
3985
+              </property>
3986
+             </widget>
3987
+            </item>
3988
+           </layout>
3848 3989
           </widget>
3849 3990
           <widget class="QWidget" name="ModelTab">
3850 3991
            <attribute name="title">
3851
-            <string>Model</string>
3992
+            <string>Modelling</string>
3852 3993
            </attribute>
3853 3994
            <widget class="QToolBox" name="toolBox">
3854 3995
             <property name="geometry">
@@ -3867,8 +4008,8 @@ background: dark grey;
3867 4008
               <rect>
3868 4009
                <x>0</x>
3869 4010
                <y>0</y>
3870
-               <width>96</width>
3871
-               <height>26</height>
4011
+               <width>100</width>
4012
+               <height>30</height>
3872 4013
               </rect>
3873 4014
              </property>
3874 4015
              <attribute name="label">

+ 1
- 1
akvo/gui/redirect.ui View File

@@ -46,7 +46,7 @@
46 46
       <bool>false</bool>
47 47
      </property>
48 48
      <property name="placeholderText">
49
-      <string>This windows outputs STDOUT from a seperate process.</string>
49
+      <string>This windows outputs STDOUT from a separate process.</string>
50 50
      </property>
51 51
     </widget>
52 52
    </item>

+ 52
- 19
akvo/tressel/calcAkvoKernel.py View File

@@ -9,9 +9,12 @@ import pyLemma.FDEM1D as em1d
9 9
 
10 10
 import numpy as np
11 11
 
12
-#import matplotlib.pyplot as plt 
13
-#import seaborn as sns
14
-#sns.set(style="ticks")
12
+import matplotlib.pyplot as plt 
13
+import seaborn as sns
14
+sns.set(style="ticks")
15
+
16
+from ruamel import yaml
17
+
15 18
 #import cmocean 
16 19
 #from SEGPlot import *
17 20
 #from matplotlib.ticker import FormatStrFormatter
@@ -60,7 +63,7 @@ def loadAkvoData(fnamein):
60 63
 def main():
61 64
 
62 65
     if len(sys.argv) < 3:
63
-        print ("usage  python calcAkvoKernel.py   AkvoDataset.yaml  Coil1.yaml SaveString " )
66
+        print ("usage  python calcAkvoKernel.py   AkvoDataset.yaml  Coil1.yaml kparams.yaml  SaveString.yaml " )
64 67
         exit()
65 68
 
66 69
     AKVO = loadAkvoData(sys.argv[1])
@@ -69,8 +72,8 @@ def main():
69 72
     B_dec = AKVO.META["B_0"]["dec"]  
70 73
     B0    = AKVO.META["B_0"]["intensity"]  
71 74
 
72
-    gamma = 2.67518e8
73 75
     fT = AKVO.transFreq
76
+    #gamma = 2.67518e8
74 77
     #B0 = (fL*2.*np.pi) /gamma * 1e9
75 78
  
76 79
     Coil1 = em1d.PolygonalWireAntenna.DeSerialize( sys.argv[2] )
@@ -78,26 +81,57 @@ def main():
78 81
     Coil1.SetFrequency(0, fT) 
79 82
     Coil1.SetCurrent(1.)
80 83
 
84
+    # read in kernel params
85
+    kparams = loadAkvoData( sys.argv[3] )
86
+
87
+    ## TODO 
81 88
     # pass this in...
82 89
     lmod = em1d.LayeredEarthEM() 
83
-    lmod.SetNumberOfLayers(4)
84
-    lmod.SetLayerThickness([15.49, 28.18])
85
-    lmod.SetLayerConductivity([0.0, 1./16.91, 1./24.06, 1./33.23])
90
+
91
+    nlay = len(kparams["sigs"])
92
+    sigs = np.array(kparams["sigs"])
93
+    tops = np.array(kparams["tops"])
94
+    bots = np.array(kparams["bots"])
95
+    
96
+    if ( (len(tops)-1) != len(bots)):
97
+        print("Layer mismatch")
98
+        exit()
99
+
100
+    thicks = bots - tops[0:-1]
101
+    
102
+    lmod.SetNumberOfLayers(nlay + 1)
103
+    lmod.SetLayerThickness(thicks)
104
+    lmod.SetLayerConductivity( np.concatenate( ( [0.0], sigs ) ))
105
+
106
+    #lmod.SetNumberOfLayers(4)
107
+    #lmod.SetLayerThickness([15.49, 28.18])
108
+    #lmod.SetLayerConductivity([0.0, 1./16.91, 1./24.06, 1./33.23])
109
+
86 110
 
87 111
     lmod.SetMagneticFieldIncDecMag( B_inc, B_dec, B0, lc.NANOTESLA )
88
-   
89 112
 
90 113
     Kern = mrln.KernelV0()
91 114
     Kern.PushCoil( "Coil 1", Coil1 )
92 115
     Kern.SetLayeredEarthEM( lmod );
93
-    Kern.SetIntegrationSize( (200,200,200) )
94
-    Kern.SetIntegrationOrigin( (0,0,0) )
95
-    Kern.SetTolerance( 1e-9 )
96
-    Kern.SetMinLevel( 3 )
116
+    Kern.SetIntegrationSize( (kparams["size_n"], kparams["size_e"], kparams["size_d"]) )
117
+    Kern.SetIntegrationOrigin( (kparams["origin_n"], kparams["origin_e"], kparams["origin_d"]) )
118
+    Kern.SetTolerance( 1e-9*kparams["branchTol"] )
119
+    Kern.SetMinLevel( kparams["minLevel"] )
120
+    Kern.SetMaxLevel( kparams["maxLevel"] )
97 121
     Kern.SetHankelTransformType( lc.FHTKEY201 )
98 122
     Kern.AlignWithAkvoDataset( sys.argv[1] )
99 123
 
100
-    thick = np.geomspace(.5, 10,num=40)
124
+    if str(kparams["Lspacing"]).strip() == "Geometric":
125
+        thick = np.geomspace(kparams["thick1"], kparams["thickN"], num=kparams["nLay"])
126
+    elif str(kparams["Lspacing"]) == "Log":
127
+        thick = np.logspace(kparams["thick1"], kparams["thickN"], num=kparams["nLay"])
128
+    elif str(kparams["Lspacing"]) == "Linear":
129
+        thick = np.linspace(kparams["thick1"], kparams["thickN"], num=kparams["nLay"])
130
+    else:
131
+        print("DOOOM!, in calcAkvoKernel layer spacing was not <Geometric>, <Log>, or <Linear>")
132
+        print( str(kparams["Lspacing"]) )
133
+        exit()
134
+
101 135
     iface = np.cumsum(thick)
102 136
     Kern.SetDepthLayerInterfaces(iface)
103 137
     #Kern.SetDepthLayerInterfaces(np.geomspace(1, 110, num=40))
@@ -110,13 +144,12 @@ def main():
110 144
     Kern.CalculateK0( ["Coil 1"], ["Coil 1"], False )
111 145
 
112 146
     #yml = open( 'test' + str(Kern.GetTolerance()) + '.yaml', 'w')
113
-    yml = open( sys.argv[3], 'w' )
147
+    yml = open( sys.argv[4], 'w' )
114 148
     print(Kern, file=yml)
115 149
 
116
-    #K0 = Kern.GetKernel()
117
-    
118
-    #plt.matshow(np.abs(K0))
119
-    #plt.show()
150
+    K0 = Kern.GetKernel()
151
+    plt.matshow(np.abs(K0))
152
+    plt.show()
120 153
 
121 154
 if __name__ == "__main__":
122 155
     main()

Loading…
Cancel
Save