[Top][All Lists]

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

[gnuastro-commits] master b79fceb 1/2: NoiseChisel warning when the edge

From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master b79fceb 1/2: NoiseChisel warning when the edges have a value of zero
Date: Thu, 3 May 2018 14:26:11 -0400 (EDT)

branch: master
commit b79fceb26150d1825045181699480deda3e4e85e
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    NoiseChisel warning when the edges have a value of zero
    Most data reduction pipelines put a value of 0.0 where there isn't any data
    (commonly on the outer-frames of the observed field). But for NoiseChisel,
    a value of 0.0 is meaningful, so it will give bad results. To help early
    users understand this important point, a small check was added to see if
    the first (and last) two pixels are 0.0 or not. If they are, a complete
    warning message will be printed at the start of NoiseChisel's run and even
    propose an solution (using Arithmetic).
 bin/noisechisel/ui.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/bin/noisechisel/ui.c b/bin/noisechisel/ui.c
index 12eebc6..ae74441 100644
--- a/bin/noisechisel/ui.c
+++ b/bin/noisechisel/ui.c
@@ -68,8 +68,8 @@ args_doc[] = "ASTRdata";
 const char
 doc[] = GAL_STRINGS_TOP_HELP_INFO PROGRAM_NAME" Detects and segments signal "
   "that is deeply burried in noise. It employs a noise-based detection and "
-  "segmentation method enabling it to be very resilient to the rich diversity "
-  "of shapes in astronomical targets.\n"
+  "segmentation method enabling it to be very resilient to the rich "
+  "diversity of shapes in astronomical targets.\n"
   /* After the list of options: */
@@ -521,6 +521,8 @@ ui_prepare_tiles(struct noisechiselparams *p)
 static void
 ui_preparations(struct noisechiselparams *p)
+  float *f;
   /* Prepare the names of the outputs. */
@@ -541,6 +543,29 @@ ui_preparations(struct noisechiselparams *p)
           "can only operate on 2D datasets (images)", p->inputname, p->cp.hdu,
+  /* A small check to see if the edges of the dataset aren't zero valued:
+     they should be masked. */
+  f=p->input->array;
+  if( (f[0]==0.0 && f[1]==0.0)
+      || (f[ p->input->size-1 ]==0.0 && f[ p->input->size-2 ]==0.0) )
+    error(0, 0, "%s (hdu %s): [*** WARNING ***]: The first and/or last few "
+          "pixels have a value of 0.0. As described below, the result of "
+          "this run may thus not be reasonable/optimal.\n\n"
+          "Some data reduction pipelines put 0.0 where there isn't data "
+          "(most commonly on the edges). However, NoiseChisel's "
+          "noise-based detection paradigm starts from the lower values of "
+          "the dataset (not high S/N peaks): its initial threshold is "
+          "mostly below the Sky value (0.0 in processed images). Therefore "
+          "0.0 is meaningful for NoiseChisel and must not be used for a "
+          "blank value.\n\n"
+          "To ignore certain pixels, they must have a blank/NaN value. "
+          "To mask (set to blank/NaN) the 0.0 valued elements, you can use "
+          "Gnuastro's Arithmetic program with a command like this:\n\n"
+          "    $ astarithmetic %s %s 0.0 eq nan where -g%s\n\n"
+          "If the few 0.0 valued pixels on the edges are meaningful for "
+          "your analysis, please ignore this warming message.\n"
+          "--------------------------",
+          p->inputname, p->cp.hdu, p->inputname, p->inputname, p->cp.hdu);
   /* If a convolved image was given, read it in. Otherwise, read the given
      kernel. */

reply via email to

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