gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 05cc693 080/113: Added 3rd dimension to MakeCa


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 05cc693 080/113: Added 3rd dimension to MakeCatalog's minimum-maximum columns
Date: Fri, 16 Apr 2021 10:33:53 -0400 (EDT)

branch: master
commit 05cc693b9fae505e2f268c5dedb826f1c89d2508
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Added 3rd dimension to MakeCatalog's minimum-maximum columns
    
    In the master branch, a new feature was added in MakeCatalog to measure the
    minimum and maximum positions of the label (on 2D). With this commit, the
    respective columns for the third dimension are also added.
---
 bin/mkcatalog/args.h    | 28 +++++++++++++++++++++
 bin/mkcatalog/columns.c | 65 ++++++++++++++++++++++++++++++++++++++++---------
 bin/mkcatalog/main.h    |  2 ++
 bin/mkcatalog/parse.c   | 21 ++++++++++++----
 bin/mkcatalog/ui.c      |  2 ++
 bin/mkcatalog/ui.h      |  2 ++
 6 files changed, 104 insertions(+), 16 deletions(-)

diff --git a/bin/mkcatalog/args.h b/bin/mkcatalog/args.h
index 1cd79fd..18fdaea 100644
--- a/bin/mkcatalog/args.h
+++ b/bin/mkcatalog/args.h
@@ -567,6 +567,34 @@ struct argp_option program_options[] =
       ui_column_codes_ll
     },
     {
+      "minz",
+      UI_KEY_MINZ,
+      0,
+      0,
+      "Minimum third FITS axis position.",
+      UI_GROUP_COLUMNS_POSITION_PIXEL,
+      0,
+      GAL_TYPE_INVALID,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+      ui_column_codes_ll
+    },
+    {
+      "maxz",
+      UI_KEY_MAXZ,
+      0,
+      0,
+      "Maximum third FITS axis position.",
+      UI_GROUP_COLUMNS_POSITION_PIXEL,
+      0,
+      GAL_TYPE_INVALID,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+      ui_column_codes_ll
+    },
+    {
       "clumpsx",
       UI_KEY_CLUMPSX,
       0,
diff --git a/bin/mkcatalog/columns.c b/bin/mkcatalog/columns.c
index 7a6db1e..bf9af4c 100644
--- a/bin/mkcatalog/columns.c
+++ b/bin/mkcatalog/columns.c
@@ -275,6 +275,8 @@ columns_sanity_check(struct mkcatalogparams *p)
           case UI_KEY_AREAXY:
           case UI_KEY_GEOAREAXY:
           case UI_KEY_Z:
+          case UI_KEY_MINZ:
+          case UI_KEY_MAXZ:
           case UI_KEY_GEOZ:
           case UI_KEY_CLUMPSZ:
           case UI_KEY_CLUMPSGEOZ:
@@ -708,6 +710,32 @@ columns_define_alloc(struct mkcatalogparams *p)
           ciflag[ CCOL_MAXY ] = 1;
           break;
 
+        case UI_KEY_MINZ:
+          name           = "MIN_Z";
+          unit           = "pixel";
+          ocomment       = "Minimum Z axis pixel position.";
+          ccomment       = ocomment;
+          otype          = GAL_TYPE_UINT32;
+          ctype          = GAL_TYPE_UINT32;
+          disp_fmt       = 0;
+          disp_width     = 10;
+          disp_precision = 0;
+          ciflag[ CCOL_MINZ ] = 1;
+          break;
+
+        case UI_KEY_MAXZ:
+          name           = "MAX_Z";
+          unit           = "pixel";
+          ocomment       = "Maximum Z axis pixel position.";
+          ccomment       = ocomment;
+          otype          = GAL_TYPE_UINT32;
+          ctype          = GAL_TYPE_UINT32;
+          disp_fmt       = 0;
+          disp_width     = 10;
+          disp_precision = 0;
+          ciflag[ CCOL_MAXZ ] = 1;
+          break;
+
         case UI_KEY_W1:
           name           = p->ctype[0];
           unit           = p->objects->wcs->cunit[0];
@@ -1693,6 +1721,7 @@ columns_clump_brightness(double *ci)
 static uint32_t
 columns_xy_extrema(struct mkcatalog_passparams *pp, size_t *coord, int key)
 {
+  size_t ndim=pp->tile->ndim;
   gal_data_t *tile=pp->tile, *block=tile->block;
 
   /* We only want to do the coordinate estimation once: in `columns_fill',
@@ -1706,22 +1735,25 @@ columns_xy_extrema(struct mkcatalog_passparams *pp, 
size_t *coord, int key)
                                  block->ndim, block->dsize, coord);
 
   /* Return the proper value: note that `coord' is in C standard: starting
-     from the slowest dimension and counting from zero.*/
+     from the slowest dimension and counting from zero. */
   switch(key)
     {
-    case UI_KEY_MINX: return coord[1] + 1;              break;
-    case UI_KEY_MAXX: return coord[1] + tile->dsize[1]; break;
-    case UI_KEY_MINY: return coord[0] + 1;              break;
-    case UI_KEY_MAXY: return coord[0] + tile->dsize[0]; break;
+    case UI_KEY_MINX: return coord[ndim-1] + 1;                   break;
+    case UI_KEY_MAXX: return coord[ndim-1] + tile->dsize[ndim-1]; break;
+    case UI_KEY_MINY: return coord[ndim-2] + 1;                   break;
+    case UI_KEY_MAXY: return coord[ndim-2] + tile->dsize[ndim-2]; break;
+    case UI_KEY_MINZ: return coord[ndim-3] + 1;                   break;
+    case UI_KEY_MAXZ: return coord[ndim-3] + tile->dsize[ndim-3]; break;
     default:
-      error(EXIT_FAILURE, 0, "%s: a bug! Please contact us to fix the "
-            "problem. The value %d is not a recognized value", __func__,
-            key);
+      error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
+            "the problem. The value %d is not a recognized value",
+            __func__, PACKAGE_BUGREPORT, key);
     }
 
   /* Control should not reach here. */
-  error(EXIT_FAILURE, 0, "%s: a bug! please contact us to fix the problem. "
-        "Control should not reach the end of this function", __func__);
+  error(EXIT_FAILURE, 0, "%s: a bug! please contact us at %s to fix the "
+        "problem. Control should not reach the end of this function",
+        __func__, PACKAGE_BUGREPORT);
   return GAL_BLANK_UINT32;
 }
 
