gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master f379085 1/2: NoiseChisel and Segment's S/N FIT


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master f379085 1/2: NoiseChisel and Segment's S/N FITS tables written in one file
Date: Thu, 6 Sep 2018 18:15:49 -0400 (EDT)

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

    NoiseChisel and Segment's S/N FITS tables written in one file
    
    When the `--checksn' option is called in NoiseChisel or segment, until now
    they would create multiple files irrespective of the table format. For text
    files we do indeed need multiple files, but for FITS tables, it is too
    much: a single file can host multiple extensions. So to make things more
    convenient when FITS tables are requested, NoiseChisel and Segment now
    write their tables into one FITS file.
---
 bin/noisechisel/detection.c | 16 +++++----
 bin/noisechisel/threshold.c | 10 +++---
 bin/noisechisel/threshold.h |  2 +-
 bin/noisechisel/ui.c        |  6 ++--
 bin/segment/clumps.c        |  8 ++---
 bin/segment/segment.c       |  7 ++--
 bin/segment/ui.c            |  4 +--
 doc/gnuastro.texi           | 82 +++++++++++++++++++++++++--------------------
 8 files changed, 73 insertions(+), 62 deletions(-)

diff --git a/bin/noisechisel/detection.c b/bin/noisechisel/detection.c
index 9ad3bca..e66c7f3 100644
--- a/bin/noisechisel/detection.c
+++ b/bin/noisechisel/detection.c
@@ -453,7 +453,7 @@ static void
 detection_sn_write_to_file(struct noisechiselparams *p, gal_data_t *sn,
                            gal_data_t *snind, int s0d1D2)
 {
-  char *str;
+  char *str, *extname;
   gal_list_str_t *comments=NULL;
 
   /* Comment for extension on further explanation. */
@@ -473,11 +473,15 @@ detection_sn_write_to_file(struct noisechiselparams *p, 
gal_data_t *sn,
   gal_list_str_add(&comments, str, 1);
 
 
-  /* Set the file name. */
+  /* Set the file name and write the table. */
   str = ( s0d1D2
           ? ( s0d1D2==2 ? p->detsn_D_name : p->detsn_d_name )
           : p->detsn_s_name );
-  threshold_write_sn_table(p, sn, snind, str, comments);
+  if( p->cp.tableformat!=GAL_TABLE_FORMAT_TXT )
+    extname = ( s0d1D2
+                ? ( s0d1D2==2 ? "GROWN_DETECTION_SN" : "DET_PSEUDODET_SN" )
+                : "SKY_PSEUDODET_SN" );
+  threshold_write_sn_table(p, sn, snind, str, comments, extname);
   gal_list_str_free(comments, 1);
 
 
@@ -820,6 +824,7 @@ detection_final_remove_small_sn(struct noisechiselparams *p,
   gal_data_t *sn, *snind;
   int32_t *l, *lf, curlab=1;
   gal_list_str_t *comments=NULL;
+  char *extname="GROWN_DETECTION_SN";
   int32_t *newlabs=gal_pointer_allocate(GAL_TYPE_INT32, num+1, 1, __func__,
                                         "newlabs");
 
@@ -867,9 +872,8 @@ detection_final_remove_small_sn(struct noisechiselparams *p,
       gal_list_str_add(&comments, "See also: `DILATED' "
                        "HDU of output with `--checkdetection'.", 1);
       gal_list_str_add(&comments, "S/N of finally grown detections.", 1);
-
-
-      threshold_write_sn_table(p, sn, snind, p->detsn_D_name, comments);
+      threshold_write_sn_table(p, sn, snind, p->detsn_D_name, comments,
+                               extname);
       gal_list_str_free(comments, 1);
 
     }
