[GRASS-SVN] r49467 - grass/trunk/gui/wxpython/wxplot
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Dec 1 15:36:17 EST 2011
Author: cmbarton
Date: 2011-12-01 12:36:17 -0800 (Thu, 01 Dec 2011)
New Revision: 49467
Modified:
grass/trunk/gui/wxpython/wxplot/base.py
grass/trunk/gui/wxpython/wxplot/dialogs.py
grass/trunk/gui/wxpython/wxplot/histogram.py
grass/trunk/gui/wxpython/wxplot/scatter.py
Log:
wxgui plots: bug fixing, error trapping, updating
Modified: grass/trunk/gui/wxpython/wxplot/base.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/base.py 2011-12-01 19:18:27 UTC (rev 49466)
+++ grass/trunk/gui/wxpython/wxplot/base.py 2011-12-01 20:36:17 UTC (rev 49467)
@@ -170,10 +170,10 @@
self.raster[r] = UserSettings.Get(group = plottype, key = 'raster') # some default settings
rdict[r] = {} # initialize sub-dictionaries for each raster in the list
+
- if ret['units'] in ('(none)', '"none"', '', None):
- rdict[r]['units'] = ''
- else:
+ rdict[r]['units'] = ''
+ if ret['units'] not in ('(none)', '"none"', '', None):
rdict[r]['units'] = ret['units']
rdict[r]['plegend'] = r.split('@')[0]
@@ -202,6 +202,7 @@
rdict = {} # initialize a dictionary
for rpair in rasterList:
+ print 'rpair = ' + str(rpair)
idx = rasterList.index(rpair)
try:
@@ -216,17 +217,14 @@
rdict[rpair] = {} # initialize sub-dictionaries for each raster in the list
rdict[rpair][0] = {}
rdict[rpair][1] = {}
+ rdict[rpair][0]['units'] = ''
+ rdict[rpair][1]['units'] = ''
- if ret0['units'] in ('(none)', '"none"', '', None):
- rdict[rpair][0]['units'] = ''
- else:
- self.raster[rpair][0]['units'] = ret0['units']
-
- if ret1['units'] in ('(none)', '"none"', '', None):
- rdict[rpair][1]['units'] = ''
- else:
- self.raster[rpair][1]['units'] = ret1['units']
-
+ if ret0['units'] not in ('(none)', '"none"', '', None):
+ rdict[rpair][0]['units'] = ret0['units']
+ if ret1['units'] not in ('(none)', '"none"', '', None):
+ rdict[rpair][1]['units'] = ret1['units']
+
rdict[rpair]['plegend'] = rpair[0].split('@')[0] + ' vs ' + rpair[1].split('@')[0]
rdict[rpair]['datalist'] = [] # list of cell value,frequency pairs for plotting histogram
rdict[rpair]['ptype'] = 'dot'
@@ -242,6 +240,8 @@
b = randint(0, 255)
g = randint(0, 255)
rdict[rpair]['pcolor'] = ((r,g,b,255))
+
+ print 'rdict =' + str(rdict)
return rdict
Modified: grass/trunk/gui/wxpython/wxplot/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/dialogs.py 2011-12-01 19:18:27 UTC (rev 49466)
+++ grass/trunk/gui/wxpython/wxplot/dialogs.py 2011-12-01 20:36:17 UTC (rev 49467)
@@ -469,8 +469,13 @@
group = '%s' % self.group,
quiet = True,
flags = 'g').strip().split('\n')
- if ret != None and ret != '':
+
+ if ret not in [None, '', ['']]:
self.rasterList = ret
+ else:
+ wx.MessageBox(message = _("Selected group must be in current mapset"),
+ caption = _('Invalid input'),
+ style = wx.OK|wx.ICON_ERROR)
def OnSetBins(self, event):
"""!Bins for histogramming FP maps (=nsteps in r.stats)
Modified: grass/trunk/gui/wxpython/wxplot/histogram.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/histogram.py 2011-12-01 19:18:27 UTC (rev 49466)
+++ grass/trunk/gui/wxpython/wxplot/histogram.py 2011-12-01 20:36:17 UTC (rev 49467)
@@ -152,13 +152,18 @@
read = True)
if not ret:
+ print 'in stats loop'
return datalist
for line in ret.splitlines():
cellval, histval = line.strip().split(',')
histval = histval.strip()
if self.raster[raster]['datatype'] != 'CELL':
- cellval = cellval.split('-')[0]
+ if cellval[0] == '-':
+ cellval = '-' + cellval.split('-')[1]
+ else:
+ cellval = cellval.split('-')[0]
+
if self.histtype == 'percent':
histval = histval.rstrip('%')
Modified: grass/trunk/gui/wxpython/wxplot/scatter.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/scatter.py 2011-12-01 19:18:27 UTC (rev 49466)
+++ grass/trunk/gui/wxpython/wxplot/scatter.py 2011-12-01 20:36:17 UTC (rev 49467)
@@ -140,17 +140,18 @@
#
# set xlabel & ylabel based on raster maps of first pair to be plotted
#
+ self.xlabel = _('Raster cell values')
+ self.ylabel = _('Raster cell values')
+
units = self.raster[self.rasterList[0]][0]['units']
- if units != '' and units != '(none)' and units != None:
- self.xlabel = _('Raster cell values %s') % units
- else:
- self.xlabel = _('Raster cell values')
+ if units != '':
+ self.xlabel += _(': %s') % units
units = self.raster[self.rasterList[0]][1]['units']
- if units != '' and units != '(none)' and units != None:
- self.ylabel = _('Raster cell values %s') % units
- else:
- self.ylabel = _('Raster cell values')
+ if units != '':
+ self.ylabel += _(': %s') % units
+
+ print 'axis labels = ' + ' x:' + self.xlabel + ' y:' + self.ylabel
def CreateDatalist(self, rpair):
"""!Build a list of cell value, frequency pairs for histogram
@@ -179,9 +180,18 @@
for line in ret.splitlines():
rast1, rast2 = line.strip().split(',')
rast1 = rast1.strip()
- if '-' in rast1: rast1 = rast1.split('-')[0]
+ if '-' in rast1:
+ if rast1[0] == '-':
+ rast1 = '-' + rast1.split('-')[1]
+ else:
+ rast1 = rast1.split('-')[0]
+
rast2 = rast2.strip()
- if '-' in rast2: rast2 = rast2.split('-')[0]
+ if '-' in rast2:
+ if rast2[0] == '-':
+ rast2 = '-' + rast2.split('-')[1]
+ else:
+ rast2 = rast2.split('-')[0]
rast1 = rast1.encode('ascii', 'ignore')
rast2 = rast2.encode('ascii', 'ignore')
More information about the grass-commit
mailing list