Skip to content

Commit

Permalink
Sediment deposition now uses more memory, but can handle larger indexes.
Browse files Browse the repository at this point in the history
  • Loading branch information
phargogh committed Oct 19, 2023
1 parent f6ea5ec commit eab9919
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/natcap/invest/sdr/sdr_core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ cdef int *ROW_OFFSETS = [0, -1, -1, -1, 0, 1, 1, 1]
cdef int *COL_OFFSETS = [1, 1, 0, -1, -1, -1, 0, 1]


cdef int is_close(double x, double y):
return abs(x-y) <= (1e-8+1e-05*abs(y))

# this is a least recently used cache written in C++ in an external file,
# exposing here so _ManagedRaster can use it
cdef extern from "LRUCache.h" nogil:
Expand Down Expand Up @@ -435,7 +432,7 @@ def calculate_sediment_deposition(
# is the original pixel `x`
cdef int *inflow_offsets = [4, 5, 6, 7, 0, 1, 2, 3]

cdef int n_cols, n_rows
cdef long n_cols, n_rows
flow_dir_info = pygeoprocessing.get_raster_info(mfd_flow_direction_path)
n_cols, n_rows = flow_dir_info['raster_size']
cdef int mfd_nodata = 0
Expand All @@ -444,11 +441,12 @@ def calculate_sediment_deposition(
sdr_path)['nodata'][0]
cdef float e_prime_nodata = pygeoprocessing.get_raster_info(
e_prime_path)['nodata'][0]
cdef int col_index, row_index, win_xsize, win_ysize, xoff, yoff
cdef int global_col, global_row, flat_index, j, k
cdef int seed_col = 0
cdef int seed_row = 0
cdef int neighbor_row, neighbor_col
cdef long col_index, row_index, win_xsize, win_ysize, xoff, yoff
cdef long global_col, global_row, j, k
cdef unsigned long flat_index
cdef long seed_col = 0
cdef long seed_row = 0
cdef long neighbor_row, neighbor_col
cdef int flow_val, neighbor_flow_val, ds_neighbor_flow_val
cdef int flow_weight, neighbor_flow_weight
cdef float flow_sum, neighbor_flow_sum
Expand Down

0 comments on commit eab9919

Please sign in to comment.