diff --git a/bin/noisechisel/threshold.c b/bin/noisechisel/threshold.c
index 2bcdbec..e372296 100644
--- a/bin/noisechisel/threshold.c
+++ b/bin/noisechisel/threshold.c
@@ -190,7 +190,7 @@ threshold_apply(struct noisechiselparams *p, float *value1,
 void
 threshold_write_sn_table(struct noisechiselparams *p, gal_data_t *insn,
                          gal_data_t *inind, char *filename,
-                         gal_list_str_t *comments)
+                         gal_list_str_t *comments, char *extname)
 {
   gal_data_t *sn, *ind, *cols;
 
@@ -225,9 +225,11 @@ threshold_write_sn_table(struct noisechiselparams *p, 
gal_data_t *insn,
   gal_table_comments_add_intro(&comments, PROGRAM_STRING, &p->rawtime);
 
 
-  /* write the table. */
-  gal_checkset_writable_remove(filename, 0, 1);
-  gal_table_write(cols, comments, p->cp.tableformat, filename, "SN", 0);
+  /* Write the table. Note that we'll set the `dontdelete' argument to 0
+     because when the output is a FITS table, we want all the tables in one
+     FITS file. We have already deleted any existing file with the same
+     name in `ui_set_output_names'.*/
+  gal_table_write(cols, comments, p->cp.tableformat, filename, extname, 0);
 
 
   /* Clean up (if necessary). */
diff --git a/bin/noisechisel/threshold.h b/bin/noisechisel/threshold.h
index 48680a7..593e420 100644
--- a/bin/noisechisel/threshold.h
+++ b/bin/noisechisel/threshold.h
@@ -40,7 +40,7 @@ threshold_apply(struct noisechiselparams *p, float *value1, 
float *value2,
 void
 threshold_write_sn_table(struct noisechiselparams *p, gal_data_t *sntable,
                          gal_data_t *snind, char *filename,
-                         gal_list_str_t *comments);
+                         gal_list_str_t *comments, char *extname);
 
 void
 threshold_interp_smooth(struct noisechiselparams *p, gal_data_t **first,
diff --git a/bin/noisechisel/ui.c b/bin/noisechisel/ui.c
index 8e31aec..0fbe803 100644
--- a/bin/noisechisel/ui.c
+++ b/bin/noisechisel/ui.c
@@ -386,13 +386,13 @@ ui_set_output_names(struct noisechiselparams *p)
     {
       p->detsn_s_name=gal_checkset_automatic_output(&p->cp, basename,
                  ( p->cp.tableformat==GAL_TABLE_FORMAT_TXT
-                   ? "_detsn_sky.txt" : "_detsn_sky.fits") );
+                   ? "_detsn_sky.txt" : "_detsn.fits") );
       p->detsn_d_name=gal_checkset_automatic_output(&p->cp, basename,
                  ( p->cp.tableformat==GAL_TABLE_FORMAT_TXT
-                   ? "_detsn_det.txt" : "_detsn_det.fits") );
+                   ? "_detsn_det.txt" : "_detsn.fits") );
       p->detsn_D_name=gal_checkset_automatic_output(&p->cp, basename,
                  ( p->cp.tableformat==GAL_TABLE_FORMAT_TXT
-                   ? "_detsn_grown.txt" : "_detsn_grown.fits") );
+                   ? "_detsn_grown.txt" : "_detsn.fits") );
     }
 
   /* Detection steps. */
diff --git a/bin/segment/clumps.c b/bin/segment/clumps.c
index 3c580ac..7b5eb7e 100644
--- a/bin/segment/clumps.c
+++ b/bin/segment/clumps.c
@@ -37,7 +37,6 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/statistics.h>
 
 #include <gnuastro-internal/timing.h>
-#include <gnuastro-internal/checkset.h>
 
 #include "main.h"
 
@@ -525,15 +524,12 @@ clumps_write_sn_table(struct segmentparams *p, gal_data_t 
*insn,
   cols       = ind;
   cols->next = sn;
 
-
   /* Prepare the comments. */
   gal_table_comments_add_intro(&comments, PROGRAM_STRING, &p->rawtime);
 
-
   /* write the table. */
-  gal_checkset_writable_remove(filename, 0, 1);
-  gal_table_write(cols, comments, p->cp.tableformat, filename, "SN", 0);
-
+  gal_table_write(cols, comments, p->cp.tableformat, filename,
+                  "SKY_CLUMP_SN", 0);
 
   /* Clean up (if necessary). */
   if(sn!=insn) gal_data_free(sn);
diff --git a/bin/segment/segment.c b/bin/segment/segment.c
index c184e6f..939bdcc 100644
--- a/bin/segment/segment.c
+++ b/bin/segment/segment.c
@@ -795,9 +795,8 @@ segment_save_sn_table(struct clumps_params *clprm)
   /* Set the column pointers and write them into a table.. */
   clumpinobj->next=sn;
   objind->next=clumpinobj;
-  gal_checkset_writable_remove(p->clumpsn_d_name, 0, 1);
   gal_table_write(objind, comments, p->cp.tableformat, p->clumpsn_d_name,
-                  "CLUMPS_SN", 0);
+                  "DET_CLUMP_SN", 0);
 
 
   /* Clean up. */
