Bladeren bron

segmentation added to harmonic noise canc.

tags/1.6.1
Trevor Irons 5 jaren geleden
bovenliggende
commit
886a0ce9c5
6 gewijzigde bestanden met toevoegingen van 440 en 288 verwijderingen
  1. 35
    17
      akvo/gui/akvoGUI.py
  2. 326
    235
      akvo/gui/main.ui
  3. 20
    16
      akvo/tressel/decay.py
  4. 1
    1
      akvo/tressel/harmonic.py
  5. 57
    18
      akvo/tressel/mrsurvey.py
  6. 1
    1
      setup.py

+ 35
- 17
akvo/gui/akvoGUI.py Bestand weergeven

@@ -694,7 +694,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
694 694
         #    self.YamlNode.Processing["Saved"] = []
695 695
         #self.YamlNode.Processing["Saved"].append(datetime.datetime.now().isoformat()) 
696 696
         #self.Log()
697
- 
697
+        
698 698
         import pickle, os 
699 699
         try:
700 700
             with open('.akvo.last.path') as f: 
@@ -725,8 +725,10 @@ class ApplicationWindow(QtWidgets.QMainWindow):
725 725
         INFO["deadTime"] = self.RAWDataProc.deadTime
726 726
         INFO["transFreq"] = self.RAWDataProc.transFreq
727 727
         INFO["headerstr"] = str(self.headerstr)
728
+        INFO["nDAQVersion"] = self.RAWDataProc.nDAQVersion
728 729
         INFO["log"] = yaml.dump( self.YamlNode )  #self.logText  #MAK 20170127
729
-    
730
+          
731
+
730 732
         self.RAWDataProc.DATADICT["INFO"] = INFO 
731 733
 
732 734
         pickle.dump(self.RAWDataProc.DATADICT, save)
@@ -779,6 +781,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
779 781
         self.RAWDataProc.nPulseMoments = self.RAWDataProc.DATADICT["INFO"]["nPulseMoments"] 
780 782
         self.RAWDataProc.deadTime = self.RAWDataProc.DATADICT["INFO"]["deadTime"] 
781 783
         self.RAWDataProc.transFreq = self.RAWDataProc.DATADICT["INFO"]["transFreq"]
784
+        self.RAWDataProc.nDAQVersion = self.RAWDataProc.DATADICT["INFO"]["nDAQVersion"]
782 785
         self.RAWDataProc.dt = 1./self.RAWDataProc.samp 
783 786
 
784 787
 
@@ -1138,15 +1141,16 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1138 1141
         if "Harmonic modelling" not in self.YamlNode.Processing.keys():
1139 1142
             self.YamlNode.Processing["Harmonic modelling"] = {}
1140 1143
             self.YamlNode.Processing["Harmonic modelling"]["NF"] = str( self.ui.NHarmonicsFreqsSpin.value() ) 
1144
+            self.YamlNode.Processing["Harmonic modelling"]["Segments"] = str( self.ui.NSegments.value() ) 
1141 1145
             self.YamlNode.Processing["Harmonic modelling"]["f0K1"] = str( self.ui.f0K1Spin.value() )
1142 1146
             self.YamlNode.Processing["Harmonic modelling"]["f0KN"] = str( self.ui.f0KNSpin.value() )
1143 1147
             self.YamlNode.Processing["Harmonic modelling"]["f0Ks"] = str( self.ui.f0KsSpin.value() )
1144 1148
             self.YamlNode.Processing["Harmonic modelling"]["f0"] = str( self.ui.f0Spin.value() )
1145
-            self.YamlNode.Processing["Harmonic modelling"]["f1K1"] = str( self.ui.f0K1Spin.value() )
1146
-            self.YamlNode.Processing["Harmonic modelling"]["f1KN"] = str( self.ui.f0KNSpin.value() )
1147
-            self.YamlNode.Processing["Harmonic modelling"]["f1Ks"] = str( self.ui.f0KsSpin.value() )
1148
-            self.YamlNode.Processing["Harmonic modelling"]["f1"] = str( self.ui.f0Spin.value() )
1149
-            self.YamlNode.Processing["Harmonic modelling"]["Segments"] = str( 1 ) # Future 
1149
+            if self.ui.NHarmonicsFreqsSpin.value() > 1:
1150
+                self.YamlNode.Processing["Harmonic modelling"]["f1K1"] = str( self.ui.f1K1Spin.value() )
1151
+                self.YamlNode.Processing["Harmonic modelling"]["f1KN"] = str( self.ui.f1KNSpin.value() )
1152
+                self.YamlNode.Processing["Harmonic modelling"]["f1Ks"] = str( self.ui.f1KsSpin.value() )
1153
+                self.YamlNode.Processing["Harmonic modelling"]["f1"] = str( self.ui.f1Spin.value() )
1150 1154
             self.Log()
1151 1155
         else:
1152 1156
             err_msg = "Harmonic modelling noise cancellation has already been applied!"
@@ -1163,6 +1167,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1163 1167
                  self.ui.f0K1Spin.value(), \
1164 1168
                  self.ui.f0KNSpin.value(), \
1165 1169
                  self.ui.f0KsSpin.value(), \
1170
+                 self.ui.NSegments.value(), \
1166 1171
                  self.ui.f1Spin.value(), \
1167 1172
                  self.ui.f1K1Spin.value(), \
1168 1173
                  self.ui.f1KNSpin.value(), \
@@ -1279,19 +1284,32 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1279 1284
 
1280 1285
     def quadDet(self):
1281 1286
 
1282
-        if "Quadrature detection" not in self.YamlNode.Processing.keys():
1283
-            self.YamlNode.Processing["Quadrature detection"] = {}
1284
-            self.YamlNode.Processing["Quadrature detection"]["trim"] = str( self.ui.trimSpin.value() )
1285
-            self.Log()
1286
-        else:
1287
-            err_msg = "Quadrature detection has already been done!"
1288
-            reply =QtWidgets.QMessageBox.critical(self, 'Error', 
1289
-                err_msg) 
1290
-            return 
1287
+        method = ['trf','dogbox','lm'][int(self.ui.QDMethod.currentIndex())]
1288
+        loss = ['linear','soft_l1','cauchy','huber'][int(self.ui.QDLoss.currentIndex())]         
1291 1289
 
