소스 검색

Yaml improvements for logging

HEAD
Trevor Irons 6 년 전
부모
커밋
82e6e13723
2개의 변경된 파일40개의 추가작업 그리고 13개의 파일을 삭제
  1. 32
    5
      akvo/gui/akvoGUI.py
  2. 8
    8
      akvo/gui/main.ui

+ 32
- 5
akvo/gui/akvoGUI.py 파일 보기

26
 from copy import deepcopy
26
 from copy import deepcopy
27
 from matplotlib.backends.backend_qt4 import NavigationToolbar2QT #as NavigationToolbar
27
 from matplotlib.backends.backend_qt4 import NavigationToolbar2QT #as NavigationToolbar
28
 import datetime, time
28
 import datetime, time
29
-import yaml
29
+
30
 
30
 
31
 from akvo.tressel import mrsurvey 
31
 from akvo.tressel import mrsurvey 
32
 import pkg_resources  # part of setuptools
32
 import pkg_resources  # part of setuptools
33
 version = pkg_resources.require("Akvo")[0].version
33
 version = pkg_resources.require("Akvo")[0].version
34
 
34
 
35
+import yaml
35
 # Writes out numpy arrays into Eigen vectors as serialized by Lemma
36
 # Writes out numpy arrays into Eigen vectors as serialized by Lemma
36
 class MatrixXr(yaml.YAMLObject):
37
 class MatrixXr(yaml.YAMLObject):
37
     yaml_tag = u'!MatrixXr'
38
     yaml_tag = u'!MatrixXr'
51
     def __repr__(self):
52
     def __repr__(self):
52
         # Converts to numpy array on import 
53
         # Converts to numpy array on import 
53
         return "np.array(%r)" % (self.data)
54
         return "np.array(%r)" % (self.data)
55
+
56
+class AkvoYamlNode(yaml.YAMLObject):
57
+    yaml_tag = u'!AkvoData'
58
+    def __init__(self):
59
+        self.Akvo_VERSION = version
60
+        self.Import = {}
61
+        self.dataProcessing = {}
62
+        #self.data = {}
63
+    # For going the other way, data import based on Yaml serialization, 
64
+    def __repr__(self):
65
+        return "%s(name=%r, hp=%r, ac=%r, attacks=%r)" % (
66
+            self.__class__.__name__, self.name, self.hp, self.ac, self.attacks, self.thingy)
54
     
67
     
55
 try:    
68
 try:    
56
     import thread 
69
     import thread 
89
                 warn.write("Gui files were not compiled locally using pyuic! Further warnings have been supressed")
102
                 warn.write("Gui files were not compiled locally using pyuic! Further warnings have been supressed")
90
                 warn.close()
103
                 warn.close()
91
         self.RAWDataProc = None 
104
         self.RAWDataProc = None 
92
-            
105
+
106
+        self.YamlNode = AkvoYamlNode()           
107
+ 
93
         # initialise some stuff
108
         # initialise some stuff
94
         self.ui.lcdNumberTauPulse2.setEnabled(0)
109
         self.ui.lcdNumberTauPulse2.setEnabled(0)
95
         self.ui.lcdNumberTauPulse1.setEnabled(0)
110
         self.ui.lcdNumberTauPulse1.setEnabled(0)
717
         nlogText.append( "  reference channels: " + str(self.refChan) )
732
         nlogText.append( "  reference channels: " + str(self.refChan) )
718
         nlogText.append( "  pulse records: " + str(self.ui.FIDProcComboBox.currentText()) ) 
733
         nlogText.append( "  pulse records: " + str(self.ui.FIDProcComboBox.currentText()) ) 
719
         nlogText.append( "  instrument dead time: " + str(1e-3 * self.ui.DeadTimeSpinBox.value( )) )   
734
         nlogText.append( "  instrument dead time: " + str(1e-3 * self.ui.DeadTimeSpinBox.value( )) )   
735
+        self.YamlNode.Import["GMR Header"] = self.headerstr
736
+        self.YamlNode.Import["opened"] = datetime.datetime.now().isoformat() 
737
+        self.YamlNode.Import["pulse Type"] = str(self.RAWDataProc.pulseType) 
738
+        self.YamlNode.Import["stacks"] = self.procStacks.tolist() 
739
+        self.YamlNode.Import["data channels"] = self.dataChan.tolist()  
740
+        self.YamlNode.Import["reference channels"] = self.refChan.tolist() 
741
+        self.YamlNode.Import["pulse records"] = str(self.ui.FIDProcComboBox.currentText())  
742
+        self.YamlNode.Import["instrument dead time"] = (1e-3 * self.ui.DeadTimeSpinBox.value( ))    
720
 
