Browse Source

fix for viridis in newest matplotlib

master
Trevor Irons 3 years ago
parent
commit
2ff3d4897a

+ 40
- 6
akvo/gui/akvoGUI.py View File

@@ -1058,9 +1058,9 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1058 1058
         INFO = {}
1059 1059
         INFO["headerstr"] = str(self.headerstr)
1060 1060
         INFO["pulseType"] = self.RAWDataProc.pulseType
1061
-        INFO["transFreq"] = self.RAWDataProc.transFreq.tolist()
1062
-        INFO["pulseLength"] = self.RAWDataProc.pulseLength.tolist()
1063
-        INFO["TuneCapacitance"] = self.RAWDataProc.TuneCapacitance.tolist()
1061
+        INFO["transFreq"] = np.array(self.RAWDataProc.transFreq).tolist()  # numpy is for MIDI datasets
1062
+        INFO["pulseLength"] = np.array(self.RAWDataProc.pulseLength).tolist()
1063
+        INFO["TuneCapacitance"] = np.array(self.RAWDataProc.TuneCapacitance).tolist()
1064 1064
         #INFO["samp"] = self.RAWDataProc.samp
1065 1065
         INFO["nPulseMoments"] = self.RAWDataProc.nPulseMoments
1066 1066
         #INFO["deadTime"] = self.RAWDataProc.deadTime
@@ -1072,6 +1072,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1072 1072
             qq = []
1073 1073
             qv = []
1074 1074
             for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):     
1075
+            #for ipm in self.pulseMoments: 
1075 1076
                 #for istack in self.RAWDataProc.DATADICT["stacks"]:
1076 1077
                 #    print ("stack q", self.RAWDataProc.DATADICT[pulse]["Q"][ipm,istack-1])
1077 1078
                 qq.append(np.mean(    self.RAWDataProc.DATADICT[pulse]["Q"][ipm,:]) )
@@ -1101,6 +1102,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1101 1102
                     #INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] =  VectorXr(   np.std(self.RAWDataProc.GATED[ichan]["NR"], axis=0) )
1102 1103
                     INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] = VectorXr( np.average(self.RAWDataProc.GATED[ichan]["BN"], axis=0) )
1103 1104
                     for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):     
1105
+                    #for ipm in self.pulseMoments: 
1104 1106
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " CA"] = VectorXr(self.RAWDataProc.GATED[ichan]["CA"][ipm])   
1105 1107
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " RE"] = VectorXr(self.RAWDataProc.GATED[ichan]["RE"][ipm])   
1106 1108
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " IM"] = VectorXr(self.RAWDataProc.GATED[ichan]["IM"][ipm])   
@@ -1409,8 +1411,25 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1409 1411
             QtWidgets.QMessageBox.critical(self, 'Error', err_msg) 
1410 1412
             return
1411 1413
 
1414
+        ######################
1415
+        # Qs
1416
+        #####################
1417
+        print("text",  self.ui.QLineEdit.text()) 
1418
+        if  self.ui.QLineEdit.text() == "":
1419
+            self.pulseMoments = [-1]  
1420
+            print("Setting pulse moments to [-1]") 
1421
+        else:
1422
+            try:
1423
+                self.pulseMoments = np.array(eval(str("np.r_["+self.ui.QLineEdit.text())+"]"))
1424
+            except:
1425
+                err_msg = "You need to set your pulse moments correctly.\n" + \
1426
+                      "This should be a Python Numpy interpretable list\n" + \
1427
+                      "of stack indices. For example 1:24 or 1:4,8:24"
1428
+                QtWidgets.QMessageBox.critical(self, 'Error', err_msg) 
1429
+
1430
+        ###################
1412 1431
         # Data Channels
1413
-        #Chan = np.arange(0,9,1)
1432
+        ###################
1414 1433
         try:
1415 1434
             self.dataChan = np.array(eval(str("np.r_["+self.ui.dataChanLineEdit.text())+"]"))
1416 1435
         except:
@@ -1428,6 +1447,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1428 1447
             reply = QtWidgets.QMessageBox.critical(self, 'Error', 
1429 1448
                 err_msg) #, QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
