Browse Source

segmentation added to harmonic noise canc.

tags/1.6.1
Trevor Irons 5 years ago
parent
commit
886a0ce9c5
6 changed files with 440 additions and 288 deletions
  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 View File

694
         #    self.YamlNode.Processing["Saved"] = []
694
         #    self.YamlNode.Processing["Saved"] = []
695
         #self.YamlNode.Processing["Saved"].append(datetime.datetime.now().isoformat()) 
695
         #self.YamlNode.Processing["Saved"].append(datetime.datetime.now().isoformat()) 
696
         #self.Log()
696
         #self.Log()
697
- 
697
+        
698
         import pickle, os 
698
         import pickle, os 
699
         try:
699
         try:
700
             with open('.akvo.last.path') as f: 
700
             with open('.akvo.last.path') as f: 
725
         INFO["deadTime"] = self.RAWDataProc.deadTime
725
         INFO["deadTime"] = self.RAWDataProc.deadTime
726
         INFO["transFreq"] = self.RAWDataProc.transFreq
726
         INFO["transFreq"] = self.RAWDataProc.transFreq
727
         INFO["headerstr"] = str(self.headerstr)
727
         INFO["headerstr"] = str(self.headerstr)
728
+        INFO["nDAQVersion"] = self.RAWDataProc.nDAQVersion
728
         INFO["log"] = yaml.dump( self.YamlNode )  #self.logText  #MAK 20170127
729
         INFO["log"] = yaml.dump( self.YamlNode )  #self.logText  #MAK 20170127
729
-    
730
+          
731
+
730
         self.RAWDataProc.DATADICT["INFO"] = INFO 
732
         self.RAWDataProc.DATADICT["INFO"] = INFO 
731
 
733
 
732
         pickle.dump(self.RAWDataProc.DATADICT, save)
734
         pickle.dump(self.RAWDataProc.DATADICT, save)
779
         self.RAWDataProc.nPulseMoments = self.RAWDataProc.DATADICT["INFO"]["nPulseMoments"] 
781
         self.RAWDataProc.nPulseMoments = self.RAWDataProc.DATADICT["INFO"]["nPulseMoments"] 
780
         self.RAWDataProc.deadTime = self.RAWDataProc.DATADICT["INFO"]["deadTime"] 
782
         self.RAWDataProc.deadTime = self.RAWDataProc.DATADICT["INFO"]["deadTime"] 
781
         self.RAWDataProc.transFreq = self.RAWDataProc.DATADICT["INFO"]["transFreq"]
783
         self.RAWDataProc.transFreq = self.RAWDataProc.DATADICT["INFO"]["transFreq"]
784
+        self.RAWDataProc.nDAQVersion = self.RAWDataProc.DATADICT["INFO"]["nDAQVersion"]
782
         self.RAWDataProc.dt = 1./self.RAWDataProc.samp 
785
         self.RAWDataProc.dt = 1./self.RAWDataProc.samp 
783
 
786
 
784
 
787
 
1138
         if "Harmonic modelling" not in self.YamlNode.Processing.keys():
1141
         if "Harmonic modelling" not in self.YamlNode.Processing.keys():
1139
             self.YamlNode.Processing["Harmonic modelling"] = {}
1142
             self.YamlNode.Processing["Harmonic modelling"] = {}
1140
             self.YamlNode.Processing["Harmonic modelling"]["NF"] = str( self.ui.NHarmonicsFreqsSpin.value() ) 
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
             self.YamlNode.Processing["Harmonic modelling"]["f0K1"] = str( self.ui.f0K1Spin.value() )
1145
             self.YamlNode.Processing["Harmonic modelling"]["f0K1"] = str( self.ui.f0K1Spin.value() )
1142
             self.YamlNode.Processing["Harmonic modelling"]["f0KN"] = str( self.ui.f0KNSpin.value() )
1146
             self.YamlNode.Processing["Harmonic modelling"]["f0KN"] = str( self.ui.f0KNSpin.value() )
1143
             self.YamlNode.Processing["Harmonic modelling"]["f0Ks"] = str( self.ui.f0KsSpin.value() )