@@ -1783,7 +1815,7 @@ columns_fill(struct mkcatalog_passparams *pp)
   void *colarr;
   gal_data_t *column;
   double *ci, *oi=pp->oi;
-  size_t coord[2]={GAL_BLANK_SIZE_T, GAL_BLANK_SIZE_T};
+  size_t coord[3]={GAL_BLANK_SIZE_T, GAL_BLANK_SIZE_T, GAL_BLANK_SIZE_T};
 
   size_t sr=pp->clumpstartindex, cind, coind;
   size_t oind=pp->object-1; /* IDs start from 1, indexs from 0. */
@@ -1900,6 +1932,8 @@ columns_fill(struct mkcatalog_passparams *pp)
         case UI_KEY_MAXX:
         case UI_KEY_MINY:
         case UI_KEY_MAXY:
+        case UI_KEY_MINZ:
+        case UI_KEY_MAXZ:
           ((uint32_t *)colarr)[oind]=columns_xy_extrema(pp, coord, key);
           break;
 
@@ -2145,6 +2179,7 @@ columns_fill(struct mkcatalog_passparams *pp)
           case UI_KEY_GEOZ:
             ((float *)colarr)[cind] = MKC_RATIO( ci[CCOL_GZ],
                                                  ci[CCOL_NUMALL] );
+
           case UI_KEY_MINX:
             ((uint32_t *)colarr)[cind] = ci[CCOL_MINX];
             break;
@@ -2161,6 +2196,14 @@ columns_fill(struct mkcatalog_passparams *pp)
             ((uint32_t *)colarr)[cind] = ci[CCOL_MAXY];
             break;
 
+          case UI_KEY_MINZ:
+            ((uint32_t *)colarr)[cind] = ci[CCOL_MINZ];
+            break;
+
+          case UI_KEY_MAXZ:
+            ((uint32_t *)colarr)[cind] = ci[CCOL_MAXZ];
+            break;
+
           case UI_KEY_W1:
           case UI_KEY_W2:
           case UI_KEY_W3:
diff --git a/bin/mkcatalog/main.h b/bin/mkcatalog/main.h
index 94cb2d3..4fa7a2c 100644
--- a/bin/mkcatalog/main.h
+++ b/bin/mkcatalog/main.h
@@ -144,6 +144,8 @@ enum clumpcols
     CCOL_MAXX,           /* Maximum X value of clump.                 */
     CCOL_MINY,           /* Minimum Y value of clump.                 */
     CCOL_MAXY,           /* Maximum Y value of clump.                 */
+    CCOL_MINZ,           /* Minimum Z value of clump.                 */
+    CCOL_MAXZ,           /* Maximum Z value of clump.                 */
     CCOL_UPPERLIMIT_B,   /* Upper limit brightness.                   */
     CCOL_UPPERLIMIT_S,   /* Upper limit one-sigma value.              */
     CCOL_UPPERLIMIT_Q,   /* Quantile of object in random distribution.*/