1290
+
1291
+        # allow overwrite of Quad Det.    
1292
+        self.YamlNode.Processing["Quadrature detection"] = {}
1293
+        self.YamlNode.Processing["Quadrature detection"]["trim"] = str( self.ui.trimSpin.value() )
1294
+        self.YamlNode.Processing["Quadrature detection"]["method"] = method 
1295
+        self.YamlNode.Processing["Quadrature detection"]["loss"] = loss
1296
+        self.Log()
1297
+
1298
+        #if "Quadrature detection" not in self.YamlNode.Processing.keys():
1299
+        #    self.YamlNode.Processing["Quadrature detection"] = {}
1300
+        #    self.YamlNode.Processing["Quadrature detection"]["trim"] = str( self.ui.trimSpin.value() )
1301
+        #    self.Log()
1302
+        #else:
1303
+        #    self.YamlNode.Processing["Quadrature detection"] = {}
1304
+        #    self.YamlNode.Processing["Quadrature detection"]["trim"] = str( self.ui.trimSpin.value() )
1305
+        #    self.Log()
1306
+            #err_msg = "Quadrature detection has already been done!"
1307
+            #reply =QtWidgets.QMessageBox.critical(self, 'Error', 
1308
+            #    err_msg) 
1309
+            #return 
1292 1310
         self.lock("quadrature detection")
1293 1311
         thread.start_new_thread(self.RAWDataProc.quadDet, \
1294
-                (self.ui.trimSpin.value(), int(self.ui.QDType.currentIndex()), self.ui.mplwidget))
1312
+                (self.ui.trimSpin.value(), method, loss, self.ui.mplwidget))
1295 1313
 
1296 1314
         self.ui.plotQD.setEnabled(True)
1297 1315
     

+ 326
- 235
akvo/gui/main.ui Bestand weergeven

@@ -519,7 +519,7 @@ background: dark grey;
519 519
                   <number>1</number>
520 520
                  </property>
521 521
                  <property name="maximum">
522
-                  <double>1000.000000000000000</double>
522
+                  <double>1200.000000000000000</double>
523 523
                  </property>
524 524
                  <property name="value">
525 525
                   <double>600.000000000000000</double>
@@ -702,7 +702,7 @@ background: dark grey;
702 702
                   <double>100.000000000000000</double>
703 703
                  </property>
704 704
                  <property name="maximum">
705
-                  <double>1000.000000000000000</double>
705
+                  <double>1600.000000000000000</double>
706 706
                  </property>
707 707
                  <property name="value">
708 708
                   <double>280.000000000000000</double>
@@ -722,7 +722,7 @@ background: dark grey;
722 722
                   <double>25.000000000000000</double>
723 723
                  </property>
724 724
                  <property name="maximum">
725
-                  <double>500.000000000000000</double>
725
+                  <double>600.000000000000000</double>
726 726
                  </property>
727 727
                  <property name="singleStep">
728 728
                   <double>5.000000000000000</double>
@@ -1021,38 +1021,6 @@ background: dark grey;
1021 1021
                <bool>true</bool>
1022 1022
               </property>
1023 1023
               <layout class="QGridLayout" name="gridLayout_9">
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>
1036
-                 </property>
1037
-                </widget>
1038
-               </item>
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">
1051
-                 <property name="orientation">
1052
-                  <enum>Qt::Horizontal</enum>
1053
-                 </property>
1054
-                </widget>
1055
-               </item>
1056 1024
                <item row="0" column="0">
1057 1025
                 <widget class="QLabel" name="label_26">
1058 1026
                  <property name="text">
@@ -1060,104 +1028,83 @@ background: dark grey;
1060 1028
                  </property>
1061 1029
                 </widget>
1062 1030
                </item>
1063
-               <item row="8" column="0">
1064
-                <widget class="QLabel" name="label_34">
1065
-                 <property name="text">
1066
-                  <string>First harmonic 2</string>
1031
+               <item row="0" column="1">
1032
+                <widget class="QSpinBox" name="NHarmonicsFreqsSpin">
1033
+                 <property name="minimum">
1034
+                  <number>1</number>
1067 1035
                  </property>
1068
-                </widget>
1069
-               </item>
1070
-               <item row="2" column="1">
1071
-                <widget class="QDoubleSpinBox" name="f0Spin">
1072 1036
                  <property name="maximum">
1073
-                  <double>25000.000000000000000</double>
1074
-                 </property>
1075
-                 <property name="singleStep">
1076
-                  <double>0.100000000000000</double>
1037
+                  <number>2</number>
1077 1038
                  </property>
1078 1039
                  <property name="value">
1079
-                  <double>60.000000000000000</double>
1040
+                  <number>1</number>
1080 1041
                  </property>
1081 1042
                 </widget>
1082 1043
                </item>
1083
-               <item row="7" column="1">
1084
-                <widget class="QDoubleSpinBox" name="f1Spin">
1085
-                 <property name="maximum">
1086
-                  <double>25000.000000000000000</double>
1044
+               <item row="5" column="1">
1045
+                <widget class="QSpinBox" name="f0KNSpin">
1046
+                 <property name="minimum">
1047
+                  <number>2</number>
1087 1048
                  </property>
1088 1049
                  <property name="value">
1089
-                  <double>60.000000000000000</double>
1050
+                  <number>40</number>
1090 1051
                  </property>
1091 1052
                 </widget>
1092 1053
                </item>
1093 1054
                <item row="4" column="1">
1094
-                <widget class="QSpinBox" name="f0KNSpin">
1055
+                <widget class="QSpinBox" name="f0K1Spin">
1095 1056
                  <property name="minimum">
1096
-                  <number>2</number>
1057
+                  <number>1</number>
1058
+                 </property>
1059
+                 <property name="maximum">
1060
+                  <number>50</number>
1097 1061
                  </property>
1098 1062
                  <property name="value">
1099
-                  <number>40</number>
1063
+                  <number>1</number>
1100 1064
                  </property>
1101 1065
                 </widget>
1102 1066
                </item>
1103
-               <item row="4" column="2">
1104
-                <widget class="QLCDNumber" name="lcdHNF">
1067
+               <item row="12" column="2">
1068
+                <widget class="QLCDNumber" name="lcdf0NK2">
1105 1069
                  <property name="styleSheet">
1106
-                  <string notr="true">#lcdHNF {
1107
-  color: green;
1108
-  background: black;
1070
+                  <string notr="true">#lcdf0NK2 { 
1071
+ color: green;
1072
+ background: black;
1109 1073
 }
1110 1074
 
