[GRASS-SVN] r57146 - in grass/trunk: gui/wxpython/scripts scripts/v.krige
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 15 06:33:07 PDT 2013
Author: aghisla
Date: 2013-07-15 06:33:06 -0700 (Mon, 15 Jul 2013)
New Revision: 57146
Modified:
grass/trunk/gui/wxpython/scripts/vkrige.py
grass/trunk/scripts/v.krige/v.krige.py
Log:
v.krige works again in GRASS7
Modified: grass/trunk/gui/wxpython/scripts/vkrige.py
===================================================================
--- grass/trunk/gui/wxpython/scripts/vkrige.py 2013-07-15 13:31:55 UTC (rev 57145)
+++ grass/trunk/gui/wxpython/scripts/vkrige.py 2013-07-15 13:33:06 UTC (rev 57146)
@@ -47,11 +47,12 @@
import wx
#import wx.lib.plot as plot # for plotting the variogram.
+import rpy2.robjects as robjects
+import rpy2.rinterface as rinterface
# global variables
maxint = 1e6 # instead of sys.maxint, not working with SpinCtrl on 64bit [reported by Bob Moskovitz]
-
#@TODO move away functions not regarding the GUI
class KrigingPanel(wx.Panel):
@@ -192,17 +193,7 @@
event.Skip()
def OnHelpButton(self, event):
- # file = os.path.join(os.getenv("GISBASE"), "docs", "html", "v.krige.html")
- # file = os.path.join(os.path.curdir, "description.html")
- # @TODO fix HelpWindow
- # helpFrame = help.HelpWindow(parent=self, id=wx.ID_ANY,
- # title=_("GRASS - Help page for v.krige"),
- # size=(640, 480),
- # file=file)
- # helpFrame.Show(True)
-
grass.run_command('g.manual', entry = 'v.krige')
-
event.Skip()
def OnInputMapChanged(self, event):
@@ -467,9 +458,8 @@
self.controller.InputData = self.controller.ImportMap(map = map,
column = column)
# fit the variogram or pick it up
- Formula = self.controller.ComposeFormula(column = column,
- isblock = self.KrigingRadioBox.GetStringSelection() == "Block kriging",
- inputdata = self.controller.InputData)
+ #~ Formula = self.controller.ComposeFormula(column = column,
+ #~ isblock = self.KrigingRadioBox.GetStringSelection() == "Block kriging")
if hasattr(self, 'VariogramCheckBox') and self.VariogramCheckBox.IsChecked():
self.model = ''
for each in ("Sill","Nugget","Range"):
@@ -482,21 +472,28 @@
for each in ("Sill","Nugget","Range"):
if getattr(self, each+'ChextBox').IsChecked(): #@FIXME will be removed when chextboxes will be frozen
setattr(self, each.lower(), getattr(self, each+"Ctrl").GetValue())
-
- self.controller.Variogram = self.controller.FitVariogram(Formula,
+
+ isblock = self.KrigingRadioBox.GetStringSelection() == "Block kriging"
+ if isblock is not '':
+ self.predictor = 'x+y'
+ else:
+ self.predictor = '1'
+ print(type(str(column)))
+ self.controller.Variogram = self.controller.FitVariogram(robjects.Formula(str(column) + "~" + self.predictor),
self.controller.InputData,
model = self.model,
sill = self.sill,
nugget = self.nugget,
range = self.range)
-
+
# use R plot function, in a separate window.
thread.start_new_thread(self.plot, ())
def plot(self):
#robjects.r.X11()
#robjects.r.png("variogram.png")
- textplot = robjects.r.plot(Variogram['datavariogram'], Variogram['variogrammodel'])
+ textplot = robjects.r.plot(self.controller.Variogram['datavariogram'],
+ self.controller.Variogram['variogrammodel'])
print textplot
self.refresh()
#robjects.r['dev.off']()
Modified: grass/trunk/scripts/v.krige/v.krige.py
===================================================================
--- grass/trunk/scripts/v.krige/v.krige.py 2013-07-15 13:31:55 UTC (rev 57145)
+++ grass/trunk/scripts/v.krige/v.krige.py 2013-07-15 13:33:06 UTC (rev 57146)
@@ -191,13 +191,13 @@
proj4string = robjects.r.CRS(robjects.r.proj4string(inputdata)))
return GridPredicted
- def ComposeFormula(self, column, isblock, inputdata):
+ def ComposeFormula(self, column, isblock):
if isblock is True:
predictor = 'x+y'
else:
predictor = '1'
+ print column + "~" + predictor
Formula = robjects.Formula(column + "~" + predictor)
- #print Formula
return Formula
def FitVariogram(self, formula, inputdata, sill, nugget, range, model = ''):
@@ -269,10 +269,13 @@
GridPredicted = self.CreateGrid(self.InputData)
logger.message(_("Fitting variogram..."))
- isblock = block is not ''
- Formula = self.ComposeFormula(column, isblock, self.InputData)
+
+ if block is not '':
+ self.predictor = 'x+y'
+ else:
+ self.predictor = '1'
if self.Variogram is None:
- self.Variogram = self.FitVariogram(Formula,
+ self.Variogram = self.FitVariogram(robjects.Formula(column + "~" + self.predictor),
self.InputData,
model = model,
sill = sill,
More information about the grass-commit
mailing list