Browse Source

Reworking multiple frequency harmonic modelling

tags/1.6.1
Trevor Irons 5 years ago
parent
commit
3498a3516d
4 changed files with 234 additions and 105 deletions
  1. 28
    1
      akvo/gui/akvoGUI.py
  2. 194
    101
      akvo/gui/main.ui
  3. 4
    1
      akvo/tressel/harmonic.py
  4. 8
    2
      akvo/tressel/mrsurvey.py

+ 28
- 1
akvo/gui/akvoGUI.py View File

@@ -173,6 +173,13 @@ class ApplicationWindow(QtWidgets.QMainWindow):
173 173
         self.ui.f0KNSpin.valueChanged.connect( self.LCDHarmonics )
174 174
         self.ui.f0KsSpin.valueChanged.connect( self.LCDHarmonics )
175 175
         self.ui.f0Spin.valueChanged.connect( self.LCDHarmonics )
176
+
177
+        self.ui.NHarmonicsFreqsSpin.valueChanged.connect( self.LCDHarmonics2 )
178
+        
179
+        self.ui.f1K1Spin.valueChanged.connect( self.LCDHarmonics2 )
180
+        self.ui.f1KNSpin.valueChanged.connect( self.LCDHarmonics2 )
181
+        self.ui.f1KsSpin.valueChanged.connect( self.LCDHarmonics2 )
182
+        self.ui.f1Spin.valueChanged.connect( self.LCDHarmonics2 )
176 183
  
177 184
         self.ui.plotQD.setEnabled(False) 
178 185
         self.ui.plotQD.pressed.connect( self.plotQD )
@@ -266,6 +273,19 @@ class ApplicationWindow(QtWidgets.QMainWindow):
266 273
         self.ui.lcdHNF.display( self.ui.f0Spin.value() * self.ui.f0KNSpin.value() )
267 274
         self.ui.lcdf0NK.setEnabled(True)
268 275
         self.ui.lcdf0NK.display( (self.ui.f0KNSpin.value()+1-self.ui.f0K1Spin.value()) * self.ui.f0KsSpin.value() )
276
+    
277
+    def LCDHarmonics2(self):
278
+        if self.ui.NHarmonicsFreqsSpin.value() == 2:
279
+            self.ui.lcdH1F2.setEnabled(True)
280
+            self.ui.lcdH1F2.display( self.ui.f1Spin.value() * self.ui.f1K1Spin.value() )
281
+            self.ui.lcdHNF2.setEnabled(True)
282
+            self.ui.lcdHNF2.display( self.ui.f1Spin.value() * self.ui.f1KNSpin.value() )
283
+            self.ui.lcdf0NK2.setEnabled(True)
284
+            self.ui.lcdf0NK2.display( (self.ui.f1KNSpin.value()+1-self.ui.f1K1Spin.value()) * self.ui.f1KsSpin.value() )
285
+        else:
286
+            self.ui.lcdH1F2.setEnabled(False)
287
+            self.ui.lcdHNF2.setEnabled(False)
288
+            self.ui.lcdf0NK2.setEnabled(False)
269 289
 
270 290
     def closeTabs(self):
271 291
         #self.ui.ProcTabs.removeTab(idx)    
@@ -1103,7 +1123,11 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1103 1123
             self.YamlNode.Processing["Harmonic modelling"]["f0K1"] = str( self.ui.f0K1Spin.value() )
1104 1124
             self.YamlNode.Processing["Harmonic modelling"]["f0KN"] = str( self.ui.f0KNSpin.value() )
1105 1125
             self.YamlNode.Processing["Harmonic modelling"]["f0Ks"] = str( self.ui.f0KsSpin.value() )
1106
-            self.YamlNode.Processing["Harmonic modelling"]["f1"] = str( self.ui.f1Spin.value() )
1126
+            self.YamlNode.Processing["Harmonic modelling"]["f0"] = str( self.ui.f0Spin.value() )
1127
+            self.YamlNode.Processing["Harmonic modelling"]["f1K1"] = str( self.ui.f0K1Spin.value() )
1128
+            self.YamlNode.Processing["Harmonic modelling"]["f1KN"] = str( self.ui.f0KNSpin.value() )
1129
+            self.YamlNode.Processing["Harmonic modelling"]["f1Ks"] = str( self.ui.f0KsSpin.value() )
1130
+            self.YamlNode.Processing["Harmonic modelling"]["f1"] = str( self.ui.f0Spin.value() )
1107 1131
             self.YamlNode.Processing["Harmonic modelling"]["Segments"] = str( 1 ) # Future 