1111
-#lcdHNF:disabled {
1075
+#lcdf0NK2:disabled {
1112 1076
   color: grey;
1113 1077
   background: dark grey;
1114 1078
 }</string>
1115 1079
                  </property>
1116 1080
                 </widget>
1117 1081
                </item>
1118
-               <item row="1" column="1">
1119
-                <widget class="Line" name="line">
1120
-                 <property name="orientation">
1121
-                  <enum>Qt::Horizontal</enum>
1122
-                 </property>
1123
-                </widget>
1124
-               </item>
1125
-               <item row="11" column="2">
1126
-                <widget class="Line" name="line_9">
1127
-                 <property name="orientation">
1128
-                  <enum>Qt::Horizontal</enum>
1129
-                 </property>
1130
-                </widget>
1131
-               </item>
1132
-               <item row="3" column="0">
1133
-                <widget class="QLabel" name="label_11">
1134
-                 <property name="text">
1135
-                  <string>First harmonic 1</string>
1136
-                 </property>
1137
-                </widget>
1138
-               </item>
1139 1082
                <item row="6" column="2">
1140
-                <widget class="Line" name="line_6">
1141
-                 <property name="orientation">
1142
-                  <enum>Qt::Horizontal</enum>
1083
+                <widget class="QLCDNumber" name="lcdf0NK">
1084
+                 <property name="styleSheet">
1085
+                  <string notr="true">#lcdf0NK { 
1086
+ color: green;
1087
+ background: black;
1088
+}
1089
+
1090
+#lcdf0NK:disabled {
1091
+  color: grey;
1092
+  background: dark grey;
1093
+}</string>
1143 1094
                  </property>
1144
-                </widget>
1145
-               </item>
1146
-               <item row="11" column="1">
1147
-                <widget class="Line" name="line_8">
1148
-                 <property name="orientation">
1149
-                  <enum>Qt::Horizontal</enum>
1095
+                 <property name="intValue" stdset="0">
1096
+                  <number>0</number>
1150 1097
                  </property>
1151 1098
                 </widget>
1152 1099
                </item>
1153
-               <item row="8" column="1">
1154
-                <widget class="QSpinBox" name="f1K1Spin">
1155
-                 <property name="minimum">
1156
-                  <number>1</number>
1100
+               <item row="10" column="0">
1101
+                <widget class="QLabel" name="label_34">
1102
+                 <property name="text">
1103
+                  <string>First harmonic 2</string>
1157 1104
                  </property>
1158 1105
                 </widget>
1159 1106
                </item>
1160
-               <item row="10" column="1">
1107
+               <item row="12" column="1">
1161 1108
                 <widget class="QSpinBox" name="f1KsSpin">
1162 1109
                  <property name="minimum">
1163 1110
                   <number>1</number>
@@ -1167,152 +1114,182 @@ background: dark grey;
1167 1114
                  </property>
1168 1115
                 </widget>
1169 1116
                </item>
1170
-               <item row="4" column="0">
1171
-                <widget class="QLabel" name="label_31">
1117
+               <item row="13" column="2">
1118
+                <widget class="Line" name="line_9">
1119
+                 <property name="orientation">
1120
+                  <enum>Qt::Horizontal</enum>
1121
+                 </property>
1122
+                </widget>
1123
+               </item>
1124
+               <item row="11" column="0">
1125
+                <widget class="QLabel" name="label_35">
1172 1126
                  <property name="text">
1173
-                  <string>Last harmonic 1</string>
1127
+                  <string>Last harmonic 2</string>
1174 1128
                  </property>
1175 1129
                 </widget>
1176 1130
                </item>
1177
-               <item row="1" column="0">
1178
-                <widget class="Line" name="line_3">
1179
-                 <property name="orientation">
1180
-                  <enum>Qt::Horizontal</enum>
1131
+               <item row="5" column="2">
1132
+                <widget class="QLCDNumber" name="lcdHNF">
1133
+                 <property name="styleSheet">
1134
+                  <string notr="true">#lcdHNF {
1135
+  color: green;
1136
+  background: black;
1137
+}
1138
+
1139
+#lcdHNF:disabled {
1140
+  color: grey;
1141
+  background: dark grey;
1142
+}</string>
1181 1143
                  </property>
1182 1144
                 </widget>
1183 1145
                </item>
1184
-               <item row="1" column="2">
1185
-                <widget class="Line" name="line_2">
1186
-                 <property name="orientation">
1187
-                  <enum>Qt::Horizontal</enum>
1146
+               <item row="4" column="2">
1147
+                <widget class="QLCDNumber" name="lcdH1F">
1148
+                 <property name="styleSheet">
1149
+                  <string notr="true">#lcdH1F {
1150
+  color: green;
1151
+  background: black;
1152
+}
1153
+
1154
+#lcdH1F:disabled {
1155
+  color: grey;
1156
+  background: dark grey;
1157
+}</string>
1188 1158
                  </property>
1189 1159
                 </widget>
1190 1160
                </item>
1191
-               <item row="5" column="2">
1192
-                <widget class="QLCDNumber" name="lcdf0NK">
1161
+               <item row="10" column="2">
1162
+                <widget class="QLCDNumber" name="lcdH1F2">
1193 1163
                  <property name="styleSheet">
1194
-                  <string notr="true">#lcdf0NK { 
1164
+                  <string notr="true">#lcdH1F2{ 
1195 1165
  color: green;
1196 1166
  background: black;
1197 1167
 }
1198 1168
 
1199
-#lcdf0NK:disabled {
1169
+#lcdH1F2:disabled {
1200 1170
   color: grey;
1201 1171
   background: dark grey;
1202 1172
 }</string>
1203 1173
                  </property>
1204
-                 <property name="intValue" stdset="0">
1205
-                  <number>0</number>
1206
-                 </property>
1207 1174
                 </widget>
1208 1175
                </item>
1209
-               <item row="7" column="0">
1210
-                <widget class="QLabel" name="label_27">
1176
+               <item row="12" column="0">
1177
+                <widget class="QLabel" name="label_41">
1211 1178
                  <property name="text">
1212
-                  <string>Base freq. 2 </string>
1179
+                  <string>Sub-harmonics</string>
1213 1180
                  </property>
1214 1181
                 </widget>
1215 1182
                </item>
