gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 036ada1: MakeCatalog: Brightness error correct


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 036ada1: MakeCatalog: Brightness error correctly calculated when noise STD<1
Date: Wed, 19 May 2021 21:15:25 -0400 (EDT)

branch: master
commit 036ada1b9bce90b54facb80a5d74973fd34290f4
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    MakeCatalog: Brightness error correctly calculated when noise STD<1
    
    Until now, the correction to fix error measurements in images with STD<1
    was not being applied to the brightness error! It was applied when
    calculating the signal-to-noise ratio (and thus the magnitude error), but
    not the brightness error. As a result, when the data are in very small
    units (like Janskies!) the brightness errors become larger than the
    brightness itself, even for very high S/N objects!
    
    This is explained more fully in Section 3.3 (S/N Equation Modiļ¬cations) of
    the NoiseChisel paper: when the image noise has a value that is less than
    1, it means that the data are not in units of counts (they are often scaled
    to other units, like electrons/sec). However, even though it is scaled
    (multiplied by a factor) from the original counts, the original noise was
    Poisson noise, it just needs to be scaled back.
    
    With this commit, this multiplication factor is now applied to the
    brightness error directly and thus propagating correctly to the S/N and the
    magnitude error.
    
    This fixes bug #60644.
---
 NEWS                    | 3 +++
 bin/mkcatalog/columns.c | 4 ++--
 bin/mkcatalog/parse.c   | 5 ++++-
 bin/mkcatalog/ui.c      | 2 +-
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index ffb9fea..ecc3160 100644
--- a/NEWS
+++ b/NEWS
@@ -254,6 +254,9 @@ See the end of the file for license conditions.
   bug #60603: Table crashes with an empty input and --range
   bug #60619: Crop crashes with differing image and WCS dimension
   bug #60634: Crop's '--hstartwcs' and '--hendwcs' wrong with comment keys
+  bug #60644: MakeCatalog's Brightness error over-estimated in images with
+              noise STD less than 1. This was not an issue for S/N or
+              Magnitude error on the same image (already corrected there).
 
 
 
diff --git a/bin/mkcatalog/columns.c b/bin/mkcatalog/columns.c
index e7340c7..d6d0469 100644
--- a/bin/mkcatalog/columns.c
+++ b/bin/mkcatalog/columns.c
@@ -2028,7 +2028,7 @@ columns_brightness_error(struct mkcatalogparams *p, 
double *row, int o0c1)
 {
   double V = row[ o0c1 ? CCOL_SUM_VAR : OCOL_SUM_VAR ];
   double OV = (o0c1 && row[ CCOL_RIV_NUM ]) ? row[ CCOL_RIV_SUM_VAR ] : 0.0;
-  return sqrt(V+OV);
+  return sqrt( (V+OV)*p->cpscorr );
 }
 
 
@@ -2050,7 +2050,7 @@ columns_sn(struct mkcatalogparams *p, double *row, int 
o0c1)
                : 0.0 );
 
   /* Return the derived value. */
-  return sqrt(1/p->cpscorr) * (I-O) / columns_brightness_error(p, row, o0c1);
+  return (I-O) / columns_brightness_error(p, row, o0c1);
 }
 
 
diff --git a/bin/mkcatalog/parse.c b/bin/mkcatalog/parse.c
index 375d72c..d42ccee 100644
--- a/bin/mkcatalog/parse.c
+++ b/bin/mkcatalog/parse.c
@@ -681,6 +681,7 @@ parse_objects(struct mkcatalog_passparams *pp)
               /* Sky standard deviation based measurements.*/
               if(p->std)
                 {
+                  /* Calculate the variance and save it in the output if 
necessary. */
                   sval = pp->st_std ? *ST : (p->std->size>1?std[tid]:std[0]);
                   var = p->variance ? sval : sval*sval;
                   if(oif[ OCOL_SUMVAR ] && (!isnan(var)))
@@ -688,6 +689,7 @@ parse_objects(struct mkcatalog_passparams *pp)
                       oi[ OCOL_NUMVAR  ]++;
                       oi[ OCOL_SUMVAR  ] += var;
                     }
+
                   /* For each pixel, we have a sky contribution to the
                      counts and the signal's contribution. The standard
                      deviation in the sky is simply 'sval', but the
@@ -701,7 +703,8 @@ parse_objects(struct mkcatalog_passparams *pp)
                   if(oif[ OCOL_SUM_VAR ] && goodvalue)
                     {
                       varval=p->variance ? var : sval;
-                      if(!isnan(varval)) oi[ OCOL_SUM_VAR ] += varval + 
fabs(*V);
+                      if(!isnan(varval))
+                        oi[ OCOL_SUM_VAR ] += varval + fabs(*V);
                     }
                 }
             }
diff --git a/bin/mkcatalog/ui.c b/bin/mkcatalog/ui.c
index 4f4cc23..a456c79 100644
--- a/bin/mkcatalog/ui.c
+++ b/bin/mkcatalog/ui.c
@@ -1425,7 +1425,7 @@ ui_preparations_read_keywords(struct mkcatalogparams *p)
 
           /* If the two keywords couldn't be read. We don't want to slow
              down the user for the median (which needs sorting). So we'll
-             just calculate if if '--forcereadstd' is called. However, we
+             just calculate it if '--forcereadstd' is called. However, we
              need the minimum for 'p->cpscorr'. */
           if(keys[1].status)
             {



reply via email to

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