gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 0c30450 7/7: Aperture photometry test added fo


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 0c30450 7/7: Aperture photometry test added for MakeCatalog
Date: Tue, 16 Aug 2016 14:30:38 +0000 (UTC)

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

    Aperture photometry test added for MakeCatalog
    
    An aperture photometry test was added for the new feature of MakeCatalog
    (to make a clumps catalog only when asked): `mkcatalog/aperturephot.sh'.
    
    The input to the `mkprof/inputascanvas.sh' test was also changed to be the
    same as NoiseChisel's input, so this new test could use the value of both
    those tests. In doing so, the positions and values of the profiles (except
    the truncation radius) was set to be similar to `mkprof/mkprofcat1.txt',
    which was used to make the input image. Note that this required
    oversampling so the `--oversample=1' option is now removed.
    
    While doing the tests, some minor corrections were also made in
    MakeCatalog:
    
      - The output name is now much more cleanly specified.
      - No clump image will be reported in the catalog comments.
    
    This finishes task #14122.
---
 doc/gnuastro.texi                                  |   70 ++++++++++++++------
 lib/checkset.c                                     |    6 +-
 src/mkcatalog/mkcatalog.c                          |    9 ++-
 src/mkcatalog/ui.c                                 |   26 +++-----
 tests/Makefile.am                                  |   29 ++++----
 .../inputascanvas.sh => mkcatalog/aperturephot.sh} |   12 ++--
 tests/mkprof/inputascanvas.sh                      |    4 +-
 tests/mkprof/inputascanvas.txt                     |    4 +-
 8 files changed, 94 insertions(+), 66 deletions(-)

diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index fd66d6c..2e16829 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -11167,7 +11167,7 @@ minimum variance.
 @node Invoking astmkcatalog, Adding new columns to MakeCatalog, Measuring 
elliptical parameters, MakeCatalog
 @subsection Invoking MakeCatalog
 
-MakeCatalog will make a catalog from an input image and a labeled
+MakeCatalog will make a catalog from an input image and at least on labeled
 image. The executable name is @file{astmkcatalog} with the following
 general template
 
@@ -11197,14 +11197,42 @@ input, there is no more need to inform MakeCatalog of 
the mask image,
 see @ref{NoiseChisel output}. The options common to all Gnuastro
 programs are explained in @ref{Common options}.
 
-By default two catalogs will be made: one for the objects (suffixed
-with @file{_o.txt}) and another for the clumps (suffixed with
address@hidden). Therefore if any value is given to the
address@hidden option, MakeCatalogs will simply append the two
-suffixes to it as the output file names. So if you want to specify an
-output name, it is best that it not have any suffix. If no value is
-given to the @option{--output} option, MakeCatalog will use the input
-name, see @ref{Automatic output}.
+MakeCatalog needs 4 (or 5) images as input. These images can be separate
+extensions in one file (NoiseChisel's default output), or each can have its
+own file and its own extension. The full 5 images are listed in
address@hidden output}. However, the clump labels image is not mandatory
+(when no clump catalog is required, for example in aperture
+photometry). When inspecting the object labels image, MakeProfiles will
+look for a @code{WCLUMPS} (short for with-clumps) header keyword. If that
+keyword is present and has a value of @code{yes} (not case sensitive, so
address@hidden, or @code{YES} are also acceptable) then a clump image must also
+be provided and a clump catalog will be made. When @code{WCLUMPS} isn't
+present or has any other value, only an object catalog will be created and
+all clump related options will be ignored.
+
address@hidden Photometry, aperture
address@hidden Aperture photometry
+For example, if you only need an object catalog from NoiseChisel's output,
+you can use Header (see @ref{Header}) to modify or remove the
address@hidden keyword in the objects HDU, then run MakeCatalog on
+it. Another example can be aperture photometry: let's assume you have made
+your labeled image (defining the apertures) with MakeProfiles. Clumps are
+not defined in this context, so besides the input and labeled image, you
+only need NoiseChisel's Sky and Sky standard deviation images. Since
+MakeProfile's output doesn't contain the @code{WCLUMPS} keyword, you just
+have to specify your labeled image with the @option{--objlabs} option and
+also set its HDU and no clumps catalog will be created. Note that labeled
+images have to be an integer type. Therefore, when using MakeProfiles to
+define the apertures/labels, you can use @option{--type=long} for example.
+
+When a clump catalog is also desired, two catalogs will be made: one for
+the objects (suffixed with @file{_o.txt}) and another for the clumps
+(suffixed with @file{_c.txt}). Therefore if any value is given to the
address@hidden option, MakeCatalogs will replace these two suffixes with
+any existing suffix in the given value. If no output value is given,
+MakeCatalog will use the input name, see @ref{Automatic output}. When only
+building an object catalog, any suffix in the value to output will just be
+replaced with @file{.txt}.
 
 The first set of options specify the properties of the inputs. Other
 necessary input images are treated very much like a mask image, see