1216
-               <item row="3" column="1">
1217
-                <widget class="QSpinBox" name="f0K1Spin">
1183
+               <item row="10" column="1">
1184
+                <widget class="QSpinBox" name="f1K1Spin">
1218 1185
                  <property name="minimum">
1219 1186
                   <number>1</number>
1220 1187
                  </property>
1221
-                 <property name="maximum">
1222
-                  <number>50</number>
1223
-                 </property>
1224
-                 <property name="value">
1225
-                  <number>1</number>
1188
+                </widget>
1189
+               </item>
1190
+               <item row="9" column="0">
1191
+                <widget class="QLabel" name="label_27">
1192
+                 <property name="text">
1193
+                  <string>Base freq. 2 </string>
1226 1194
                  </property>
1227 1195
                 </widget>
1228 1196
                </item>
1229
-               <item row="11" column="0">
1230
-                <widget class="Line" name="line_7">
1197
+               <item row="8" column="1">
1198
+                <widget class="Line" name="line_5">
1231 1199
                  <property name="orientation">
1232 1200
                   <enum>Qt::Horizontal</enum>
1233 1201
                  </property>
1234 1202
                 </widget>
1235 1203
                </item>
1236
-               <item row="0" column="1">
1237
-                <widget class="QSpinBox" name="NHarmonicsFreqsSpin">
1238
-                 <property name="minimum">
1239
-                  <number>1</number>
1204
+               <item row="8" column="2">
1205
+                <widget class="Line" name="line_6">
1206
+                 <property name="orientation">
1207
+                  <enum>Qt::Horizontal</enum>
1240 1208
                  </property>
1209
+                </widget>
1210
+               </item>
1211
+               <item row="3" column="1">
1212
+                <widget class="QDoubleSpinBox" name="f0Spin">
1241 1213
                  <property name="maximum">
1242
-                  <number>2</number>
1214
+                  <double>25000.000000000000000</double>
1215
+                 </property>
1216
+                 <property name="singleStep">
1217
+                  <double>0.100000000000000</double>
1243 1218
                  </property>
1244 1219
                  <property name="value">
1245
-                  <number>1</number>
1220
+                  <double>60.000000000000000</double>
1246 1221
                  </property>
1247 1222
                 </widget>
1248 1223
                </item>
1249
-               <item row="5" column="1">
1250
-                <widget class="QSpinBox" name="f0KsSpin">
1251
-                 <property name="toolTip">
1252
-                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Would you like to calculate subharmonics? For instance, setting this to 1, will calculate only the exact harmonics, setting this to 2 will calculate 1/2 step subharmonics (i.e. if the baseline frequency is 60 Hz, this will result in calcualtion of 30 Hz subharmonics)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1253
-                 </property>
1254
-                 <property name="minimum">
1255
-                  <number>1</number>
1256
-                 </property>
1224
+               <item row="9" column="1">
1225
+                <widget class="QDoubleSpinBox" name="f1Spin">
1257 1226
                  <property name="maximum">
1258
-                  <number>3</number>
1227
+                  <double>25000.000000000000000</double>
1259 1228
                  </property>
1260 1229
                  <property name="value">
1261
-                  <number>1</number>
1230
+                  <double>60.000000000000000</double>
1262 1231
                  </property>
1263 1232
                 </widget>
1264 1233
                </item>
1265
-               <item row="2" column="0">
1266
-                <widget class="QLabel" name="label_25">
1267
-                 <property name="text">
1268
-                  <string>Base freq. 1</string>
1234
+               <item row="2" column="2">
1235
+                <widget class="Line" name="line_2">
1236
+                 <property name="orientation">
1237
+                  <enum>Qt::Horizontal</enum>
1269 1238
                  </property>
1270 1239
                 </widget>
1271 1240
                </item>
1272
-               <item row="13" column="2">
1241
+               <item row="15" column="2">
1273 1242
                 <widget class="QPushButton" name="harmonicGO">
1274 1243
                  <property name="layoutDirection">
1275 1244
                   <enum>Qt::LeftToRight</enum>
1276 1245
                  </property>
1277
-                 <property name="styleSheet">
1278
-                  <string notr="true">#harmonicGO {background: green;}
1279
-#harmonicGO:disabled{background: black;}</string>
1246
+                 <property name="styleSheet">
1247
+                  <string notr="true">#harmonicGO {background: green;}
1248
+#harmonicGO:disabled{background: black;}</string>
1249
+                 </property>
1250
+                 <property name="text">
1251
+                  <string>GO</string>
1252
+                 </property>
1253
+                </widget>
1254
+               </item>
1255
+               <item row="6" column="1">
1256
+                <widget class="QSpinBox" name="f0KsSpin">
1257
+                 <property name="toolTip">
1258
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Would you like to calculate subharmonics? For instance, setting this to 1, will calculate only the exact harmonics, setting this to 2 will calculate 1/2 step subharmonics (i.e. if the baseline frequency is 60 Hz, this will result in calcualtion of 30 Hz subharmonics)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1259
+                 </property>
1260
+                 <property name="minimum">
1261
+                  <number>1</number>
1262
+                 </property>
1263
+                 <property name="maximum">
1264
+                  <number>3</number>
1280 1265
                  </property>
1281
-                 <property name="text">
1282
-                  <string>GO</string>
1266
+                 <property name="value">
1267
+                  <number>1</number>
1283 1268
                  </property>
1284 1269
                 </widget>
1285 1270
                </item>
1286
-               <item row="5" column="0">
1287
-                <widget class="QLabel" name="label_33">
1288
-                 <property name="text">
1289
-                  <string>Sub-harmonics </string>
1271
+               <item row="2" column="1">
1272
+                <widget class="Line" name="line">
1273
+                 <property name="orientation">
1274
+                  <enum>Qt::Horizontal</enum>
1290 1275
                  </property>
1291 1276
                 </widget>
1292 1277
                </item>
1293
-               <item row="6" column="0">
1294
-                <widget class="Line" name="line_4">
1295
-                 <property name="orientation">
1296
-                  <enum>Qt::Horizontal</enum>
1278
+               <item row="5" column="0">
1279
+                <widget class="QLabel" name="label_31">
1280
+                 <property name="text">
1281
+                  <string>Last harmonic 1</string>
1297 1282
                  </property>
1298 1283
                 </widget>
1299 1284
                </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>
1285
+               <item row="3" column="0">
1286
+                <widget class="QLabel" name="label_25">
1287
+                 <property name="text">
1288
+                  <string>Base freq. 1</string>
1312 1289
                  </property>