1108 1132
             self.Log()
1109 1133
         else:
@@ -1122,6 +1146,9 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1122 1146
                  self.ui.f0KNSpin.value(), \
1123 1147
                  self.ui.f0KsSpin.value(), \
1124 1148
                  self.ui.f1Spin.value(), \
1149
+                 self.ui.f1K1Spin.value(), \
1150
+                 self.ui.f1KNSpin.value(), \
1151
+                 self.ui.f1KsSpin.value(), \
1125 1152
                  self.ui.plotHarmonic.isChecked(), \
1126 1153
                  self.ui.mplwidget \
1127 1154
                 ) \

+ 194
- 101
akvo/gui/main.ui View File

@@ -1005,7 +1005,7 @@ background: dark grey;
1005 1005
               <property name="maximumSize">
1006 1006
                <size>
1007 1007
                 <width>16777215</width>
1008
-                <height>350</height>
1008
+                <height>430</height>
1009 1009
                </size>
1010 1010
               </property>
1011 1011
               <property name="toolTip">
@@ -1021,55 +1021,97 @@ background: dark grey;
1021 1021
                <bool>true</bool>
1022 1022
               </property>
1023 1023
               <layout class="QGridLayout" name="gridLayout_9">
1024
-               <item row="1" column="2">
1025
-                <widget class="Line" name="line_2">
1026
-                 <property name="orientation">
1027
-                  <enum>Qt::Horizontal</enum>
1024
+               <item row="3" column="2">
1025
+                <widget class="QLCDNumber" name="lcdH1F">
1026
+                 <property name="styleSheet">
1027
+                  <string notr="true">#lcdH1F {
1028
+  color: green;
1029
+  background: black;
1030
+}
1031
+
1032
+#lcdH1F:disabled {
1033
+  color: grey;
1034
+  background: dark grey;
1035
+}</string>
1028 1036
                  </property>
1029 1037
                 </widget>
1030 1038
                </item>
1031
-               <item row="8" column="1">
1032
-                <widget class="Line" name="line_8">
1039
+               <item row="13" column="1">
1040
+                <widget class="QCheckBox" name="plotHarmonic">
1041
+                 <property name="text">
1042
+                  <string>Plot</string>
1043
+                 </property>
1044
+                 <property name="checked">
1045
+                  <bool>true</bool>
1046
+                 </property>
1047
+                </widget>
1048
+               </item>
1049
+               <item row="6" column="1">
1050
+                <widget class="Line" name="line_5">
1033 1051
                  <property name="orientation">
1034 1052
                   <enum>Qt::Horizontal</enum>
1035 1053
                  </property>
1036 1054
                 </widget>
1037 1055
                </item>
1038
-               <item row="5" column="0">
1039
-                <widget class="QLabel" name="label_33">
1056
+               <item row="0" column="0">
1057
+                <widget class="QLabel" name="label_26">
1040 1058
                  <property name="text">
1041
-                  <string>Sub-harmonics </string>
1059
+                  <string>N freqs</string>
1042 1060
                  </property>
1043 1061
                 </widget>
1044 1062
                </item>
1045
-               <item row="7" column="1">
1046
-                <widget class="QDoubleSpinBox" name="f1Spin">
1063
+               <item row="8" column="0">
1064
+                <widget class="QLabel" name="label_34">
1065
+                 <property name="text">
1066
+                  <string>First harmonic 2</string>
1067
+                 </property>
1068
+                </widget>
1069
+               </item>
1070
+               <item row="2" column="1">
1071
+                <widget class="QDoubleSpinBox" name="f0Spin">
1047 1072
                  <property name="maximum">
1048 1073
                   <double>25000.000000000000000</double>
1049 1074
                  </property>
1075
+                 <property name="singleStep">
1076
+                  <double>0.100000000000000</double>
1077
+                 </property>
1050 1078
                  <property name="value">
