[Top][All Lists]

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

[gnuastro-commits] master 092fdd68: MakeProfiles: --kernel normalized fo

From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 092fdd68: MakeProfiles: --kernel normalized for any zeropoint
Date: Tue, 28 Jun 2022 11:51:35 -0400 (EDT)

branch: master
commit 092fdd681234b3d29eec486cfdbaecc90f47bbd0
Author: Mohammad Akhlaghi <>
Commit: Mohammad Akhlaghi <>

    MakeProfiles: --kernel normalized for any zeropoint
    Until now, the output of the '--kernel' option was only normalized (the sum
    of its pixels were zero) for a zeropoint of 0.0. When a different zeropoint
    was used, the output kernel would not be normalized.
    With this commit, the final magnitude of the output kernel is set to be
    equal to the zeropoint (unless the '--mcolisbrightness' option is given; in
    this case, it is set to 1.0).
    In the process, I also noticed that with '--magatpeak' the output of
    '--kernel' will not be normalized (because the peak value is set to
    1.0!). Therefore, if '--magatpeak' is given with '--kernel', MakeProfiles
    will abort and print a message to tell the user that these two options
    can't be called together.
    This bug was found with the help of Raul Infante-Sainz.
    This fixes bug #62679.
 NEWS            | 3 +++
 bin/mkprof/ui.c | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 672e7c0e..c46533e5 100644
--- a/NEWS
+++ b/NEWS
@@ -171,6 +171,9 @@ See the end of the file for license conditions.
   bug #62674: Column arithmetic can't use columns from --catcolumnfile.
   bug #62678: Radial profile script using values image instead of STD image
               when '--instd' not used. Found and fixed by Raul Infante-Sainz.
+  bug #62679: MakeProfiles kernel only normalized when zeropoint is
+              zero. Found by Raul Infante-Sainz.
diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index efa0f1a8..bf15aa93 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -554,6 +554,13 @@ ui_read_check_only_options(struct mkprofparams *p)
           "called (i.e., when the contents of '--mcol' must be "
           "interpretted as a magnitude, not brightness).");
+  /* The kernel should always be normalized to 1.0. So '--magatpeak' should
+     never be called with '--kernel'. */
+  if(p->kernel && p->magatpeak)
+    error(EXIT_FAILURE, 0, "the kernel created by '--kernel' should "
+          "always be normalized (sum of its values) to 1.0. Therefore "
+          "it shouldn't be called with '--magatpeak'");
   /* Make sure no zero value is given for the '--mergedsize' option (only
      when it is necessary). */
   if(p->dsize && p->backname==NULL)
@@ -1272,7 +1279,7 @@ ui_prepare_columns(struct mkprofparams *p)
       p->n[0]  = n;
       p->p1[0] = 0.0f;
       p->q1[0] = 1.0f;
-      p->m[0]  = 0.0f;
+      p->m[0]  = p->mcolisbrightness ? 1.0f : p->zeropoint;
       p->t[0]  = t;

reply via email to

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