[GRASS-SVN] r61233 - sandbox/annakrat/r3.flow
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 10 09:17:42 PDT 2014
Author: annakrat
Date: 2014-07-10 09:17:42 -0700 (Thu, 10 Jul 2014)
New Revision: 61233
Modified:
sandbox/annakrat/r3.flow/r3.flow.py
sandbox/annakrat/r3.flow/rast3d_functions.py
Log:
r3.flow: various fixes
Modified: sandbox/annakrat/r3.flow/r3.flow.py
===================================================================
--- sandbox/annakrat/r3.flow/r3.flow.py 2014-07-10 15:57:13 UTC (rev 61232)
+++ sandbox/annakrat/r3.flow/r3.flow.py 2014-07-10 16:17:42 UTC (rev 61233)
@@ -133,7 +133,7 @@
def compute_flowline(map_info, seed, velocity_obj, integration, flowline_vector, flowacc):
- count = 0
+ count = 1
point = seed.x, seed.y, seed.z
if seed.flowline:
line = Line([Point(seed.x, seed.y, seed.z)])
@@ -173,7 +173,7 @@
for p in additional:
flowacc[p[2]][p[1]][p[0]] += 1
last_coords = (col, row, depth)
- point = new_point
+ point = new_point[:]
count += 1
if seed.flowline and len(line) > 1:
@@ -259,6 +259,8 @@
flowacc = garray.array3d()
for depth in range(map_info['depths']):
flowacc[depth] = np.zeros((map_info['rows'], map_info['cols']))
+ else:
+ flowacc = None
# try open seed points map and get number of points
if options['seed_points']:
Modified: sandbox/annakrat/r3.flow/rast3d_functions.py
===================================================================
--- sandbox/annakrat/r3.flow/rast3d_functions.py 2014-07-10 15:57:13 UTC (rev 61232)
+++ sandbox/annakrat/r3.flow/rast3d_functions.py 2014-07-10 16:17:42 UTC (rev 61233)
@@ -145,9 +145,13 @@
"""!Returns column, row and depth of a cell where the input
coordinates (north, east, top) lie."""
# math.floor to get because int(-0.8) gives 0
- col = int(math.floor((east - rast3d_region['west']) / rast3d_region['ewres']))
- row = int(math.floor((rast3d_region['north'] - north) / rast3d_region['nsres']))
- depth = int(math.floor((top - rast3d_region['bottom']) / rast3d_region['tbres']))
+ col = int(math.floor((east - rast3d_region['west']) / (rast3d_region['east'] -
+ rast3d_region['west']) * rast3d_region['cols']))
+ row = int(math.floor((north - rast3d_region['south']) / (rast3d_region['north'] -
+ rast3d_region['south']) * rast3d_region['rows']))
+ depth = int(math.floor((top - rast3d_region['bottom']) / (rast3d_region['top'] -
+ rast3d_region['bottom']) * rast3d_region['depths']))
+ row = rast3d_region['rows'] - row - 1
return col, row, depth
More information about the grass-commit
mailing list