1051 1079
                   <double>60.000000000000000</double>
1052 1080
                  </property>
1053 1081
                 </widget>
1054 1082
                </item>
1055
-               <item row="8" column="2">
1056
-                <widget class="Line" name="line_9">
1057
-                 <property name="orientation">
1058
-                  <enum>Qt::Horizontal</enum>
1083
+               <item row="7" column="1">
1084
+                <widget class="QDoubleSpinBox" name="f1Spin">
1085
+                 <property name="maximum">
1086
+                  <double>25000.000000000000000</double>
1087
+                 </property>
1088
+                 <property name="value">
1089
+                  <double>60.000000000000000</double>
1059 1090
                  </property>
1060 1091
                 </widget>
1061 1092
                </item>
1062
-               <item row="3" column="0">
1063
-                <widget class="QLabel" name="label_11">
1064
-                 <property name="text">
1065
-                  <string>First harmonic 1</string>
1093
+               <item row="4" column="1">
1094
+                <widget class="QSpinBox" name="f0KNSpin">
1095
+                 <property name="minimum">
1096
+                  <number>2</number>
1097
+                 </property>
1098
+                 <property name="value">
1099
+                  <number>40</number>
1066 1100
                  </property>
1067 1101
                 </widget>
1068 1102
                </item>
1069
-               <item row="6" column="1">
1070
-                <widget class="Line" name="line_5">
1071
-                 <property name="orientation">
1072
-                  <enum>Qt::Horizontal</enum>
1103
+               <item row="4" column="2">
1104
+                <widget class="QLCDNumber" name="lcdHNF">
1105
+                 <property name="styleSheet">
1106
+                  <string notr="true">#lcdHNF {
1107
+  color: green;
1108
+  background: black;
1109
+}
1110
+
1111
+#lcdHNF:disabled {
1112
+  color: grey;
1113
+  background: dark grey;
1114
+}</string>
1073 1115
                  </property>
1074 1116
                 </widget>
1075 1117
                </item>
@@ -1080,20 +1122,17 @@ background: dark grey;
1080 1122
                  </property>
1081 1123
                 </widget>
1082 1124
                </item>
1083
-               <item row="8" column="0">
1084
-                <widget class="Line" name="line_7">
1125
+               <item row="11" column="2">
1126
+                <widget class="Line" name="line_9">
1085 1127
                  <property name="orientation">
1086 1128
                   <enum>Qt::Horizontal</enum>
1087 1129
                  </property>
1088 1130
                 </widget>
1089 1131
                </item>
1090
-               <item row="10" column="1">
1091
-                <widget class="QCheckBox" name="plotHarmonic">
1132
+               <item row="3" column="0">
1133
+                <widget class="QLabel" name="label_11">
1092 1134
                  <property name="text">
1093
-                  <string>Plot</string>
1094
-                 </property>
1095
-                 <property name="checked">
1096
-                  <bool>true</bool>
1135
+                  <string>First harmonic 1</string>
1097 1136
                  </property>
1098 1137
                 </widget>
1099 1138
                </item>
@@ -1104,64 +1143,67 @@ background: dark grey;
1104 1143
                  </property>
1105 1144
                 </widget>
1106 1145
                </item>
1107
-               <item row="4" column="2">
1108
-                <widget class="QLCDNumber" name="lcdHNF">
1109
-                 <property name="styleSheet">
1110
-                  <string notr="true">#lcdHNF {
1111
-  color: green;
1112
-  background: black;
1113
-}
1114
-
1115
-#lcdHNF:disabled {
1116
-  color: grey;
1117
-  background: dark grey;
1118
-}</string>
1146
+               <item row="11" column="1">
1147
+                <widget class="Line" name="line_8">
1148
+                 <property name="orientation">
1149
+                  <enum>Qt::Horizontal</enum>
1119 1150
                  </property>
1120 1151
                 </widget>
1121 1152
                </item>
1122
-               <item row="4" column="1">
1123
-                <widget class="QSpinBox" name="f0KNSpin">
1153
+               <item row="8" column="1">
1154
+                <widget class="QSpinBox" name="f1K1Spin">
1124 1155
                  <property name="minimum">