1147
             self.YamlNode.Processing["Harmonic modelling"]["f0Ks"] = str( self.ui.f0KsSpin.value() )
1144
             self.YamlNode.Processing["Harmonic modelling"]["f0"] = str( self.ui.f0Spin.value() )
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
             self.Log()
1154
             self.Log()
1151
         else:
1155
         else:
1152
             err_msg = "Harmonic modelling noise cancellation has already been applied!"
1156
             err_msg = "Harmonic modelling noise cancellation has already been applied!"
1163
                  self.ui.f0K1Spin.value(), \
1167
                  self.ui.f0K1Spin.value(), \
1164
                  self.ui.f0KNSpin.value(), \
1168
                  self.ui.f0KNSpin.value(), \
1165
                  self.ui.f0KsSpin.value(), \
1169
                  self.ui.f0KsSpin.value(), \
1170
+                 self.ui.NSegments.value(), \
1166
                  self.ui.f1Spin.value(), \
1171
                  self.ui.f1Spin.value(), \
1167
                  self.ui.f1K1Spin.value(), \
1172
                  self.ui.f1K1Spin.value(), \
1168
                  self.ui.f1KNSpin.value(), \
1173
                  self.ui.f1KNSpin.value(), \
1279
 
1284
 
1280
     def quadDet(self):
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
         self.lock("quadrature detection")
1310
         self.lock("quadrature detection")
1293
         thread.start_new_thread(self.RAWDataProc.quadDet, \
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
         self.ui.plotQD.setEnabled(True)
1314
         self.ui.plotQD.setEnabled(True)
1297
     
1315
     

+ 326
- 235
akvo/gui/main.ui View File

519
                   <number>1</number>
519
                   <number>1</number>
520
                  </property>
520
                  </property>
521
                  <property name="maximum">
521
                  <property name="maximum">
522
-                  <double>1000.000000000000000</double>
522
+                  <double>1200.000000000000000</double>
523
                  </property>
523
                  </property>
524
                  <property name="value">
524
                  <property name="value">
525
                   <double>600.000000000000000</double>
525
                   <double>600.000000000000000</double>
702
                   <double>100.000000000000000</double>
702
                   <double>100.000000000000000</double>
703
                  </property>
703
                  </property>
704
                  <property name="maximum">
704
                  <property name="maximum">
705
-                  <double>1000.000000000000000</double>
705
+                  <double>1600.000000000000000</double>
706
                  </property>
706
                  </property>
707
                  <property name="value">
707
                  <property name="value">
708
                   <double>280.000000000000000</double>
708
                   <double>280.000000000000000</double>
722
                   <double>25.000000000000000</double>
722
                   <double>25.000000000000000</double>
723
                  </property>
723
                  </property>
724
                  <property name="maximum">
724
                  <property name="maximum">
725
-                  <double>500.000000000000000</double>
725
+                  <double>600.000000000000000</double>
726
                  </property>
726
                  </property>
727
                  <property name="singleStep">
727
                  <property name="singleStep">
728
                   <double>5.000000000000000</double>
728
                   <double>5.000000000000000</double>
1021
                <bool>true</bool>
1021
                <bool>true</bool>
1022
               </property>
1022
               </property>
1023
               <layout class="QGridLayout" name="gridLayout_9">
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
                <item row="0" column="0">
1024
                <item row="0" column="0">
1057
                 <widget class="QLabel" name="label_26">
1025
                 <widget class="QLabel" name="label_26">
1058
                  <property name="text">
1026
                  <property name="text">
1060
                  </property>
1028
                  </property>
1061
                 </widget>
1029
                 </widget>
1062
                </item>
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
                  </property>
1035
                  </property>
1068
-                </widget>
1069
-               </item>
1070
-               <item row="2" column="1">
1071
-                <widget class="QDoubleSpinBox" name="f0Spin">
1072
                  <property name="maximum">
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
                  </property>
1038
                  </property>
1078
                  <property name="value">
1039
                  <property name="value">
1079
-                  <double>60.000000000000000</double>
1040
+                  <number>1</number>
1080
                  </property>
1041
                  </property>
1081
                 </widget>
1042
                 </widget>
1082
                </item>
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
                  </property>
1048
                  </property>
1088
                  <property name="value">
1049
                  <property name="value">
1089
-                  <double>60.000000000000000</double>
1050
+                  <number>40</number>
1090
                  </property>
1051
                  </property>
1091
                 </widget>
1052
                 </widget>
1092
                </item>
1053
                </item>
1093
                <item row="4" column="1">
1054
                <item row="4" column="1">
1094
-                <widget class="QSpinBox" name="f0KNSpin">
1055
+                <widget class="QSpinBox" name="f0K1Spin">
1095
                  <property name="minimum">
1056
                  <property name="minimum">
1096
-                  <number>2</number>
1057
+                  <number>1</number>
1058
+                 </property>
1059
+                 <property name="maximum">
1060
+                  <number>50</number>
1097
                  </property>
1061
                  </property>
1098
                  <property name="value">
1062
                  <property name="value">
1099
-                  <number>40</number>
1063
+                  <number>1</number>
1100
                  </property>
1064
                  </property>
1101
                 </widget>
1065
                 </widget>
1102
                </item>
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
                  <property name="styleSheet">
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
   color: grey;
1076
   color: grey;
1113
   background: dark grey;
1077
   background: dark grey;
1114
 }</string>
