gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master b5c6f2a 1/3: MakeCatalog brightness is NaN whe


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master b5c6f2a 1/3: MakeCatalog brightness is NaN when no pixels were used
Date: Thu, 1 Jun 2017 13:28:06 -0400 (EDT)

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

    MakeCatalog brightness is NaN when no pixels were used
    
    In MakeCatalog, until now, when no image pixels were used in measuring the
    brightness, the brightness columns would report 0. But 0 is meaningful (it
    might indeed be the sum of the pixels of a profile after sky
    subtraction). So to avoid such confusions from now on, when no pixels were
    used, the reported value is NaN.
    
    Also, to be more similar to the options, the `*_NUMPOS' and `*_SUMPOS'
    constants are now renamed to `*_NUMWHT' and `*_SUMWHT'.
---
 bin/mkcatalog/columns.c   | 51 ++++++++++++++++++++--------------------
 bin/mkcatalog/main.h      | 12 +++++-----
 bin/mkcatalog/mkcatalog.c | 12 +++++-----
 doc/gnuastro.texi         | 60 +++++++++++++++++++++++++++--------------------
 4 files changed, 72 insertions(+), 63 deletions(-)

diff --git a/bin/mkcatalog/columns.c b/bin/mkcatalog/columns.c
index b1d63ac..809f673 100644
--- a/bin/mkcatalog/columns.c
+++ b/bin/mkcatalog/columns.c
@@ -315,8 +315,8 @@ columns_define_alloc(struct mkcatalogparams *p)
           disp_fmt       = 0;
           disp_width     = 5;
           disp_precision = 0;
-          oiflag[ OCOL_NUMPOS ] = 1;
-          ciflag[ CCOL_NUMPOS ] = 1;
+          oiflag[ OCOL_NUMWHT ] = 1;
+          ciflag[ CCOL_NUMWHT ] = 1;
           break;
 
         case UI_KEY_X:
