Using python to extract UPNESS index as used by Summerell et al.

697
0
11-07-2011 06:51 PM
JeromeSebadduka
New Contributor
I am a new user of python and trying to read Summerell et al's FOTRAN code into python. This code is used to determining contributing area as viewed from a groundwater perspective. Rather than flow accumulation as we know it, it conceives accumulation to be permissible even when a cell is outside a catchment, for as long as it is at a higher elevation, it can potentially contribute flow to a lower cell.

For a cell ...
process_cell(target, current):
  mask(current) = 1;
  UPNESS(target) = UPNESS(target) + 1;
  for i = each cell adjacent to current
    if elev(i) equals nodata then
      mask(i) = 1;
    else if elev(i) greater than or equals elev(current) then
      if mask(i) equals 0 then
        call process_cell(target, i);
      endif
     endif
    endfor
   end;
where mask(current) is a temporary mask grid that tracks which cells have been processed for each target UPNESS cell (UPNESS(target)); UPNESS(target) is the output cell for the sum of all cells monotonically uphill; and elev(current) is the input grid cell corresponding to UPNESS(current).

For the whole DEM ...
for n = each cell in grid
  if elevn not_equals nodata
   for i = each cell in grid
    maski = 0;
   endfor
   UPNESSn = 0;
   process_cell(n,n);
  endif
endfor;
end:


Thank you
Tags (2)
0 Kudos
0 Replies