[GRASS-SVN] r57134 - in grass/trunk: gui/wxpython/scripts scripts scripts/v.krige

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 15 02:53:58 PDT 2013


Author: aghisla
Date: 2013-07-15 02:53:58 -0700 (Mon, 15 Jul 2013)
New Revision: 57134

Modified:
   grass/trunk/gui/wxpython/scripts/vkrige.py
   grass/trunk/scripts/Makefile
   grass/trunk/scripts/v.krige/v.krige.py
Log:
Removed global variables from GUI and core scripts.

Modified: grass/trunk/gui/wxpython/scripts/vkrige.py
===================================================================
--- grass/trunk/gui/wxpython/scripts/vkrige.py	2013-07-15 09:49:51 UTC (rev 57133)
+++ grass/trunk/gui/wxpython/scripts/vkrige.py	2013-07-15 09:53:58 UTC (rev 57134)
@@ -463,14 +463,13 @@
         column = self.parent.InputDataColumn.GetValue()
         
         # import data or pick them up
-        if globals()["InputData"] is None:
-            globals()["InputData"] = controller.ImportMap(map = map,
+        if self.controller.InputData is None:
+            self.controller.InputData = controller.ImportMap(map = map,
                                                           column = column)
         # fit the variogram or pick it up
         Formula = controller.ComposeFormula(column = column,
                                             isblock = self.KrigingRadioBox.GetStringSelection() == "Block kriging",
-                                            inputdata = globals()['InputData'])
-        #if globals()["Variogram"] is None:
+                                            inputdata = self.controller.InputData)
         if hasattr(self, 'VariogramCheckBox') and self.VariogramCheckBox.IsChecked():
             self.model = ''
             for each in ("Sill","Nugget","Range"):
@@ -484,8 +483,8 @@
                 if getattr(self, each+'ChextBox').IsChecked(): #@FIXME will be removed when chextboxes will be frozen
                     setattr(self, each.lower(), getattr(self, each+"Ctrl").GetValue())
             
-        globals()["Variogram"] = controller.FitVariogram(Formula,
-                                                         InputData,
+        self.controller.Variogram = controller.FitVariogram(Formula,
+                                                         self.controller.InputData,
                                                          model = self.model,
                                                          sill = self.sill,
                                                          nugget = self.nugget,

Modified: grass/trunk/scripts/Makefile
===================================================================
--- grass/trunk/scripts/Makefile	2013-07-15 09:49:51 UTC (rev 57133)
+++ grass/trunk/scripts/Makefile	2013-07-15 09:53:58 UTC (rev 57134)
@@ -68,9 +68,9 @@
 	v.pack \
 	v.unpack \
 	v.what.vect \
-	wxpyimgview
+	wxpyimgview \
 
-#        v.krige \
+	v.krige \
 
 #	r.mapcalculator \
 #	r3.mapcalculator \

Modified: grass/trunk/scripts/v.krige/v.krige.py
===================================================================
--- grass/trunk/scripts/v.krige/v.krige.py	2013-07-15 09:49:51 UTC (rev 57133)
+++ grass/trunk/scripts/v.krige/v.krige.py	2013-07-15 09:53:58 UTC (rev 57134)
@@ -124,18 +124,26 @@
 
 # globals
 
-Command = None
-InputData = None
-Variogram = None
-VariogramFunction = None
-robjects = None
-rinterface = None
+#~ Command = None
+#~ InputData = None
+#~ Variogram = None
+#~ VariogramFunction = None
+#~ robjects = None
+#~ rinterface = None
 
 #classes in alphabetical order. methods in logical order :)
 
 # <2.5 class definition, without () - please test 
 class Controller:
     """ Executes analysis. For the moment, only with gstat functions."""
+    # moved here the global variables
+    def __init__(self):
+        #~ self.Command = None
+        self.InputData = None
+        self.Variogram = None
+        #~ VariogramFunction = None
+        #~ robjects = None
+        #~ rinterface = None
     
     def ImportMap(self, map, column):
         """ Imports GRASS map as SpatialPointsDataFrame and adds x/y columns to attribute table.
@@ -252,20 +260,20 @@
                          "exponentially with resolution." % grass.region()['cells']))
         logger.message(_("Importing data..."))
 
-        if globals()["InputData"] is None:
-            globals()["InputData"] = self.ImportMap(input, column)
+        if self.InputData is None:
+            self.InputData = self.ImportMap(input, column)
         # and from here over, InputData refers to the global variable
         #print(robjects.r.slot(InputData, 'data').names)
         logger.message(_("Data successfully imported."))
         
-        GridPredicted = self.CreateGrid(InputData)
+        GridPredicted = self.CreateGrid(self.InputData)
         
         logger.message(_("Fitting variogram..."))
         isblock = block is not ''
-        Formula = self.ComposeFormula(column, isblock, InputData)
-        if globals()["Variogram"] is None:
-            globals()["Variogram"] = self.FitVariogram(Formula,
-                                          InputData,
+        Formula = self.ComposeFormula(column, isblock, self.InputData)
+        if self.Variogram is None:
+            self.Variogram = self.FitVariogram(Formula,
+                                          self.InputData,
                                           model = model,
                                           sill = sill,
                                           nugget = nugget,
@@ -273,8 +281,8 @@
         logger.message(_("Variogram fitting complete."))
         
         logger.message(_("Kriging..."))
-        KrigingResult = self.DoKriging(Formula, InputData,
-                 GridPredicted, Variogram['variogrammodel'], block) # using global ones
+        KrigingResult = self.DoKriging(Formula, self.InputData,
+                 GridPredicted, self.Variogram['variogrammodel'], block) # using global ones
         logger.message(_("Kriging complete."))
         
         self.ExportMap(map = KrigingResult,
@@ -282,14 +290,14 @@
                        name = output,
                        overwrite = overwrite,
                        command = command,
-                       variograms = Variogram)
+                       variograms = self.Variogram)
         if output_var is not '':
             self.ExportMap(map = KrigingResult,
                            column='var1.var',
                            name = output_var,
                            overwrite = overwrite,
                            command = command,
-                           variograms = Variogram)
+                           variograms = self.Variogram)
         
 def main(argv = None):
     """ Main. Calls either GUI or CLI, depending on arguments provided. """



More information about the grass-commit mailing list