1078
 }</string>
1115
                  </property>
1079
                  </property>
1116
                 </widget>
1080
                 </widget>
1117
                </item>
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
                <item row="6" column="2">
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
                  </property>
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
                  </property>
1097
                  </property>
1151
                 </widget>
1098
                 </widget>
1152
                </item>
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
                  </property>
1104
                  </property>
1158
                 </widget>
1105
                 </widget>
1159
                </item>
1106
                </item>
1160
-               <item row="10" column="1">
1107
+               <item row="12" column="1">
1161
                 <widget class="QSpinBox" name="f1KsSpin">
1108
                 <widget class="QSpinBox" name="f1KsSpin">
1162
                  <property name="minimum">
1109
                  <property name="minimum">
1163
                   <number>1</number>
1110
                   <number>1</number>
1167
                  </property>
1114
                  </property>
1168
                 </widget>
1115
                 </widget>
1169
                </item>
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
                  <property name="text">
1126
                  <property name="text">
1173
-                  <string>Last harmonic 1</string>
1127
+                  <string>Last harmonic 2</string>
1174
                  </property>
1128
                  </property>
1175
                 </widget>
1129
                 </widget>
1176
                </item>
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
                  </property>
1143
                  </property>
1182
                 </widget>
1144
                 </widget>
1183
                </item>
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
                  </property>
1158
                  </property>
1189
                 </widget>
1159
                 </widget>
1190
                </item>
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
                  <property name="styleSheet">
1163
                  <property name="styleSheet">
1194
-                  <string notr="true">#lcdf0NK { 
1164
+                  <string notr="true">#lcdH1F2{ 
1195
  color: green;
1165
  color: green;
1196
  background: black;
1166
  background: black;
1197
 }
1167
 }
1198
 
1168
 
1199
-#lcdf0NK:disabled {
1169
+#lcdH1F2:disabled {
1200
   color: grey;
1170
   color: grey;
1201
   background: dark grey;
1171
   background: dark grey;
1202
 }</string>
1172
 }</string>
1203
                  </property>
1173
                  </property>
1204
-                 <property name="intValue" stdset="0">
1205
-                  <number>0</number>
1206
-                 </property>
1207
                 </widget>
1174
                 </widget>
1208
                </item>
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
                  <property name="text">
1178
                  <property name="text">
1212
-                  <string>Base freq. 2 </string>
1179
+                  <string>Sub-harmonics</string>
1213
                  </property>
1180
                  </property>
1214
                 </widget>
1181
                 </widget>
1215
                </item>
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
                  <property name="minimum">
1185
                  <property name="minimum">
1219
                   <number>1</number>
1186
                   <number>1</number>
1220
                  </property>
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
                  </property>
1194
                  </property>
1227
                 </widget>
1195
                 </widget>
1228
                </item>
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
                  <property name="orientation">
