gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 5600f2e: MakeCatalog: columns to measure sigma


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 5600f2e: MakeCatalog: columns to measure sigma-clipped pixel values
Date: Thu, 13 Feb 2020 16:07:36 -0500 (EST)

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

    MakeCatalog: columns to measure sigma-clipped pixel values
    
    With this commit, MakeCatalog has four new output columns to measure the
    sigma-clipped number, median, mean and standard deviation of the
    object/clump pixels.
    
    This task was suggested by Raul Infante-Sainz.
---
 NEWS                            |   8 +++
 bin/mkcatalog/args.h            |  70 ++++++++++++++++++++++
 bin/mkcatalog/astmkcatalog.conf |   1 +
 bin/mkcatalog/columns.c         | 113 ++++++++++++++++++++++++++++++++++++
 bin/mkcatalog/main.h            |   9 +++
 bin/mkcatalog/mkcatalog.c       |  11 +++-
 bin/mkcatalog/parse.c           | 125 ++++++++++++++++++++++++++++++----------
 bin/mkcatalog/parse.h           |   2 +-
 bin/mkcatalog/ui.c              |  10 ++++
 bin/mkcatalog/ui.h              |   5 ++
 doc/gnuastro.texi               |  24 ++++++++
 11 files changed, 343 insertions(+), 35 deletions(-)

diff --git a/NEWS b/NEWS
index 301134c..efd3e2d 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,14 @@ See the end of the file for license conditions.
   Fits:
    --datasum: Calculate and print the given HDU's "datasum" to stdout.
 
+  MakeCatalog:
+   --sigmaclip: defines the sigma-clipping parameters for those columns.
+   New output columns:
+     --sigclip-number: Number of sigma-clipped pixels in object/clump.
+     --sigclip-median: Sigma-clipped median of pixels in object/clump.
+     --sigclip-mean: Sigma-clipped mean of pixels in object/clump.
+     --sigclip-std: Sigma-clipped standard deviation of pixels in object/clump.
+
   Table:
    --equal: Can now work on columns with string type also.
    --notequal: Can now work on columns with string type also.
diff --git a/bin/mkcatalog/args.h b/bin/mkcatalog/args.h
index dc2ec11..3ef319b 100644
--- a/bin/mkcatalog/args.h
+++ b/bin/mkcatalog/args.h
@@ -175,6 +175,20 @@ struct argp_option program_options[] =
       GAL_OPTIONS_NOT_MANDATORY,
       GAL_OPTIONS_NOT_SET
     },
+    {
+      "sigmaclip",
+      UI_KEY_SIGMACLIP,
+      "FLT,FLT",
+      0,
+      "Sigma-clip column multiple and tolerance.",
+      GAL_OPTIONS_GROUP_INPUT,
+      &p->sigmaclip,
+      GAL_TYPE_STRING,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+      gal_options_read_sigma_clip
+    },
 
 
 
@@ -1202,6 +1216,62 @@ struct argp_option program_options[] =
       GAL_OPTIONS_NOT_SET,
       ui_column_codes_ll
     },
+    {
+      "sigclip-number",
+      UI_KEY_SIGCLIPNUMBER,
+      0,
+      0,
+      "Number of pixels in Sigma-clipped measurement.",
+      UI_GROUP_COLUMNS_BRIGHTNESS,
+      0,
+      GAL_TYPE_INVALID,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+      ui_column_codes_ll
+    },
+    {
+      "sigclip-median",
+      UI_KEY_SIGCLIPMEDIAN,
+      0,
+      0,
+      "Median after Sigma-clipping",
+      UI_GROUP_COLUMNS_BRIGHTNESS,
+      0,
+      GAL_TYPE_INVALID,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+      ui_column_codes_ll
+    },
+    {
+      "sigclip-mean",
+      UI_KEY_SIGCLIPMEAN,
+      0,
+      0,
+      "Mean after Sigma-clipping",
+      UI_GROUP_COLUMNS_BRIGHTNESS,
+      0,
+      GAL_TYPE_INVALID,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+      ui_column_codes_ll
+    },
+    {
+      "sigclip-std",
+      UI_KEY_SIGCLIPSTD,
+      0,
+      0,
+      "Standard deviation after Sigma-clipping",
+      UI_GROUP_COLUMNS_BRIGHTNESS,
+      0,
+      GAL_TYPE_INVALID,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+      ui_column_codes_ll
+    },
 
 
 