@@ -809,7 +808,9 @@ segment_save_sn_table(struct clumps_params *clprm)
 
   /* Abort NoiseChisel if necessary. */
   if(!p->continueaftercheck)
-    ui_abort_after_check(p, p->clumpsn_s_name, p->clumpsn_d_name,
+    ui_abort_after_check(p, p->clumpsn_s_name,
+                         ( p->cp.tableformat==GAL_TABLE_FORMAT_TXT
+                           ? p->clumpsn_d_name : NULL ),
                          "showing all clump S/N values");
 }
 
diff --git a/bin/segment/ui.c b/bin/segment/ui.c
index eb4a752..707b396 100644
--- a/bin/segment/ui.c
+++ b/bin/segment/ui.c
@@ -380,10 +380,10 @@ ui_set_output_names(struct segmentparams *p)
     {
       p->clumpsn_s_name=gal_checkset_automatic_output(&p->cp, basename,
                  ( p->cp.tableformat==GAL_TABLE_FORMAT_TXT
-                   ? "_clumpsn_sky.txt" : "_clumpsn_sky.fits") );
+                   ? "_clumpsn_sky.txt" : "_clumpsn.fits") );
       p->clumpsn_d_name=gal_checkset_automatic_output(&p->cp, basename,
                  ( p->cp.tableformat==GAL_TABLE_FORMAT_TXT
-                   ? "_clumpsn_det.txt" : "_clumpsn_det.fits") );
+                   ? "_clumpsn_det.txt" : "_clumpsn.fits") );
     }
 
   /* Segmentation steps. */
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index d9a3d17..3d21ba8 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -3223,9 +3223,9 @@ two extensions/steps ahead (in the first 
@code{HOLES-FILLED}), you can see
 that during the process of finding false pseudo-detections, too many holes
 have been filled: see how the many of the brighter galaxies are connected?
 
-Try looking two extensions ahead (in @code{PSEUDOS-FOR-SN}), you can see
-that there aren't too many pseudo-detections because of all those extended
-filled holes. If you look closely, you can see the number of
+Try looking two extensions ahead (in the first @code{PSEUDOS-FOR-SN}), you
+can see that there aren't too many pseudo-detections because of all those
+extended filled holes. If you look closely, you can see the number of
 pseudo-detections in the result NoiseChisel prints (around 4000). This is
 another side-effect of correlated noise. To address it, we should slightly
 increase the pseudo-detection threhold (@option{--dthresh}, run with
@@ -3250,15 +3250,20 @@ $ astnoisechisel flat-ir/xdf-f160w.fits 
--kernel=kernel.fits  \
                  --dthresh=0.2 --checkdetection --checksn
 @end example
 
-The output @file{xdf-f160w_detsn_sky.fits} table contains the label and
-signal-to-noise ratio of all the pseudo-detections in
address@hidden You can see the table columns with the first command
-below and get a feeling for its distribution with the second command. We'll
-discuss the two Table and Statistics programs later.
+The output @file{xdf-f160w_detsn.fits} file contains two extensions for the
+pseudo-detections over the undetected (sky) regions and those over
+detections. The first column is the pseudo-detection label which you can
+see in the address@hidden first @code{PSEUDOS-FOR-SN} in
address@hidden is for the pseudo-detections over the
+undetected regions and the second is for those over detected regions.}
address@hidden extension of @file{xdf-f160w_detcheck.fits}. You can
+see the table columns with the first command below and get a feeling for
+its distribution with the second command. We'll discuss the two Table and
+Statistics programs later.
 
 @example