1430 1449
             return
1450
+
1431 1451
         #############################
1432 1452
         # Reference Channels
1433 1453
         # TODO make sure no overlap between data and ref channels
@@ -1451,7 +1471,8 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1451 1471
         self.procThread = thread.start_new_thread(self.RAWDataProc.loadMIDI2, \
1452 1472
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
1453 1473
                  str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
1454
-                1e-3 * self.ui.DeadTimeSpinBox.value( ), self.ui.plotImportCheckBox.isChecked() )) #, self)) 
1474
+                1e-3 * self.ui.DeadTimeSpinBox.value( ), self.pulseMoments,
1475
+                self.ui.plotImportCheckBox.isChecked() )) #, self)) 
1455 1476
 
1456 1477
         self.YamlNode.Import["MIDI Header"] = self.headerstr
1457 1478
         self.YamlNode.Import["opened"] = datetime.datetime.now().isoformat() 
@@ -1511,6 +1532,18 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1511 1532
             QtWidgets.QMessageBox.critical(self, 'Error', err_msg) 
1512 1533
             return
1513 1534
 
1535
+        # Qs
1536
+        if  self.ui.QLineEdit.text() == "Optional":
1537
+            self.pulseMoments = [-1] 
1538
+        else:
1539
+            try:
1540
+                self.pulseMoments = np.array(eval(str("np.r_["+self.ui.QLineEdit.text())+"]"))
1541
+            except:
1542
+                err_msg = "You need to set your pulse moments correctly.\n" + \
1543
+                      "This should be a Python Numpy interpretable list\n" + \
1544
+                      "of stack indices. For example 1:24 or 1:4,8:24"
1545
+                QtWidgets.QMessageBox.critical(self, 'Error', err_msg) 
1546
+
1514 1547
         # Data Channels
1515 1548
         #Chan = np.arange(0,9,1)
1516 1549
         try:
@@ -1555,7 +1588,8 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1555 1588
             self.procThread = thread.start_new_thread(self.RAWDataProc.loadFIDData, \
1556 1589
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
1557 1590
                  str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
1558
-                1e-3 * self.ui.DeadTimeSpinBox.value( ), self.ui.plotImportCheckBox.isChecked() )) #, self)) 
1591
+                1e-3 * self.ui.DeadTimeSpinBox.value( ), 
1592
+                self.ui.plotImportCheckBox.isChecked() )) #, self)) 
1559 1593
         elif self.RAWDataProc.pulseType == "4PhaseT1":
1560 1594
             self.procThread = thread.start_new_thread(self.RAWDataProc.load4PhaseT1Data, \
1561 1595
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \

+ 87
- 67
akvo/gui/main.ui View File

@@ -711,7 +711,7 @@ background: dark grey;
711 711
          <x>0</x>
712 712
          <y>0</y>
713 713
          <width>537</width>
714
-         <height>982</height>
714
+         <height>1025</height>
715 715
         </rect>
716 716
        </property>
717 717
        <property name="sizePolicy">
@@ -824,21 +824,15 @@ background: dark grey;
824 824
                <string>Input parameters</string>
825 825
               </property>
826 826
               <layout class="QGridLayout" name="gridLayout_4">
827
-               <item row="0" column="0">
828
-                <widget class="QLabel" name="label">
829
-                 <property name="toolTip">
830
-                  <string/>
831
-                 </property>
832
-                 <property name="statusTip">
833
-                  <string comment="yo" extracomment="jldafjlk   kldajflj  adlkfjl"/>
834
-                 </property>
827
+               <item row="1" column="0">
828
+                <widget class="QLabel" name="label_23">
835 829
                  <property name="text">
836
-                  <string>Stacks</string>
830
+                  <string>Data Chs.</string>
837 831
                  </property>
838 832
                 </widget>
839 833
                </item>
840
-               <item row="0" column="1">
841
-                <widget class="QLineEdit" name="stacksLineEdit">
834
+               <item row="3" column="1">
835
+                <widget class="QComboBox" name="FIDProcComboBox">
842 836
                  <property name="maximumSize">
843 837
                   <size>
844 838
                    <width>16777215</width>
@@ -846,22 +840,38 @@ background: dark grey;
846 840
                   </size>
847 841
                  </property>
848 842
                  <property name="toolTip">
849
-                  <string notr="true">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the stacks that you would like processed.&lt;/p&gt;&lt;p&gt;This must be a valid set of numpy array indices. Remember that Python uses non end-inclusive indexing. &lt;/p&gt;&lt;p&gt;So things like [1:24] will include stacks 1-23&lt;/p&gt;&lt;p&gt;Furthermore [1:8,12:24] will include stacks 1-7 and 12:23. Any list of valid indices will be accepted, but they must be comma seperated. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
843
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;For T1 or CPMG pulses, which pulse(s) would you like to process. Note that for very short delay T1 pulses, the first pulse may be disabled. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
850 844
                  </property>
851
-                 <property name="placeholderText">
852
-                  <string>required</string>
845
+                </widget>
846
+               </item>
847
+               <item row="3" column="3">
848
+                <widget class="QPushButton" name="loadDataPushButton">
849
+                 <property name="enabled">
850
+                  <bool>false</bool>
851
+                 </property>
852
+                 <property name="styleSheet">
853
+                  <string notr="true">#loadDataPushButton {
854
+    background: green;
855
+}
856
+
857
+#loadDataPushButton:disabled {
858
+    background: black;
859
+}</string>
860
+                 </property>
861
+                 <property name="text">
862
+                  <string>Load Data</string>
853 863
                  </property>
