From 87650a12c28643386b2bf46fa363100c28c0ec64 Mon Sep 17 00:00:00 2001 From: Mihai Cara Date: Wed, 8 Feb 2023 11:45:59 -0500 Subject: [PATCH] Fix incorrect identification of lines to be skipped --- CHANGES.rst | 12 +++++++++++- src/cdrizzlemap.c | 17 ++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index cfd901b..f3054cc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,9 +4,18 @@ Release Notes ============= -.. 1.13.7 (unreleased) +.. 1.13.8 (unreleased) =================== + +1.13.7 (2023-02-09) +=================== + +- Fixed a bug in identification of lines in input images that should be skipped + because they would not map to the output image. This bug may result in large + chunks of input image incorrectly missing from the resampled image. [#89] + + 1.13.6 (2021-08-05) =================== @@ -24,6 +33,7 @@ Release Notes resulted in shifts of the resampled image typically by 0.5 pixels compared to the location indicated by the WCS. [#83] + 1.13.4 (2021-12-23) =================== diff --git a/src/cdrizzlemap.c b/src/cdrizzlemap.c index 580e4ff..e415d12 100644 --- a/src/cdrizzlemap.c +++ b/src/cdrizzlemap.c @@ -104,13 +104,18 @@ shrink_segment(struct segment *self, PyArrayObject *array, int (*is_bad_value)(PyArrayObject *, int, int)) { - int i, j, imin, imax, jmin, jmax; + int i, j, imin, imax, jmin, jmax, i1, i2, j1, j2; imin = self->point[1][0]; jmin = self->point[1][1]; - for (j = self->point[0][1]; j < self->point[1][1]; ++j) { - for (i = self->point[0][0]; i < self->point[1][0]; ++ i) { + j1 = (int) ceil(self->point[1][1]); + j2 = (int) self->point[0][1]; + i1 = (int) ceil(self->point[1][0]); + i2 = (int) self->point[0][0]; + + for (j = j2; j < j1; ++j) { + for (i = i2; i < i1; ++i) { if (! is_bad_value(array, i, j)) { if (i < imin) { imin = i; @@ -125,9 +130,8 @@ shrink_segment(struct segment *self, imax = self->point[0][0]; jmax = self->point[0][1]; - - for (j = self->point[1][1]; j > self->point[0][1]; --j) { - for (i = self->point[1][0]; i > self->point[0][0]; -- i) { + for (j = j1; j > j2; --j) { + for (i = i1; i > i2; --i) { if (! is_bad_value(array, i-1, j-1)) { if (i > imax) { imax = i; @@ -139,7 +143,6 @@ shrink_segment(struct segment *self, } } } - initialize_segment(self, imin, jmin, imax, jmax); self->invalid = imin >= imax || jmin >= jmax; return;