Bläddra i källkod

Fixes for recovering all the META data from dmp files

tags/1.6.1
Trevor Irons 5 år sedan
förälder
incheckning
87fa0ef60d
1 ändrade filer med 50 tillägg och 9 borttagningar
  1. 50
    9
      akvo/gui/akvoGUI.py

+ 50
- 9
akvo/gui/akvoGUI.py Visa fil

@@ -745,7 +745,6 @@ class ApplicationWindow(QtWidgets.QMainWindow):
745 745
         fdir = os.path.dirname(fpath)
746 746
         # Pickle the preprocessed data dictionary 
747 747
         SaveStr = QtWidgets.QFileDialog.getSaveFileName(self, "Save as", fdir, r"Pickle (*.dmp)")
748
-        print(SaveStr)
749 748
  
750 749
         spath,filen=os.path.split(str(SaveStr[0]))
751 750
         f = open('.akvo.last.path', 'w')
@@ -776,9 +775,11 @@ class ApplicationWindow(QtWidgets.QMainWindow):
776 775
             TXRX.append(txrx)
777 776
         INFO["TXRX"] = TXRX       
778 777
 
779
-        self.RAWDataProc.DATADICT["INFO"] = INFO 
778
+        # 
779
+        print("META SAVE")
780
+        print("INFO log", INFO["log"])
780 781
 
781
-        print ("TXRX", TXRX)
782
+        self.RAWDataProc.DATADICT["INFO"] = INFO 
782 783
 
783 784
         pickle.dump(self.RAWDataProc.DATADICT, save)
784 785
         save.close()
@@ -857,6 +858,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
857 858
 
858 859
         
859 860
         self.logText = self.RAWDataProc.DATADICT["INFO"]["log"] # YAML 
861
+        parse = yaml.load( self.logText, Loader=yaml.Loader )
860 862
 
861 863
         self.YamlNode = AkvoYamlNode( )  #self.logText )
862 864
        
@@ -865,12 +867,14 @@ class ApplicationWindow(QtWidgets.QMainWindow):
865 867
         if  AKVO_VERSION[0] >= 1 and AKVO_VERSION[1] >= 2 and AKVO_VERSION[2] >= 3:
866 868
             self.RAWDataProc.interpulseDelay = self.RAWDataProc.DATADICT["INFO"]["interpulseDelay"]
867 869
 
868
-        self.YamlNode.Import =   OrderedDict((yaml.load( self.logText, Loader=yaml.Loader )).Import)
869
-        self.YamlNode.Processing = list((yaml.load( self.logText, Loader=yaml.Loader )).Processing)
870
-        self.YamlNode.Stacking = OrderedDict((yaml.load( self.logText, Loader=yaml.Loader )).Stacking)
871
-        self.YamlNode.META =     OrderedDict((yaml.load( self.logText, Loader=yaml.Loader )).META)
870
+        self.YamlNode.Import =   OrderedDict(parse.Import)
871
+        self.YamlNode.Processing = list(parse.Processing)
872
+        self.YamlNode.Stacking = OrderedDict(parse.Stacking)
873
+        self.YamlNode.META =     OrderedDict(parse.META)
874
+        
875
+        self.logGUI()
872 876
         self.Log()
873
- 
877
+
874 878
             #self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False)  )
875 879
         #except KeyError:
876 880
         #    pass
@@ -1298,7 +1302,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1298 1302
         # Log processing 
1299 1303
         Adapt = OrderedDict()
1300 1304
         Adapt["STEP"] = "TD noise cancellation"
1301
-        #print(Adapt)
1305
+        print(Adapt) # this locks STEP in as first...
1302 1306
         Adapt["n_Taps"] = str(self.ui.MTapsSpinBox.value())
1303 1307
         Adapt["lambda"] = str(self.ui.adaptLambdaSpinBox.value())
1304 1308
         Adapt["truncate"] = str(self.ui.adaptTruncateSpinBox.value())
@@ -1337,6 +1341,43 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1337 1341
                 self.ui.CentralVSpinBox.value(), \
1338 1342
                 self.ui.mplwidget))
1339 1343
 
1344
+    def logGUI(self):
1345
+        # You have a race condiditon where the GUI is modifying the Yaml node while you are updating it
1346
+        # hence, we need to cache these. More elegant solutions exist       
1347
+        if "B_0" in self.YamlNode.META:
1348
+            B0 = self.YamlNode.META["B_0"]["intensity"]
1349
+            Bdec = self.YamlNode.META["B_0"]["dec"]
1350
+            Binc = self.YamlNode.META["B_0"]["inc"]
1351
+        if "DateTime" in self.YamlNode.META:
1352
+            [Date,Time] = self.YamlNode.META["DateTime"].split("T")
1353
+            year,month,day = Date.split("-")
1354
+        if "Temp" in self.YamlNode.META:
1355
+            temp = float(self.YamlNode.META["Temp"])
1356
+        if "Coordinates" in self.YamlNode.META:
1357
+            UTM = self.YamlNode.META["Coordinates"]["UTM"] 
1358
+            LatBand = self.YamlNode.META["Coordinates"]["LatBand"] 
1359
+            Ellipsoid = self.YamlNode.META["Coordinates"]["ellipsoid"] 
1360
+
1361
+        # and set
1362
+        if "Location" in self.YamlNode.META:
1363
+            self.ui.locEdit.setText( self.YamlNode.META["Location"] )
1364
+        if "Field Notes" in self.YamlNode.META:
1365
+            self.ui.txtComments.setText( self.YamlNode.META["Field Notes"] )
1366
+        if "B_0" in self.YamlNode.META:
1367
+            self.ui.incSpinBox.setValue( Binc )  
1368
+            self.ui.decSpinBox.setValue( Bdec )  
1369
+            self.ui.intensitySpinBox.setValue( B0 ) 
1370
+        if "DateTime" in self.YamlNode.META:
1371
+            self.ui.dateEdit.setDate( datetime.date(int(year), int(month), int(day)) )            
1372
+            self.ui.timeEdit.setTime( datetime.time.fromisoformat( Time ) )            
1373
+        if "Temp" in self.YamlNode.META:
1374
+            self.ui.tempSpinBox.setValue(temp)
1375
+        if "Coordinates" in self.YamlNode.META:
1376
+            self.ui.UTMzone.setCurrentText(UTM)
1377
+            self.ui.latBand.setCurrentText(LatBand) 
1378
+            self.ui.ellipsoid.setCurrentText(Ellipsoid)
1379
+
1380
+
1340 1381
     def logSite(self):
1341 1382
         self.YamlNode.META["Location"] = self.ui.locEdit.text()
1342 1383
         self.YamlNode.META["Coordinates"] = OrderedDict() 

Laddar…
Avbryt
Spara