854 864
                 </widget>
855 865
                </item>
856
-               <item row="0" column="2">
857
-                <widget class="QLabel" name="label_24">
866
+               <item row="3" column="0">
867
+                <widget class="QLabel" name="label_29">
858 868
                  <property name="text">
859
-                  <string>Dead time [ms]</string>
869
+                  <string>Process FID</string>
860 870
                  </property>
861 871
                 </widget>
862 872
                </item>
863
-               <item row="0" column="3">
864
-                <widget class="QDoubleSpinBox" name="DeadTimeSpinBox">
873
+               <item row="1" column="1">
874
+                <widget class="QLineEdit" name="dataChanLineEdit">
865 875
                  <property name="maximumSize">
866 876
                   <size>
867 877
                    <width>16777215</width>
@@ -869,28 +879,28 @@ background: dark grey;
869 879
                   </size>
870 880
                  </property>
871 881
                  <property name="toolTip">
872
-                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is the instrument dead time that is used. You may remove additonal or less dead time as an option. By default Akvo uses the recommended instrument dead times.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
873
-                 </property>
874
-                 <property name="minimum">
875
-                  <double>0.500000000000000</double>
876
-                 </property>
877
-                 <property name="singleStep">
878
-                  <double>0.500000000000000</double>
882
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the data channels that you would like processed.&lt;/p&gt;&lt;p&gt;This must be a valid set of numpy array indices. Remember that Python uses non end-inclusive indexing. &lt;/p&gt;&lt;p&gt;So things like [1:3] will use channels 1 and 2&lt;/p&gt;&lt;p&gt;Any list of valid indices will be accepted, but they must be comma seperated. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
879 883
                  </property>
880
-                 <property name="value">
881
-                  <double>5.000000000000000</double>
884
+                 <property name="placeholderText">
885
+                  <string>required</string>
882 886
                  </property>
883 887
                 </widget>
884 888
                </item>
885
-               <item row="1" column="0">
886
-                <widget class="QLabel" name="label_23">
889
+               <item row="3" column="2">
890
+                <widget class="QCheckBox" name="plotImportCheckBox">
891
+                 <property name="enabled">
892
+                  <bool>false</bool>
893
+                 </property>
887 894
                  <property name="text">
888
-                  <string>Data Chs.</string>
895
+                  <string> Plot RAW</string>
896
+                 </property>
897
+                 <property name="checked">
898
+                  <bool>true</bool>
889 899
                  </property>
890 900
                 </widget>
891 901
                </item>
892
-               <item row="1" column="1">
893
-                <widget class="QLineEdit" name="dataChanLineEdit">
902
+               <item row="0" column="1">
903
+                <widget class="QLineEdit" name="stacksLineEdit">
894 904
                  <property name="maximumSize">
