[GRASS-SVN] r65099 - grass-addons/grass6/raster/r.ipso
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Apr 19 07:57:27 PDT 2015
Author: madi
Date: 2015-04-19 07:57:27 -0700 (Sun, 19 Apr 2015)
New Revision: 65099
Modified:
grass-addons/grass6/raster/r.ipso/r.ipso.py
Log:
fixed findint function to handle the case in which the function presents two min
Modified: grass-addons/grass6/raster/r.ipso/r.ipso.py
===================================================================
--- grass-addons/grass6/raster/r.ipso/r.ipso.py 2015-04-19 14:53:08 UTC (rev 65098)
+++ grass-addons/grass6/raster/r.ipso/r.ipso.py 2015-04-19 14:57:27 UTC (rev 65099)
@@ -59,6 +59,7 @@
import matplotlib.pyplot as plt
import grass.script as grass
import numpy as np
+from operator import itemgetter
def main():
stats = grass.read_command('r.stats', input = options['map'], fs = 'space', nv = '*', nsteps = '255', flags = 'inc').split('\n')[:-1]
@@ -122,8 +123,14 @@
def findint(kl,f):
- Xf = np.abs(kl-f); Xf = np.where(Xf==Xf.min())
- z1 , z2 , f1 , f2 = kl[float(Xf[0])][0] , kl[float(Xf[0]-1)][0] , kl[float(Xf[0])][1] , kl[float(Xf[0]-1)][1]
+ Xf = np.abs(kl-f)
+ Xf = np.where(Xf==Xf.min())
+ item = itemgetter(0)(Xf)
+ Xf = item[0] # added this further step to handle the case the function has 2 min
+ z1 = kl[float(Xf)][0]
+ z2 = kl[float(Xf-1)][0]
+ f1 = kl[float(Xf)][1]
+ f2 = kl[float(Xf-1)][1]
z = z1 + ((z2 - z1) / (f2 - f1)) * (f - f1)
return z
More information about the grass-commit
mailing list