1199
                  <property name="orientation">
1232
                   <enum>Qt::Horizontal</enum>
1200
                   <enum>Qt::Horizontal</enum>
1233
                  </property>
1201
                  </property>
1234
                 </widget>
1202
                 </widget>
1235
                </item>
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
                  </property>
1208
                  </property>
1209
+                </widget>
1210
+               </item>
1211
+               <item row="3" column="1">
1212
+                <widget class="QDoubleSpinBox" name="f0Spin">
1241
                  <property name="maximum">
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
                  </property>
1218
                  </property>
1244
                  <property name="value">
1219
                  <property name="value">
1245
-                  <number>1</number>
1220
+                  <double>60.000000000000000</double>
1246
                  </property>
1221
                  </property>
1247
                 </widget>
1222
                 </widget>
1248
                </item>
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
                  <property name="maximum">
1226
                  <property name="maximum">
1258
-                  <number>3</number>
1227
+                  <double>25000.000000000000000</double>
1259
                  </property>
1228
                  </property>
1260
                  <property name="value">
1229
                  <property name="value">
1261
-                  <number>1</number>
1230
+                  <double>60.000000000000000</double>
1262
                  </property>
1231
                  </property>
1263
                 </widget>
1232
                 </widget>
1264
                </item>
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
                  </property>
1238
                  </property>
1270
                 </widget>
1239
                 </widget>
1271
                </item>
1240
                </item>
1272
-               <item row="13" column="2">
1241
+               <item row="15" column="2">
1273
                 <widget class="QPushButton" name="harmonicGO">
1242
                 <widget class="QPushButton" name="harmonicGO">
1274
                  <property name="layoutDirection">
1243
                  <property name="layoutDirection">
1275
                   <enum>Qt::LeftToRight</enum>
1244
                   <enum>Qt::LeftToRight</enum>
1276
                  </property>
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
                  </property>
1265
                  </property>
1281
-                 <property name="text">
1282
-                  <string>GO</string>
1266
+                 <property name="value">
1267
+                  <number>1</number>
1283
                  </property>
1268
                  </property>
1284
                 </widget>
1269
                 </widget>
1285
                </item>
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
                  </property>
1275
                  </property>
1291
                 </widget>
1276
                 </widget>
1292
                </item>
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
                  </property>
1282
                  </property>
1298
                 </widget>
1283
                 </widget>
1299
                </item>
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
                  </property>
1289
                  </property>
1313
                 </widget>
1290
                 </widget>
1314
                </item>
1291
                </item>
1315
-               <item row="9" column="2">
1292
+               <item row="11" column="2">
1316
                 <widget class="QLCDNumber" name="lcdHNF2">
1293
                 <widget class="QLCDNumber" name="lcdHNF2">
1317
                  <property name="styleSheet">
1294
                  <property name="styleSheet">
1318
                   <string notr="true">#lcdHNF2 { 
1295
                   <string notr="true">#lcdHNF2 { 
1327
                  </property>
1304
                  </property>
1328
                 </widget>
1305
                 </widget>
1329
                </item>
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
                  </property>
1314
                  </property>
1343
                 </widget>
1315
                 </widget>
1344
                </item>
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
                  <property name="text">
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
                  </property>
1324
                  </property>
1350
                 </widget>
1325
                 </widget>
1351
                </item>
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
                  <property name="text">
1343
                  <property name="text">
1355
-                  <string>Sub-harmonics</string>
1344
+                  <string>Sub-harmonics </string>
1356
                  </property>
1345
                  </property>
1357
                 </widget>
1346
                 </widget>
1358
                </item>
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
                  <property name="minimum">
1371
                  <property name="minimum">
1362
-                  <number>2</number>
1372
+                  <number>1</number>
1373
+                 </property>
1374
+                 <property name="maximum">
1375
+                  <number>10</number>
1363
                  </property>
1376
                  </property>
1364
                  <property name="value">
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
                  </property>
1386
                  </property>
1367
                 </widget>
1387
                 </widget>
1368
                </item>
1388
                </item>
1830
                <bool>true</bool>
1850
                <bool>true</bool>
1831
               </property>