895 905
                   <size>
896 906
                    <width>16777215</width>
@@ -898,7 +908,7 @@ background: dark grey;
898 908
                   </size>
899 909
                  </property>
900 910
                  <property name="toolTip">
901
-                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the data channels that you would like processed.&lt;/p&gt;&lt;p&gt;This must be a valid set of numpy array indices. Remember that Python uses non end-inclusive indexing. &lt;/p&gt;&lt;p&gt;So things like [1:3] will use channels 1 and 2&lt;/p&gt;&lt;p&gt;Any list of valid indices will be accepted, but they must be comma seperated. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
911
+                  <string notr="true">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the stacks that you would like processed.&lt;/p&gt;&lt;p&gt;This must be a valid set of numpy array indices. Remember that Python uses non end-inclusive indexing. &lt;/p&gt;&lt;p&gt;So things like [1:24] will include stacks 1-23&lt;/p&gt;&lt;p&gt;Furthermore [1:8,12:24] will include stacks 1-7 and 12:23. Any list of valid indices will be accepted, but they must be comma seperated. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
902 912
                  </property>
903 913
                  <property name="placeholderText">
904 914
                   <string>required</string>
@@ -931,15 +941,8 @@ background: dark grey;
931 941
                  </property>
932 942
                 </widget>
933 943
                </item>
934
-               <item row="2" column="0">
935
-                <widget class="QLabel" name="label_29">
936
-                 <property name="text">
937
-                  <string>Process FID</string>
938
-                 </property>
939
-                </widget>
940
-               </item>
941
-               <item row="2" column="1">
942
-                <widget class="QComboBox" name="FIDProcComboBox">
944
+               <item row="0" column="3">
945
+                <widget class="QDoubleSpinBox" name="DeadTimeSpinBox">
943 946
                  <property name="maximumSize">
944 947
                   <size>
945 948
                    <width>16777215</width>
@@ -947,39 +950,56 @@ background: dark grey;
947 950
                   </size>
948 951
                  </property>
949 952
                  <property name="toolTip">
950
-                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;For T1 or CPMG pulses, which pulse(s) would you like to process. Note that for very short delay T1 pulses, the first pulse may be disabled. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
953
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is the instrument dead time that is used. You may remove additonal or less dead time as an option. By default Akvo uses the recommended instrument dead times.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
954
+                 </property>
955
+                 <property name="minimum">
956
+                  <double>0.500000000000000</double>
957
+                 </property>
958
+                 <property name="singleStep">
959
+                  <double>0.500000000000000</double>
960
+                 </property>
961
+                 <property name="value">
962
+                  <double>5.000000000000000</double>
951 963
                  </property>
952 964
                 </widget>
953 965
                </item>
954
-               <item row="2" column="2">
955
-                <widget class="QCheckBox" name="plotImportCheckBox">
956
-                 <property name="enabled">
957
-                  <bool>false</bool>
966
+               <item row="0" column="0">
967
+                <widget class="QLabel" name="label">
968
+                 <property name="toolTip">
969
+                  <string/>
970
+                 </property>
971
+                 <property name="statusTip">
972
+                  <string comment="yo" extracomment="jldafjlk   kldajflj  adlkfjl"/>
958 973
                  </property>
959 974
                  <property name="text">
960
-                  <string> Plot RAW</string>
975
+                  <string>Stacks</string>
961 976
                  </property>
962
-                 <property name="checked">
963
-                  <bool>true</bool>
977
+                </widget>
978
+               </item>
979
+               <item row="0" column="2">
980
+                <widget class="QLabel" name="label_24">
981
+                 <property name="text">
982
+                  <string>Dead time [ms]</string>
964 983
                  </property>
965 984
                 </widget>
966 985
                </item>