1313 1290
                 </widget>
1314 1291
                </item>
1315
-               <item row="9" column="2">
1292
+               <item row="11" column="2">
1316 1293
                 <widget class="QLCDNumber" name="lcdHNF2">
1317 1294
                  <property name="styleSheet">
1318 1295
                   <string notr="true">#lcdHNF2 { 
@@ -1327,42 +1304,85 @@ background: dark grey;
1327 1304
                  </property>
1328 1305
                 </widget>
1329 1306
                </item>
1330
-               <item row="8" column="2">
1331
-                <widget class="QLCDNumber" name="lcdH1F2">
1332
-                 <property name="styleSheet">
1333
-                  <string notr="true">#lcdH1F2{ 
1334
- color: green;
1335
- background: black;
1336
-}
1337
-
1338
-#lcdH1F2:disabled {
1339
-  color: grey;
1340
-  background: dark grey;
1341
-}</string>
1307
+               <item row="11" column="1">
1308
+                <widget class="QSpinBox" name="f1KNSpin">
1309
+                 <property name="minimum">
1310
+                  <number>2</number>
1311
+                 </property>
1312
+                 <property name="value">
1313
+                  <number>40</number>
1342 1314
                  </property>
1343 1315
                 </widget>
1344 1316
                </item>
1345
-               <item row="9" column="0">
1346
-                <widget class="QLabel" name="label_35">
1317
+               <item row="15" column="1">
1318
+                <widget class="QCheckBox" name="plotHarmonic">
1347 1319
                  <property name="text">
1348
-                  <string>Last harmonic 2</string>
1320
+                  <string>Plot</string>
1321
+                 </property>
1322
+                 <property name="checked">
1323
+                  <bool>true</bool>
1349 1324
                  </property>
1350 1325
                 </widget>
1351 1326
                </item>
1352
-               <item row="10" column="0">
1353
-                <widget class="QLabel" name="label_41">
1327
+               <item row="13" column="1">
1328
+                <widget class="Line" name="line_8">
1329
+                 <property name="orientation">
1330
+                  <enum>Qt::Horizontal</enum>
1331
+                 </property>
1332
+                </widget>
1333
+               </item>
1334
+               <item row="13" column="0">
1335
+                <widget class="Line" name="line_7">
1336
+                 <property name="orientation">
1337
+                  <enum>Qt::Horizontal</enum>
1338
+                 </property>
1339
+                </widget>
1340
+               </item>
1341
+               <item row="6" column="0">
1342
+                <widget class="QLabel" name="label_33">
1354 1343
                  <property name="text">
1355
-                  <string>Sub-harmonics</string>
1344
+                  <string>Sub-harmonics </string>
1356 1345
                  </property>
1357 1346
                 </widget>
1358 1347
                </item>
1359
-               <item row="9" column="1">
1360
-                <widget class="QSpinBox" name="f1KNSpin">
1348
+               <item row="4" column="0">
1349
+                <widget class="QLabel" name="label_11">
1350
+                 <property name="text">
1351
+                  <string>First harmonic 1</string>
1352
+                 </property>
1353
+                </widget>
1354
+               </item>
1355
+               <item row="2" column="0">
1356
+                <widget class="Line" name="line_3">
1357
+                 <property name="orientation">
1358
+                  <enum>Qt::Horizontal</enum>
1359
+                 </property>
1360
+                </widget>
1361
+               </item>
1362
+               <item row="8" column="0">
1363
+                <widget class="Line" name="line_4">
1364
+                 <property name="orientation">
1365
+                  <enum>Qt::Horizontal</enum>
1366
+                 </property>
1367
+                </widget>
1368
+               </item>
1369
+               <item row="1" column="1">
1370
+                <widget class="QSpinBox" name="NSegments">
1361 1371
                  <property name="minimum">
1362
-                  <number>2</number>
1372
+                  <number>1</number>
1373
+                 </property>
1374
+                 <property name="maximum">
1375
+                  <number>10</number>
1363 1376
                  </property>
1364 1377
                  <property name="value">
1365
-                  <number>40</number>
1378
+                  <number>1</number>
1379
+                 </property>
1380
+                </widget>
1381
+               </item>
1382
+               <item row="1" column="0">
1383
+                <widget class="QLabel" name="label_49">
1384
+                 <property name="text">
1385
+                  <string>N segments</string>
1366 1386
                  </property>
1367 1387
                 </widget>
1368 1388
                </item>
@@ -1830,42 +1850,26 @@ background: dark grey;
1830 1850
                <bool>true</bool>
1831 1851
               </property>
1832 1852
               <layout class="QGridLayout" name="gridLayout_15">
1833
-               <item row="1" column="3">
1834
-                <widget class="QPushButton" name="qdGO">
1835
-                 <property name="styleSheet">
1836
-                  <string notr="true">#qdGO {
1837
-    background: green;
1838
-}
1839
-
1840
-#qdGO:disabled{
1841
-    background: black;
1842
-}</string>
1843
-                 </property>
1844
-                 <property name="text">
1845
-                  <string>GO</string>
1846
-                 </property>
1847
-                </widget>
1848
-               </item>
1849 1853
                <item row="2" column="2">
1850
-                <widget class="QComboBox" name="QDType">
1854
+                <widget class="QComboBox" name="QDMethod">
1851 1855
                  <item>
1852 1856
                   <property name="text">
1853
-                   <string>Real/Imag</string>
1857
+                   <string>Trust region reflective</string>
1854 1858
                   </property>
1855 1859
                  </item>
1856 1860
                  <item>
1857 1861
                   <property name="text">
1858
-                   <string>Amp/Phase</string>
1862
+                   <string>Dogbox</string>
1859 1863
                   </property>
1860 1864
                  </item>
1861 1865
                  <item>
1862 1866
                   <property name="text">
1863
-                   <string>Phased</string>
1867
+                   <string>Levenberg-Marquardt</string>
1864 1868
                   </property>
1865 1869
                  </item>
1866 1870
                 </widget>
1867 1871
                </item>
1868
-               <item row="2" column="3">
1872
+               <item row="5" column="3">
1869 1873
                 <widget class="QPushButton" name="plotQD">
1870 1874
                  <property name="enabled">
1871 1875
                   <bool>false</bool>
@@ -1887,16 +1891,58 @@ background: dark grey;
1887 1891
                  </property>
1888 1892
                 </widget>
1889 1893
                </item>