diff --git a/bin/mkcatalog/parse.c b/bin/mkcatalog/parse.c
index a593308..52225f5 100644
--- a/bin/mkcatalog/parse.c
+++ b/bin/mkcatalog/parse.c
@@ -414,6 +414,8 @@ parse_clumps(struct mkcatalog_passparams *pp)
                   || cif[ CCOL_MAXX ]
                   || cif[ CCOL_MINY ]
                   || cif[ CCOL_MAXY ]
+                  || cif[ CCOL_MINZ ]
+                  || cif[ CCOL_MAXZ ]
                   || sc
                   || tid==GAL_BLANK_SIZE_T )
                 ? gal_pointer_allocate(GAL_TYPE_SIZE_T, ndim, 0, __func__,
@@ -470,7 +472,8 @@ parse_clumps(struct mkcatalog_passparams *pp)
                   /* Add to the area of this object. */
                   if( cif[ CCOL_NUMALL ]
                       || cif[ CCOL_MINX ] || cif[ CCOL_MAXX ]
-                      || cif[ CCOL_MINY ] || cif[ CCOL_MAXY ] )
+                      || cif[ CCOL_MINY ] || cif[ CCOL_MAXY ]
+                      || cif[ CCOL_MINZ ] || cif[ CCOL_MAXZ ] )
                     ci[ CCOL_NUMALL ]++;
                   if(cif[ CCOL_NUMALLXY ])
                     ((uint8_t *)(xybin[*C-1].array))[ pind ] = 1;
@@ -482,10 +485,18 @@ parse_clumps(struct mkcatalog_passparams *pp)
                       gal_dimension_index_to_coord(O-objects, ndim, dsize, c);
 
                       /* Position extrema measurements. */
-                      if(cif[ CCOL_MINX ]) ci[CCOL_MINX]=CMIN(CCOL_MINX, 1);
-                      if(cif[ CCOL_MAXX ]) ci[CCOL_MAXX]=CMAX(CCOL_MAXX, 1);
-                      if(cif[ CCOL_MINY ]) ci[CCOL_MINY]=CMIN(CCOL_MINY, 0);
-                      if(cif[ CCOL_MAXY ]) ci[CCOL_MAXY]=CMAX(CCOL_MAXY, 0);
+                      if(cif[ CCOL_MINX ])
+                        ci[CCOL_MINX]=CMIN(CCOL_MINX, ndim-1);
+                      if(cif[ CCOL_MAXX ])
+                        ci[CCOL_MAXX]=CMAX(CCOL_MAXX, ndim-1);
+                      if(cif[ CCOL_MINY ])
+                        ci[CCOL_MINY]=CMIN(CCOL_MINY, ndim-2);
+                      if(cif[ CCOL_MAXY ])
+                        ci[CCOL_MAXY]=CMAX(CCOL_MAXY, ndim-2);
+                      if(cif[ CCOL_MINZ ])
+                        ci[CCOL_MINZ]=CMIN(CCOL_MINZ, ndim-3);
+                      if(cif[ CCOL_MAXZ ])
+                        ci[CCOL_MAXZ]=CMAX(CCOL_MAXZ, ndim-3);
 
                       /* If we need tile-ID, get the tile ID now. */
                       if(tid!=GAL_BLANK_SIZE_T)
diff --git a/bin/mkcatalog/ui.c b/bin/mkcatalog/ui.c
index 10d1595..95be85d 100644
--- a/bin/mkcatalog/ui.c
+++ b/bin/mkcatalog/ui.c
@@ -778,6 +778,8 @@ ui_necessary_inputs(struct mkcatalogparams *p, int *values, 
int *sky,
           case CCOL_MAXX:             /* Only clump labels. */     break;
           case CCOL_MINY:             /* Only clump labels. */     break;
           case CCOL_MAXY:             /* Only clump labels. */     break;
+          case CCOL_MINZ:             /* Only clump labels. */     break;
+          case CCOL_MAXZ:             /* Only clump labels. */     break;
           case CCOL_UPPERLIMIT_B:     *values        = 1;          break;
           case CCOL_UPPERLIMIT_S:     *values        = 1;          break;
           case CCOL_UPPERLIMIT_Q:     *values        = 1;          break;
diff --git a/bin/mkcatalog/ui.h b/bin/mkcatalog/ui.h
index 86a4cc2..1fae21e 100644
--- a/bin/mkcatalog/ui.h
+++ b/bin/mkcatalog/ui.h
@@ -120,6 +120,8 @@ enum option_keys_enum
   UI_KEY_MAXX,
   UI_KEY_MINY,
   UI_KEY_MAXY,
+  UI_KEY_MINZ,
+  UI_KEY_MAXZ,
   UI_KEY_W1,
   UI_KEY_W2,
   UI_KEY_W3,



reply via email to

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