@@ -11267,18 +11295,16 @@ only relevant when the Signal to noise ratio is to be 
calculated.
 
 @item -T
 @itemx --threshold
-(@option{=FLT}) For all the columns, only consider pixels that are
-above a given relative threshold. Symbolizing the value of this option
-as @mymath{T}, the Sky for a pixel at @mymath{(i,j)} with
address@hidden,j}} and its Standard deviation with
address@hidden, that pixel will only be used if its value
-(@mymath{B_{ij}}) satisfies this condition:
address@hidden>\mu_{ij}+{T}\sigma_{ij}}. The only calculations that
-will not be affected are is the average river values
-(@option{--riverave}), since they are used as a reference. A commented
-row will be added in the header of the output catalog that will print
-the given value, since this is a very important issue, it starts with
address@hidden
+(@option{=FLT}) For all the columns, only consider pixels that are above a
+given relative threshold. Symbolizing the value of this option as
address@hidden, the Sky for a pixel at @mymath{(i,j)} with @mymath{\mu_{ij}}
+and its Standard deviation with @mymath{\sigma_{ij}}, that pixel will only
+be used if its value (@mymath{B_{ij}}) satisfies this condition:
address@hidden>\mu_{ij}+{T}\sigma_{ij}}. The only calculations that will
+not be affected are is the average river values (@option{--riverave}),
+since they are used as a reference. A commented row will be added in the
+header of the output catalog that will print the given value, since this is
+a very important issue, it starts with @command{**IMPORTANT**}.
 
 NoiseChisel will detect very diffuse signal which is useful in most
 cases where the aggregate properties of the detections are desired,
@@ -12348,7 +12374,7 @@ $ astmkprof --individual --oversample 3 -x500 -y500 
catalog.txt
 @end example
 
 @noindent