1851
               </property>
1832
               <layout class="QGridLayout" name="gridLayout_15">
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
                <item row="2" column="2">
1853
                <item row="2" column="2">
1850
-                <widget class="QComboBox" name="QDType">
1854
+                <widget class="QComboBox" name="QDMethod">
1851
                  <item>
1855
                  <item>
1852
                   <property name="text">
1856
                   <property name="text">
1853
-                   <string>Real/Imag</string>
1857
+                   <string>Trust region reflective</string>
1854
                   </property>
1858
                   </property>
1855
                  </item>
1859
                  </item>
1856
                  <item>
1860
                  <item>
1857
                   <property name="text">
1861
                   <property name="text">
1858
-                   <string>Amp/Phase</string>
1862
+                   <string>Dogbox</string>
1859
                   </property>
1863
                   </property>
1860
                  </item>
1864
                  </item>
1861
                  <item>
1865
                  <item>
1862
                   <property name="text">
1866
                   <property name="text">
1863
-                   <string>Phased</string>
1867
+                   <string>Levenberg-Marquardt</string>
1864
                   </property>
1868
                   </property>
1865
                  </item>
1869
                  </item>
1866
                 </widget>
1870
                 </widget>
1867
                </item>
1871
                </item>
1868
-               <item row="2" column="3">
1872
+               <item row="5" column="3">
1869
                 <widget class="QPushButton" name="plotQD">
1873
                 <widget class="QPushButton" name="plotQD">
1870
                  <property name="enabled">
1874
                  <property name="enabled">
1871
                   <bool>false</bool>
1875
                   <bool>false</bool>
1887
                  </property>
1891
                  </property>
1888
                 </widget>
1892
                 </widget>
1889
                </item>
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
                <item row="1" column="2">
1901
                <item row="1" column="2">
1891
                 <widget class="QSpinBox" name="trimSpin">
1902
                 <widget class="QSpinBox" name="trimSpin">
1892
                  <property name="minimum">
1903
                  <property name="minimum">
1893
                   <number>0</number>
1904
                   <number>0</number>
1894
                  </property>
1905
                  </property>
1895
                  <property name="value">
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
                  </property>
1924
                  </property>
1898
                 </widget>
1925
                 </widget>
1899
                </item>
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
                <item row="1" column="0">
1946
                <item row="1" column="0">
1901
                 <widget class="QLabel" name="label_38">
1947
                 <widget class="QLabel" name="label_38">
1902
                  <property name="text">
1948
                  <property name="text">
1904
                  </property>
1950
                  </property>
1905
                 </widget>
1951
                 </widget>
1906
                </item>
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
               </layout>
1998
               </layout>
1908
              </widget>
1999
              </widget>
1909
             </item>
2000
             </item>
1937
                <bool>true</bool>
2028
                <bool>true</bool>
1938
               </property>
2029
               </property>
1939
               <layout class="QGridLayout" name="gridLayout_16">
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
                  </property>
2035
                  </property>
1951
                 </widget>
2036
                 </widget>
1952
                </item>
2037
                </item>
1966
                  </property>
2051
                  </property>
1967
                 </widget>
2052
                 </widget>
1968
                </item>
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
                <item row="1" column="3">
2054
                <item row="1" column="3">
1977
                 <widget class="QPushButton" name="plotGI">
2055
                 <widget class="QPushButton" name="plotGI">
1978
                  <property name="enabled">
2056
                  <property name="enabled">
1995
                  </property>
2073
                  </property>
1996
                 </widget>
2074
                 </widget>
1997
                </item>
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
                <item row="1" column="2">
2089
                <item row="1" column="2">
1999
                 <widget class="QComboBox" name="QDType_2">
2090
                 <widget class="QComboBox" name="QDType_2">
2000
                  <item>
2091
                  <item>

+ 20
- 16
akvo/tressel/decay.py View File

60
         x[3] = T2
60
         x[3] = T2
61
     """
61
     """
62
     # concatenated real and imaginary parts  
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
 def fun2(x, t, y):
66
 def fun2(x, t, y):
68
     """ Cost function for regression, single exponential, no DC term 
67
     """ Cost function for regression, single exponential, no DC term 