743
 
721
         self.Log ( nlogText )     
744
         self.Log ( nlogText )     
722
 
745
 
741
         self.ui.mplwidget.draw()
764
         self.ui.mplwidget.draw()
742
 
765
 
743
     def Log(self, nlogText):
766
     def Log(self, nlogText):
744
-        for line in nlogText: 
745
-            self.ui.logTextBrowser.append( line )
746
-            self.logText.append( line ) 
767
+        #for line in yaml.dump(self.YamlNode, default_flow_style=False):
768
+        #for line in nlogText: 
769
+        #    self.ui.logTextBrowser.append( line )
770
+        #    self.logText.append( line ) 
771
+            
772
+        self.ui.logTextBrowser.clear() 
773
+        self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False)  )
747
 
774
 
748
     def disable(self):
775
     def disable(self):
749
         self.ui.BandPassBox.setEnabled(False)
776
         self.ui.BandPassBox.setEnabled(False)

+ 8
- 8
akvo/gui/main.ui 파일 보기

73
         <rect>
73
         <rect>
74
          <x>0</x>
74
          <x>0</x>
75
          <y>0</y>
75
          <y>0</y>
76
-         <width>966</width>
77
-         <height>924</height>
76
+         <width>982</width>
77
+         <height>921</height>
78
         </rect>
78
         </rect>
79
        </property>
79
        </property>
80
        <layout class="QHBoxLayout" name="horizontalLayout_2">
80
        <layout class="QHBoxLayout" name="horizontalLayout_2">
96
            <enum>Qt::LeftToRight</enum>
96
            <enum>Qt::LeftToRight</enum>
97
           </property>
97
           </property>
98
           <property name="currentIndex">
98
           <property name="currentIndex">
99
-           <number>3</number>
99
+           <number>0</number>
100
           </property>
100
           </property>
101
           <widget class="QWidget" name="tab">
101
           <widget class="QWidget" name="tab">
102
            <property name="minimumSize">
102
            <property name="minimumSize">
801
               <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
801
               <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
802
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
802
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
803
 p, li { white-space: pre-wrap; }
803
 p, li { white-space: pre-wrap; }
804
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:8pt; font-weight:400; font-style:italic;&quot;&gt;
804
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:8pt; font-weight:400; font-style:italic;&quot;&gt;
805
 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Serif'; font-size:9pt;&quot;&gt;Load supported RAW Dataset header from file menu&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
805
 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Serif'; font-size:9pt;&quot;&gt;Load supported RAW Dataset header from file menu&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
806
              </property>
806
              </property>
807
             </widget>
807
             </widget>
854
               <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
854
               <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
855
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
855
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
856
 p, li { white-space: pre-wrap; }
856
 p, li { white-space: pre-wrap; }
857
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:italic;&quot;&gt;
857
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:italic;&quot;&gt;
858
 &lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Serif'; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
858
 &lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Serif'; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
859
              </property>
859
              </property>
860
             </widget>
860
             </widget>
3092
              <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
3092
              <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
3093
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
3093
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
3094
 p, li { white-space: pre-wrap; }
3094
 p, li { white-space: pre-wrap; }
3095
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
3096
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;All processing steps are recorded here for your records&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
3095
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
3096
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;All processing steps are recorded here for your records&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
3097
             </property>
3097
             </property>
3098
            </widget>
3098
            </widget>
3099
            <widget class="QLabel" name="label_53">
3099
            <widget class="QLabel" name="label_53">
3124
      <x>0</x>
3124
      <x>0</x>
3125
      <y>0</y>
3125
      <y>0</y>
3126
      <width>1000</width>
3126
      <width>1000</width>
3127
-     <height>25</height>
3127
+     <height>19</height>
3128
     </rect>
3128
     </rect>
3129
    </property>
3129
    </property>
3130
    <widget class="QMenu" name="menuFile">
3130
    <widget class="QMenu" name="menuFile">

Loading…
취소
저장