1894
+               <item row="2" column="0">
1895
+                <widget class="QLabel" name="label_42">
1896
+                 <property name="text">
1897
+                  <string>Method/loss</string>
1898
+                 </property>
1899
+                </widget>
1900
+               </item>
1890 1901
                <item row="1" column="2">
1891 1902
                 <widget class="QSpinBox" name="trimSpin">
1892 1903
                  <property name="minimum">
1893 1904
                   <number>0</number>
1894 1905
                  </property>
1895 1906
                  <property name="value">
1896
-                  <number>0</number>
1907
+                  <number>2</number>
1908
+                 </property>
1909
+                </widget>
1910
+               </item>
1911
+               <item row="3" column="3">
1912
+                <widget class="QPushButton" name="qdGO">
1913
+                 <property name="styleSheet">
1914
+                  <string notr="true">#qdGO {
1915
+    background: green;
1916
+}
1917
+
1918
+#qdGO:disabled{
1919
+    background: black;
1920
+}</string>
1921
+                 </property>
1922
+                 <property name="text">
1923
+                  <string>GO</string>
1897 1924
                  </property>
1898 1925
                 </widget>
1899 1926
                </item>
1927
+               <item row="5" column="2">
1928
+                <widget class="QComboBox" name="QDType">
1929
+                 <item>
1930
+                  <property name="text">
1931
+                   <string>Real/Imag</string>
1932
+                  </property>
1933
+                 </item>
1934
+                 <item>
1935
+                  <property name="text">
1936
+                   <string>Amp/Phase</string>
1937
+                  </property>
1938
+                 </item>
1939
+                 <item>
1940
+                  <property name="text">
1941
+                   <string>Phased</string>
1942
+                  </property>
1943
+                 </item>
1944
+                </widget>
1945
+               </item>
1900 1946
                <item row="1" column="0">
1901 1947
                 <widget class="QLabel" name="label_38">
1902 1948
                  <property name="text">
@@ -1904,6 +1950,51 @@ background: dark grey;
1904 1950
                  </property>
1905 1951
                 </widget>
1906 1952
                </item>
1953
+               <item row="2" column="3">
1954
+                <widget class="QComboBox" name="QDLoss">
1955
+                 <item>
1956
+                  <property name="text">
1957
+                   <string>linear</string>
1958
+                  </property>
1959
+                 </item>
1960
+                 <item>
1961
+                  <property name="text">
1962
+                   <string>soft L1</string>
1963
+                  </property>
1964
+                 </item>
1965
+                 <item>
1966
+                  <property name="text">
1967
+                   <string>Cauchy</string>
1968
+                  </property>
1969
+                 </item>
1970
+                 <item>
1971
+                  <property name="text">
1972
+                   <string>Huber</string>
1973
+                  </property>
1974
+                 </item>
1975
+                </widget>
1976
+               </item>
1977
+               <item row="4" column="2">
1978
+                <widget class="Line" name="line_10">
1979
+                 <property name="orientation">
1980
+                  <enum>Qt::Horizontal</enum>
1981
+                 </property>
1982
+                </widget>
1983
+               </item>
1984
+               <item row="4" column="0">
1985
+                <widget class="Line" name="line_11">
1986
+                 <property name="orientation">
1987
+                  <enum>Qt::Horizontal</enum>
1988
+                 </property>
1989
+                </widget>
1990
+               </item>
1991
+               <item row="4" column="3">
1992
+                <widget class="Line" name="line_12">
1993
+                 <property name="orientation">
1994
+                  <enum>Qt::Horizontal</enum>
1995
+                 </property>
1996
+                </widget>
1997
+               </item>
1907 1998
               </layout>
1908 1999
              </widget>
1909 2000
             </item>
@@ -1937,16 +2028,10 @@ background: dark grey;
1937 2028
                <bool>true</bool>
1938 2029
               </property>
1939 2030
               <layout class="QGridLayout" name="gridLayout_16">
1940
-               <item row="0" column="1">
1941
-                <widget class="QSpinBox" name="GPDspinBox">
1942
-                 <property name="minimum">
1943
-                  <number>6</number>
1944
-                 </property>
1945
-                 <property name="maximum">
1946
-                  <number>30</number>
1947
-                 </property>
1948
-                 <property name="value">
1949
-                  <number>20</number>
2031
+               <item row="0" column="0">
2032
+                <widget class="QLabel" name="label_53">
2033
+                 <property name="text">
2034
+                  <string>Gates per decade </string>
1950 2035
                  </property>
1951 2036
                 </widget>
1952 2037
                </item>
@@ -1966,13 +2051,6 @@ background: dark grey;
1966 2051
                  </property>
1967 2052
                 </widget>
1968 2053
                </item>
1969
-               <item row="0" column="0">
1970
-                <widget class="QLabel" name="label_53">
1971
-                 <property name="text">
1972
-                  <string>Gates per decade </string>
1973
-                 </property>
1974
-                </widget>
1975
-               </item>
1976 2054
                <item row="1" column="3">
1977 2055
                 <widget class="QPushButton" name="plotGI">
1978 2056
                  <property name="enabled">
@@ -1995,6 +2073,19 @@ background: dark grey;
1995 2073
                  </property>
1996 2074
                 </widget>
1997 2075
                </item>
2076
+               <item row="0" column="1">
2077
+                <widget class="QSpinBox" name="GPDspinBox">
2078
+                 <property name="minimum">
2079
+                  <number>6</number>
2080
+                 </property>
2081
+                 <property name="maximum">
2082
+                  <number>30</number>
2083
+                 </property>
2084
+                 <property name="value">
2085
+                  <number>20</number>
2086
+                 </property>
2087
+                </widget>
2088
+               </item>
1998 2089
                <item row="1" column="2">
1999 2090
                 <widget class="QComboBox" name="QDType_2">
2000 2091
                  <item>

+ 20
- 16
akvo/tressel/decay.py Bestand weergeven

@@ -60,9 +60,8 @@ def fun(x, t, y):
60 60
         x[3] = T2
61 61
     """
62 62
     # concatenated real and imaginary parts  
63
-    pre =  np.concatenate((-x[0]*np.sin(2.*np.pi*x[2]*t + x[1])*np.exp(-t/x[3]), \
64
-                           +x[0]*np.cos(2.*np.pi*x[2]*t + x[1])*np.exp(-t/x[3])))  
65
-    return y-pre
63
+    return y - np.concatenate((-x[0]*np.sin(2.*np.pi*x[2]*t + x[1])*np.exp(-t/x[3]), \
64
+                               +x[0]*np.cos(2.*np.pi*x[2]*t + x[1])*np.exp(-t/x[3])))  
66 65
 
67 66
 def fun2(x, t, y):
68 67
     """ Cost function for regression, single exponential, no DC term 