72
     """
71
     """
73
     # concatenated real and imaginary parts  
72
     # concatenated real and imaginary parts  
74
     pre =  np.concatenate((x[0]*np.cos(x[1])*np.exp(-t/x[2]), \
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
     return y-pre
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
     """ Pure python quadrature detection using Scipy.  
79
     """ Pure python quadrature detection using Scipy.  
81
         X = real part of NMR signal 
80
         X = real part of NMR signal 
82
         Y = imaginary component of NMR signal 
81
         Y = imaginary component of NMR signal 
83
         tt = time 
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
     if x0=="None":
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
         x = res_lsq.x 
100
         x = res_lsq.x 
97
         print ("A0={} zeta={} df={} T2={}".format(x[0],x[1],x[2],x[3]))
101
         print ("A0={} zeta={} df={} T2={}".format(x[0],x[1],x[2],x[3]))
98
     else:
102
     else:
99
         res_lsq = least_squares(fun, x0, args=(tt, np.concatenate((X, Y))), loss=loss, f_scale=1.0,\
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
             method=method 
105
             method=method 
102
             )
106
             )
103
 
107
 

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

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

+ 57
- 18
akvo/tressel/mrsurvey.py View File

540
     #def harmonicModel(self, nF, nK, f0, f1, plot, canvas):
540
     #def harmonicModel(self, nF, nK, f0, f1, plot, canvas):
541
     
541
     
542
     def harmonicModel(self, nF, \
542
     def harmonicModel(self, nF, \
543
-        f0, f0K1, f0KN, f0Ks,  \
543
+        f0, f0K1, f0KN, f0Ks, f0ns, \
544
         f1, f1K1, f1KN, f1Ks,  \
544
         f1, f1K1, f1KN, f1Ks,  \
545
         plot, canvas):
545
         plot, canvas):
546
         """ nF = number of base frequencies, must be 1 or 2 
546
         """ nF = number of base frequencies, must be 1 or 2 
548
             f0K1 = first harmonic to model for first base frequency 
548
             f0K1 = first harmonic to model for first base frequency 
549
             f0KN = last harmonic to model for the first base frequency 
549
             f0KN = last harmonic to model for the first base frequency 
550
             f0Ks = subharmonic spacing, set to 1 for no subharmonics.
550
             f0Ks = subharmonic spacing, set to 1 for no subharmonics.
551
+            f0Ns = number of segments for f0
551
             f1 = second base frequency  
552
             f1 = second base frequency  
552
             f1K1 = first harmonic to model for second base frequency 
553
             f1K1 = first harmonic to model for second base frequency 
553
             f1KN = last harmonic to model for the second base frequency 
554
             f1KN = last harmonic to model for the second base frequency 
566
 
567
 
567
         # Data
568
         # Data
568
         iFID = 0
569
         iFID = 0
570
+
569
         for pulse in self.DATADICT["PULSES"]:
571
         for pulse in self.DATADICT["PULSES"]:
570
             self.DATADICT[pulse]["TIMES"] =  self.DATADICT[pulse]["TIMES"]
572
             self.DATADICT[pulse]["TIMES"] =  self.DATADICT[pulse]["TIMES"]
573
+
571
             for ipm in range(self.DATADICT["nPulseMoments"]):
574
             for ipm in range(self.DATADICT["nPulseMoments"]):
572
                 for istack in self.DATADICT["stacks"]:
575
                 for istack in self.DATADICT["stacks"]:
573
                     canvas.ax1.clear()
576
                     canvas.ax1.clear()
574
                     canvas.ax2.clear()
577
                     canvas.ax2.clear()
575
                     #for ichan in np.append(self.DATADICT[pulse]["chan"], self.DATADICT[pulse]["rchan"]):
578
                     #for ichan in np.append(self.DATADICT[pulse]["chan"], self.DATADICT[pulse]["rchan"]):
576
                     for ichan in self.DATADICT[pulse]["rchan"]:
579
                     for ichan in self.DATADICT[pulse]["rchan"]:
577
-                        
578
                         if plot:
580
                         if plot:
579
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
581
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
580
                                 label = "orig " +  pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " rchan="  + str(ichan))