967
-               <item row="2" column="3">
968
-                <widget class="QPushButton" name="loadDataPushButton">
969
-                 <property name="enabled">
970
-                  <bool>false</bool>
986
+               <item row="2" column="1">
987
+                <widget class="QLineEdit" name="QLineEdit">
988
+                 <property name="toolTip">
989
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If you would like to only process certain pulse moments you can specify the q indices to process. This also uses python conventions, so for instance 0:5,9:14 would process indices 0,1,2,3,4,9,10,11,12,13,14. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
971 990
                  </property>
972
-                 <property name="styleSheet">
973
-                  <string notr="true">#loadDataPushButton {
974
-    background: green;
975
-}
976
-
977
-#loadDataPushButton:disabled {
978
-    background: black;
979
-}</string>
991
+                 <property name="text">
992
+                  <string/>
993
+                 </property>
994
+                 <property name="placeholderText">
995
+                  <string>optional</string>
980 996
                  </property>
997
+                </widget>
998
+               </item>
999
+               <item row="2" column="0">
1000
+                <widget class="QLabel" name="label_87">
981 1001
                  <property name="text">
982
-                  <string>Load Data</string>
1002
+                  <string>Q indices</string>
983 1003
                  </property>
984 1004
                 </widget>
985 1005
                </item>
@@ -4195,8 +4215,8 @@ background: dark grey;
4195 4215
               <rect>
4196 4216
                <x>0</x>
4197 4217
                <y>0</y>
4198
-               <width>411</width>
4199
-               <height>67</height>
4218
+               <width>96</width>
4219
+               <height>26</height>
4200 4220
               </rect>
4201 4221
              </property>
4202 4222
              <attribute name="label">

+ 3
- 2
akvo/terminal/plotyaml.py View File

@@ -99,8 +99,9 @@ def plotQt( akvo ):
99 99
 
100 100
     #plt.matshow(RE)
101 101
     #plt.matshow(IM)
102
-    plt.savefig("data.pdf")
103
-    plt.show()
102
+    plt.savefig("data.pgf")
103
+    plt.savefig("data.png", dpi=300)
104
+    #plt.show()
104 105
 
105 106
 if __name__ == "__main__":
106 107
     akvo = loadAkvoData( sys.argv[1] ) #, "Chan. 1")

+ 3
- 1
akvo/tressel/calcAkvoKernel.py View File

@@ -152,7 +152,9 @@ def main():
152 152
         print( str(kparams["Lspacing"]) )
153 153
         exit()
154 154
 
155
-    iface = np.cumsum(thick)
155
+    print( np.array(kparams["origin_d"]) )
156
+    print( np.cumsum(thick)[0:-1] ) 
157
+    iface = np.concatenate( (np.array( [kparams["origin_d"]] ), kparams["origin_d"]+np.cumsum(thick)[0:-1]) )
156 158
     Kern.SetDepthLayerInterfaces(iface)
157 159
     #Kern.SetDepthLayerInterfaces(np.geomspace(1, 110, num=40))
158 160
     #Kern.SetDepthLayerInterfaces(np.linspace(1, 110, num=50))

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

@@ -94,7 +94,7 @@ def quadratureDetect2(X, Y, tt, method, loss, x0="None"):
94 94
         else:
95 95
             x0 = np.array( [50., 0., 0., .200] ) # A0, zeta, df, T2 
96 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] , [5000., np.pi, 5, .800] ),
97
+                    bounds=( [1, -np.pi, -10, .01] , [500., np.pi, 10, .800] ),
98 98
                     method=method 
99 99
                     )
100 100
         x = res_lsq.x 

+ 6
- 2
akvo/tressel/invertTA.py View File

@@ -125,6 +125,7 @@ def main():
125 125
             cont = (yaml.load(stream, Loader=yaml.Loader))
126 126
         except yaml.YAMLError as exc:
127 127
             print(exc)
128
+            exit(1)
128 129
 
129 130
     ###############################################
130 131
     # Load in data
@@ -185,7 +186,7 @@ def main():
185 186
     # Linear Inversion 
186 187
     ############################################### 
187 188
     print("Calling inversion", flush=True)