@@ -72,32 +71,37 @@ def fun2(x, t, y):
72 71
     """
73 72
     # concatenated real and imaginary parts  
74 73
     pre =  np.concatenate((x[0]*np.cos(x[1])*np.exp(-t/x[2]), \
75
-                       -1.*x[0]*np.sin(x[1])*np.exp(-t/x[2])))  
74
+                          -x[0]*np.sin(x[1])*np.exp(-t/x[2])))  
76 75
     return y-pre
77 76
 
78 77
 
79
-def quadratureDetect2(X, Y, tt, x0="None"): 
78
+def quadratureDetect2(X, Y, tt, method, loss, x0="None"): 
80 79
     """ Pure python quadrature detection using Scipy.  
81 80
         X = real part of NMR signal 
82 81
         Y = imaginary component of NMR signal 
83 82
         tt = time 
84 83
     """
85
-    print("Pure Python Quad Det", "TODO look at loss functions and method")
86
-    # Loss functions, linear, soft_l1, huber, cauchy, arctan 
87
-    # df
88
-    loss = 'cauchy'  #  'soft_l1'
89
-    method = 'trf'   # trf, dogbox, lm 
84
+
85
+    #method = ['trf','dogbox','lm'][method_int]
86
+    #loss = ['linear','soft_l1','cauchy','huber'][loss_int] 
87
+    print ("method", method, 'loss', loss) 
90 88
     if x0=="None":
91
-        x0 = np.array( [1., 0., 0., .2] ) # A0, zeta, df, T2 
92
-        res_lsq = least_squares(fun, x0, args=(tt, np.concatenate((X, Y))), loss=loss, f_scale=1.0,\
93
-            bounds=( [1., -np.pi, -5, .005] , [1000., np.pi, 5, .800] ),
94
-            method=method 
95
-            )
89
+        if method == 'lm':
90
+            x0 = np.array( [50., 0., 0., .200] ) # A0, zeta, df, T2 
91
+            res_lsq = least_squares(fun, x0, args=(tt, np.concatenate((X, Y))), loss=loss, f_scale=1.0,\
92
+                    method=method 
93
+                    )
94
+        else:
95
+            x0 = np.array( [50., 0., 0., .200] ) # A0, zeta, df, T2 
96
+            res_lsq = least_squares(fun, x0, args=(tt, np.concatenate((X, Y))), loss=loss, f_scale=1.0,\
97
+                    bounds=( [5, -np.pi, -5, .001] , [1000., np.pi, 5, .800] ),
98
+                    method=method 
99
+                    )
96 100
         x = res_lsq.x 
97 101
         print ("A0={} zeta={} df={} T2={}".format(x[0],x[1],x[2],x[3]))
98 102
     else:
99 103
         res_lsq = least_squares(fun, x0, args=(tt, np.concatenate((X, Y))), loss=loss, f_scale=1.0,\
100
-            bounds=( [1., -np.pi, -5, .005] , [1000., np.pi, 5, .800] ),
104
+            #bounds=( [1., -np.pi, -5, .005] , [1000., np.pi, 5, .800] ),
101 105
             method=method 
102 106
             )
103 107
 

+ 1
- 1
akvo/tressel/harmonic.py Bestand weergeven

@@ -40,7 +40,7 @@ def harmonicNorm (f0, sN, fs, t, k1, kN, ks):
40 40
 def minHarmonic(sN, fs, t, f0, k1, kN, ks):
41 41
     # CG, BFGS, Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr
42 42
     res = minimize(harmonicNorm, np.array((f0)), args=(sN, fs, t, k1, kN, ks), jac='2-point', method='BFGS') # hess=None, bounds=None )
43
-    print(res)
43
+    #print(res)
44 44
     return harmonicEuler(sN, fs, t, res.x[0], k1, kN, ks)#[0]
45 45
 
46 46
 def harmonicEuler2 ( sN, fs, t, f0, f0k1, f0kN, f0ks, f1, f1k1, f1kN, f1ks ): 

+ 57
- 18
akvo/tressel/mrsurvey.py Bestand weergeven

@@ -540,7 +540,7 @@ class GMRDataProcessor(SNMRDataProcessor):
540 540
     #def harmonicModel(self, nF, nK, f0, f1, plot, canvas):
541 541
     
542 542
     def harmonicModel(self, nF, \
543
-        f0, f0K1, f0KN, f0Ks,  \
543
+        f0, f0K1, f0KN, f0Ks, f0ns, \
544 544
         f1, f1K1, f1KN, f1Ks,  \
545 545
         plot, canvas):
546 546
         """ nF = number of base frequencies, must be 1 or 2 
@@ -548,6 +548,7 @@ class GMRDataProcessor(SNMRDataProcessor):
548 548
             f0K1 = first harmonic to model for first base frequency 
549 549
             f0KN = last harmonic to model for the first base frequency 
550 550
             f0Ks = subharmonic spacing, set to 1 for no subharmonics.
551
+            f0Ns = number of segments for f0
551 552
             f1 = second base frequency  
552 553
             f1K1 = first harmonic to model for second base frequency 
553 554
             f1KN = last harmonic to model for the second base frequency 
@@ -566,28 +567,47 @@ class GMRDataProcessor(SNMRDataProcessor):
566 567
 
567 568
         # Data
568 569
         iFID = 0
570
+
569 571
         for pulse in self.DATADICT["PULSES"]:
570 572
             self.DATADICT[pulse]["TIMES"] =  self.DATADICT[pulse]["TIMES"]
573
+
571 574
             for ipm in range(self.DATADICT["nPulseMoments"]):
572 575
                 for istack in self.DATADICT["stacks"]:
573 576
                     canvas.ax1.clear()
574 577
                     canvas.ax2.clear()
575 578
                     #for ichan in np.append(self.DATADICT[pulse]["chan"], self.DATADICT[pulse]["rchan"]):
576 579
                     for ichan in self.DATADICT[pulse]["rchan"]:
577
-                        
578 580
                         if plot:
579 581
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
580 582
                                 label = "orig " +  pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " rchan="  + str(ichan))