582
                                 label = "orig " +  pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " rchan="  + str(ichan))
581
 
583
 
582
                         if nF == 1:
584
                         if nF == 1:
583
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
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
                         elif nF == 2:
597
                         elif nF == 2:
587
                             #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"] ) 
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
                         # plot
611
                         # plot
592
                         if plot:
612
                         if plot:
593
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
613
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
601
                         
621
                         
602
                         if nF == 1:
622
                         if nF == 1:
603
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
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
                         elif nF == 2:
634
                         elif nF == 2:
607
                             #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"] ) 
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
                         # plot
650
                         # plot
614
                         if plot:
651
                         if plot:
901
 #                             self.DATADICT[pulse][chsum][ipm][istack] = self.DATADICT[pulse][chans[ich]][ipm][istack] + self.DATADICT[pulse][ch][ipm][istack] 
938
 #                             self.DATADICT[pulse][chsum][ipm][istack] = self.DATADICT[pulse][chans[ich]][ipm][istack] + self.DATADICT[pulse][ch][ipm][istack] 
902
         self.doneTrigger.emit() 
939
         self.doneTrigger.emit() 
903
 
940
 
904
-    def quadDet(self, clip, phase, canvas):
941
+    def quadDet(self, clip, method, loss, canvas):
905
 
942
 
906
         from scipy import signal
943
         from scipy import signal
907
         self.RotatedAmplitude = True 
944
         self.RotatedAmplitude = True 
960
                     #############################################################
997
                     #############################################################
961
                     # Rotated amplitude
998
                     # Rotated amplitude
962
                     #if ipm != 0:
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
                     #[success, E0, df, phi, T2] = decay.quadratureDetect( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"] )
1001
                     #[success, E0, df, phi, T2] = decay.quadratureDetect( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"] )
965
                     #else:
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
                     #[success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], (E0,phi,df,T2))
1004
                     #[success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], (E0,phi,df,T2))
968
                     #[success, E0, df, phi, T2] = decay.quadratureDetect( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"] )
1005
                     #[success, E0, df, phi, T2] = decay.quadratureDetect( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"] )
969
                     #print("success", success, "E0", E0, "phi", phi, "df", df, "T2", T2)
1006
                     #print("success", success, "E0", E0, "phi", phi, "df", df, "T2", T2)
1591
         for pulse in self.DATADICT["PULSES"]:
1628
         for pulse in self.DATADICT["PULSES"]:
1592
             H[pulse] = {}
1629
             H[pulse] = {}
1593
             for ichan in self.DATADICT[pulse]["chan"]:
1630
             for ichan in self.DATADICT[pulse]["chan"]:
1594
-                print("setting H", pulse, ichan)
1595
                 H[pulse][ichan] = np.zeros(M)
1631
                 H[pulse][ichan] = np.zeros(M)
1596
         
1632
         
1597
         iFID = 0 
1633
         iFID = 0 
2371
         fnames = []
2407
         fnames = []
2372
         for istack in procStacks:
2408
         for istack in procStacks:
2373
             if self.nDAQVersion <= 1.0:
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
             elif self.nDAQVersion < 2.3:
2414
             elif self.nDAQVersion < 2.3:
2376
                 #rawfname = base + "_" + str(istack) 
2415
                 #rawfname = base + "_" + str(istack) 
2377
                 self.loadGMRASCIIFID( base + "_" + str(istack), istack )
2416
                 self.loadGMRASCIIFID( base + "_" + str(istack), istack )

+ 1
- 1
setup.py View File

21
     long_description = fh.read()
21
     long_description = fh.read()
22
 
22
 
23
 setup(name='Akvo',
23
 setup(name='Akvo',
24
-      version='1.2.4',
24
+      version='1.2.5',
25
       description='Surface nuclear magnetic resonance workbench',
25
       description='Surface nuclear magnetic resonance workbench',
26
       long_description=long_description,
26
       long_description=long_description,
27
       long_description_content_type='text/markdown',
27
       long_description_content_type='text/markdown',

Loading…
Cancel
Save