188
-    inv, ibreak, errn, phim, phid, mkappa, Wd, Wm, alphastar = logBarrier(KQT, np.ravel(V), T2Bins, "lcurve", MAXITER=150, sigma=np.ravel(VS), alpha=1e6, smooth="Smallest" ) 
189
+    inv, ibreak, errn, phim, phid, mkappa, Wd, Wm, alphastar = logBarrier(KQT, np.ravel(V), T2Bins, "lcurve", MAXITER=150, sigma=np.ravel(VS), alpha=1e7, smooth="Smallest" ) 
189 190
 
190 191
 
191 192
     ################################
@@ -295,6 +296,8 @@ def main():
295 296
                 PREc = np.reshape( prec, np.shape(V)  )
296 297
                 print("PHID linear=", errn, "PHID nonlinear=", phidc/len(np.ravel(V)))
297 298
             else:
299
+                nonLinearRefinement = False
300
+                print("Non-linear inversion failed, results will not be shown")
298 301
                 break
299 302
 
300 303
             if phidc_old - phidc/len(np.ravel(V)) < 0.005:
@@ -553,9 +556,10 @@ def main():
553 556
     # Only show ticks on the left and bottom spines
554 557
     ax.yaxis.set_ticks_position('left')
555 558
     ax.xaxis.set_ticks_position('bottom')   
559
+    plt.legend()  
556 560
  
557 561
     plt.savefig("akvoInversionWC.pdf")
558
-    plt.legend()  
562
+
559 563
     
560 564
     fr = pd.DataFrame( INV, columns=T2Bins ) #[0:-1] )
561 565
     fr.insert(0, "layer top", ifaces[0:-1] )

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

@@ -218,7 +218,7 @@ def logBarrier(A, b, T2Bins, lambdastar, x_0=0, xr=0, alpha=10, mu1=10, mu2=10,
218 218
         #print("inversion progress", i, alpha, np.sqrt(phid/len(b)), phim, flush=True)      
219 219
         #print ("{:<8} {:<15} {:<10} {:<10}".format(i, alpha, np.sqrt(phid/len(b)), phim), flush=True) 
220 220
         
221
-        if i < 4:        
221
+        if i <= 4:        
222 222
             print ("{:^5} {:>15.4f} {:>15.4f} {:>15.4f} {:>15.4f}".format(i, alpha, np.sqrt(phid/len(b)), phim, tphi ), flush=True) 
223 223
 
224 224
 #         if np.sqrt(phid/len(b)) < 0.97: 

+ 41
- 25
akvo/tressel/mrsurvey.py View File

@@ -35,12 +35,12 @@ import akvo.tressel.cmaps as cmaps
35 35
 import akvo.tressel.harmonic as harmonic
36 36
 
37 37
 import cmocean # colormaps for geophysical data 
38
-plt.register_cmap(name='viridis', cmap=cmaps.viridis)
39
-plt.register_cmap(name='inferno', cmap=cmaps.inferno)
40
-plt.register_cmap(name='inferno_r', cmap=cmaps.inferno_r)
41
-
42
-plt.register_cmap(name='magma', cmap=cmaps.magma)
43
-plt.register_cmap(name='magma_r', cmap=cmaps.magma_r)
38
+# not needed with latest matplotlib 
39
+#plt.register_cmap(name='viridis', cmap=cmaps.viridis)
40
+#plt.register_cmap(name='inferno', cmap=cmaps.inferno)
41
+#plt.register_cmap(name='inferno_r', cmap=cmaps.inferno_r)
42
+#plt.register_cmap(name='magma', cmap=cmaps.magma)
43
+#plt.register_cmap(name='magma_r', cmap=cmaps.magma_r)
44 44
 
45 45
 
46 46
 def xxloadGMRBinaryFID( rawfname, info ):
@@ -1070,11 +1070,11 @@ class GMRDataProcessor(SNMRDataProcessor):
1070 1070
                     IP[pulse][chan][ipm,:] = np.angle(ht)[clip::]
1071 1071
                     #############################################################
1072 1072
                     # Rotated amplitude
1073
-                    #if ipm != 0:
1074
-                    #    [success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], (E0,phi,df,T2))
1073
+                    if ipm != 0:
1074
+                        [success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], method, loss, (E0,phi,df,T2))
1075 1075
                     #[success, E0, df, phi, T2] = decay.quadratureDetect( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"] )