diff --git a/bin/mkcatalog/astmkcatalog.conf b/bin/mkcatalog/astmkcatalog.conf
index 0a912b8..ed85245 100644
--- a/bin/mkcatalog/astmkcatalog.conf
+++ b/bin/mkcatalog/astmkcatalog.conf
@@ -26,6 +26,7 @@
  skyhdu           SKY
  stdhdu       SKY_STD
  zeropoint        0.0
+ sigmaclip      3,0.2
 
 # Output:
  sfmagnsigma        1
diff --git a/bin/mkcatalog/columns.c b/bin/mkcatalog/columns.c
index e73ea71..15e692b 100644
--- a/bin/mkcatalog/columns.c
+++ b/bin/mkcatalog/columns.c
@@ -265,6 +265,23 @@ columns_sanity_check(struct mkcatalogparams *p)
      based on it (for units and names). */
   columns_wcs_preparation(p);
 
+  /* If sigma-clipping measurements are requested, make sure the necessary
+     parameters are provided. */
+  for(colcode=p->columnids; colcode!=NULL; colcode=colcode->next)
+    switch(colcode->v)
+      {
+      case UI_KEY_SIGCLIPSTD:
+      case UI_KEY_SIGCLIPMEAN:
+      case UI_KEY_SIGCLIPNUMBER:
+      case UI_KEY_SIGCLIPMEDIAN:
+        if(isnan(p->sigmaclip[0]) || isnan(p->sigmaclip[1]))
+          error(EXIT_FAILURE, 0, "no sigma-clip defined! When any of the "
+                "sigma-clipping columns are requested, it is necessary to "
+                "specify the necessary sigma-clipping parameters with the "
+                "`--sigmaclip' option");
+        break;
+      }
+
   /* Check for dimension-specific columns. */
   switch(p->objects->ndim)
     {
@@ -1081,6 +1098,70 @@ columns_define_alloc(struct mkcatalogparams *p)
                                    ciflag[ CCOL_RIV_SUM ] = 1;
           break;
 
+        case UI_KEY_SIGCLIPNUMBER:
+          name           = "SIGCLIP-NUMBER";
+          unit           = "counter";
+          ocomment       = "Number of pixels in Sigma-clipped object";
+          ccomment       = "Number of pixels in Sigma-clipped clump.";
+          otype          = GAL_TYPE_INT32;
+          ctype          = GAL_TYPE_INT32;
+          disp_fmt       = 0;
+          disp_width     = 6;
+          disp_precision = 0;
+          oiflag[ OCOL_NUM        ] = ciflag[ CCOL_NUM        ] = 1;
+          oiflag[ OCOL_SIGCLIPNUM ] = ciflag[ CCOL_SIGCLIPNUM ] = 1;
+                                      ciflag[ CCOL_RIV_NUM    ] = 1;
+                                      ciflag[ CCOL_RIV_SUM    ] = 1;
+          break;
+
+        case UI_KEY_SIGCLIPMEDIAN:
+          name           = "SIGCLIP-MEDIAN";
+          unit           = MKCATALOG_NO_UNIT;
+          ocomment       = "Sigma-clipped median of object pixels.";
+          ccomment       = "Sigma-clipped median of clump pixels.";
+          otype          = GAL_TYPE_FLOAT32;
+          ctype          = GAL_TYPE_FLOAT32;
+          disp_fmt       = GAL_TABLE_DISPLAY_FMT_GENERAL;
+          disp_width     = 10;
+          disp_precision = 5;
+          oiflag[ OCOL_NUM           ] = ciflag[ CCOL_NUM           ] = 1;
+          oiflag[ OCOL_SIGCLIPMEDIAN ] = ciflag[ CCOL_SIGCLIPMEDIAN ] = 1;
+                                         ciflag[ CCOL_RIV_NUM       ] = 1;
+                                         ciflag[ CCOL_RIV_SUM       ] = 1;
+          break;
+
+        case UI_KEY_SIGCLIPMEAN:
+          name           = "SIGCLIP-MEAN";
+          unit           = MKCATALOG_NO_UNIT;
+          ocomment       = "Sigma-clipped mean of object pixels.";
+          ccomment       = "Sigma-clipped mean of clump pixels.";
+          otype          = GAL_TYPE_FLOAT32;
+          ctype          = GAL_TYPE_FLOAT32;
+          disp_fmt       = GAL_TABLE_DISPLAY_FMT_GENERAL;
+          disp_width     = 10;
+          disp_precision = 5;
+          oiflag[ OCOL_NUM         ] = ciflag[ CCOL_NUM         ] = 1;
+          oiflag[ OCOL_SIGCLIPMEAN ] = ciflag[ CCOL_SIGCLIPMEAN ] = 1;
+                                       ciflag[ CCOL_RIV_NUM     ] = 1;
+                                       ciflag[ CCOL_RIV_SUM     ] = 1;
+          break;
+
+        case UI_KEY_SIGCLIPSTD:
+          name           = "SIGCLIP-STD";
+          unit           = MKCATALOG_NO_UNIT;
+          ocomment       = "Sigma-clipped standard deviation of object 
pixels.";
+          ccomment       = "Sigma-clipped standard deviation of clump pixels.";
+          otype          = GAL_TYPE_FLOAT32;
+          ctype          = GAL_TYPE_FLOAT32;
+          disp_fmt       = GAL_TABLE_DISPLAY_FMT_GENERAL;
+          disp_width     = 10;
+          disp_precision = 5;
+          oiflag[ OCOL_NUM        ] = ciflag[ CCOL_NUM        ] = 1;
+          oiflag[ OCOL_SIGCLIPSTD ] = ciflag[ CCOL_SIGCLIPSTD ] = 1;
+                                      ciflag[ CCOL_RIV_NUM   ] = 1;
+                                      ciflag[ CCOL_RIV_SUM   ] = 1;
+          break;
+
         case UI_KEY_MAGNITUDE:
           name           = "MAGNITUDE";
           unit           = "log";
@@ -2032,6 +2113,22 @@ columns_fill(struct mkcatalog_passparams *pp)
                                       : NAN );
           break;
 