-If mock galaxies are to be made, the catalog (which stores the
+If mock images are to be made, the catalog (which stores the
 parameters for each mock profile) is the mandatory argument. The input
 catalog has to be a text file formatted in a table with columns
 separated by space, tab or comma (@key{,}) characters. See @ref{Common
diff --git a/lib/checkset.c b/lib/checkset.c
index 6715029..58de7cd 100644
--- a/lib/checkset.c
+++ b/lib/checkset.c
@@ -738,9 +738,9 @@ gal_checkset_automatic_output(char *inname, char *suffix, 
int removedirinfo,
      this.*/
   out=gal_checkset_malloc_cat(inname, suffix);
 
-  /* Put the input in the space and remove all elements including and after 
'.'.
-     Note that if there is no '.' in the name, gal_checkset_malloc_cat has
-     already appended inname and suffix.*/
+  /* Put the input in the space and remove all elements including and after
+     '.'.  Note that if there is no '.' in the name,
+     gal_checkset_malloc_cat has already appended inname and suffix.*/
   l=strlen(inname);
   strcpy(out, inname);
   for(i=l;i!=0;--i)
diff --git a/src/mkcatalog/mkcatalog.c b/src/mkcatalog/mkcatalog.c
index 80352d9..de86d9f 100644
--- a/src/mkcatalog/mkcatalog.c
+++ b/src/mkcatalog/mkcatalog.c
@@ -464,9 +464,12 @@ makeoutput(struct mkcatalogparams *p)
       sprintf(p->line, "# Objects %s (hdu: %s)\n", p->up.objlabsname,
               p->up.objhdu);
       strcat(comment, p->line);
-      sprintf(p->line, "# Clumps  %s (hdu: %s)\n", p->up.clumplabsname,
-              p->up.clumphdu);
-      strcat(comment, p->line);
+      if(p->up.clumplabsname)
+        {
+          sprintf(p->line, "# Clumps  %s (hdu: %s)\n", p->up.clumplabsname,
+                  p->up.clumphdu);
+          strcat(comment, p->line);
+        }
       sprintf(p->line, "# Sky     %s (hdu: %s)\n", p->up.skyname,
               p->up.skyhdu);
       strcat(comment, p->line);
diff --git a/src/mkcatalog/ui.c b/src/mkcatalog/ui.c
index 8035f7d..19daaa2 100644
--- a/src/mkcatalog/ui.c
+++ b/src/mkcatalog/ui.c
@@ -838,6 +838,7 @@ void
 sanitycheck(struct mkcatalogparams *p)
 {
   struct uiparams *up=&p->up;
+  struct gal_commonparams *cp=&p->cp;
   struct gal_fits_read_header_keys keys[1];
 
   /* Make sure the input file exists. */
@@ -894,21 +895,16 @@ sanitycheck(struct mkcatalogparams *p)
               OFlxWhtRA, OFlxWhtDec);
     }
 
-  /* Set the output names: */
-  if(p->cp.outputset)
-    {
-      p->ocatname=gal_checkset_malloc_cat(p->cp.output, "_o.txt");
-      p->ccatname=gal_checkset_malloc_cat(p->cp.output, "_c.txt");
-    }
-  else
-    {
-      gal_checkset_automatic_output(up->inputname, "_o.txt",
-                                    p->cp.removedirinfo, p->cp.dontdelete,
-                                    &p->ocatname);
-      gal_checkset_automatic_output(up->inputname, "_c.txt",
-                                    p->cp.removedirinfo, p->cp.dontdelete,
-                                    &p->ccatname);
-    }
+  /* Set the output names, based on if the output is set or not. */
+  gal_checkset_automatic_output(cp->outputset ? cp->output : up->inputname,
+                                up->clumplabsname ? "_o.txt" : ".txt",
+                                cp->outputset ? 0 : p->cp.removedirinfo,
+                                p->cp.dontdelete, &p->ocatname);
+  if(up->clumplabsname)
+    gal_checkset_automatic_output(cp->outputset ? cp->output : up->inputname,
+                                  "_c.txt",
+                                  cp->outputset ? 0 : p->cp.removedirinfo,
+                                  p->cp.dontdelete, &p->ccatname);
 }
 
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a040a4a..f9810ab 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -30,18 +30,19 @@ export topsrc=$(top_srcdir);                        \
 export haslibjpeg=$(MAYBE_HASLIBJPEG);              \
 export hasghostscript=$(MAYBE_HASGHOSTSCRIPT);
 
-TESTS = prepconf.sh mkprof/mosaic1.sh mkprof/mosaic2.sh mkprof/mosaic3.sh  \
-mkprof/mosaic4.sh mkprof/radeccat.sh imgcrop/imgcat.sh imgcrop/wcscat.sh   \
-imgcrop/xcyc.sh imgcrop/xcycnoblank.sh imgcrop/section.sh imgcrop/radec.sh \
-imgcrop/imgpolygon.sh imgcrop/imgoutpolygon.sh imgcrop/wcspolygon.sh       \
-convertt/fitstotxt.sh convertt/fitstojpeg.sh convertt/blankch.sh           \
-convertt/jpegtotxt.sh convertt/fitstojpegcmyk.sh convertt/jpegtofits.sh    \
-convertt/fitstopdf.sh convolve/spatial.sh convolve/frequency.sh            \
-imgwarp/imgwarp_scale.sh imgwarp/homographic.sh mknoise/addnoise.sh        \
-mkprof/ellipticalmasks.sh mkprof/inputascanvas.sh header/write.sh          \
-header/print.sh header/update.sh header/delete.sh imgstat/basicstats.sh        
   \
-subtractsky/subtractsky.sh noisechisel/noisechisel.sh mkcatalog/simple.sh  \
-arithmetic/snimage.sh arithmetic/onlynumbers.sh cosmiccal/simpletest.sh
+TESTS = prepconf.sh mkprof/mosaic1.sh mkprof/mosaic2.sh mkprof/mosaic3.sh   \
+mkprof/mosaic4.sh mkprof/radeccat.sh imgcrop/imgcat.sh imgcrop/wcscat.sh    \
+imgcrop/xcyc.sh imgcrop/xcycnoblank.sh imgcrop/section.sh imgcrop/radec.sh  \
+imgcrop/imgpolygon.sh imgcrop/imgoutpolygon.sh imgcrop/wcspolygon.sh        \
+convertt/fitstotxt.sh convertt/fitstojpeg.sh convertt/blankch.sh            \
+convertt/jpegtotxt.sh convertt/fitstojpegcmyk.sh convertt/jpegtofits.sh     \
+convertt/fitstopdf.sh convolve/spatial.sh convolve/frequency.sh             \
+imgwarp/imgwarp_scale.sh imgwarp/homographic.sh mknoise/addnoise.sh         \
+mkprof/ellipticalmasks.sh mkprof/inputascanvas.sh header/write.sh           \
+header/print.sh header/update.sh header/delete.sh imgstat/basicstats.sh     \
+subtractsky/subtractsky.sh noisechisel/noisechisel.sh mkcatalog/simple.sh   \
+mkcatalog/aperturephot.sh arithmetic/snimage.sh arithmetic/onlynumbers.sh   \
+cosmiccal/simpletest.sh
 
 EXTRA_DIST = $(TESTS) during-dev.sh mkprof/mkprofcat1.txt                  \
 mkprof/ellipticalmasks.txt mkprof/inputascanvas.txt mkprof/mkprofcat2.txt  \
@@ -102,7 +103,7 @@ imgwarp/imgwarp_scale.sh: convolve/spatial.sh.log
 imgwarp/homographic.sh: convolve/spatial.sh.log
 mknoise/addnoise.sh: imgwarp/imgwarp_scale.sh.log
 mkprof/ellipticalmasks.sh: mknoise/addnoise.sh.log
-mkprof/inputascanvas.sh: mkprof/ellipticalmasks.sh.log
+mkprof/inputascanvas.sh: mknoise/addnoise.sh.log
 header/write.sh: convolve/spatial.sh.log
 header/print.sh: header/write.sh.log
 header/update.sh: header/write.sh.log
@@ -111,6 +112,8 @@ imgstat/basicstats.sh: mknoise/addnoise.sh.log
 subtractsky/subtractsky.sh: mknoise/addnoise.sh.log
 noisechisel/noisechisel.sh: mknoise/addnoise.sh.log
 mkcatalog/simple.sh: noisechisel/noisechisel.sh.log
+mkcatalog/aperturephot.sh: noisechisel/noisechisel.sh.log          \
+                           mkprof/inputascanvas.sh
 arithmetic/snimage.sh: noisechisel/noisechisel.sh.log
 arithmetic/onlynumbers.sh: prepconf.sh.log
 cosmiccal/simpletest.sh: prepconf.sh.log
diff --git a/tests/mkprof/inputascanvas.sh b/tests/mkcatalog/aperturephot.sh
similarity index 81%
copy from tests/mkprof/inputascanvas.sh
copy to tests/mkcatalog/aperturephot.sh
index 6412902..c1c8c57 100755
--- a/tests/mkprof/inputascanvas.sh
+++ b/tests/mkcatalog/aperturephot.sh
@@ -1,4 +1,4 @@
-# Make labeled regions on an image with blank pixels.
+# Make a simple catalog for NoiseChisel's output.
 #
 # See the Tests subsection of the manual for a complete explanation
 # (in the Installing gnuastro section).
@@ -22,10 +22,10 @@
 # Set the variabels (The executable is in the build tree). Do the
 # basic checks to see if the executable is made or if the defaults
 # file exists (basicchecks.sh is in the source tree).
-prog=mkprof
-img=ellipticalmasks.fits
+prog=mkcatalog
+objimg=inputascanvas.fits
 execname=../src/$prog/ast$prog
-cat=$topsrc/tests/$prog/inputascanvas.txt
+img=convolve_spatial_noised_labeled.fits
 
 
 
@@ -49,5 +49,5 @@ if [ ! -f $execname ] || [ ! -f $img ]; then exit 77; fi
 
 # Actual test script
 # ==================
-$execname $cat $img --mforflatpix --oversample=1 --inputascanvas  \
-          --type=long --output="inputascanvas.fits"
+$execname $img --objlabs=$objimg --objhdu=0 --output=aperturephot.txt  \
+          --sn --magnitude --dec --ra --y --x
diff --git a/tests/mkprof/inputascanvas.sh b/tests/mkprof/inputascanvas.sh
index 6412902..ac690a9 100755
--- a/tests/mkprof/inputascanvas.sh
+++ b/tests/mkprof/inputascanvas.sh
@@ -23,8 +23,8 @@
 # basic checks to see if the executable is made or if the defaults
 # file exists (basicchecks.sh is in the source tree).
 prog=mkprof
-img=ellipticalmasks.fits
 execname=../src/$prog/ast$prog
+img=convolve_spatial_noised.fits
 cat=$topsrc/tests/$prog/inputascanvas.txt
 
 
@@ -49,5 +49,5 @@ if [ ! -f $execname ] || [ ! -f $img ]; then exit 77; fi
 
 # Actual test script
 # ==================
-$execname $cat $img --mforflatpix --oversample=1 --inputascanvas  \
+$execname $cat $img --mforflatpix --inputascanvas  \
           --type=long --output="inputascanvas.fits"
diff --git a/tests/mkprof/inputascanvas.txt b/tests/mkprof/inputascanvas.txt
index d7ca67d..d32a888 100644
--- a/tests/mkprof/inputascanvas.txt
+++ b/tests/mkprof/inputascanvas.txt
@@ -8,5 +8,5 @@
 # Column 7: Axis ratio
 # Column 8: Magnitude
 # Column 9: Truncation radius
-1 21.00 21.00 4 5 1 45.000 1.000  34 2.000
-2 80.00 80.00 4 8 1 77.650 0.501  45 2.000
+1 100.40 100.40 4 20.00 1 45.000 1.000  1 2.000
+2 50.321 50.827 4 5.978 1 77.650 0.801  2 2.000



reply via email to

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