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
         INFO = {}
1058
         INFO = {}
1059
         INFO["headerstr"] = str(self.headerstr)
1059
         INFO["headerstr"] = str(self.headerstr)
1060
         INFO["pulseType"] = self.RAWDataProc.pulseType
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
         #INFO["samp"] = self.RAWDataProc.samp
1064
         #INFO["samp"] = self.RAWDataProc.samp
1065
         INFO["nPulseMoments"] = self.RAWDataProc.nPulseMoments
1065
         INFO["nPulseMoments"] = self.RAWDataProc.nPulseMoments
1066
         #INFO["deadTime"] = self.RAWDataProc.deadTime
1066
         #INFO["deadTime"] = self.RAWDataProc.deadTime
1072
             qq = []
1072
             qq = []
1073
             qv = []
1073
             qv = []
1074
             for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):     
1074
             for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):     
1075
+            #for ipm in self.pulseMoments: 
1075
                 #for istack in self.RAWDataProc.DATADICT["stacks"]:
1076
                 #for istack in self.RAWDataProc.DATADICT["stacks"]:
1076
                 #    print ("stack q", self.RAWDataProc.DATADICT[pulse]["Q"][ipm,istack-1])
1077
                 #    print ("stack q", self.RAWDataProc.DATADICT[pulse]["Q"][ipm,istack-1])
1077
                 qq.append(np.mean(    self.RAWDataProc.DATADICT[pulse]["Q"][ipm,:]) )
1078
                 qq.append(np.mean(    self.RAWDataProc.DATADICT[pulse]["Q"][ipm,:]) )
1101
                     #INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] =  VectorXr(   np.std(self.RAWDataProc.GATED[ichan]["NR"], axis=0) )
1102
                     #INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] =  VectorXr(   np.std(self.RAWDataProc.GATED[ichan]["NR"], axis=0) )
1102
                     INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] = VectorXr( np.average(self.RAWDataProc.GATED[ichan]["BN"], axis=0) )
1103
                     INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] = VectorXr( np.average(self.RAWDataProc.GATED[ichan]["BN"], axis=0) )
1103
                     for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):     
1104
                     for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):     
1105
+                    #for ipm in self.pulseMoments: 
1104
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " CA"] = VectorXr(self.RAWDataProc.GATED[ichan]["CA"][ipm])   
1106
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " CA"] = VectorXr(self.RAWDataProc.GATED[ichan]["CA"][ipm])   
1105
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " RE"] = VectorXr(self.RAWDataProc.GATED[ichan]["RE"][ipm])   
1107
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " RE"] = VectorXr(self.RAWDataProc.GATED[ichan]["RE"][ipm])   
1106
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " IM"] = VectorXr(self.RAWDataProc.GATED[ichan]["IM"][ipm])   
1108
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " IM"] = VectorXr(self.RAWDataProc.GATED[ichan]["IM"][ipm])   
1409
             QtWidgets.QMessageBox.critical(self, 'Error', err_msg) 
1411
             QtWidgets.QMessageBox.critical(self, 'Error', err_msg) 
1410
             return
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
         # Data Channels
1431
         # Data Channels
1413
-        #Chan = np.arange(0,9,1)
1432
+        ###################
1414
         try:
1433
         try:
1415
             self.dataChan = np.array(eval(str("np.r_["+self.ui.dataChanLineEdit.text())+"]"))
1434
             self.dataChan = np.array(eval(str("np.r_["+self.ui.dataChanLineEdit.text())+"]"))
1416
         except:
1435
         except:
1428
             reply = QtWidgets.QMessageBox.critical(self, 'Error', 
1447
             reply = QtWidgets.QMessageBox.critical(self, 'Error', 
1429
                 err_msg) #, QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
1448
                 err_msg) #, QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
1430
             return
1449
             return
1450
+
1431
         #############################
1451
         #############################
1432
         # Reference Channels
1452
         # Reference Channels
1433
         # TODO make sure no overlap between data and ref channels
1453
         # TODO make sure no overlap between data and ref channels