@@ -1048,7 +1048,7 @@ columns_second_order(struct mkcatalog_passparams *pp, 
double *row,
     case UI_KEY_POSITIONANGLE:
 
       /* Denominator (to be divided). */
-      denom = row[ o0c1 ? CCOL_SUMPOS : OCOL_SUMPOS ];
+      denom = row[ o0c1 ? CCOL_SUMWHT : OCOL_SUMWHT ];
 
       /* First order. */
       x  = MKC_RATIO( row[ o0c1 ? CCOL_VX     : OCOL_VX     ], denom );
@@ -1161,9 +1161,9 @@ columns_second_order(struct mkcatalog_passparams *pp, 
double *row,
    write them into the output columns. The list of columns here is in the
    same order as `columns_alloc_set_out_cols', see there for the type of
    each column. */
-#define POS_V_G(ARRAY, SUMPOS_COL, NUMALL_COL, V_COL, G_COL)            \
-  ( (ARRAY)[ SUMPOS_COL ]>0                                             \
-    ? MKC_RATIO( (ARRAY)[ V_COL ], (ARRAY)[ SUMPOS_COL ] )              \
+#define POS_V_G(ARRAY, SUMWHT_COL, NUMALL_COL, V_COL, G_COL)            \
+  ( (ARRAY)[ SUMWHT_COL ]>0                                             \
+    ? MKC_RATIO( (ARRAY)[ V_COL ], (ARRAY)[ SUMWHT_COL ] )              \
     : MKC_RATIO( (ARRAY)[ G_COL ], (ARRAY)[ NUMALL_COL ] ) )
 void
 columns_fill(struct mkcatalog_passparams *pp)
@@ -1205,16 +1205,16 @@ columns_fill(struct mkcatalog_passparams *pp)
           break;
 
         case UI_KEY_WEIGHTAREA:
-          ((int32_t *)colarr)[oind] = oi[OCOL_NUMPOS];
+          ((int32_t *)colarr)[oind] = oi[OCOL_NUMWHT];
           break;
 
         case UI_KEY_X:
-          ((float *)colarr)[oind] = POS_V_G(oi, OCOL_SUMPOS, OCOL_NUMALL,
+          ((float *)colarr)[oind] = POS_V_G(oi, OCOL_SUMWHT, OCOL_NUMALL,
                                             OCOL_VX, OCOL_GX);
           break;
 
         case UI_KEY_Y:
-          ((float *)colarr)[oind] = POS_V_G(oi, OCOL_SUMPOS, OCOL_NUMALL,
+          ((float *)colarr)[oind] = POS_V_G(oi, OCOL_SUMWHT, OCOL_NUMALL,
                                             OCOL_VY, OCOL_GY);
           break;
 
@@ -1227,12 +1227,12 @@ columns_fill(struct mkcatalog_passparams *pp)
           break;
 
         case UI_KEY_CLUMPSX:
-          ((float *)colarr)[oind] = POS_V_G(oi, OCOL_C_SUMPOS, OCOL_C_NUMALL,
+          ((float *)colarr)[oind] = POS_V_G(oi, OCOL_C_SUMWHT, OCOL_C_NUMALL,
                                             OCOL_C_VX, OCOL_C_GX);
           break;
 
         case UI_KEY_CLUMPSY:
-          ((float *)colarr)[oind] = POS_V_G(oi, OCOL_C_SUMPOS, OCOL_C_NUMALL,
+          ((float *)colarr)[oind] = POS_V_G(oi, OCOL_C_SUMWHT, OCOL_C_NUMALL,
                                             OCOL_C_VY, OCOL_C_GY);
           break;
 
@@ -1248,9 +1248,9 @@ columns_fill(struct mkcatalog_passparams *pp)
 
         case UI_KEY_RA:
         case UI_KEY_DEC:
-          p->rd_vo[0][oind] = POS_V_G(oi, OCOL_SUMPOS, OCOL_NUMALL,
+          p->rd_vo[0][oind] = POS_V_G(oi, OCOL_SUMWHT, OCOL_NUMALL,
                                       OCOL_VX, OCOL_GX);
-          p->rd_vo[1][oind] = POS_V_G(oi, OCOL_SUMPOS, OCOL_NUMALL,
+          p->rd_vo[1][oind] = POS_V_G(oi, OCOL_SUMWHT, OCOL_NUMALL,
                                       OCOL_VY, OCOL_GY);
           break;
 
@@ -1262,9 +1262,9 @@ columns_fill(struct mkcatalog_passparams *pp)
 
         case UI_KEY_CLUMPSRA:
         case UI_KEY_CLUMPSDEC:
-          p->rd_vcc[0][oind] = POS_V_G(oi, OCOL_C_SUMPOS, OCOL_C_NUMALL,
+          p->rd_vcc[0][oind] = POS_V_G(oi, OCOL_C_SUMWHT, OCOL_C_NUMALL,
                                        OCOL_C_VX, OCOL_C_GX);
-          p->rd_vcc[1][oind] = POS_V_G(oi, OCOL_C_SUMPOS, OCOL_C_NUMALL,
+          p->rd_vcc[1][oind] = POS_V_G(oi, OCOL_C_SUMWHT, OCOL_C_NUMALL,
                                        OCOL_C_VY, OCOL_C_GY);
           break;
 
@@ -1275,11 +1275,11 @@ columns_fill(struct mkcatalog_passparams *pp)
           break;
 
         case UI_KEY_BRIGHTNESS:
-          ((float *)colarr)[oind] = oi[ OCOL_SUM ];
+          ((float *)colarr)[oind] = oi[ OCOL_NUM ]>0.0f ? oi[ OCOL_SUM ] : NAN;
           break;
 
         case UI_KEY_CLUMPSBRIGHTNESS:
-          ((float *)colarr)[oind] = oi[ OCOL_C_SUM ];
+          ((float *)colarr)[oind] = oi[ OCOL_C_NUM ]>0.0f ?oi[ OCOL_C_SUM 
]:NAN;
           break;
 
         case UI_KEY_MAGNITUDE:
@@ -1384,16 +1384,16 @@ columns_fill(struct mkcatalog_passparams *pp)
             break;
 
           case UI_KEY_WEIGHTAREA:
-            ((int32_t *)colarr)[cind]=ci[CCOL_NUMPOS];
+            ((int32_t *)colarr)[cind]=ci[CCOL_NUMWHT];
             break;
 
           case UI_KEY_X:
-            ((float *)colarr)[cind] = POS_V_G(ci, CCOL_SUMPOS, CCOL_NUMALL,
+            ((float *)colarr)[cind] = POS_V_G(ci, CCOL_SUMWHT, CCOL_NUMALL,
                                               CCOL_VX, CCOL_GX);
             break;
 
           case UI_KEY_Y:
-            ((float *)colarr)[cind] = POS_V_G(ci, CCOL_SUMPOS, CCOL_NUMALL,
+            ((float *)colarr)[cind] = POS_V_G(ci, CCOL_SUMWHT, CCOL_NUMALL,
                                               CCOL_VY, CCOL_GY);
             break;
 
@@ -1409,9 +1409,9 @@ columns_fill(struct mkcatalog_passparams *pp)
 
           case UI_KEY_RA:
           case UI_KEY_DEC:
-            p->rd_vc[0][cind] = POS_V_G(ci, CCOL_SUMPOS, CCOL_NUMALL,
+            p->rd_vc[0][cind] = POS_V_G(ci, CCOL_SUMWHT, CCOL_NUMALL,
                                         CCOL_VX, CCOL_GX);
-            p->rd_vc[1][cind] = POS_V_G(ci, CCOL_SUMPOS, CCOL_NUMALL,
+            p->rd_vc[1][cind] = POS_V_G(ci, CCOL_SUMWHT, CCOL_NUMALL,
                                         CCOL_VY, CCOL_GY);
             break;
 
@@ -1426,16 +1426,17 @@ columns_fill(struct mkcatalog_passparams *pp)
                rivers are present. When grown clumps are requested, the
                clumps can fully cover a detection (that has one or no
                clumps). */
-            tmp = ( ci[ CCOL_RIV_NUM ]
+            tmp = ( ci[ CCOL_RIV_NUM ]>0.0f
                     ? ci[ CCOL_RIV_SUM ]/ci[ CCOL_RIV_NUM ]*ci[ CCOL_NUM ]
                     : 0 );
 
             /* Subtract it from the clump's brightness. */
-            ((float *)colarr)[cind] = ci[ CCOL_SUM ] - tmp;
+            ((float *)colarr)[cind] = ( ci[ CCOL_NUM ]>0.0f
+                                        ? (ci[ CCOL_SUM ] - tmp) : NAN );
             break;
 
           case UI_KEY_NORIVERBRIGHTNESS:
-            ((float *)colarr)[cind] = ci[ CCOL_SUM ];
+            ((float *)colarr)[cind] = ci[ CCOL_NUM ]>0.0f ? ci[ CCOL_SUM ]:NAN;
             break;
 
           case UI_KEY_MAGNITUDE: /* Similar: brightness for clumps */
diff --git a/bin/mkcatalog/main.h b/bin/mkcatalog/main.h
index e2eea74..0dd53e9 100644
--- a/bin/mkcatalog/main.h
+++ b/bin/mkcatalog/main.h
@@ -78,8 +78,8 @@ enum objectcols
     OCOL_VXY,            /* Sum of (value-sky) * x * y.               */
     OCOL_SUMSKY,         /* Sum of sky value on this object.          */
     OCOL_SUMSTD,         /* Sum of sky STD value on this object.      */
-    OCOL_SUMPOS,         /* Sum of positive image pixels.             */
-    OCOL_NUMPOS,         /* Number of positive pixels used for wht.   */
+    OCOL_SUMWHT,         /* Sum of positive image pixels.             */
+    OCOL_NUMWHT,         /* Number of positive pixels used for wht.   */
     OCOL_GX,             /* Geometric center of object in X.          */
     OCOL_GY,             /* Geometric center of object in Y.          */
     OCOL_GXX,            /* Second order geometric variable: X*X.     */
@@ -93,8 +93,8 @@ enum objectcols
     OCOL_C_VY,           /* Sum of (value-sky)*y on obj. clumps.      */
     OCOL_C_GX,           /* Geometric center of clumps in object X.   */
     OCOL_C_GY,           /* Geometric center of clumps in object Y.   */
-    OCOL_C_SUMPOS,       /* Sum of positive image pixels for wht.     */
-    OCOL_C_NUMPOS,       /* Num of positive image pixels for wht.     */
+    OCOL_C_SUMWHT,       /* Sum of positive image pixels for wht.     */
+    OCOL_C_NUMWHT,       /* Num of positive image pixels for wht.     */
 
     OCOL_NUMCOLS,        /* SHOULD BE LAST: total number of columns.  */
   };
@@ -113,8 +113,8 @@ enum clumpcols
     CCOL_RIV_NUM,        /* Num river pixels around this clump.       */
     CCOL_SUMSKY,         /* Sum of sky value on this object.          */
     CCOL_SUMSTD,         /* Sum of sky STD value on this object.      */
-    CCOL_SUMPOS,         /* Sum of positive image pixels for wht.     */
-    CCOL_NUMPOS,         /* Num of positive image pixels for wht.     */
+    CCOL_SUMWHT,         /* Sum of positive image pixels for wht.     */
+    CCOL_NUMWHT,         /* Num of positive image pixels for wht.     */
     CCOL_GX,             /* Geometric center of clump in X.           */
     CCOL_GY,             /* Geometric center of clump in Y.           */
     CCOL_GXX,            /* Second order geometric moment.            */
diff --git a/bin/mkcatalog/mkcatalog.c b/bin/mkcatalog/mkcatalog.c
index e8464fe..5a90129 100644
--- a/bin/mkcatalog/mkcatalog.c
+++ b/bin/mkcatalog/mkcatalog.c
@@ -215,8 +215,8 @@ mkcatalog_first_pass(struct mkcatalog_passparams *pp)
                      values, so do those measurements here. */
                   if( ss > 0.0f )
                     {
-                      oi[ OCOL_NUMPOS ]++;
-                      oi[ OCOL_SUMPOS ] += ss;
+                      oi[ OCOL_NUMWHT ]++;
+                      oi[ OCOL_SUMWHT ] += ss;
                       oi[ OCOL_VX     ] += ss * c[1];
                       oi[ OCOL_VY     ] += ss * c[0];
                       oi[ OCOL_VXX    ] += ss * sc[1] * sc[1];
@@ -224,8 +224,8 @@ mkcatalog_first_pass(struct mkcatalog_passparams *pp)
                       oi[ OCOL_VXY    ] += ss * sc[1] * sc[0];
                       if(p->clumps && *C>0)
                         {
-                          oi[ OCOL_C_NUMPOS ]++;
-                          oi[ OCOL_C_SUMPOS ] += ss;
+                          oi[ OCOL_C_NUMWHT ]++;
+                          oi[ OCOL_C_SUMWHT ] += ss;
                           oi[ OCOL_C_VX     ] += ss * c[1];
                           oi[ OCOL_C_VY     ] += ss * c[0];
                         }
@@ -326,8 +326,8 @@ mkcatalog_second_pass(struct mkcatalog_passparams *pp)
                       ci[ CCOL_SUMSTD ] += *ST;
                       if( ss > 0.0f )
                         {
-                          ci[ CCOL_NUMPOS ]++;
-                          ci[ CCOL_SUMPOS ] += ss;
+                          ci[ CCOL_NUMWHT ]++;
+                          ci[ CCOL_SUMWHT ] += ss;
                           ci[ CCOL_VX     ] += ss * c[1];
                           ci[ CCOL_VY     ] += ss * c[0];
                           ci[ CCOL_VXX    ] += ss * sc[1] * sc[1];
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 0508ff5..2310b32 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -13947,37 +13947,45 @@ see @option{--geox}.
 @item -b
 @itemx --brightness
 The brightness (sum of all pixel values), see @ref{Flux Brightness and
-magnitude}. For each clump in the clumps catalog, the ambient
-brightness (flux of river pixels around the clump multiplied by the
-area of the clump) is removed, see @option{--riverflux}. So the sum of
-clump brightnesses in the clump catalog will be smaller than the total
-clump brightness in the @option{--clumpbrightness} column of the
-objects catalog.
+magnitude}. For clumps, the ambient brightness (flux of river pixels around
+the clump multiplied by the area of the clump) is removed, see
address@hidden So the sum of clump brightnesses in the clump catalog
+will be smaller than the total clump brightness in the
address@hidden column of the objects catalog.
+
+If no usable pixels (blank or below the threshold) are present over the
+clump or object, the stored value will be NaN (note that zero is
+meaningful).
 
 @item --clumpbrightness
 [Objects] The total brightness of the clumps within an object. This is
-simply the sum of the pixels associated with clumps in the object.
+simply the sum of the pixels associated with clumps in the object. If no
+usable pixels (blank or below the threshold) are present over the clump or
+object, the stored value will be NaN, because zero (note that zero is
+meaningful).
 
 @item --noriverbrightness
-[Clumps] The Sky (not river) subtracted clump brightness. By
-definition, for the clumps, the average brightness of the rivers
-surrounding it are subtracted from it for a first order accounting for
-contamination by neighbors. In cases where you will be calculating the
-flux brightness difference later (one example below) the contamination
-will be (mostly) removed at that stage, which is why this column was
-added.
-
-One example might be this: you want to know the change in the clump
-flux as a function of threshold (see @option{--threshold}). So you
-will make two catalogs (each having this column but with different
-thresholds) and then subtract the lower threshold catalog (higher
-brightness) from the higher threshold catalog (lower brightness). The
-effect is most visible when the rivers have a high average
-signal-to-noise ratio. The removed contribution from the pixels below
-the threshold will be less than the river pixels. Therefore the
-river-subtracted brightness (@option{--brightness}) for the
-thresholded catalog for such clumps will be larger than the brightness
-with no threshold!
+[Clumps] The Sky (not river) subtracted clump brightness. By definition,
+for the clumps, the average brightness of the rivers surrounding it are
+subtracted from it for a first order accounting for contamination by
+neighbors. In cases where you will be calculating the flux brightness
+difference later (one example below) the contamination will be (mostly)
+removed at that stage, which is why this column was added.
+
+One example might be this: you want to know the change in the clump flux as
+a function of threshold (see @option{--threshold}). So you will make two
+catalogs (each having this column but with different thresholds) and then
+subtract the lower threshold catalog (higher brightness) from the higher
+threshold catalog (lower brightness). The effect is most visible when the
+rivers have a high average signal-to-noise ratio. The removed contribution
+from the pixels below the threshold will be less than the river
+pixels. Therefore the river-subtracted brightness (@option{--brightness})
+for the thresholded catalog for such clumps will be larger than the
+brightness with no threshold!
+
+If no usable pixels (blank or below the possibly given threshold) are
+present over the clump or object, the stored value will be NaN (note that
+zero is meaningful).
 
 @item -m
 @itemx --magnitude



reply via email to

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