+        case UI_KEY_SIGCLIPNUMBER:
+          ((int32_t *)colarr)[oind] = oi[ OCOL_SIGCLIPNUM ];
+          break;
+
+        case UI_KEY_SIGCLIPMEDIAN:
+          ((float *)colarr)[oind] = oi[ OCOL_SIGCLIPMEDIAN ];
+          break;
+
+        case UI_KEY_SIGCLIPMEAN:
+          ((float *)colarr)[oind] = oi[ OCOL_SIGCLIPMEAN ];
+          break;
+
+        case UI_KEY_SIGCLIPSTD:
+          ((float *)colarr)[oind] = oi[ OCOL_SIGCLIPSTD ];
+          break;
+
         case UI_KEY_MAGNITUDE:
           ((float *)colarr)[oind] = ( oi[ OCOL_NUM ]>0.0f
                                       ? MKC_MAG(oi[ OCOL_SUM ])
@@ -2274,6 +2371,22 @@ columns_fill(struct mkcatalog_passparams *pp)
                                         ? ci[ CCOL_MEDIAN ] : NAN );
             break;
 
+          case UI_KEY_SIGCLIPNUMBER:
+            ((int32_t *)colarr)[cind] = ci[ CCOL_SIGCLIPNUM ];
+            break;
+
+          case UI_KEY_SIGCLIPMEDIAN:
+            ((float *)colarr)[cind] = ci[ CCOL_SIGCLIPMEDIAN ];
+            break;
+
+          case UI_KEY_SIGCLIPMEAN:
+            ((float *)colarr)[cind] = ci[ CCOL_SIGCLIPMEAN ];
+            break;
+
+          case UI_KEY_SIGCLIPSTD:
+            ((float *)colarr)[cind] = ci[ CCOL_SIGCLIPSTD ];
+            break;
+
           case UI_KEY_MAGNITUDE: /* Similar: brightness for clumps */
             tmp = ( ci[ CCOL_RIV_NUM ]
                     ? ci[ CCOL_RIV_SUM ]/ci[ CCOL_RIV_NUM ]*ci[ CCOL_NUM ]
diff --git a/bin/mkcatalog/main.h b/bin/mkcatalog/main.h
index b1d5851..a85fda1 100644
--- a/bin/mkcatalog/main.h
+++ b/bin/mkcatalog/main.h
@@ -77,6 +77,10 @@ enum objectcols
     OCOL_SUM,            /* Sum of (value-sky) in object.             */
     OCOL_SUM_VAR,        /* Variance including values (not just sky). */
     OCOL_MEDIAN,         /* Median of value in object.                */
+    OCOL_SIGCLIPNUM,     /* Sigma-clipped mean of this object.        */
+    OCOL_SIGCLIPSTD,     /* Sigma-clipped mean of this object.        */
+    OCOL_SIGCLIPMEAN,    /* Sigma-clipped mean of this object.        */
+    OCOL_SIGCLIPMEDIAN,  /* Sigma-clipped mean of this object.        */
     OCOL_VX,             /* Sum of (value-sky) * x.                   */
     OCOL_VY,             /* Sum of (value-sky) * y.                   */
     OCOL_VZ,             /* Sum of (value-sky) * z.                   */
@@ -123,6 +127,10 @@ enum clumpcols
     CCOL_SUM,            /* River subtracted brightness.              */
     CCOL_SUM_VAR,        /* Variance including values (not just sky). */
     CCOL_MEDIAN,         /* Median of values in clump.                */
+    CCOL_SIGCLIPNUM,     /* Sigma-clipped mean of this clump.         */
+    CCOL_SIGCLIPSTD,     /* Sigma-clipped mean of this clump.         */
+    CCOL_SIGCLIPMEAN,    /* Sigma-clipped mean of this clump.         */
+    CCOL_SIGCLIPMEDIAN,  /* Sigma-clipped mean of this clump.         */
     CCOL_RIV_NUM,        /* Num river pixels around this clump.       */
     CCOL_RIV_SUM,        /* Sum of rivers around clump.               */
     CCOL_RIV_SUM_VAR,    /* Variance of sum (for error measurements). */
@@ -189,6 +197,7 @@ struct mkcatalogparams
   float             sfmagarea;  /* Surface brightness area (arcsec^2).  */
   uint8_t            spectrum;  /* Object spectrum for 3D datasets.     */
   uint8_t       inbetweenints;  /* Keep rows (integer ids) with no labels. */
+  double         sigmaclip[2];  /* Sigma clip column settings.          */
 
   char            *upmaskfile;  /* Name of upper limit mask file.       */
   char             *upmaskhdu;  /* HDU of upper limit mask file.        */
diff --git a/bin/mkcatalog/mkcatalog.c b/bin/mkcatalog/mkcatalog.c
index 3eebcd6..55361ff 100644
--- a/bin/mkcatalog/mkcatalog.c
+++ b/bin/mkcatalog/mkcatalog.c
@@ -179,9 +179,14 @@ mkcatalog_single_object(void *in_prm)
           parse_clumps(&pp);
         }
 