1125
-                  <number>2</number>
1156
+                  <number>1</number>
1126 1157
                  </property>
1127
-                 <property name="value">
1128
-                  <number>40</number>
1158
+                </widget>
1159
+               </item>
1160
+               <item row="10" column="1">
1161
+                <widget class="QSpinBox" name="f1KsSpin">
1162
+                 <property name="minimum">
1163
+                  <number>1</number>
1164
+                 </property>
1165
+                 <property name="maximum">
1166
+                  <number>3</number>
1129 1167
                  </property>
1130 1168
                 </widget>
1131 1169
                </item>
1132
-               <item row="2" column="0">
1133
-                <widget class="QLabel" name="label_25">
1170
+               <item row="4" column="0">
1171
+                <widget class="QLabel" name="label_31">
1134 1172
                  <property name="text">
1135
-                  <string>Base freq. 1</string>
1173
+                  <string>Last harmonic 1</string>
1136 1174
                  </property>
1137 1175
                 </widget>
1138 1176
                </item>
1139
-               <item row="2" column="1">
1140
-                <widget class="QDoubleSpinBox" name="f0Spin">
1141
-                 <property name="maximum">
1142
-                  <double>25000.000000000000000</double>
1143
-                 </property>
1144
-                 <property name="singleStep">
1145
-                  <double>0.100000000000000</double>
1177
+               <item row="1" column="0">
1178
+                <widget class="Line" name="line_3">
1179
+                 <property name="orientation">
1180
+                  <enum>Qt::Horizontal</enum>
1146 1181
                  </property>
1147
-                 <property name="value">
1148
-                  <double>60.000000000000000</double>
1182
+                </widget>
1183
+               </item>
1184
+               <item row="1" column="2">
1185
+                <widget class="Line" name="line_2">
1186
+                 <property name="orientation">
1187
+                  <enum>Qt::Horizontal</enum>
1149 1188
                  </property>
1150 1189
                 </widget>
1151 1190
                </item>
1152
-               <item row="3" column="2">
1153
-                <widget class="QLCDNumber" name="lcdH1F">
1191
+               <item row="5" column="2">
1192
+                <widget class="QLCDNumber" name="lcdf0NK">
1154 1193
                  <property name="styleSheet">
1155
-                  <string notr="true">#lcdH1F {
1156
-  color: green;
1157
-  background: black;
1194
+                  <string notr="true">#lcdf0NK { 
1195
+ color: green;
1196
+ background: black;
1158 1197
 }
1159 1198
 
1160
-#lcdH1F:disabled {
1199
+#lcdf0NK:disabled {
1161 1200
   color: grey;
1162 1201
   background: dark grey;
1163 1202
 }</string>
1164 1203
                  </property>
1204
+                 <property name="intValue" stdset="0">
1205
+                  <number>0</number>
1206
+                 </property>
1165 1207
                 </widget>
1166 1208
                </item>
1167 1209
                <item row="7" column="0">
@@ -1171,30 +1213,36 @@ background: dark grey;
1171 1213
                  </property>
1172 1214
                 </widget>
1173 1215
                </item>
1174
-               <item row="0" column="1">
1175
-                <widget class="QSpinBox" name="NHarmonicsFreqsSpin">
1216
+               <item row="3" column="1">
1217
+                <widget class="QSpinBox" name="f0K1Spin">
1176 1218
                  <property name="minimum">
1177 1219
                   <number>1</number>
1178 1220
                  </property>
1179 1221
                  <property name="maximum">
1180
-                  <number>1</number>
1222
+                  <number>50</number>
1181 1223
                  </property>
1182 1224
                  <property name="value">
1183 1225
                   <number>1</number>
1184 1226
                  </property>
1185 1227
                 </widget>
1186 1228
                </item>
1187
-               <item row="6" column="0">
1188
-                <widget class="Line" name="line_4">
1229
+               <item row="11" column="0">
1230
+                <widget class="Line" name="line_7">
1189 1231
                  <property name="orientation">
1190 1232
                   <enum>Qt::Horizontal</enum>
1191 1233
                  </property>
1192 1234
                 </widget>
1193 1235
                </item>
