Browse Source

Yaml improvements for logging

HEAD
Trevor Irons 7 years ago
parent
commit
82e6e13723
2 changed files with 40 additions and 13 deletions
  1. 32
    5
      akvo/gui/akvoGUI.py
  2. 8
    8
      akvo/gui/main.ui

+ 32
- 5
akvo/gui/akvoGUI.py View File

@@ -26,12 +26,13 @@ import os
26 26
 from copy import deepcopy
27 27
 from matplotlib.backends.backend_qt4 import NavigationToolbar2QT #as NavigationToolbar
28 28
 import datetime, time
29
-import yaml
29
+
30 30
 
31 31
 from akvo.tressel import mrsurvey 
32 32
 import pkg_resources  # part of setuptools
33 33
 version = pkg_resources.require("Akvo")[0].version
34 34
 
35
+import yaml
35 36
 # Writes out numpy arrays into Eigen vectors as serialized by Lemma
36 37
 class MatrixXr(yaml.YAMLObject):
37 38
     yaml_tag = u'!MatrixXr'
@@ -51,6 +52,18 @@ class VectorXr(yaml.YAMLObject):
51 52
     def __repr__(self):
52 53
         # Converts to numpy array on import 
53 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 68
 try:    
56 69
     import thread 
@@ -89,7 +102,9 @@ class ApplicationWindow(QtWidgets.QMainWindow):
89 102
                 warn.write("Gui files were not compiled locally using pyuic! Further warnings have been supressed")
90 103
                 warn.close()
91 104
         self.RAWDataProc = None 
92
-            
105
+
106
+        self.YamlNode = AkvoYamlNode()           
107
+ 
93 108
         # initialise some stuff
94 109
         self.ui.lcdNumberTauPulse2.setEnabled(0)
95 110
         self.ui.lcdNumberTauPulse1.setEnabled(0)
@@ -717,6 +732,14 @@ class ApplicationWindow(QtWidgets.QMainWindow):
717 732
         nlogText.append( "  reference channels: " + str(self.refChan) )
718 733
         nlogText.append( "  pulse records: " + str(self.ui.FIDProcComboBox.currentText()) ) 
719 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 744
         self.Log ( nlogText )     
722 745
 
@@ -741,9 +764,13 @@ class ApplicationWindow(QtWidgets.QMainWindow):
741 764
         self.ui.mplwidget.draw()
742 765
 
743 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 775
     def disable(self):
749 776
         self.ui.BandPassBox.setEnabled(False)

+ 8
- 8
akvo/gui/main.ui View File

@@ -73,8 +73,8 @@
73 73
         <rect>
74 74
          <x>0</x>
75 75
          <y>0</y>
76
-         <width>966</width>
77
-         <height>924</height>
76
+         <width>982</width>
77
+         <height>921</height>
78 78
         </rect>
79 79
        </property>
80 80
        <layout class="QHBoxLayout" name="horizontalLayout_2">
@@ -96,7 +96,7 @@
96 96
            <enum>Qt::LeftToRight</enum>
97 97
           </property>
98 98
           <property name="currentIndex">
99
-           <number>3</number>
99
+           <number>0</number>
100 100
           </property>
101 101
           <widget class="QWidget" name="tab">
102 102
            <property name="minimumSize">
@@ -801,7 +801,7 @@ background: dark grey;
801 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 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 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 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 806
              </property>
807 807
             </widget>
@@ -854,7 +854,7 @@ p, li { white-space: pre-wrap; }
854 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 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 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 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 859
              </property>
860 860
             </widget>
@@ -3092,8 +3092,8 @@ background: red;
3092 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 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 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 3097
             </property>
3098 3098
            </widget>
3099 3099
            <widget class="QLabel" name="label_53">
@@ -3124,7 +3124,7 @@ p, li { white-space: pre-wrap; }
3124 3124
      <x>0</x>
3125 3125
      <y>0</y>
3126 3126
      <width>1000</width>
3127
-     <height>25</height>
3127
+     <height>19</height>
3128 3128
     </rect>
3129 3129
    </property>
3130 3130
    <widget class="QMenu" name="menuFile">

Loading…
Cancel
Save