1076
-                    #else:
1077
-                    [success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], method, loss)
1076
+                    else:
1077
+                        [success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], method, loss)
1078 1078
                     #[success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], (E0,phi,df,T2))
1079 1079
                     #[success, E0, df, phi, T2] = decay.quadratureDetect( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"] )
1080 1080
                     #print("success", success, "E0", E0, "phi", phi, "df", df, "T2", T2)
@@ -2564,9 +2564,12 @@ class GMRDataProcessor(SNMRDataProcessor):
2564 2564
 
2565 2565
 
2566 2566
 
2567
-    def loadMIDI2(self, directory, procStacks, chanin, rchanin, FIDProc, canvas, deadTime, plot):
2567
+    def loadMIDI2(self, directory, procStacks, chanin, rchanin, FIDProc, canvas, deadTime, pulseMoments, plot):
2568 2568
         """Reads a MRS MIDI2 experiment. 
2569 2569
         """
2570
+
2571
+        print("Loading MIDI2 data")
2572
+
2570 2573
         canvas.reAx3(True,False)
2571 2574
 
2572 2575
         chan = []
@@ -2582,6 +2585,16 @@ class GMRDataProcessor(SNMRDataProcessor):
2582 2585
         PULSES = [FIDProc]
2583 2586
         PULSES = ["Pulse 1"]
2584 2587
 
2588
+        if pulseMoments[0] == -1:
2589
+            print("using default pulse moments, all of them")
2590
+            self.pulseMoments = range(0, self.nPulseMoments) # use all of them, assume starting at 0 
2591
+        else:
2592
+            self.pulseMoments = pulseMoments
2593
+        
2594
+        self.nPulseMoments = len(self.pulseMoments)
2595
+
2596
+        print("nPulseMoments", self.nPulseMoments, self.pulseMoments)
2597
+
2585 2598
         self.DATADICT = {}
2586 2599
         self.DATADICT["nPulseMoments"] = self.nPulseMoments
2587 2600
         self.DATADICT["stacks"] = procStacks
@@ -2606,7 +2619,8 @@ class GMRDataProcessor(SNMRDataProcessor):
2606 2619
         iistack = 0
2607 2620
         idead = int( (self.pulseLength[0]+deadTime) / self.dt)
2608 2621
 
2609
-        for iq in range(self.nPulseMoments):
2622
+        
2623
+        for ipm, iq in enumerate(self.pulseMoments):
2610 2624
 
2611 2625
             fidbase = self.datadir #+ self.QFiles[iq][0:-5]
2612 2626
             
@@ -2624,16 +2638,17 @@ class GMRDataProcessor(SNMRDataProcessor):
2624 2638
                             break 
2625 2639
 
2626 2640
                     # use numpy for now, consider pandas for faster read? 
2641
+                    print("Loading", FID)
2627 2642
                     DATA = np.genfromtxt(FID, skip_header=0, skip_footer=1 )
2628 2643
                     #DATA = pd.read_csv(fidname, skiprows=headerLine, skipfooter=1, sep='\t', encoding='ascii')
2629 2644
            
2630 2645
                     for ichan in np.append(chan,rchan):
2631 2646
                  
2632 2647
                         if int(ichan) <= 3: 
2633
-                            self.DATADICT["Pulse 1"][ichan][iq][istack] = DATA[idead:,int(ichan)] / float(self.MIDIGain[int(ichan)-1])
2648
+                            self.DATADICT["Pulse 1"][ichan][ipm][istack] = DATA[idead:,int(ichan)] / float(self.MIDIGain[int(ichan)-1])
2634 2649
 
2635 2650
                         elif int(ichan) > 3:     
2636
-                            self.DATADICT["Pulse 1"][ichan][iq][istack] = DATA[idead:,int(ichan)+1] / float(self.MIDIGain[int(ichan)-1])
2651
+                            self.DATADICT["Pulse 1"][ichan][ipm][istack] = DATA[idead:,int(ichan)+1] / float(self.MIDIGain[int(ichan)-1])
2637 2652
                    
2638 2653
                         # truncate after dead time  
2639 2654
 
