[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master c03089f: Crop: floating point errors accounted

From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master c03089f: Crop: floating point errors accounted, when checking pixel scale
Date: Mon, 27 Jul 2020 05:44:50 -0400 (EDT)

branch: master
commit c03089f7170ab6321c8578ed8114b4880d5c211f
Author: Mohammad Akhlaghi <>
Commit: Mohammad Akhlaghi <>

    Crop: floating point errors accounted, when checking pixel scale
    In WCS mode, Crop can take multiple images and stitch them together. To do
    this, it needs to make sure that all images have the same pixel scale. But
    until now, it used a simple equality check to see if the pixel scales are
    the equal. However, floating point errors can create problems in this
    check, causing a crash in Crop (which will complain about the images not
    having the same pixel scale).
    To fix this, instead of using a simple equal, I changed the check to see if
    the difference between the two pixel scales is larger than floating point
    errors (roughly 1x10^{-10}).
    This bug was reported by Joanna Sakowska.
    This fixes bug #58835.
 NEWS               | 1 +
 bin/crop/wcsmode.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 22d813c..54c7481 100644
--- a/NEWS
+++ b/NEWS
@@ -99,6 +99,7 @@ See the end of the file for license conditions.
   bug #58774: Warp' s output on a cube is a 2D image or wrong size.
   bug #58809: NoiseChisel not removing negative outlier tiles.
   bug #58833: Segment crashes when detetion map has blank pixels
+  bug #58835: Floating point errors when comparing pixel scale in Crop.
diff --git a/bin/crop/wcsmode.c b/bin/crop/wcsmode.c
index cda480f..94aa34a 100644
--- a/bin/crop/wcsmode.c
+++ b/bin/crop/wcsmode.c
@@ -116,7 +116,7 @@ wcsmode_check_prepare(struct cropparams *p, struct 
inputimgs *img)
-        if(p->pixscale[i] != pixscale[i])
+        if(fabs(p->pixscale[i]-pixscale[i])>1e-10) /* Floating point errors. */
           error(EXIT_FAILURE, 0, "%s (hdu %s): has resolution of %g along "
                 "dimension %d. However, previously checked input(s) had "
                 "a resolution of %g in this dimension", img->name, p->cp.hdu,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]