581 583
 
582 584
                         if nF == 1:
583 585
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
584
-                            self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
585
-                                f0, f0K1, f0KN, f0Ks ) 
586
+                            for iseg in range(f0ns):
587
+                                if iseg < f0ns-2:
588
+                                    Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
589
+                                else:
590
+                                    Nseg = int( np.ceil(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
591
+                                self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], \
592
+                                            self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
593
+                                            f0, f0K1, f0KN, f0Ks ) 
594
+
595
+                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
596
+                            #    f0, f0K1, f0KN, f0Ks ) 
586 597
                         elif nF == 2:
587 598
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic2( f0-1e-2, f1+1e-2, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
588
-                            self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
589
-                                f0-1e-2, f0K1, f0KN, f0Ks,  \
590
-                                f1+1e-2, f1K1, f1KN, f1Ks ) 
599
+                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
600
+                            #    f0-1e-2, f0K1, f0KN, f0Ks,  \
601
+                            #    f1+1e-2, f1K1, f1KN, f1Ks ) 
602
+                            for iseg in range(f0ns):
603
+                                if iseg < f0ns-2:
604
+                                    Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
605
+                                else:
606
+                                    Nseg = int( np.ceil(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
607
+                                self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg],\
608
+                                     self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
609
+                                     f0-1e-2, f0K1, f0KN, f0Ks,  \
610
+                                     f1+1e-2, f1K1, f1KN, f1Ks ) 
591 611
                         # plot
592 612
                         if plot:
593 613
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
@@ -601,14 +621,31 @@ class GMRDataProcessor(SNMRDataProcessor):
601 621
                         
602 622
                         if nF == 1:
603 623
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
604
-                            self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
605
-                                f0, f0K1, f0KN, f0Ks ) 
624
+                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
625
+                            #    f0, f0K1, f0KN, f0Ks ) 
626
+                            for iseg in range(f0ns):
627
+                                if iseg < f0ns-2:
628
+                                    Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
629
+                                else:
630
+                                    Nseg = int( np.ceil(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
631
+                                self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], 
632
+                                            self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
633
+                                            f0, f0K1, f0KN, f0Ks ) 
606 634
                         elif nF == 2:
607 635
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic2( f0-1e-2, f1+1e-2, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
608
-                        #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.harmonicEuler( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 20, self.DATADICT[pulse]["TIMES"] ) 
609
-                            self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
610
-                                f0-1e-2, f0K1, f0KN, f0Ks,  \
611
-                                f1+1e-2, f1K1, f1KN, f1Ks ) 
636
+                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.harmonicEuler( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 20, self.DATADICT[pulse]["TIMES"] ) 
637
+                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
638
+                            #    f0-1e-2, f0K1, f0KN, f0Ks,  \
639
+                            #    f1+1e-2, f1K1, f1KN, f1Ks ) 
640
+                            for iseg in range(f0ns):
641
+                                if iseg < f0ns-2:
642
+                                    Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
643
+                                else:
644
+                                    Nseg = int( np.ceil(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
645
+                                self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg],\
646
+                                     self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
647
+                                     f0-1e-2, f0K1, f0KN, f0Ks,  \
648
+                                     f1+1e-2, f1K1, f1KN, f1Ks ) 
612 649
                
613 650
                         # plot
614 651
                         if plot:
@@ -901,7 +938,7 @@ class GMRDataProcessor(SNMRDataProcessor):
901 938
 #                             self.DATADICT[pulse][chsum][ipm][istack] = self.DATADICT[pulse][chans[ich]][ipm][istack] + self.DATADICT[pulse][ch][ipm][istack] 
902 939
         self.doneTrigger.emit() 
903 940
 
904
-    def quadDet(self, clip, phase, canvas):
941
+    def quadDet(self, clip, method, loss, canvas):
905 942
 
906 943
         from scipy import signal
907 944
         self.RotatedAmplitude = True 
@@ -960,10 +997,10 @@ class GMRDataProcessor(SNMRDataProcessor):
960 997
                     #############################################################
961 998
                     # Rotated amplitude
962 999
                     #if ipm != 0:
963
-                    #[success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], (E0,phi,df,T2))
1000
+                    #    [success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], (E0,phi,df,T2))
964 1001
                     #[success, E0, df, phi, T2] = decay.quadratureDetect( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"] )
965 1002
                     #else:
966
-                    [success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"])
1003
+                    [success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], method, loss)
967 1004
                     #[success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], (E0,phi,df,T2))
968 1005
                     #[success, E0, df, phi, T2] = decay.quadratureDetect( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"] )
969 1006
                     #print("success", success, "E0", E0, "phi", phi, "df", df, "T2", T2)
@@ -1591,7 +1628,6 @@ class GMRDataProcessor(SNMRDataProcessor):
1591 1628
         for pulse in self.DATADICT["PULSES"]:
1592 1629
             H[pulse] = {}
1593 1630
             for ichan in self.DATADICT[pulse]["chan"]:
1594
-                print("setting H", pulse, ichan)
1595 1631
                 H[pulse][ichan] = np.zeros(M)
1596 1632
         
1597 1633
         iFID = 0 
@@ -2371,7 +2407,10 @@ class GMRDataProcessor(SNMRDataProcessor):
2371 2407
         fnames = []
2372 2408
         for istack in procStacks:
2373 2409
             if self.nDAQVersion <= 1.0:
2374
-                self.loadGMRASCIIFID( base + "_" + str(istack) + ".lvm", istack )
2410
+                try:
2411
+                    self.loadGMRASCIIFID( base + "_" + str(istack), istack )
2412
+                except:
2413
+                    self.loadGMRASCIIFID( base + "_" + str(istack) + ".lvm", istack )
2375 2414
             elif self.nDAQVersion < 2.3:
2376 2415
                 #rawfname = base + "_" + str(istack) 
2377 2416
                 self.loadGMRASCIIFID( base + "_" + str(istack), istack )

+ 1
- 1
setup.py Bestand weergeven

@@ -21,7 +21,7 @@ with open("README.md", "r") as fh:
21 21
     long_description = fh.read()
22 22
 
23 23
 setup(name='Akvo',
24
-      version='1.2.4',
24
+      version='1.2.5',
25 25
       description='Surface nuclear magnetic resonance workbench',
26 26
       long_description=long_description,
27 27
       long_description_content_type='text/markdown',

Laden…
Annuleren
Opslaan