@@ -2642,26 +2657,27 @@ class GMRDataProcessor(SNMRDataProcessor):
2642 2657
                         # truncate until dead time
2643 2658
                         ipulse = int(self.pulseLength[0] / self.dt)
2644 2659
                         self.DATADICT["Pulse 1"]["PULSE_TIMES"] = DATA[0:ipulse,0]
2645
-                        self.DATADICT["Pulse 1"]["CURRENT"][iq][istack] = DATA[0:ipulse,4]
2660
+                        self.DATADICT["Pulse 1"]["CURRENT"][ipm][istack] = DATA[0:ipulse,4]
2646 2661
 
2647 2662
                         if plot: 
2648 2663
                             canvas.softClear()                           
2649 2664
 
2650 2665
                             for ichan in chan:
2651
-                                canvas.ax1.plot(self.DATADICT["Pulse 1"]["PULSE_TIMES"], self.DATADICT["Pulse 1"]["CURRENT"][iq][istack] , color='black')
2652
-                                canvas.ax3.plot(self.DATADICT["Pulse 1"]["TIMES"],       self.DATADICT["Pulse 1"][ichan][iq][istack], label="Pulse 1 FID data ch. "+str(ichan)) #, color='blue')
2666
+                                canvas.ax1.plot(self.DATADICT["Pulse 1"]["PULSE_TIMES"], self.DATADICT["Pulse 1"]["CURRENT"][ipm][istack] , color='black')
2667
+                                canvas.ax3.plot(self.DATADICT["Pulse 1"]["TIMES"],       self.DATADICT["Pulse 1"][ichan][ipm][istack], label="Pulse 1 FID data ch. "+str(ichan)) #, color='blue')
2653 2668
 
2654 2669
                             for ichan in rchan:
2655
-                                canvas.ax2.plot(self.DATADICT["Pulse 1"]["TIMES"], self.DATADICT["Pulse 1"][ichan][iq][istack], label="Pulse 1 FID ref ch. "+str(ichan)) #, color='blue')
2670
+                                canvas.ax2.plot(self.DATADICT["Pulse 1"]["TIMES"], self.DATADICT["Pulse 1"][ichan][ipm][istack], label="Pulse 1 FID ref ch. "+str(ichan)) #, color='blue')
2656 2671
 
2657 2672
                             # reference axis
2658
-                            canvas.ax2.tick_params(axis='both', which='major', labelsize=10)
2659
-                            canvas.ax2.tick_params(axis='both', which='minor', labelsize=10)
2660
-                            #canvas.ax2.xaxis.set_ticklabels([])
2661
-                            plt.setp(canvas.ax2.get_xticklabels(), visible=False)
2662
-                            canvas.ax2.legend(prop={'size':10}, loc='upper right')
2663
-                            canvas.ax2.set_title("stack "+str(istack)+" pulse index " + str(iq), fontsize=10)
2664
-                            canvas.ax2.set_ylabel("RAW signal [V]", fontsize=10)
2673
+                            if len(rchan) > 0:
2674
+                                canvas.ax2.legend(prop={'size':10}, loc='upper right')
2675
+                                canvas.ax2.tick_params(axis='both', which='major', labelsize=10)
2676
+                                canvas.ax2.tick_params(axis='both', which='minor', labelsize=10)
2677
+                                #canvas.ax2.xaxis.set_ticklabels([])
2678
+                                plt.setp(canvas.ax2.get_xticklabels(), visible=False)
2679
+                                canvas.ax2.set_title("stack "+str(istack)+" pulse index " + str(iq), fontsize=10)
2680
+                                canvas.ax2.set_ylabel("RAW signal [V]", fontsize=10)
2665 2681
 
2666 2682
                             canvas.ax1.set_ylabel("Current (A)", fontsize=10) 
2667 2683
                             canvas.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 

+ 1
- 1
setup.py View File

@@ -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.7.0', 
24
+      version='1.7.1', 
25 25
       python_requires='>3.7.0', # due to pyLemma 
26 26
       description='Surface nuclear magnetic resonance workbench',
27 27
       long_description=long_description,

Loading…
Cancel
Save