Skip to content

Commit

Permalink
Merge pull request #193 from richpsharp/bugfix/percentile-percent-wro…
Browse files Browse the repository at this point in the history
…ng-192

fixes #192, change to long, better logging, updated history
  • Loading branch information
dcdenu4 authored May 14, 2021
2 parents afb9c43 + 4dab739 commit ca16832
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Unreleased Changes
box's coordinates were finite. This guards against cases where a transform
into another coordinate system creates a degenerate bounding box.
Previously the function would silently return non-finite coordinates.
* Fixing issue when calculating histogram for floating point rasters the
logging progress percent would be incorrectly calculated.

2.1.2 (2020-12-03)
------------------
Expand Down
15 changes: 9 additions & 6 deletions src/pygeoprocessing/geoprocessing_core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,9 @@ def _raster_band_percentile_int(
pixels_processed += block_data.size
if time.time() - last_update > 5.0:
LOGGER.debug(
'data sort to heap %.2f%% complete',
(100.*pixels_processed)/n_pixels)
f'data sort to heap {(100.*pixels_processed)/n_pixels:.1f}% '
f'complete, {pixels_processed} out of {n_pixels}'),

last_update = time.time()
buffer_data = numpy.sort(
block_data[~numpy.isclose(block_data, nodata)]).astype(
Expand Down Expand Up @@ -868,8 +869,9 @@ def _raster_band_percentile_double(
raster_info = pygeoprocessing.get_raster_info(
base_raster_path_band[0])
nodata = raster_info['nodata'][base_raster_path_band[1]-1]
n_pixels = numpy.prod(raster_info['raster_size'])
pixels_processed = 0
cdef long long n_pixels = (
raster_info['raster_size'][0] * raster_info['raster_size'][1])
cdef long long pixels_processed = 0

last_update = time.time()
LOGGER.debug('sorting data to heap')
Expand All @@ -878,8 +880,9 @@ def _raster_band_percentile_double(
pixels_processed += block_data.size
if time.time() - last_update > 5.0:
LOGGER.debug(
'data sort to heap %.2f%% complete',
(100.*pixels_processed)/n_pixels)
f'data sort to heap {(100.*pixels_processed)/n_pixels:.1f}% '
f'complete, {pixels_processed} out of {n_pixels}'),

last_update = time.time()
buffer_data = numpy.sort(
block_data[~numpy.isclose(block_data, nodata)]).astype(
Expand Down

0 comments on commit ca16832

Please sign in to comment.