[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 165f36d 2/3: MakeCatalog also outputs mean pix
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 165f36d 2/3: MakeCatalog also outputs mean pixel value column |
Date: |
Fri, 23 Feb 2018 10:00:24 -0500 (EST) |
branch: master
commit 165f36d6c9dbb27cceb4632023c69c1460311124
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
MakeCatalog also outputs mean pixel value column
Similar to the previous commit, I saw my self having to manually derive the
mean flux within each object by dividing the brightness and area columns
multiple times. So to make life easier, a `--mean' column is now available
in MakeCatalog that will simply return the mean pixel value.
Also, the median now uses all pixels above the threshold. In the previous
commit, it was all pixels.
---
bin/mkcatalog/args.h | 14 ++++++++++++++
bin/mkcatalog/columns.c | 37 +++++++++++++++++++++++++++++++++++++
bin/mkcatalog/mkcatalog.c | 15 ++++++++-------
bin/mkcatalog/ui.h | 1 +
doc/gnuastro.texi | 8 ++++++++
5 files changed, 68 insertions(+), 7 deletions(-)
diff --git a/bin/mkcatalog/args.h b/bin/mkcatalog/args.h
index 7bd1cb1..c3a4a04 100644
--- a/bin/mkcatalog/args.h
+++ b/bin/mkcatalog/args.h
@@ -703,6 +703,20 @@ struct argp_option program_options[] =
ui_column_codes_ll
},
{
+ "mean",
+ UI_KEY_MEAN,
+ 0,
+ 0,
+ "Mean of values in object/clump.",
+ UI_GROUP_COLUMNS_BRIGHTNESS,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
"median",
UI_KEY_MEDIAN,
0,
diff --git a/bin/mkcatalog/columns.c b/bin/mkcatalog/columns.c
index 3cdb618..bb539a7 100644
--- a/bin/mkcatalog/columns.c
+++ b/bin/mkcatalog/columns.c
@@ -660,6 +660,24 @@ columns_define_alloc(struct mkcatalogparams *p)
ciflag[ CCOL_SUM ] = 1;
break;
+ case UI_KEY_MEAN:
+ name = "MEAN";
+ unit = p->input->unit ? p->input->unit : "pixelunit";
+ ocomment = "Mean of sky subtracted values.";
+ ccomment = "Mean of pixels subtracted by rivers.";
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = GAL_TABLE_DISPLAY_FMT_GENERAL;
+ disp_width = 10;
+ disp_precision = 4;
+ oiflag[ OCOL_NUM ] = 1;
+ oiflag[ OCOL_SUM ] = 1;
+ ciflag[ CCOL_NUM ] = 1;
+ ciflag[ CCOL_SUM ] = 1;
+ ciflag[ CCOL_RIV_NUM ] = 1;
+ ciflag[ CCOL_RIV_SUM ] = 1;
+ break;
+
case UI_KEY_MEDIAN:
name = "MEDIAN";
unit = p->input->unit ? p->input->unit : "pixelunit";
@@ -1375,6 +1393,12 @@ columns_fill(struct mkcatalog_passparams *pp)
: NAN );
break;
+ case UI_KEY_MEAN:
+ ((float *)colarr)[oind] = ( oi[ OCOL_NUM ]>0.0f
+ ? oi[ OCOL_SUM ] / oi[ OCOL_NUM ]
+ : NAN );
+ break;
+
case UI_KEY_MEDIAN:
((float *)colarr)[oind] = ( oi[ OCOL_NUM ]>0.0f
? oi[ OCOL_MEDIAN ]
@@ -1539,6 +1563,19 @@ columns_fill(struct mkcatalog_passparams *pp)
? ci[ CCOL_SUM ] : NAN );
break;
+ case UI_KEY_MEAN:
+ /* Similar to brightness. */
+ tmp = ( ci[ CCOL_RIV_NUM ]>0.0f
+ ? ci[ CCOL_RIV_SUM ]/ci[ CCOL_RIV_NUM ]
+ : 0 );
+
+ /* Subtract it from the clump's mean. */
+ ((float *)colarr)[cind] = ( ci[ CCOL_NUM ]>0.0f
+ ? (ci[CCOL_SUM]/ci[CCOL_NUM] - tmp)
+ : NAN );
+
+ break;
+
case UI_KEY_MEDIAN:
((float *)colarr)[cind] = ( ci[ CCOL_NUM ]>0.0f
? ci[ CCOL_MEDIAN ] : NAN );
diff --git a/bin/mkcatalog/mkcatalog.c b/bin/mkcatalog/mkcatalog.c
index 3f9ea99..517e8ce 100644
--- a/bin/mkcatalog/mkcatalog.c
+++ b/bin/mkcatalog/mkcatalog.c
@@ -418,7 +418,7 @@ mkcatalog_median_pass(struct mkcatalog_passparams *pp)
gal_data_t **clumpsmed=NULL;
float ss, *I, *II, *SK, *ST;
size_t i, increment=0, num_increment=1;
- size_t counter=0, *ccounter=NULL, tsize=pp->oi[OCOL_NUMALL];
+ size_t counter=0, *ccounter=NULL, tsize=pp->oi[OCOL_NUM];
gal_data_t *objmed=gal_data_alloc(NULL, p->input->type, 1, &tsize, NULL, 0,
p->cp.minmapsize, NULL, NULL, NULL);
@@ -442,7 +442,7 @@ mkcatalog_median_pass(struct mkcatalog_passparams *pp)
__func__, "ccounter");
for(i=0;i<pp->clumpsinobj;++i)
{
- tsize=pp->ci[ i * CCOL_NUMCOLS + CCOL_NUMALL ];
+ tsize=pp->ci[ i * CCOL_NUMCOLS + CCOL_NUM ];
clumpsmed[i]=gal_data_alloc(NULL, p->input->type, 1, &tsize, NULL,
0, p->cp.minmapsize, NULL, NULL, NULL);
}
@@ -463,11 +463,12 @@ mkcatalog_median_pass(struct mkcatalog_passparams *pp)
/* Parse the next contiguous region of this tile. */
do
{
- /* If this pixel belongs to the requested object, is a clumps and
- isn't NAN, then do the processing. `hasblank' is constant, so
- when the input doesn't have any blank values, the `isnan' will
- never be checked. */
- if( *O==pp->object && !isnan(*I) )
+ /* If this pixel belongs to the requested object, then do the
+ processing. `hasblank' is constant, so when the input doesn't
+ have any blank values, the `isnan' will never be checked. */
+ if( *O==pp->object
+ && !( p->hasblank && isnan(*I) )
+ && !( (ss = *I - *SK) < p->threshold * *ST ))
{
/* Copy the value for the whole object. */
ss = *I - *SK;
diff --git a/bin/mkcatalog/ui.h b/bin/mkcatalog/ui.h
index 27da86c..4586527 100644
--- a/bin/mkcatalog/ui.h
+++ b/bin/mkcatalog/ui.h
@@ -115,6 +115,7 @@ enum option_keys_enum
UI_KEY_CLUMPSGEOW2,
UI_KEY_CLUMPSBRIGHTNESS,
UI_KEY_NORIVERBRIGHTNESS,
+ UI_KEY_MEAN,
UI_KEY_MEDIAN,
UI_KEY_CLUMPSMAGNITUDE,
UI_KEY_UPPERLIMIT,
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 58d61f3..68e647e 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -15086,6 +15086,9 @@ work-horses: @code{mkcatalog_first_pass} and
@code{mkcatalog_second_pass},
their names are descriptive enough and their internals are also clear and
heavily commented.
address@hidden doc/gnuastro.texi
+Update this manual and add a description for the new column.
+
@end table
@@ -15594,6 +15597,11 @@ 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).
address@hidden --mean
+The mean sky subtracted value of pixels within the object or clump. For
+clumps, the average river flux is subtracted from the sky subtracted
+mean.
+
@item --median
The median sky subtracted value of pixels within the object or clump. For
clumps, the average river flux is subtracted from the sky subtracted