1194
-               <item row="4" column="0">
1195
-                <widget class="QLabel" name="label_31">
1196
-                 <property name="text">
1197
-                  <string>Last harmonic 1</string>
1236
+               <item row="0" column="1">
1237
+                <widget class="QSpinBox" name="NHarmonicsFreqsSpin">
1238
+                 <property name="minimum">
1239
+                  <number>1</number>
1240
+                 </property>
1241
+                 <property name="maximum">
1242
+                  <number>2</number>
1243
+                 </property>
1244
+                 <property name="value">
1245
+                  <number>1</number>
1198 1246
                  </property>
1199 1247
                 </widget>
1200 1248
                </item>
@@ -1214,14 +1262,14 @@ background: dark grey;
1214 1262
                  </property>
1215 1263
                 </widget>
1216 1264
                </item>
1217
-               <item row="1" column="0">
1218
-                <widget class="Line" name="line_3">
1219
-                 <property name="orientation">
1220
-                  <enum>Qt::Horizontal</enum>
1265
+               <item row="2" column="0">
1266
+                <widget class="QLabel" name="label_25">
1267
+                 <property name="text">
1268
+                  <string>Base freq. 1</string>
1221 1269
                  </property>
1222 1270
                 </widget>
1223 1271
                </item>
1224
-               <item row="10" column="2">
1272
+               <item row="13" column="2">
1225 1273
                 <widget class="QPushButton" name="harmonicGO">
1226 1274
                  <property name="layoutDirection">
1227 1275
                   <enum>Qt::LeftToRight</enum>
@@ -1235,41 +1283,86 @@ background: dark grey;
1235 1283
                  </property>
1236 1284
                 </widget>
1237 1285
                </item>
1238
-               <item row="3" column="1">
1239
-                <widget class="QSpinBox" name="f0K1Spin">
1240
-                 <property name="minimum">
1241
-                  <number>1</number>
1286
+               <item row="5" column="0">
1287
+                <widget class="QLabel" name="label_33">
1288
+                 <property name="text">
1289
+                  <string>Sub-harmonics </string>
1242 1290
                  </property>
1243
-                 <property name="maximum">
1244
-                  <number>50</number>
1291
+                </widget>
1292
+               </item>
1293
+               <item row="6" column="0">
1294
+                <widget class="Line" name="line_4">
1295
+                 <property name="orientation">
1296
+                  <enum>Qt::Horizontal</enum>
1245 1297
                  </property>
1246
-                 <property name="value">
1247
-                  <number>1</number>
1298
+                </widget>
1299
+               </item>
1300
+               <item row="10" column="2">
1301
+                <widget class="QLCDNumber" name="lcdf0NK2">
1302
+                 <property name="styleSheet">
1303
+                  <string notr="true">#lcdf0NK2 { 
1304
+ color: green;
1305
+ background: black;
1306
+}
1307
+
1308
+#lcdf0NK2:disabled {
1309
+  color: grey;
1310
+  background: dark grey;
1311
+}</string>
1248 1312
                  </property>
1249 1313
                 </widget>
1250 1314
                </item>
1251
-               <item row="0" column="0">
1252
-                <widget class="QLabel" name="label_26">
1253
-                 <property name="text">
1254
-                  <string>N freqs</string>
1315
+               <item row="9" column="2">
1316
+                <widget class="QLCDNumber" name="lcdHNF2">
1317
+                 <property name="styleSheet">
1318
+                  <string notr="true">#lcdHNF2 { 
1319
+ color: green;
1320
+ background: black;
1321
+}
1322
+
1323
+#lcdHNF2:disabled {
1324
+  color: grey;
1325
+  background: dark grey;
1326
+}</string>
1255 1327
                  </property>
1256 1328
                 </widget>
1257 1329
                </item>
1258
-               <item row="5" column="2">
1259
-                <widget class="QLCDNumber" name="lcdf0NK">
1330
+               <item row="8" column="2">
1331
+                <widget class="QLCDNumber" name="lcdH1F2">
1260 1332
                  <property name="styleSheet">
1261
-                  <string notr="true">#lcdf0NK { 
1333
+                  <string notr="true">#lcdH1F2{ 
1262 1334
  color: green;