-      /* If the median is requested, another pass is necessary. */
-      if( p->oiflag[ OCOL_MEDIAN ] )
-        parse_median(&pp);
+      /* If an order-based calculation is requested, another pass is
+         necessary. */
+      if( p->oiflag[ OCOL_MEDIAN ]
+          || p->oiflag[ OCOL_SIGCLIPNUM ]
+          || p->oiflag[ OCOL_SIGCLIPSTD ]
+          || p->oiflag[ OCOL_SIGCLIPMEAN ]
+          || p->oiflag[ OCOL_SIGCLIPMEDIAN ])
+        parse_order_based(&pp);
 
       /* Calculate the upper limit magnitude (if necessary). */
       if(p->upperlimit) upperlimit_calculate(&pp);
diff --git a/bin/mkcatalog/parse.c b/bin/mkcatalog/parse.c
index 722d3a7..cabd17d 100644
--- a/bin/mkcatalog/parse.c
+++ b/bin/mkcatalog/parse.c
@@ -1062,29 +1062,31 @@ parse_clumps(struct mkcatalog_passparams *pp)
 
 
 void
-parse_median(struct mkcatalog_passparams *pp)
+parse_order_based(struct mkcatalog_passparams *pp)
 {
   struct mkcatalogparams *p=pp->p;
 
   float *V;
   double *ci;
-  gal_data_t *median;
+  float *sigcliparr;
+  gal_data_t *result;
   int32_t *O, *OO, *C=NULL;
-  gal_data_t **clumpsmed=NULL;
+  gal_data_t **clumpsvals=NULL;
   size_t i, increment=0, num_increment=1;
   size_t *tsize=pp->tile->dsize, ndim=p->objects->ndim;
   size_t counter=0, *ccounter=NULL, tmpsize=pp->oi[OCOL_NUM];
-  gal_data_t *objmed=gal_data_alloc(NULL, p->values->type, 1, &tmpsize, NULL,
-                                    0, p->cp.minmapsize, p->cp.quietmmap,
-                                    NULL, NULL, NULL);
+  gal_data_t *objvals=gal_data_alloc(NULL, p->values->type, 1, &tmpsize, NULL,
+                                     0, p->cp.minmapsize, p->cp.quietmmap,
+                                     NULL, NULL, NULL);
 
-  /* Allocate space for the clump medians. */
+
+  /* Allocate space for the clump values. */
   if(p->clumps)
     {
       errno=0;
-      clumpsmed=malloc(pp->clumpsinobj * sizeof *clumpsmed);
-      if(clumpsmed==NULL)
-        error(EXIT_FAILURE, errno, "%s: couldn't allocate `clumpsmed' for "
+      clumpsvals=malloc(pp->clumpsinobj * sizeof *clumpsvals);
+      if(clumpsvals==NULL)
+        error(EXIT_FAILURE, errno, "%s: couldn't allocate `clumpsvals' for "
               "%zu clumps", __func__, pp->clumpsinobj);
 
 
@@ -1094,9 +1096,9 @@ parse_median(struct mkcatalog_passparams *pp)
       for(i=0;i<pp->clumpsinobj;++i)
         {
           tmpsize=pp->ci[ i * CCOL_NUMCOLS + CCOL_NUM ];
-          clumpsmed[i]=gal_data_alloc(NULL, p->values->type, 1, &tmpsize,
-                                      NULL, 0, p->cp.minmapsize,
-                                      p->cp.quietmmap, NULL, NULL, NULL);
+          clumpsvals[i]=gal_data_alloc(NULL, p->values->type, 1, &tmpsize,
+                                       NULL, 0, p->cp.minmapsize,
+                                       p->cp.quietmmap, NULL, NULL, NULL);
         }
     }
 
@@ -1119,15 +1121,15 @@ parse_median(struct mkcatalog_passparams *pp)
           if( *O==pp->object && !( p->hasblank && isnan(*V) ) )
             {
               /* Copy the value for the whole object. */
-              memcpy( gal_pointer_increment(objmed->array, counter++,
+              memcpy( gal_pointer_increment(objvals->array, counter++,
                                              p->values->type), V,
                       gal_type_sizeof(p->values->type) );
 
               /* We are also on a clump. */
               if(p->clumps && *C>0)
-                memcpy( gal_pointer_increment(clumpsmed[*C-1]->array,
-                                               ccounter[*C-1]++,
-                                               p->values->type), V,
+                memcpy( gal_pointer_increment(clumpsvals[*C-1]->array,
+                                              ccounter[*C-1]++,
+                                              p->values->type), V,
                         gal_type_sizeof(p->values->type) );
             }
 
@@ -1143,28 +1145,89 @@ parse_median(struct mkcatalog_passparams *pp)
     }
 
 
-  /* Calculate the final medians for objects. */
-  median=gal_data_copy_to_new_type_free(gal_statistics_median(objmed, 1),
-                                        GAL_TYPE_FLOAT64);
-  pp->oi[OCOL_MEDIAN]=*((double *)(median->array));
-  gal_data_free(objmed);
-  gal_data_free(median);
+  /* Calculate the necessary values for the objects. */
+  if(p->oiflag[ OCOL_MEDIAN ])
+    {
+      result=gal_data_copy_to_new_type_free(gal_statistics_median(objvals, 1),
+                                            GAL_TYPE_FLOAT64);
+      pp->oi[OCOL_MEDIAN]=*((double *)(result->array));
+      gal_data_free(result);
+    }
+  if(p->oiflag[ OCOL_SIGCLIPNUM ]
+     || p->oiflag[ OCOL_SIGCLIPSTD ]
+     || p->oiflag[ OCOL_SIGCLIPMEAN ]
+     || p->oiflag[ OCOL_SIGCLIPMEDIAN ])
+    {
+      /* Calculate the sigma-clipped results and write them in any
+         requested column. */
+      result=gal_statistics_sigma_clip(objvals, p->sigmaclip[0],
+                                       p->sigmaclip[1], 1, 1);
+      sigcliparr=result->array;
+      if(p->oiflag[ OCOL_SIGCLIPNUM ])
+        pp->oi[OCOL_SIGCLIPNUM]=sigcliparr[0];
+      if(p->oiflag[ OCOL_SIGCLIPSTD ])
+        pp->oi[OCOL_SIGCLIPSTD]=sigcliparr[3];
+      if(p->oiflag[ OCOL_SIGCLIPMEAN ])
+        pp->oi[OCOL_SIGCLIPMEAN]=sigcliparr[2];
+      if(p->oiflag[ OCOL_SIGCLIPMEDIAN ])
+        pp->oi[OCOL_SIGCLIPMEDIAN]=sigcliparr[1];
+
+      /* Clean up the sigma-clipped values. */
+      gal_data_free(result);
+    }
+
+
+  /* Clean up the object values. */
+  gal_data_free(objvals);
 
 
-  /* Calculate the median for clumps. */
+  /* Calculate the necessary value for clumps. */
   if(p->clumps)
     {
       for(i=0;i<pp->clumpsinobj;++i)
         {
+          /* Set the main row to fill. */
           ci=&pp->ci[ i * CCOL_NUMCOLS ];
-          median=gal_statistics_median(clumpsmed[i], 1);
-          median=gal_data_copy_to_new_type_free(median, GAL_TYPE_FLOAT64);
-          ci[ CCOL_MEDIAN ] = ( *((double *)(median->array))
-                                - (ci[ CCOL_RIV_SUM ]/ci[ CCOL_RIV_NUM ]) );
-          gal_data_free(clumpsmed[i]);
-          gal_data_free(median);
+
+          /* Do the necessary calculation. */
+          if(p->ciflag[ CCOL_MEDIAN ])
+            {
+              result=gal_statistics_median(clumpsvals[i], 1);
+              result=gal_data_copy_to_new_type_free(result, GAL_TYPE_FLOAT64);
+              ci[ CCOL_MEDIAN ] = ( *((double *)(result->array))
+                                    - (ci[ CCOL_RIV_SUM ]/ci[ CCOL_RIV_NUM ]) 
);
+              gal_data_free(result);
+            }
+          if(p->ciflag[ CCOL_SIGCLIPNUM ]
+             || p->ciflag[ CCOL_SIGCLIPSTD ]
+             || p->ciflag[ CCOL_SIGCLIPMEAN ]
+             || p->ciflag[ CCOL_SIGCLIPMEDIAN ])
+            {
+              /* Calculate the sigma-clipped results and write them in any
+                 requested column. */
+              result=gal_statistics_sigma_clip(clumpsvals[i], p->sigmaclip[0],
+                                               p->sigmaclip[1], 1, 1);
+              sigcliparr=result->array;
+              if(p->ciflag[ CCOL_SIGCLIPNUM ])
+                pp->ci[CCOL_SIGCLIPNUM]=sigcliparr[0];
+              if(p->ciflag[ CCOL_SIGCLIPSTD ])
+                pp->ci[CCOL_SIGCLIPSTD]=( sigcliparr[3]
+                                          - (ci[ CCOL_RIV_SUM ]/ci[ 
CCOL_RIV_NUM ]));
+              if(p->ciflag[ CCOL_SIGCLIPMEAN ])
+                pp->ci[CCOL_SIGCLIPMEAN]=( sigcliparr[2]
+                                           - (ci[ CCOL_RIV_SUM ]/ci[ 
CCOL_RIV_NUM ]));
+              if(p->ciflag[ CCOL_SIGCLIPMEDIAN ])
+                pp->ci[CCOL_SIGCLIPMEDIAN]=( sigcliparr[1]
+                                             - (ci[ CCOL_RIV_SUM ]/ci[ 
CCOL_RIV_NUM ]));
+
+              /* Clean up the sigma-clipped values. */
+              gal_data_free(result);
+            }
+
+          /* Clean up this clump's values. */
+          gal_data_free(clumpsvals[i]);
         }
-      free(clumpsmed);
+      free(clumpsvals);
       free(ccounter);
     }
 }
diff --git a/bin/mkcatalog/parse.h b/bin/mkcatalog/parse.h
index 208236c..6b22a0f 100644
--- a/bin/mkcatalog/parse.h
+++ b/bin/mkcatalog/parse.h
@@ -33,6 +33,6 @@ void
 parse_clumps(struct mkcatalog_passparams *pp);
 
 void
-parse_median(struct mkcatalog_passparams *pp);
+parse_order_based(struct mkcatalog_passparams *pp);
 
 #endif
diff --git a/bin/mkcatalog/ui.c b/bin/mkcatalog/ui.c
index 662230e..f8df810 100644
--- a/bin/mkcatalog/ui.c
+++ b/bin/mkcatalog/ui.c
@@ -126,6 +126,8 @@ ui_initialize_options(struct mkcatalogparams *p,
   p->sfmagarea      = NAN;
   p->upnsigma       = NAN;
   p->zeropoint      = NAN;
+  p->sigmaclip[0]   = NAN;
+  p->sigmaclip[1]   = NAN;
   p->upsigmaclip[0] = NAN;
   p->upsigmaclip[1] = NAN;
   p->checkuplim[0]  = GAL_BLANK_INT32;
@@ -928,6 +930,10 @@ ui_necessary_inputs(struct mkcatalogparams *p, int 
*values, int *sky,
         case OCOL_SUM:                *values        = 1;          break;
         case OCOL_SUM_VAR:            *values = *std = 1;          break;
         case OCOL_MEDIAN:             *values        = 1;          break;
+        case OCOL_SIGCLIPNUM:         *values        = 1;          break;
+        case OCOL_SIGCLIPMEDIAN:      *values        = 1;          break;
+        case OCOL_SIGCLIPMEAN:        *values        = 1;          break;
+        case OCOL_SIGCLIPSTD:         *values        = 1;          break;
         case OCOL_VX:                 *values        = 1;          break;
         case OCOL_VY:                 *values        = 1;          break;
         case OCOL_VZ:                 *values        = 1;          break;
@@ -979,6 +985,10 @@ ui_necessary_inputs(struct mkcatalogparams *p, int 
*values, int *sky,
           case CCOL_SUM:              *values        = 1;          break;
           case CCOL_SUM_VAR:          *values = *std = 1;          break;
           case CCOL_MEDIAN:           *values        = 1;          break;
+          case CCOL_SIGCLIPNUM:    *values        = 1;          break;
+          case CCOL_SIGCLIPMEDIAN:    *values        = 1;          break;
+          case CCOL_SIGCLIPMEAN:      *values        = 1;          break;
+          case CCOL_SIGCLIPSTD:       *values        = 1;          break;
           case CCOL_RIV_NUM:          /* Only clump labels. */     break;
           case CCOL_RIV_SUM:          *values        = 1;          break;
           case CCOL_RIV_SUM_VAR:      *values = *std = 1;          break;
diff --git a/bin/mkcatalog/ui.h b/bin/mkcatalog/ui.h
index ff32b92..bee10ba 100644
--- a/bin/mkcatalog/ui.h
+++ b/bin/mkcatalog/ui.h
@@ -87,6 +87,7 @@ enum option_keys_enum
   UI_KEY_STDHDU,
   UI_KEY_WITHCLUMPS,
   UI_KEY_ZEROPOINT,
+  UI_KEY_SIGMACLIP,
   UI_KEY_VARIANCE,
   UI_KEY_SUBTRACTSKY,
   UI_KEY_SFMAGNSIGMA,
@@ -151,6 +152,10 @@ enum option_keys_enum
   UI_KEY_RIVERNUM,
   UI_KEY_SKY,
   UI_KEY_STD,
+  UI_KEY_SIGCLIPNUMBER,
+  UI_KEY_SIGCLIPMEDIAN,
+  UI_KEY_SIGCLIPMEAN,
+  UI_KEY_SIGCLIPSTD,
   UI_KEY_GEOSEMIMAJOR,
   UI_KEY_GEOSEMIMINOR,
   UI_KEY_GEOAXISRATIO,
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 1fc5945..35c2900 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -14854,6 +14854,13 @@ The dataset given to @option{--stdfile} (and 
@option{--stdhdu} has the Sky varia
 @itemx --zeropoint=FLT
 The zero point magnitude for the input image, see @ref{Flux Brightness and 
magnitude}.
 
+@item --sigmaclip FLT,FLT
+The sigma-clipping parameters when any of the sigma-clipping related columns 
are requested (for example @option{--sigclip-median} or 
@option{--sigclip-number}).
+
+This option takes two values: the first is the multiple of @mymath{\sigma}, 
and the second is the termination criteria.
+If the latter is larger than 1, it is read as an integer number and will be 
the number of times to clip.
+If it is smaller than 1, it is interpreted as the tolerance level to stop 
clipping. See @ref{Sigma clipping} for a complete explanation.
+
 @end table
 
 
@@ -15145,6 +15152,23 @@ For clumps, the average river flux is subtracted from 
the sky subtracted mean.
 The median sky subtracted value of pixels within the object or clump.
 For clumps, the average river flux is subtracted from the sky subtracted 
median.
 
+@item --sigclip-number
+The number of elements/pixels in the dataset after sigma-clipping the object 
or clump.
+The sigma-clipping parameters can be set with the @option{--sigmaclip} option 
described in @ref{MakeCatalog inputs and basic settings}.
+For more on Sigma-clipping, see @ref{Sigma clipping}.
+
+@item --sigclip-median
+The sigma-clipped median value of the object of clump's pixel distribution.
+For more on sigma-clipping and how to define it, see @option{--sigclip-number}.
+
+@item --sigclip-mean
+The sigma-clipped mean value of the object of clump's pixel distribution.
+For more on sigma-clipping and how to define it, see @option{--sigclip-number}.
+
+@item --sigclip-std
+The sigma-clipped standard deviation of the object of clump's pixel 
distribution.
+For more on sigma-clipping and how to define it, see @option{--sigclip-number}.
+
 @item -m
 @itemx --magnitude
 The magnitude of clumps or objects, see @option{--brightness}.



reply via email to

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