-$ asttable xdf-f160w_detsn_sky.fits
-$ aststatistics xdf-f160w_detsn_sky.fits -c2
+$ asttable xdf-f160w_detsn.fits
+$ aststatistics xdf-f160w_detsn.fits -c2
 @end example
 
 The correlated noise is again visible in this pseudo-detection
@@ -3268,7 +3273,7 @@ the difference between the three 0.99, 0.95 and 0.90 
quantiles with this
 command:
 
 @example
-$ aststatistics xdf-f160w_detsn_sky.fits -c2                   \
+$ aststatistics xdf-f160w_detsn.fits -c2                        \
                 --quantile=0.99 --quantile=0.95 --quantile=0.90
 @end example
 
@@ -16374,21 +16379,20 @@ psudo-detection that is smaller than this area. Use
 @option{--detsnhistnbins} to check if this value is reasonable or not.
 
 @item --checksn
-Save the S/N values of the pseudo-detections and dilated detections into
-three files ending with @file{_detsn_sky.XXX}, @file{_detsn_det.XXX}, and
address@hidden The @file{.XXX} is determined from the
address@hidden option (see @ref{Input output options}, for example
address@hidden or @file{.fits}). You can use these to inspect the S/N values
-and their distribution (in combination with the @option{--checkdetection}
-option to see where the pseudo-detections are).  You can use Gnuastro's
address@hidden to make a histogram of the distribution or any other
-analysis you would like for better understanding of the distribution (for
-example through a histogram).
-
-With this option, NoiseChisel will abort as soon as the tables are
-created. This allows you to inspect the steps leading to the final quantile
-threshold, this behavior (to abort NoiseChisel) can be disabled with
address@hidden
+Save the S/N values of the pseudo-detections (and possibly grown detections
+if @option{--cleangrowndet} is called) into seprate tables. If
address@hidden is a FITS table, each table will be written into a
+separate extension of one file suffixed with @file{_detsn.fits}. If it is
+plain text, a separate file will be made for each table (ending in
address@hidden, @file{_detsn_det.txt} and
address@hidden). For more on @option{--tableformat} see @ref{Input
+output options}.
+
+You can use these to inspect the S/N values and their distribution (in
+combination with the @option{--checkdetection} option to see where the
+pseudo-detections are).  You can use Gnuastro's @ref{Statistics} to make a
+histogram of the distribution or any other analysis you would like for
+better understanding of the distribution (for example through a histogram).
 
 @item --minnumfalse=INT
 The minimum number of `pseudo-detections' over the undetected regions to
@@ -17185,17 +17189,21 @@ psudo-detections are found on the input image. You 
can use
 value is reasonable or not.
 
 @item --checksn
-Save the S/N values of the clumps into two files ending with
address@hidden and @file{_clumpsn_det.XXX}. The @file{.XXX} is
-determined from the @option{--tableformat} option (see @ref{Input output
-options}, for example @file{.txt} or @file{.fits}). You can use these to
-inspect the S/N values and their distribution (in combination with the
address@hidden option to see where the clumps are). You can
-use Gnuastro's @ref{Statistics} to make a histogram of the distribution
-(ready for plotting in a text file, or a crude ASCII-art demonstration on
-the command-line).
-
-With this option, NoiseChisel will abort as soon as the two tables are
+Save the S/N values of the clumps over the sky and detected regions into
+seprate tables. If @option{--tableformat} is a FITS format, each table will
+be written into a separate extension of one file suffixed with
address@hidden If it is plain text, a separate file will be made for
+each table (ending in @file{_clumpsn_sky.txt} and
address@hidden). For more on @option{--tableformat} see @ref{Input
+output options}.
+
+You can use these tables to inspect the S/N values and their distribution
+(in combination with the @option{--checksegmentation} option to see where
+the clumps are). You can use Gnuastro's @ref{Statistics} to make a
+histogram of the distribution (ready for plotting in a text file, or a
+crude ASCII-art demonstration on the command-line).
+
+With this option, Segment will abort as soon as the two tables are
 created. This allows you to inspect the steps leading to the final S/N
 quantile threshold, this behavior can be disabled with
 @option{--continueaftercheck}.



reply via email to

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