1263 1335
  background: black;
1264 1336
 }
1265 1337
 
1266
-#lcdf0NK:disabled {
1338
+#lcdH1F2:disabled {
1267 1339
   color: grey;
1268 1340
   background: dark grey;
1269 1341
 }</string>
1270 1342
                  </property>
1271
-                 <property name="intValue" stdset="0">
1272
-                  <number>0</number>
1343
+                </widget>
1344
+               </item>
1345
+               <item row="9" column="0">
1346
+                <widget class="QLabel" name="label_35">
1347
+                 <property name="text">
1348
+                  <string>Last harmonic 2</string>
1349
+                 </property>
1350
+                </widget>
1351
+               </item>
1352
+               <item row="10" column="0">
1353
+                <widget class="QLabel" name="label_41">
1354
+                 <property name="text">
1355
+                  <string>Sub-harmonics</string>
1356
+                 </property>
1357
+                </widget>
1358
+               </item>
1359
+               <item row="9" column="1">
1360
+                <widget class="QSpinBox" name="f1KNSpin">
1361
+                 <property name="minimum">
1362
+                  <number>2</number>
1363
+                 </property>
1364
+                 <property name="value">
1365
+                  <number>40</number>
1273 1366
                  </property>
1274 1367
                 </widget>
1275 1368
                </item>
@@ -1592,8 +1685,8 @@ background: dark grey;
1592 1685
               <widget class="QPushButton" name="calcQGO">
1593 1686
                <property name="geometry">
1594 1687
                 <rect>
1595
-                 <x>380</x>
1596
-                 <y>80</y>
1688
+                 <x>400</x>
1689
+                 <y>100</y>
1597 1690
                  <width>84</width>
1598 1691
                  <height>30</height>
1599 1692
                 </rect>

+ 4
- 1
akvo/tressel/harmonic.py View File

@@ -40,7 +40,10 @@ def harmonicEuler ( sN, fs, t, f0, k1, kN, ks ):
40 40
     res = sN-h # residual 
41 41
 
42 42
 def harmonicNorm (f0, sN, fs, t, k1, kN, ks): 
43
-    return np.linalg.norm( harmonicEuler(sN, fs, t, f0, k1, kN, ks)) 
43
+    #print ("norm diff")
44
+    #return np.linalg.norm( harmonicEuler(sN, fs, t, f0, k1, kN, ks)) 
45
+    ii =  sN < (3.* np.std(sN))
46
+    return np.linalg.norm( harmonicEuler(sN, fs, t, f0, k1, kN, ks)[ii] ) 
44 47
 
45 48
 def minHarmonic(sN, fs, t, f0, k1, kN, ks):
46 49
     # CG, BFGS, Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr

+ 8
- 2
akvo/tressel/mrsurvey.py View File

@@ -519,14 +519,20 @@ class GMRDataProcessor(SNMRDataProcessor):
519 519
 
520 520
     #def harmonicModel(self, nF, nK, f0, f1, plot, canvas):
521 521
     
522
-    def harmonicModel(self, nF, f0, f0K1, f0KN, f0Ks, f1, plot, canvas):
522
+    def harmonicModel(self, nF, \
523
+        f0, f0K1, f0KN, f0Ks,  \
524
+        f1, f1K1, f1KN, K1Ks,  \
525
+        plot, canvas):
523 526
         """ nF = number of base frequencies, must be 1 or 2 
524 527
             f0 = first base frequency  
525 528
             f0K1 = first harmonic to model for first base frequency 
526 529
             f0KN = last harmonic to model for the first base frequency 
527 530
             f0Ks = subharmonic spacing, set to 1 for no subharmonics.
528
-            plot = should Akvo plot the results 
529 531
             f1 = second base frequency  
532
+            f1K1 = first harmonic to model for second base frequency 
533
+            f1KN = last harmonic to model for the second base frequency 
534
+            f1Ks = subharmonic spacing for the second base frequency, set to 1 for no subharmonics.
535
+            plot = should Akvo plot the results 
530 536
             canvas = mpl plotting axis      
531 537
         """
532 538
         #print("harmonic modelling...", f0)

Loading…
Cancel
Save