1451
         self.procThread = thread.start_new_thread(self.RAWDataProc.loadMIDI2, \
1471
         self.procThread = thread.start_new_thread(self.RAWDataProc.loadMIDI2, \
1452
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
1472
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
1453
                  str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
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
         self.YamlNode.Import["MIDI Header"] = self.headerstr
1477
         self.YamlNode.Import["MIDI Header"] = self.headerstr
1457
         self.YamlNode.Import["opened"] = datetime.datetime.now().isoformat() 
1478
         self.YamlNode.Import["opened"] = datetime.datetime.now().isoformat() 
1511
             QtWidgets.QMessageBox.critical(self, 'Error', err_msg) 
1532
             QtWidgets.QMessageBox.critical(self, 'Error', err_msg) 
1512
             return
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
         # Data Channels
1547
         # Data Channels
1515
         #Chan = np.arange(0,9,1)
1548
         #Chan = np.arange(0,9,1)
1516
         try:
1549
         try:
1555
             self.procThread = thread.start_new_thread(self.RAWDataProc.loadFIDData, \
1588
             self.procThread = thread.start_new_thread(self.RAWDataProc.loadFIDData, \
1556
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
1589
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
1557
                  str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
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
         elif self.RAWDataProc.pulseType == "4PhaseT1":
1593
         elif self.RAWDataProc.pulseType == "4PhaseT1":
1560
             self.procThread = thread.start_new_thread(self.RAWDataProc.load4PhaseT1Data, \
1594
             self.procThread = thread.start_new_thread(self.RAWDataProc.load4PhaseT1Data, \
1561
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
1595
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \

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

711
          <x>0</x>
711
          <x>0</x>
712
          <y>0</y>
712
          <y>0</y>
713
          <width>537</width>
713
          <width>537</width>
714
-         <height>982</height>
714
+         <height>1025</height>
715
         </rect>
715
         </rect>
716
        </property>
716
        </property>
717
        <property name="sizePolicy">
717
        <property name="sizePolicy">
824
                <string>Input parameters</string>
824
                <string>Input parameters</string>
825
               </property>
825
               </property>
826
               <layout class="QGridLayout" name="gridLayout_4">
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
                  <property name="text">
829
                  <property name="text">
836
-                  <string>Stacks</string>
830
+                  <string>Data Chs.</string>
837
                  </property>
831
                  </property>
838
                 </widget>
832
                 </widget>
839
                </item>
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
                  <property name="maximumSize">
836
                  <property name="maximumSize">
843
                   <size>
837
                   <size>
844
                    <width>16777215</width>
838
                    <width>16777215</width>
846
                   </size>
840
                   </size>
847
                  </property>
841
                  </property>
848
                  <property name="toolTip">
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
                  </property>
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
                  </property>
863
                  </property>
854
                 </widget>
864
                 </widget>
855
                </item>
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
                  <property name="text">
868
                  <property name="text">
859
-                  <string>Dead time [ms]</string>
869
+                  <string>Process FID</string>
860
                  </property>
870
                  </property>
861
                 </widget>
871
                 </widget>
862
                </item>
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
                  <property name="maximumSize">
875
                  <property name="maximumSize">
866
                   <size>
876
                   <size>
867
                    <width>16777215</width>
877
                    <width>16777215</width>
869
                   </size>
879
                   </size>
870
                  </property>
880
                  </property>
871
                  <property name="toolTip">
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
                  </property>
883
                  </property>
880
-                 <property name="value">
881
-                  <double>5.000000000000000</double>
884
+                 <property name="placeholderText">
885
+                  <string>required</string>
882
                  </property>
886
                  </property>
883
                 </widget>
887
                 </widget>
884
                </item>
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
                  <property name="text">
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
                  </property>
899
                  </property>
890
                 </widget>
900
                 </widget>
891
                </item>
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
                  <property name="maximumSize">
904
                  <property name="maximumSize">
895
                   <size>
905
                   <size>
896
                    <width>16777215</width>
906
                    <width>16777215</width>
898
                   </size>
908
                   </size>
899
                  </property>
909
                  </property>
900
                  <property name="toolTip">
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
                  </property>
912
                  </property>
903
                  <property name="placeholderText">
913
                  <property name="placeholderText">
904
                   <string>required</string>
914
                   <string>required</string>
931
                  </property>
941
                  </property>
932
                 </widget>
942
                 </widget>
933
                </item>
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
                  <property name="maximumSize">
946
                  <property name="maximumSize">
944
                   <size>
947
                   <size>
945
                    <width>16777215</width>
948
                    <width>16777215</width>
947
                   </size>
950
                   </size>
948
                  </property>
951
                  </property>
949
                  <property name="toolTip">
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
                  </property>
963
                  </property>
952
                 </widget>
964
                 </widget>
953
                </item>
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
                  </property>
973
                  </property>
959
                  <property name="text">
974
                  <property name="text">
960
-                  <string> Plot RAW</string>
975
+                  <string>Stacks</string>
961
                  </property>
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
                  </property>
983
                  </property>
965
                 </widget>
984
                 </widget>
966
                </item>
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
                  </property>
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
                  </property>
996
                  </property>
997
+                </widget>
998
+               </item>
999
+               <item row="2" column="0">
1000
+                <widget class="QLabel" name="label_87">
981
                  <property name="text">
1001
                  <property name="text">
982
-                  <string>Load Data</string>
1002
+                  <string>Q indices</string>
983
                  </property>
1003
                  </property>
984
                 </widget>
1004
                 </widget>
985
                </item>
1005
                </item>
4195
               <rect>
4215
               <rect>
4196
                <x>0</x>
4216
                <x>0</x>
4197
                <y>0</y>
4217
                <y>0</y>
4198
-               <width>411</width>
4199
-               <height>67</height>
4218
+               <width>96</width>
4219
+               <height>26</height>
4200
               </rect>
4220
               </rect>
4201
              </property>
4221
              </property>
4202
              <attribute name="label">
4222
              <attribute name="label">

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

99
 
99
 
100
     #plt.matshow(RE)
100
     #plt.matshow(RE)
101
     #plt.matshow(IM)
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
 if __name__ == "__main__":
106
 if __name__ == "__main__":
106
     akvo = loadAkvoData( sys.argv[1] ) #, "Chan. 1")
107
     akvo = loadAkvoData( sys.argv[1] ) #, "Chan. 1")

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

152
         print( str(kparams["Lspacing"]) )
152
         print( str(kparams["Lspacing"]) )
153
         exit()
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
     Kern.SetDepthLayerInterfaces(iface)
158
     Kern.SetDepthLayerInterfaces(iface)
157
     #Kern.SetDepthLayerInterfaces(np.geomspace(1, 110, num=40))
159
     #Kern.SetDepthLayerInterfaces(np.geomspace(1, 110, num=40))
158
     #Kern.SetDepthLayerInterfaces(np.linspace(1, 110, num=50))
160
     #Kern.SetDepthLayerInterfaces(np.linspace(1, 110, num=50))

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

94
         else:
94
         else:
95
             x0 = np.array( [50., 0., 0., .200] ) # A0, zeta, df, T2 
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,\
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
                     method=method 
98
                     method=method 
99
                     )
99
                     )
100
         x = res_lsq.x 
100
         x = res_lsq.x 

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

125
             cont = (yaml.load(stream, Loader=yaml.Loader))
125
             cont = (yaml.load(stream, Loader=yaml.Loader))
126
         except yaml.YAMLError as exc:
126
         except yaml.YAMLError as exc:
127
             print(exc)
127
             print(exc)
128
+            exit(1)
128
 
129
 
129
     ###############################################
130
     ###############################################
130
     # Load in data
131
     # Load in data
185
     # Linear Inversion 
186
     # Linear Inversion 
186
     ############################################### 
187
     ############################################### 
187
     print("Calling inversion", flush=True)
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
                 PREc = np.reshape( prec, np.shape(V)  )
296
                 PREc = np.reshape( prec, np.shape(V)  )
296
                 print("PHID linear=", errn, "PHID nonlinear=", phidc/len(np.ravel(V)))
297
                 print("PHID linear=", errn, "PHID nonlinear=", phidc/len(np.ravel(V)))
297
             else:
298
             else:
299
+                nonLinearRefinement = False
300
+                print("Non-linear inversion failed, results will not be shown")
298
                 break
301
                 break
299
 
302
 
300
             if phidc_old - phidc/len(np.ravel(V)) < 0.005:
303
             if phidc_old - phidc/len(np.ravel(V)) < 0.005:
553
     # Only show ticks on the left and bottom spines
556
     # Only show ticks on the left and bottom spines
554
     ax.yaxis.set_ticks_position('left')
557
     ax.yaxis.set_ticks_position('left')
555
     ax.xaxis.set_ticks_position('bottom')   
558
     ax.xaxis.set_ticks_position('bottom')   
559
+    plt.legend()  
556
  
560
  
557
     plt.savefig("akvoInversionWC.pdf")
561
     plt.savefig("akvoInversionWC.pdf")
558
-    plt.legend()  
562
+
559
     
563
     
560
     fr = pd.DataFrame( INV, columns=T2Bins ) #[0:-1] )
564
     fr = pd.DataFrame( INV, columns=T2Bins ) #[0:-1] )
561
     fr.insert(0, "layer top", ifaces[0:-1] )
565
     fr.insert(0, "layer top", ifaces[0:-1] )

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

218
         #print("inversion progress", i, alpha, np.sqrt(phid/len(b)), phim, flush=True)      
218
         #print("inversion progress", i, alpha, np.sqrt(phid/len(b)), phim, flush=True)      
219
         #print ("{:<8} {:<15} {:<10} {:<10}".format(i, alpha, np.sqrt(phid/len(b)), phim), flush=True) 
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
             print ("{:^5} {:>15.4f} {:>15.4f} {:>15.4f} {:>15.4f}".format(i, alpha, np.sqrt(phid/len(b)), phim, tphi ), flush=True) 
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
 #         if np.sqrt(phid/len(b)) < 0.97: 
224
 #         if np.sqrt(phid/len(b)) < 0.97: 

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

35
 import akvo.tressel.harmonic as harmonic
35
 import akvo.tressel.harmonic as harmonic
36
 
36
 
37
 import cmocean # colormaps for geophysical data 
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
 def xxloadGMRBinaryFID( rawfname, info ):
46
 def xxloadGMRBinaryFID( rawfname, info ):
1070
                     IP[pulse][chan][ipm,:] = np.angle(ht)[clip::]
1070
                     IP[pulse][chan][ipm,:] = np.angle(ht)[clip::]
1071
                     #############################################################
1071
                     #############################################################
1072
                     # Rotated amplitude
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
                     #[success, E0, df, phi, T2] = decay.quadratureDetect( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"] )
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
                     #[success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], (E0,phi,df,T2))
1078
                     #[success, E0, df, phi, T2] = decay.quadratureDetect2( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"], (E0,phi,df,T2))
1079
                     #[success, E0, df, phi, T2] = decay.quadratureDetect( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"] )
1079
                     #[success, E0, df, phi, T2] = decay.quadratureDetect( ht.real, ht.imag, self.DATADICT[pulse]["TIMES"] )
1080
                     #print("success", success, "E0", E0, "phi", phi, "df", df, "T2", T2)
1080
                     #print("success", success, "E0", E0, "phi", phi, "df", df, "T2", T2)
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
         """Reads a MRS MIDI2 experiment. 
2568
         """Reads a MRS MIDI2 experiment. 
2569
         """
2569
         """
2570
+
2571
+        print("Loading MIDI2 data")
2572
+
2570
         canvas.reAx3(True,False)
2573
         canvas.reAx3(True,False)
2571
 
2574
 
2572
         chan = []
2575
         chan = []
2582
         PULSES = [FIDProc]
2585
         PULSES = [FIDProc]
2583
         PULSES = ["Pulse 1"]
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
         self.DATADICT = {}
2598
         self.DATADICT = {}
2586
         self.DATADICT["nPulseMoments"] = self.nPulseMoments
2599
         self.DATADICT["nPulseMoments"] = self.nPulseMoments
2587
         self.DATADICT["stacks"] = procStacks
2600
         self.DATADICT["stacks"] = procStacks
2606
         iistack = 0
2619
         iistack = 0
2607
         idead = int( (self.pulseLength[0]+deadTime) / self.dt)
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
             fidbase = self.datadir #+ self.QFiles[iq][0:-5]
2625
             fidbase = self.datadir #+ self.QFiles[iq][0:-5]
2612
             
2626
             
2624
                             break 
2638
                             break 
2625
 
2639
 
2626
                     # use numpy for now, consider pandas for faster read? 
2640
                     # use numpy for now, consider pandas for faster read? 
2641
+                    print("Loading", FID)
2627
                     DATA = np.genfromtxt(FID, skip_header=0, skip_footer=1 )
2642
                     DATA = np.genfromtxt(FID, skip_header=0, skip_footer=1 )
2628
                     #DATA = pd.read_csv(fidname, skiprows=headerLine, skipfooter=1, sep='\t', encoding='ascii')
2643
                     #DATA = pd.read_csv(fidname, skiprows=headerLine, skipfooter=1, sep='\t', encoding='ascii')
2629
            
2644
            
2630
                     for ichan in np.append(chan,rchan):
2645
                     for ichan in np.append(chan,rchan):
2631
                  
2646
                  
2632
                         if int(ichan) <= 3: 
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
                         elif int(ichan) > 3:     
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
                         # truncate after dead time  
2653
                         # truncate after dead time  
2639
 
2654
 
2642
                         # truncate until dead time
2657
                         # truncate until dead time
2643
                         ipulse = int(self.pulseLength[0] / self.dt)
2658
                         ipulse = int(self.pulseLength[0] / self.dt)
2644
                         self.DATADICT["Pulse 1"]["PULSE_TIMES"] = DATA[0:ipulse,0]
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
                         if plot: 
2662
                         if plot: 
2648
                             canvas.softClear()                           
2663
                             canvas.softClear()                           
2649
 
2664
 
2650
                             for ichan in chan:
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
                             for ichan in rchan:
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
                             # reference axis
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
                             canvas.ax1.set_ylabel("Current (A)", fontsize=10) 
2682
                             canvas.ax1.set_ylabel("Current (A)", fontsize=10) 
2667
                             canvas.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 
2683
                             canvas.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 

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

Loading…
Cancel
Save