gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master ffaa059 101/125: Tessellation options now comm


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master ffaa059 101/125: Tessellation options now common to all programs
Date: Sun, 23 Apr 2017 22:36:47 -0400 (EDT)

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

    Tessellation options now common to all programs
    
    Tessellation is used in several programs currently (Convolve, NoiseChisel
    and SubtractSky), and we will be later implementing it in Statistics
    too. Managing its options in the separate programs would be a burden for
    the developers and also the users (in case their short or long option names
    mistakenly differs). So with this commit, the tessellation related options
    are now part of the common options. A short description of each option has
    also been added in the new `Processing options' of the book (a
    sub-sub-section of the `Common options' section).
    
    In the process, the following corrections were also made:
    
     - The values of tessellation options in the Convolve program are now taken
       from the common options structure, not its own structure.
    
     - The values to these new common tessellation options has been moved to
       `gnuastro.conf' to be visible by all programs.
    
     - The programs that don't use tessellation now completely ignore these
       options (in reading/writing of option names/values for example with
       `--help'). A new class of option selection by group was defined for this
       job in the `ui.c' file of such programs.
    
     - A `Tessellation' subsection was added to the `Common program behavior'
       chapter of the book. It will be further expanded in the next commits and
       is not final yet. Especially since it is strongly related to
       Interpolation and also the old `SubtractSky' program which may be
       removed (since its job can possibly be broken `Statistics' and
       `Arithmetic').
    
     - The `Automatic output' subsection was moved close the end of the `Common
       program options' before the `Output headers' subsection.
    
     - The three `--onlyversion', `--cite' and `--config' options were
       previously treated separately with the `options_immediate'
       function. However, afterwords, options were given the ability to call
       certain functions when they are called. So that old function was removed
       and three functions were defined in `lib/options.c' for these options.
    
     - The short option values of all the programs were checked with the list
       of common options' short letters and corrected where necessary to have
       no overlap.
---
 bin/arithmetic/ui.c           |  52 ++--
 bin/convertt/ui.c             |  60 +++--
 bin/convertt/ui.h             |  10 +-
 bin/convolve/args.h           |  78 +-----
 bin/convolve/astconvolve.conf |   6 -
 bin/convolve/convolve.c       |   7 +-
 bin/convolve/main.h           |   6 -
 bin/convolve/ui.c             |  19 +-
 bin/convolve/ui.h             |   2 +-
 bin/cosmiccal/ui.c            |  16 +-
 bin/cosmiccal/ui.h            |   5 +-
 bin/crop/ui.c                 |  58 ++---
 bin/crop/ui.h                 |   5 +-
 bin/fits/ui.c                 |  47 ++--
 bin/fits/ui.h                 |   7 +-
 bin/mknoise/ui.c              |  38 ++-
 bin/mknoise/ui.h              |   5 +-
 bin/mkprof/ui.c               |  45 ++--
 bin/mkprof/ui.h               |   7 +-
 bin/statistics/ui.h           |   6 +-
 bin/table/ui.c                |  30 ++-
 bin/table/ui.h                |   3 +-
 bin/warp/ui.c                 |  34 ++-
 bin/warp/ui.h                 |   6 +-
 doc/gnuastro.texi             | 535 ++++++++++++++++++++++++------------------
 lib/commonopts.h              |  88 ++++++-
 lib/gnuastro.conf             |   6 +
 lib/options.c                 | 324 +++++++++++++------------
 lib/options.h                 | 106 +++++----
 29 files changed, 916 insertions(+), 695 deletions(-)

diff --git a/bin/arithmetic/ui.c b/bin/arithmetic/ui.c
index 633551b..f2f2b13 100644
--- a/bin/arithmetic/ui.c
+++ b/bin/arithmetic/ui.c
@@ -121,27 +121,39 @@ ui_initialize_options(struct imgarithparams *p,
   cp->program_authors    = PROGRAM_AUTHORS;
   cp->coptions           = gal_commonopts_options;
 
-  /* Modify the common options for this program. */
+  /* Modify the common options. */
   for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
-    switch(cp->coptions[i].key)
-      {
-      case GAL_OPTIONS_KEY_HDU:
-        cp->coptions[i].value=&p->hdus;
-        cp->coptions[i].type=GAL_DATA_TYPE_STRLL;
-        cp->coptions[i].doc="Nth call, used for HDU of Nth input FITS.";
-        break;
-
-      case GAL_OPTIONS_KEY_TYPE:
-      case GAL_OPTIONS_KEY_SEARCHIN:
-      case GAL_OPTIONS_KEY_IGNORECASE:
-      case GAL_OPTIONS_KEY_TABLEFORMAT:
-        cp->coptions[i].flags=OPTION_HIDDEN;
-        break;
-
-      case GAL_OPTIONS_KEY_MINMAPSIZE:
-        cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
-        break;
-      }
+    {
+      /* Select individually. */
+      switch(cp->coptions[i].key)
+        {
+        case GAL_OPTIONS_KEY_HDU:
+          cp->coptions[i].value=&p->hdus;
+          cp->coptions[i].type=GAL_DATA_TYPE_STRLL;
+          cp->coptions[i].doc="Nth call, used for HDU of Nth input FITS.";
+          break;
+
+        case GAL_OPTIONS_KEY_TYPE:
+        case GAL_OPTIONS_KEY_SEARCHIN:
+        case GAL_OPTIONS_KEY_IGNORECASE:
+        case GAL_OPTIONS_KEY_TABLEFORMAT:
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+
+        case GAL_OPTIONS_KEY_MINMAPSIZE:
+          cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
+          break;
+        }
+
+      /* Select by group. */
+      switch(cp->coptions[i].group)
+        {
+        case GAL_OPTIONS_GROUP_TESSELLATION:
+          cp->coptions[i].doc=NULL; /* Necessary to remove title. */
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
+    }
 }
 
 
diff --git a/bin/convertt/ui.c b/bin/convertt/ui.c
index 2371ff4..1474a6a 100644
--- a/bin/convertt/ui.c
+++ b/bin/convertt/ui.c
@@ -127,32 +127,44 @@ ui_initialize_options(struct converttparams *p,
   p->quality             = UINT8_MAX;
   p->maxbyte             = UINT8_MAX;
 
-  /* Edit the common options. */
+  /* Modify the common options. */
   for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
-    switch(cp->coptions[i].key)
-      {
-      case GAL_OPTIONS_KEY_HDU:
-        cp->coptions[i].value=&p->hdus;
-        cp->coptions[i].type=GAL_DATA_TYPE_STRLL;
-        cp->coptions[i].doc="FITS input HDU, multiple calls possible.";
-        break;
-
-      case GAL_OPTIONS_KEY_OUTPUT:
-        cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
-        cp->coptions[i].doc="Output filename or suffix.";
-        break;
-
-      case GAL_OPTIONS_KEY_MINMAPSIZE:
-        cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
-        break;
+    {
+      /* Select individually */
+      switch(cp->coptions[i].key)
+        {
+        case GAL_OPTIONS_KEY_HDU:
+          cp->coptions[i].value=&p->hdus;
+          cp->coptions[i].type=GAL_DATA_TYPE_STRLL;
+          cp->coptions[i].doc="FITS input HDU, multiple calls possible.";
+          break;
+
+        case GAL_OPTIONS_KEY_OUTPUT:
+          cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
+          cp->coptions[i].doc="Output filename or suffix.";
+          break;
+
+        case GAL_OPTIONS_KEY_MINMAPSIZE:
+          cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
+          break;
+
+        case GAL_OPTIONS_KEY_TYPE:
+        case GAL_OPTIONS_KEY_SEARCHIN:
+        case GAL_OPTIONS_KEY_IGNORECASE:
+        case GAL_OPTIONS_KEY_TABLEFORMAT:
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
 
-      case GAL_OPTIONS_KEY_TYPE:
-      case GAL_OPTIONS_KEY_SEARCHIN:
-      case GAL_OPTIONS_KEY_IGNORECASE:
-      case GAL_OPTIONS_KEY_TABLEFORMAT:
-        cp->coptions[i].flags=OPTION_HIDDEN;
-        break;
-      }
+      /* Select by group. */
+      switch(cp->coptions[i].group)
+        {
+        case GAL_OPTIONS_GROUP_TESSELLATION:
+          cp->coptions[i].doc=NULL; /* Necessary to remove title. */
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
+    }
 }
 
 
diff --git a/bin/convertt/ui.h b/bin/convertt/ui.h
index 0cf6df5..b28ccf0 100644
--- a/bin/convertt/ui.h
+++ b/bin/convertt/ui.h
@@ -29,8 +29,9 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 /* Available letters for short options:
 
-   d e f g j k l n p r s t v y z
-   A B E F G I J M O Q R T U W X Y Z      */
+   a d e f g j k l n p r s t v y z
+   E G J O Q R W X Y
+*/
 enum option_keys_enum
 {
   /* With short-option version. */
@@ -40,10 +41,9 @@ enum option_keys_enum
   ARGS_OPTION_KEY_HEX                 = 'x',
   ARGS_OPTION_KEY_FLUXLOW             = 'L',
   ARGS_OPTION_KEY_FLUXHIGH            = 'H',
-  ARGS_OPTION_KEY_HIGH                = 'H',
   ARGS_OPTION_KEY_MAXBYTE             = 'm',
-  ARGS_OPTION_KEY_FLMINBYTE           = 'a',
-  ARGS_OPTION_KEY_FHMAXBYTE           = 'b',
+  ARGS_OPTION_KEY_FLMINBYTE           = 'A',
+  ARGS_OPTION_KEY_FHMAXBYTE           = 'B',
   ARGS_OPTION_KEY_CHANGE              = 'c',
   ARGS_OPTION_KEY_CHANGEAFTERTRUNC    = 'C',
   ARGS_OPTION_KEY_INVERT              = 'i',
diff --git a/bin/convolve/args.h b/bin/convolve/args.h
index 98bd78e..b898321 100644
--- a/bin/convolve/args.h
+++ b/bin/convolve/args.h
@@ -100,6 +100,8 @@ struct argp_option program_options[] =
 
 
 
+
+
     /* Outputs */
     {
       "checkfreqsteps",
@@ -119,82 +121,6 @@ struct argp_option program_options[] =
 
 
 
-    /* Tile grid options. */
-    {
-      0, 0, 0, 0,
-      "Tessellation (only for spatial domain):",
-      ARGS_GROUP_MESH_GRID
-    },
-    {
-      "tilesize",
-      ARGS_OPTION_KEY_TILESIZE,
-      "INT[,INT]",
-      0,
-      "Size of regular tiles on each dim. (FITS order).",
-      ARGS_GROUP_MESH_GRID,
-      &p->tilesize,
-      GAL_DATA_TYPE_SIZE_T,
-      GAL_OPTIONS_RANGE_GT_0,
-      GAL_OPTIONS_NOT_MANDATORY,
-      GAL_OPTIONS_NOT_SET,
-      gal_options_parse_sizes_reverse
-    },
-    {
-      "numchannels",
-      ARGS_OPTION_KEY_NUMCHANNELS,
-      "INT[,..]",
-      0,
-      "No. of channels along each dim. (FITS order).",
-      ARGS_GROUP_MESH_GRID,
-      &p->numchannels,
-      GAL_DATA_TYPE_STRING,
-      GAL_OPTIONS_RANGE_ANY,
-      GAL_OPTIONS_NOT_MANDATORY,
-      GAL_OPTIONS_NOT_SET,
-      gal_options_parse_sizes_reverse
-    },
-    {
-      "remainderfrac",
-      ARGS_OPTION_KEY_REMAINDERFRAC,
-      "FLT",
-      0,
-      "Fraction of remainder to split last tile.",
-      ARGS_GROUP_MESH_GRID,
-      &p->remainderfrac,
-      GAL_DATA_TYPE_FLOAT32,
-      GAL_OPTIONS_RANGE_GT_0_LT_1,
-      GAL_OPTIONS_NOT_MANDATORY,
-      GAL_OPTIONS_NOT_SET,
-    },
-    {
-      "convoverch",
-      ARGS_OPTION_KEY_CONVOVERCH,
-      0,
-      0,
-      "Convolve over channel borders.",
-      ARGS_GROUP_MESH_GRID,
-      &p->convoverch,
-      GAL_OPTIONS_NO_ARG_TYPE,
-      GAL_OPTIONS_RANGE_0_OR_1,
-      GAL_OPTIONS_NOT_MANDATORY,
-      GAL_OPTIONS_NOT_SET
-    },
-    {
-      "checktiles",
-      ARGS_OPTION_KEY_CHECKTILES,
-      0,
-      0,
-      "Tile IDs in an image, the size of input.",
-      ARGS_GROUP_MESH_GRID,
-      &p->checktiles,
-      GAL_OPTIONS_NO_ARG_TYPE,
-      GAL_OPTIONS_RANGE_0_OR_1,
-      GAL_OPTIONS_NOT_MANDATORY,
-      GAL_OPTIONS_NOT_SET
-    },
-
-
-
     /* Operating mode. */
     {
       "domain",
diff --git a/bin/convolve/astconvolve.conf b/bin/convolve/astconvolve.conf
index da3d0f5..d8e2ba0 100644
--- a/bin/convolve/astconvolve.conf
+++ b/bin/convolve/astconvolve.conf
@@ -24,12 +24,6 @@
 # Output:
  type               float32
 
-# Mesh grid:
- tilesize           30,30
- numchannels        1,1
- remainderfrac      0.1
- convoverch         0
-
 # Operating mode:
  domain             frequency
  minsharpspec       0.005
\ No newline at end of file
diff --git a/bin/convolve/convolve.c b/bin/convolve/convolve.c
index f179440..8ab9007 100644
--- a/bin/convolve/convolve.c
+++ b/bin/convolve/convolve.c
@@ -776,8 +776,9 @@ convolve(struct convolveparams *p)
   if(p->domain==CONVOLVE_DOMAIN_SPATIAL)
     {
       /* Prepare the mesh structure. */
-      gal_tile_all_position_two_layers(p->input, p->channelsize, p->tilesize,
-                                       p->remainderfrac, &channels, &tiles);
+      gal_tile_all_position_two_layers(p->input, p->cp.channelsize,
+                                       p->cp.tilesize, p->cp.remainderfrac,
+                                       &channels, &tiles);
 
       /* Save the tile IDs if they are requested. */
       if(p->tilesname)
@@ -785,7 +786,7 @@ convolve(struct convolveparams *p)
 
       /* Do the spatial convolution. */
       out=gal_convolve_spatial(tiles, p->kernel, p->cp.numthreads,
-                               p->convoverch);
+                               p->cp.workoverch);
 
       /* Clean up */
       gal_data_free(p->input);
diff --git a/bin/convolve/main.h b/bin/convolve/main.h
index 4d08549..e978a4a 100644
--- a/bin/convolve/main.h
+++ b/bin/convolve/main.h
@@ -79,16 +79,10 @@ struct convolveparams
   uint8_t       nokernelnorm;  /* Do not normalize the kernel.            */
   double        minsharpspec;  /* Deconvolution: min spect. of sharp img. */
   uint8_t     checkfreqsteps;  /* View the frequency domain steps.        */
-  size_t           *tilesize;  /* Size of tiles along each dim. (C order).*/
-  size_t        *numchannels;  /* No. of tiles along each dim. (C order). */
-  float        remainderfrac;  /* Frac. of remainers in each dim to cut.  */
-  uint8_t         convoverch;  /* Convolve over channel borders.          */
-  uint8_t         checktiles;  /* Tile IDs in an img, the size of input.  */
   char            *domainstr;  /* String value specifying domain.         */
   size_t          makekernel;  /* Make a kernel to create input.          */
 
   /* Internal */
-  size_t        *channelsize;  /* Size of channels along each dimension.  */
   int                 domain;  /* Frequency or spatial domain conv.       */
   gal_data_t          *input;  /* Input image array.                      */
   gal_data_t         *kernel;  /* Input Kernel array.                     */
diff --git a/bin/convolve/ui.c b/bin/convolve/ui.c
index eb51aff..483ee4a 100644
--- a/bin/convolve/ui.c
+++ b/bin/convolve/ui.c
@@ -221,6 +221,8 @@ parse_opt(int key, char *arg, struct argp_state *state)
 static void
 ui_read_check_only_options(struct convolveparams *p)
 {
+  struct gal_options_common_params *cp=&p->cp;
+
   /* Read the domain from a string into an integer. */
   if( !strcmp("spatial", p->domainstr) )
     p->domain=CONVOLVE_DOMAIN_SPATIAL;
@@ -233,16 +235,16 @@ ui_read_check_only_options(struct convolveparams *p)
   /* If we are in the spatial domain, make sure that the necessary
      parameters are set. */
   if( p->domain==CONVOLVE_DOMAIN_SPATIAL )
-    if( p->tilesize==NULL || p->numchannels==NULL )
+    if( cp->tilesize==NULL || cp->numchannels==NULL )
       {
-        if( p->tilesize==NULL && p->numchannels==NULL )
+        if( cp->tilesize==NULL && cp->numchannels==NULL )
           error(EXIT_FAILURE, 0, "in spatial convolution, `--numchannels' "
                 "and `--tilesize' are mandatory");
         else
           error(EXIT_FAILURE, 0, "in spatial convolution, `--%s' is "
                 "mandatory: you should use it to set the %s",
-                p->tilesize ? "numchannels" : "tilesize",
-                ( p->tilesize
+                cp->tilesize ? "numchannels" : "tilesize",
+                ( cp->tilesize
                   ? "number of channels along each dimension of the input"
                   : "size of tiles to cover the input along each "
                   "dimension" ) );
@@ -315,9 +317,9 @@ ui_preparations(struct convolveparams *p)
   size_t i, size;
   gal_data_t *sum;
   float *kernel, tmp;
+  struct gal_options_common_params *cp=&p->cp;
   char *outsuffix = p->makekernel ? "_kernel.fits" : "_convolved.fits";
 
-
   /* Set the output name if the user hasn't set it. */
   if(p->cp.output==NULL)
     p->cp.output=gal_checkset_automatic_output(&p->cp, p->filename,
@@ -329,7 +331,7 @@ ui_preparations(struct convolveparams *p)
                                                      "_freqsteps.fits");
       gal_checkset_check_remove_file(p->freqstepsname, 0, p->cp.dontdelete);
     }
-  if(p->checktiles)
+  if(cp->checktiles)
     {
       p->tilesname=gal_checkset_automatic_output(&p->cp, p->filename,
                                                  "_tiled.fits");
@@ -360,8 +362,9 @@ ui_preparations(struct convolveparams *p)
                 PROGRAM_NAME);
     }
   else
-    p->channelsize=gal_tile_all_sanity_check(p->filename, p->cp.hdu, p->input,
-                                             p->tilesize, p->numchannels);
+    cp->channelsize=gal_tile_all_sanity_check(p->filename, p->cp.hdu,
+                                              p->input, cp->tilesize,
+                                              cp->numchannels);
 
 
 
diff --git a/bin/convolve/ui.h b/bin/convolve/ui.h
index 53413ad..2721706 100644
--- a/bin/convolve/ui.h
+++ b/bin/convolve/ui.h
@@ -30,7 +30,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Available letters for short options:
 
    a b e f g i j l n p s v w x y z
-   A B E F G J L M O Q R W X Y Z
+   A B E G J L O Q R W X Y
 */
 enum option_keys_enum
 {
diff --git a/bin/cosmiccal/ui.c b/bin/cosmiccal/ui.c
index 92b17ab..9521537 100644
--- a/bin/cosmiccal/ui.c
+++ b/bin/cosmiccal/ui.c
@@ -97,6 +97,7 @@ ui_initialize_options(struct cosmiccalparams *p,
                       struct argp_option *program_options,
                       struct argp_option *gal_commonopts_options)
 {
+  size_t i;
   struct gal_options_common_params *cp=&p->cp;
 
   /* Set the necessary common parameters structure. */
@@ -108,7 +109,20 @@ ui_initialize_options(struct cosmiccalparams *p,
   cp->coptions           = gal_commonopts_options;
 
   /* Speed of light: */
-  p->c=GSL_CONST_MKSA_SPEED_OF_LIGHT;
+  p->c                   = GSL_CONST_MKSA_SPEED_OF_LIGHT;
+
+  /* Modify the common options. */
+  for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
+    {
+      /* Select by group. */
+      switch(cp->coptions[i].group)
+        {
+        case GAL_OPTIONS_GROUP_TESSELLATION:
+          cp->coptions[i].doc=NULL; /* Necessary to remove title. */
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
+    }
 }
 
 
diff --git a/bin/cosmiccal/ui.h b/bin/cosmiccal/ui.h
index 42ff358..7c4fdab 100644
--- a/bin/cosmiccal/ui.h
+++ b/bin/cosmiccal/ui.h
@@ -29,8 +29,9 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 /* Available letters for short options:
 
-   a b d e f g j k l m n p r s t u v w x y z
-   A B C E F G H J L M O Q R T U W X Y Z  */
+   b c d e f g i j k n p s t u w x y
+   A B C E G J L O Q R W X Y
+*/
 enum option_keys_enum
 {
   /* With short-option version. */
diff --git a/bin/crop/ui.c b/bin/crop/ui.c
index 02214f2..18cb8b6 100644
--- a/bin/crop/ui.c
+++ b/bin/crop/ui.c
@@ -122,11 +122,12 @@ ui_initialize_options(struct cropparams *p,
 
 
   /* Set the necessary common parameters structure. */
-  cp->poptions           = program_options;
   cp->program_name       = PROGRAM_NAME;
   cp->program_exec       = PROGRAM_EXEC;
   cp->program_bibtex     = PROGRAM_BIBTEX;
   cp->program_authors    = PROGRAM_AUTHORS;
+  cp->poptions           = program_options;
+  cp->numthreads         = gal_threads_number();
   cp->coptions           = gal_commonopts_options;
 
 
@@ -136,33 +137,36 @@ ui_initialize_options(struct cropparams *p,
   cp->searchin    = GAL_TABLE_SEARCH_INVALID;
 
 
-  /* Set the mandatory common options. */
+  /* Modify common options. */
   for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
-    switch(cp->coptions[i].key)
-      {
-      case GAL_OPTIONS_KEY_HDU:
-        cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
-        cp->coptions[i].doc="Extension name or number of (all) input(s).";
-        break;
-
-      case GAL_OPTIONS_KEY_MINMAPSIZE:
-        cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
-        break;
-
-      case GAL_OPTIONS_KEY_SEARCHIN:
-        cp->coptions[i].group=ARGS_GROUP_CENTER_CATALOG;
-        break;
-
-      case GAL_OPTIONS_KEY_IGNORECASE:
-        cp->coptions[i].group=ARGS_GROUP_CENTER_CATALOG;
-        break;
-      }
-
-
-  /* Read the number of threads available to the user, this should be done
-     before reading command-line and configuration file options, since they
-     can change it.  */
-  cp->numthreads=gal_threads_number();
+    {
+      /* Select individually */
+      switch(cp->coptions[i].key)
+        {
+        case GAL_OPTIONS_KEY_HDU:
+          cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
+          cp->coptions[i].doc="Extension name or number of (all) input(s).";
+          break;
+
+        case GAL_OPTIONS_KEY_MINMAPSIZE:
+          cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
+          break;
+
+        case GAL_OPTIONS_KEY_SEARCHIN:
+        case GAL_OPTIONS_KEY_IGNORECASE:
+          cp->coptions[i].group=ARGS_GROUP_CENTER_CATALOG;
+          break;
+        }
+
+      /* Select by group. */
+      switch(cp->coptions[i].group)
+        {
+        case GAL_OPTIONS_GROUP_TESSELLATION:
+          cp->coptions[i].doc=NULL; /* Necessary to remove title. */
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
+    }
 }
 
 
diff --git a/bin/crop/ui.h b/bin/crop/ui.h
index e4c4226..d42feac 100644
--- a/bin/crop/ui.h
+++ b/bin/crop/ui.h
@@ -30,7 +30,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Available letters for short options:
 
    e k m t u v
-   A B E F G H I J L O Q R T U W X Y Z  */
+   A B E G H J L Q R W X Y
+*/
 enum option_keys_enum
 {
   /* With short-option version. */
@@ -52,7 +53,7 @@ enum option_keys_enum
   ARGS_OPTION_KEY_SECTION        = 's',
   ARGS_OPTION_KEY_POLYGON        = 'l',
   ARGS_OPTION_KEY_ZEROISNOTBLANK = 'z',
-  ARGS_OPTION_KEY_MODE           = 'M',
+  ARGS_OPTION_KEY_MODE           = 'O',
 
   /* Only with long version (start with a value 1000, the rest will be set
      automatically). */
diff --git a/bin/fits/ui.c b/bin/fits/ui.c
index 6ce9363..65420d4 100644
--- a/bin/fits/ui.c
+++ b/bin/fits/ui.c
@@ -117,26 +117,37 @@ ui_initialize_options(struct fitsparams *p,
   /* For clarity and non-zero initializations. */
   p->mode                = FITS_MODE_INVALID;
 
-  /* Don't show the unused options. */
+  /* Modify common options. */
   for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
-    switch(cp->coptions[i].key)
-      {
-      case GAL_OPTIONS_KEY_SEARCHIN:
-      case GAL_OPTIONS_KEY_IGNORECASE:
-      case GAL_OPTIONS_KEY_TYPE:
-      case GAL_OPTIONS_KEY_TABLEFORMAT:
-      case GAL_OPTIONS_KEY_DONTDELETE:
-      case GAL_OPTIONS_KEY_LOG:
-      case GAL_OPTIONS_KEY_MINMAPSIZE:
-      case GAL_OPTIONS_KEY_NUMTHREADS:
-        cp->coptions[i].flags=OPTION_HIDDEN;
-        break;
-
-      case GAL_OPTIONS_KEY_OUTPUT:
-        cp->coptions[i].doc="Output file name (only for writing HDUs).";
-        break;
-      }
+    {
+      /* Select individually. */
+      switch(cp->coptions[i].key)
+        {
+        case GAL_OPTIONS_KEY_SEARCHIN:
+        case GAL_OPTIONS_KEY_IGNORECASE:
+        case GAL_OPTIONS_KEY_TYPE:
+        case GAL_OPTIONS_KEY_TABLEFORMAT:
+        case GAL_OPTIONS_KEY_DONTDELETE:
+        case GAL_OPTIONS_KEY_LOG:
+        case GAL_OPTIONS_KEY_MINMAPSIZE:
+        case GAL_OPTIONS_KEY_NUMTHREADS:
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+
+        case GAL_OPTIONS_KEY_OUTPUT:
+          cp->coptions[i].doc="Output file name (only for writing HDUs).";
+          break;
+        }
 
+      /* Select by group. */
+      switch(cp->coptions[i].group)
+        {
+        case GAL_OPTIONS_GROUP_TESSELLATION:
+          cp->coptions[i].doc=NULL; /* Necessary to remove title. */
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
+    }
 }
 
 
diff --git a/bin/fits/ui.h b/bin/fits/ui.h
index 6bceab3..8ce6491 100644
--- a/bin/fits/ui.h
+++ b/bin/fits/ui.h
@@ -29,10 +29,9 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 /* Available letters for short options:
 
-   b e f g j l m n s v x y z
-   A B E F G J L M O W X Y Z
-
-*/
+   b e f g i j l m n s v x y z
+   A B E G J L O W X Y
+ */
 enum option_keys_enum
 {
   /* With short-option version. */
diff --git a/bin/mknoise/ui.c b/bin/mknoise/ui.c
index 78d7c5d..dc6a99e 100644
--- a/bin/mknoise/ui.c
+++ b/bin/mknoise/ui.c
@@ -110,20 +110,32 @@ ui_initialize_options(struct mknoiseparams *p,
   cp->coptions           = gal_commonopts_options;
 
 
-  /* Set the mandatory common options. */
+  /* Modify common options. */
   for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
-    switch(cp->coptions[i].key)
-      {
-      case GAL_OPTIONS_KEY_TYPE:
-      case GAL_OPTIONS_KEY_MINMAPSIZE:
-        cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
-        break;
-
-      case GAL_OPTIONS_KEY_SEARCHIN:
-      case GAL_OPTIONS_KEY_TABLEFORMAT:
-        cp->coptions[i].flags=OPTION_HIDDEN;
-        break;
-      }
+    {
+      /* Selet individually */
+      switch(cp->coptions[i].key)
+        {
+        case GAL_OPTIONS_KEY_TYPE:
+        case GAL_OPTIONS_KEY_MINMAPSIZE:
+          cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
+          break;
+
+        case GAL_OPTIONS_KEY_SEARCHIN:
+        case GAL_OPTIONS_KEY_TABLEFORMAT:
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
+
+      /* Select by group. */
+      switch(cp->coptions[i].group)
+        {
+        case GAL_OPTIONS_GROUP_TESSELLATION:
+          cp->coptions[i].doc=NULL; /* Necessary to remove title. */
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
+    }
 }
 
 
diff --git a/bin/mknoise/ui.h b/bin/mknoise/ui.h
index 070237d..0e3fc40 100644
--- a/bin/mknoise/ui.h
+++ b/bin/mknoise/ui.h
@@ -29,8 +29,9 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 /* Available letters for short options:
 
-   a c f g i j k l m n p r t u v w x y
-   A B C E F G H I J L M O Q R T U W X Y Z  */
+   a c d f g i j k l m n p r t u v w x y
+   A B C E G H J L O Q R W X Y
+*/
 enum option_keys_enum
 {
   /* With short-option version. */
diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index 09cb801..bc97109 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -132,24 +132,33 @@ ui_initialize_options(struct mkprofparams *p,
 
   /* Modify the common options for this program. */
   for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
-    switch(cp->coptions[i].key)
-      {
-      case GAL_OPTIONS_KEY_HDU:
-        cp->coptions[i].doc="Input catalog HDU name or number (if FITS).";
-        break;
-
-      case GAL_OPTIONS_KEY_TABLEFORMAT:
-        cp->coptions[i].flags=OPTION_HIDDEN;
-        break;
-
-      case GAL_OPTIONS_KEY_SEARCHIN:
-        cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
-        break;
-
-      case GAL_OPTIONS_KEY_MINMAPSIZE:
-        cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
-        break;
-      }
+    {
+      /* Select individually. */
+      switch(cp->coptions[i].key)
+        {
+        case GAL_OPTIONS_KEY_HDU:
+          cp->coptions[i].doc="Input catalog HDU name or number (if FITS).";
+          break;
+
+        case GAL_OPTIONS_KEY_TABLEFORMAT:
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+
+        case GAL_OPTIONS_KEY_SEARCHIN:
+        case GAL_OPTIONS_KEY_MINMAPSIZE:
+          cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
+          break;
+        }
+
+      /* Select by group. */
+      switch(cp->coptions[i].group)
+        {
+        case GAL_OPTIONS_GROUP_TESSELLATION:
+          cp->coptions[i].doc=NULL; /* Necessary to remove title. */
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
+    }
 }
 
 
diff --git a/bin/mkprof/ui.h b/bin/mkprof/ui.h
index b166599..fe954fa 100644
--- a/bin/mkprof/ui.h
+++ b/bin/mkprof/ui.h
@@ -31,8 +31,9 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
    Available letters (-V which is used by GNU is also removed):
 
-   a d f g j l u v
-   A E G H I J L M O Q U W Z     */
+   a b d g j l n u v
+   A E G H J L O Q W
+*/
 enum option_keys_enum
 {
   /* With short-option version. */
@@ -54,7 +55,7 @@ enum option_keys_enum
   ARGS_OPTION_KEY_CIRCUMWIDTH     = 'w',
   ARGS_OPTION_KEY_REPLACE         = 'R',
   ARGS_OPTION_KEY_ENVSEED         = 'e',
-  ARGS_OPTION_KEY_MFORFLATPIX     = 'F',
+  ARGS_OPTION_KEY_MFORFLATPIX     = 'f',
 
   /* Only with long version. */
   ARGS_OPTION_KEY_PSFINIMG        = 1000,
diff --git a/bin/statistics/ui.h b/bin/statistics/ui.h
index 519d64d..7838859 100644
--- a/bin/statistics/ui.h
+++ b/bin/statistics/ui.h
@@ -29,8 +29,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 /* Available letters for short options:
 
-   a b c d e f i j k p v w x y z
-   B E F G J L R W X Y Z
+   a b d e f i j k p v w x y z
+   B G J L R W X Y
 */
 enum option_keys_enum
 {
@@ -42,7 +42,7 @@ enum option_keys_enum
   ARGS_OPTION_KEY_QRANGE       = 'Q',
   ARGS_OPTION_KEY_MEAN         = 'm',
   ARGS_OPTION_KEY_STD          = 't',
-  ARGS_OPTION_KEY_MEDIAN       = 'M',
+  ARGS_OPTION_KEY_MEDIAN       = 'E',
   ARGS_OPTION_KEY_MODE         = 'O',
   ARGS_OPTION_KEY_QUANTILE     = 'u',
   ARGS_OPTION_KEY_ASCIIHIST    = 'A',
diff --git a/bin/table/ui.c b/bin/table/ui.c
index 383c563..e859934 100644
--- a/bin/table/ui.c
+++ b/bin/table/ui.c
@@ -114,16 +114,28 @@ ui_initialize_options(struct tableparams *p,
   cp->coptions           = gal_commonopts_options;
 
 
-  /* Set the mandatory common options. */
+  /* Modify common options. */
   for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
-    switch(cp->coptions[i].key)
-      {
-      case GAL_OPTIONS_KEY_SEARCHIN:
-      case GAL_OPTIONS_KEY_MINMAPSIZE:
-      case GAL_OPTIONS_KEY_TABLEFORMAT:
-        cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
-        break;
-      }
+    {
+      /* Select individually. */
+      switch(cp->coptions[i].key)
+        {
+        case GAL_OPTIONS_KEY_SEARCHIN:
+        case GAL_OPTIONS_KEY_MINMAPSIZE:
+        case GAL_OPTIONS_KEY_TABLEFORMAT:
+          cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
+          break;
+        }
+
+      /* Select by group. */
+      switch(cp->coptions[i].group)
+        {
+        case GAL_OPTIONS_GROUP_TESSELLATION:
+          cp->coptions[i].doc=NULL; /* Necessary to remove title. */
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
+    }
 }
 
 
diff --git a/bin/table/ui.h b/bin/table/ui.h
index 57e4a85..50fb96c 100644
--- a/bin/table/ui.h
+++ b/bin/table/ui.h
@@ -30,7 +30,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Available letters for short options:
 
    a b d e f g j k l m n p r s t u v w x y z
-   A B C E F G H J L M O Q R T U W X Y Z  */
+   A B C E G H J L O Q R W X Y
+*/
 enum option_keys_enum
 {
   /* With short-option version. */
diff --git a/bin/warp/ui.c b/bin/warp/ui.c
index 3760929..d9faf45 100644
--- a/bin/warp/ui.c
+++ b/bin/warp/ui.c
@@ -126,17 +126,29 @@ ui_initialize_options(struct warpparams *p,
 
   /* Set the mandatory common options. */
   for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
-    switch(cp->coptions[i].key)
-      {
-      case GAL_OPTIONS_KEY_MINMAPSIZE:
-        cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
-        break;
-
-      case GAL_OPTIONS_KEY_SEARCHIN:
-      case GAL_OPTIONS_KEY_TABLEFORMAT:
-        cp->coptions[i].flags=OPTION_HIDDEN;
-        break;
-      }
+    {
+      /* Select individually. */
+      switch(cp->coptions[i].key)
+        {
+        case GAL_OPTIONS_KEY_MINMAPSIZE:
+          cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
+          break;
+
+        case GAL_OPTIONS_KEY_SEARCHIN:
+        case GAL_OPTIONS_KEY_TABLEFORMAT:
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
+
+      /* Select by group. */
+      switch(cp->coptions[i].group)
+        {
+        case GAL_OPTIONS_GROUP_TESSELLATION:
+          cp->coptions[i].doc=NULL; /* Necessary to remove title. */
+          cp->coptions[i].flags=OPTION_HIDDEN;
+          break;
+        }
+    }
 }
 
 
diff --git a/bin/warp/ui.h b/bin/warp/ui.h
index e49a73c..c6ca23d 100644
--- a/bin/warp/ui.h
+++ b/bin/warp/ui.h
@@ -29,14 +29,14 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 /* Available letters for short options:
 
-   b g i j l n u v w x y
-   A B E F G H I J L M O Q R T U W X Y Z  */
+   b d g i j l n u v w x y z
+   A B E G H J L O Q R W X Y
+*/
 enum option_keys_enum
 {
   /* With short-option version. */
   ARGS_OPTION_KEY_KEEPWCS         = 'k',
   ARGS_OPTION_KEY_COVEREDFRAC     = 'C',
-  ARGS_OPTION_KEY_TYPE            = 'T',
   ARGS_OPTION_KEY_ALIGN           = 'a',
   ARGS_OPTION_KEY_ROTATE          = 'r',
   ARGS_OPTION_KEY_SCALE           = 's',
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 9d01695..e91e5b9 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -279,11 +279,12 @@ Common program behavior
 
 * Command-line::                How to use the command-line.
 * Configuration files::         Values for unspecified variables.
-* Threads in Gnuastro::         How threads are managed in Gnuastro.
-* Automatic output::            About automatic output names.
+* Multi-threaded operations::   How threads are managed in Gnuastro.
 * Numeric data types::          Different types and how to specify them.
-* Tables in Gnuastro::          Recognized table formats.
+* Tables::                      Recognized table formats.
+* Tessellation::                Tile the dataset into non-overlapping bins.
 * Getting help::                Getting more information on the go.
+* Automatic output::            About automatic output names.
 * Output headers::              Common headers to all FITS outputs.
 
 Command-line
@@ -298,7 +299,8 @@ Arguments and options
 
 Common options
 
-* Input output::                Common input/output options.
+* Input output options::        Common input/output options.
+* Processing options::          Options for common processing steps.
 * Operating mode options::      Common operating mode options.
 
 Configuration files
@@ -308,12 +310,12 @@ Configuration files
 * Current directory and User wide::  Local and user configuration files.
 * System wide::                 System wide configuration files.
 
-Threads in Gnuastro
+Multi-threaded operations
 
 * A note on threads::           Caution and suggestion on using threads.
 * How to run simultaneous operations::  How to run things simultaneously.
 
-Tables in Gnuastro
+Tables
 
 * Recognized table formats::    Table formats that are recognized in Gnuastro.
 * Gnuastro text table format::  Gnuastro's convention plain text tables.
@@ -2372,7 +2374,7 @@ option by the distribution. This option allows CFITSIO to 
open a file in
 multiple threads, it can thus provide great speed improvements. If CFITSIO
 was not configured with this option, any program which needs this
 capability will warn you and abort when you ask for multiple threads (see
address@hidden in Gnuastro}).
address@hidden operations}).
 
 To install CFITSIO from source, we strongly recommend that you have a look
 through Chapter 2 (Creating the CFITSIO library) of the CFITSIO manual and
@@ -3972,11 +3974,12 @@ command-line.
 @menu
 * Command-line::                How to use the command-line.
 * Configuration files::         Values for unspecified variables.
-* Threads in Gnuastro::         How threads are managed in Gnuastro.
-* Automatic output::            About automatic output names.
+* Multi-threaded operations::   How threads are managed in Gnuastro.
 * Numeric data types::          Different types and how to specify them.
-* Tables in Gnuastro::          Recognized table formats.
+* Tables::                      Recognized table formats.
+* Tessellation::                Tile the dataset into non-overlapping bins.
 * Getting help::                Getting more information on the go.
+* Automatic output::            About automatic output names.
 * Output headers::              Common headers to all FITS outputs.
 @end menu
 
@@ -4099,7 +4102,7 @@ format, that filename extension is used to separate the 
kinds of
 arguments. The list below shows the data formats that are recognized in
 Gnuastro's programs based on their file name endings. Any argument that
 doesn't end with the specified extensions below is considered to be a text
-file (usually catalogs, see @ref{Tables in Gnuastro}). In some cases, a program
+file (usually catalogs, see @ref{Tables}). In some cases, a program
 can accept specific formats, for example @ref{ConvertType} also accepts
 @file{.jpg} images.
 
@@ -4294,17 +4297,19 @@ starts from 0 for a special option, it will be 
explicitly mentioned.
 To facilitate the job of the users and developers, all the programs in
 Gnuastro share some basic command-line options for the options that are
 common to many of the programs. The full list is classified as @ref{Input
-output}, and @ref{Operating mode options}. In some programs, some of the 
options
-are irrelevant, but still recognized (you won't get an unrecognized option
-error, but the value isn't used). Unless otherwise mentioned, these options
-are identical between all programs.
+output options}, @ref{Processing options}, and @ref{Operating mode
+options}. In some programs, some of the options are irrelevant, but still
+recognized (you won't get an unrecognized option error, but the value isn't
+used). Unless otherwise mentioned, these options are identical between all
+programs.
 
 @menu
-* Input output::                Common input/output options.
+* Input output options::        Common input/output options.
+* Processing options::          Options for common processing steps.
 * Operating mode options::      Common operating mode options.
 @end menu
 
address@hidden Input output, Operating mode options, Common options, Common 
options
address@hidden Input output options, Processing options, Common options, Common 
options
 @subsubsection Input/Output options
 
 These options are to do with the input and outputs of the various
@@ -4405,7 +4410,61 @@ A FITS binary table (see @ref{Recognized table formats}).
 
 @end vtable
 
address@hidden Operating mode options,  , Input output, Common options
+
address@hidden Processing options, Operating mode options, Input output 
options, Common options
address@hidden Processing options
+
+Some processing steps are common to several programs, so to help in using
+those steps in the different programs, they are defined as common options
+to all programs. Note that this class of common options is thus necessarily
+less common between all the programs than those described in @ref{Input
+output options}, or @ref{Operating mode options} options.
+
address@hidden @option
+
address@hidden -Z INT[,INT[,...]]
address@hidden --tilesize=[,INT[,...]]
+The size of regular tiles for tessellation, see @ref{Tessellation}. For
+each dimension an integer length (in units of data-elements or pixels) is
+necessary. If the input dimensionality is different from the number of
+values given to this option, the program will stop with an error. Values
+must be separated by commas (@key{,}) and can also be fractions (for
+example @code{4/2}). If they are fractions, the result must be an integer,
+otherwise an error will be printed.
+
address@hidden -M INT[,INT[,...]]
address@hidden --numchannels=INT[,INT[,...]]
+The number of channels for larger input tessellation, see
address@hidden The number and types of acceptable values are similar
+to @option{--tilesize}. The only difference is that instead of length, the
+integers values given to this option represent the @emph{number} of
+channels, not their size.
+
address@hidden -F FLT
address@hidden --remainderfrac=FLT
+The fraction of remainder size along all dimensions to add to the first
+tile. See @ref{Tessellation} for a complete description. This option is
+only relevant if @option{--tilesize} is not exactly divisible by the input
+dataset's size in a dimension. If the remainder size is larger than this
+fraction (compared to @option{--tilesize}), then the remainder size will be
+added with one regular tile size and divided between two tiles at the start
+and end of the given dimension.
+
address@hidden --workoverch
+Ignore the channel borders for the high-level job of the given
+application. As a result, while the channel borders are respected in
+defining the small tiles (such that no tile will cross a channel border),
+the higher-level program operation will ignore them, see
address@hidden
+
address@hidden --checktiles
+Make a FITS file with the same dimensions as the input but each pixel is
+replaced with the ID of the tile that it is associated with. Note that the
+tile IDs start from 0. See @ref{Tessellation} for more on Tiling an image
+in Gnuastro.
address@hidden table
+
address@hidden Operating mode options,  , Processing options, Common options
 @subsubsection Operating mode options
 
 Another group of options that are common to all the programs in Gnuastro
@@ -4619,7 +4678,7 @@ ignored.
 @item -N INT
 @itemx --numthreads=INT
 Use @option{INT} CPU threads when running a Gnuastro program (see
address@hidden in Gnuastro}). Note that multi-threaded programming is only
address@hidden operations}). Note that multi-threaded programming is only
 relevant to some programs. In others, this option will be ignored. If this
 option is not specified on the command-line or any configuration file, the
 number of threads will be determined by the programs at configuration time.
@@ -4631,7 +4690,7 @@ number of threads will be determined by the programs at 
configuration time.
 
 
 
address@hidden Configuration files, Threads in Gnuastro, Command-line, Common 
program behavior
address@hidden Configuration files, Multi-threaded operations, Command-line, 
Common program behavior
 @section Configuration files
 
 @cindex @file{etc}
@@ -4661,7 +4720,7 @@ necessary parameters are not given through any of these 
methods, the
 program will print a missing option error and abort. The only exception to
 this is @option{--numthreads}, whose default value is determined at
 run-time using the number of threads available to your system, see
address@hidden in Gnuastro}. Of course, you can still provide a default value
address@hidden operations}. Of course, you can still provide a default value
 for the number of threads at any of the levels below, but if you don't, the
 program will not abort. Also note that through automatic output name
 generation, the value to the @option{--output} option is also not mandatory
@@ -4752,13 +4811,6 @@ address@hidden an example, the @option{--setdirconf} and
 @option{--setusrconf} options will also write the common options they have
 read in their produced @file{astprogname.conf}.}.
 
-Note that through the @option{--config} and @option{--lastconfig} options
-you can define other files to parse for option values, or stop the reading
-of subsequent configuration files in the list below (see @ref{Operating
-mode options}). Recall that the file given to @option{--config} is parsed
-immediately when this option is confronted (on the command-line or in a
-configuration file).
-
 @enumerate
 @item
 Command-line options, for a particular run of ProgramName.
@@ -4790,7 +4842,27 @@ system-wide installation directory (see @ref{System 
wide} for
 @file{prefix}).
 
 @end enumerate
+
address@hidden
 @noindent
address@hidden the order:} You can manipulate this order or add new
+files with the following two options which are fully described in
address@hidden mode options}:
address@hidden @option
address@hidden --config
+Allows you to define any file to be parsed as a configuration file on the
+command-line or within the any other configuration file. Recall that the
+file given to @option{--config} is parsed immediately when this option is
+confronted (on the command-line or in a configuration file).
+
address@hidden --lastconfig
+Allows you to stop the parsing of subsequent configuration files. Note that
+if this option is given in a configuration file, it will be fully read, so
+its position in the configuration doesn't matter (unlike
address@hidden).
address@hidden table
address@hidden cartouche
+
 
 One example of benefiting from these configuration files can be this: raw
 telescope images usually have their main image extension in the second FITS
@@ -4807,7 +4879,7 @@ behavior in this single file, all Gnuastro programs in 
the respective
 directory, user, or system-wide steps will behave similarly. For example to
 keep the input's directory when no specific output is given (see
 @ref{Automatic output}), or to not delete an existing file if it has the
-same name as a given output (see @ref{Input output}).
+same name as a given output (see @ref{Input output options}).
 
 
 @node Current directory and User wide, System wide, Configuration file 
precedence, Configuration files
@@ -4870,8 +4942,8 @@ source by your self as in @ref{Quick start}.
 
 
 
address@hidden Threads in Gnuastro, Automatic output, Configuration files, 
Common program behavior
address@hidden Threads in Gnuastro
address@hidden Multi-threaded operations, Numeric data types, Configuration 
files, Common program behavior
address@hidden Multi-threaded operations
 
 @pindex nproc
 @cindex pthread
@@ -4908,7 +4980,7 @@ on the command-line or in the configuration files.
 * How to run simultaneous operations::  How to run things simultaneously.
 @end menu
 
address@hidden A note on threads, How to run simultaneous operations, Threads 
in Gnuastro, Threads in Gnuastro
address@hidden A note on threads, How to run simultaneous operations, 
Multi-threaded operations, Multi-threaded operations
 @subsection A note on threads
 
 @cindex Using multiple threads
@@ -4971,7 +5043,7 @@ explained in @ref{How to run simultaneous operations}.
 
 
 
address@hidden How to run simultaneous operations,  , A note on threads, 
Threads in Gnuastro
address@hidden How to run simultaneous operations,  , A note on threads, 
Multi-threaded operations
 @subsection How to run simultaneous operations
 
 There are address@hidden third way would be to open multiple terminal
@@ -5076,61 +5148,7 @@ important.
 
 
 
address@hidden Automatic output, Numeric data types, Threads in Gnuastro, 
Common program behavior
address@hidden Automatic output
-
address@hidden Automatic output file names
address@hidden Output file names, automatic
address@hidden Setting output file names automatically
-All the programs in Gnuastro are designed such that specifying an
-output file or directory (based on the program context) is optional.
-The outputs of most programs are automatically found based on the
-input and what the program does. For example when you are converting a
-FITS image named @file{FITSimage.fits} to a JPEG image, the JPEG image
-will be saved in @file{FITSimage.jpg}.
-
address@hidden --keepinputdir
-Another very important part of the automatic output generation is that
-all the directory information of the input file name is stripped off
-of it. This feature can be disabled with the @option{--keepinputdir}
-option, see @ref{Common options}. It is the default because
-astronomical data are usually very large and organized specially with
-special file names. In some cases, the user might not have write
-permissions in those directories. In fact, even if the data is stored
-on your own computer, it is advised to only grant write permissions to
-the super user or root. This way, you won't accidentally delete or
-modify your valuable data!
-
-Let's assume that we are working on a report and want to process the
-FITS images from two projects (ABC and DEF), which are stored in the
-sub-directories named @file{ABCproject/} and @file{DEFproject/} of our
-top data directory (@file{/mnt/data}). The following shell commands
-show how one image from the former is first converted to a JPEG image
-through ConvertType and then the objects from an image in the latter
-project are detected using NoiseChisel. The text after the @command{#}
-sign are comments (not typed!).
-
address@hidden
-$ pwd                                               # Current location
-/home/usrname/research/report
-$ ls                                         # List directory contents
-ABC01.jpg
-$ ls /mnt/data/ABCproject                                  # Archive 1
-ABC01.fits ABC02.fits ABC03.fits
-$ ls /mnt/data/DEFproject                                  # Archive 2
-DEF01.fits DEF02.fits DEF03.fits
-$ astconvertt /mnt/data/ABCproject/ABC02.fits --output=jpg    # Prog 1
-$ ls
-ABC01.jpg ABC02.jpg
-$ astnoisechisel /mnt/data/DEFproject/DEF01.fits              # Prog 2
-$ ls
-ABC01.jpg ABC02.jpg DEF01_labeled.fits
address@hidden example
-
-
-
-
address@hidden Numeric data types, Tables in Gnuastro, Automatic output, Common 
program behavior
address@hidden Numeric data types, Tables, Multi-threaded operations, Common 
program behavior
 @section Numeric data types
 
 @cindex Bit
@@ -5187,7 +5205,7 @@ convert them to the most efficient type.
 The short and long names for the recognized numeric data types in Gnuastro
 are listed below. Both short and long names can be used when you want to
 speicy a type. For example, as a value to the common option @option{--type}
-(see @ref{Input output}), or in the information comment lines of
+(see @ref{Input output options}), or in the information comment lines of
 @ref{Gnuastro text table format}. The ranges listed below are inclusive.
 
 @table @code
@@ -5263,8 +5281,8 @@ range of types.
 
 
 
address@hidden Tables in Gnuastro, Getting help, Numeric data types, Common 
program behavior
address@hidden Tables in Gnuastro
address@hidden Tables, Tessellation, Numeric data types, Common program behavior
address@hidden Tables
 
 ``A table is a collection of related data held in a structured format
 within a database. It consists of columns, and rows.'' (from
@@ -5319,7 +5337,7 @@ table. They are thoroughly discussed in @ref{Selecting 
table columns}.
 * Selecting table columns::     Identify/select certain columns from a table
 @end menu
 
address@hidden Recognized table formats, Gnuastro text table format, Tables in 
Gnuastro, Tables in Gnuastro
address@hidden Recognized table formats, Gnuastro text table format, Tables, 
Tables
 @subsection Recognized table formats
 
 The list of table formats that Gnuastro can currently read from and write
@@ -5415,7 +5433,7 @@ also contain non-numerical columns.
 * Gnuastro text table format::  Reading plain text tables
 @end menu
 
address@hidden Gnuastro text table format, Selecting table columns, Recognized 
table formats, Tables in Gnuastro
address@hidden Gnuastro text table format, Selecting table columns, Recognized 
table formats, Tables
 @subsection Gnuastro text table format
 
 Plain text files are most generic, portable, and easiest way to (manually)
@@ -5595,7 +5613,7 @@ reading/converting into a file, or with the 
@file{gnuastro/table.h} library
 functions when reading into memory).
 
 
address@hidden Selecting table columns,  , Gnuastro text table format, Tables 
in Gnuastro
address@hidden Selecting table columns,  , Gnuastro text table format, Tables
 @subsection Selecting table columns
 
 At the lowest level, the only defining aspect of a column in a table is its
@@ -5635,8 +5653,8 @@ ask for column 0, the respective program will abort with 
an error. When the
 value can't be interpretted as an a integer number, it will be seen as a
 string of characters which will be used to match/search in the table's
 meta-data. The meta-data field which the value will be compared with can be
-selected through the @option{--searchin} option, see @ref{Input
-output}. @option{--searchin} can take three values: @code{name},
+selected through the @option{--searchin} option, see @ref{Input output
+options}. @option{--searchin} can take three values: @code{name},
 @code{unit}, @code{comment}. The matching will be done following this
 convention:
 
@@ -5658,7 +5676,7 @@ matches the given value in the given field will be 
selected.
 @end itemize
 
 Note that in both cases, you can ignore the case of alphabetic characters
-with the @option{--ignorecase} option, see @ref{Input output}. Also, in
+with the @option{--ignorecase} option, see @ref{Input output options}. Also, in
 both cases, multiple columns may be selected with one call to this
 function. In this case, the order of the selected columns (with one call)
 will be the same order as they appear in the table.
@@ -5666,7 +5684,104 @@ will be the same order as they appear in the table.
 
 
 
address@hidden Getting help, Output headers, Tables in Gnuastro, Common program 
behavior
+
address@hidden Tessellation, Getting help, Tables, Common program behavior
address@hidden Tessellation
+
+It is sometimes necessary to classify the elements in a dataset (for
+example pixels in an image) into a grid of individual, non-overlapping
+tiles. For example when background sky gradients are present in an image,
+you can define a tile grid over the image. When the tile sizes are set
+properly, the background's variation over each tile will be negligble,
+allowing you to measure (and subtract) it. In other cases (for example
+spatial domain convolution in Gnuastro, see @ref{Convolve}), it might
+simply be for speed of processing, since each tile can be processed
+independently on a separate CPU thread. In the arts and mathematics, this
+process is formally known as
address@hidden://en.wikipedia.org/wiki/Tessellation, tessellation}.
+
+The size of the regular tiles (in units of data-elements, or pixels in an
+image) can be defined with the @option{--tilesize} option. It takes
+multiple numbers (separated by a comma) which will be the length along the
+respective dimension (in Fortran/FITS order). For example
address@hidden,40} can be used for an image (a 2D dataset). The
+regular tile size along the first FITS axis (horizontal when viewed in SAO
+ds9) will be 30 pixels and along the second it will be 40 pixels. Ideally,
address@hidden should be selected such that all tiles in the image
+have exactly the same size. In other words, that the dataset length in each
+dimension is divisible by the tile size in that dimension.
+
+However, this is not always possible: the dataset can be any size and every
+pixel in it is valuable. In such cases, Gnuastro will look at the
+significance of the remainder length, if it is not significant (for example
+one or two pixels), then it will just increase the size of the first tile
+in the respective dimension and allow the rest of the tiles to have the
+required size. When the remainder is significant (for example one pixel
+less than the size along that dimension), the remainder will be added to
+one regular tile's size and the large tile will be cut in half and put in
+the two ends of the grid/tessellation. In this way, all the tiles in the
+central regions of the dataset will have the regular tile sizes and the
+tiles on the edge will be slightly smaller. You can set the significance
+fraction with the @option{--remainderfrac} option.
+
+The best tile size is directly related to the spatial properties of the
+gradient on the image. In practice we assume that the gradient is not
+present over each tile. So if there is a strong gradient (for example in
+long wavelength ground based images) or the image is of a crowded area
+where there isn't too much blank area, you have to choose a smaller tile
+size. A larger mesh will give more pixels and so the scatter in the results
+will be less.
+
address@hidden CCD
address@hidden Amplifier
address@hidden Bias current
address@hidden Subaru Telescope
address@hidden Hyper Suprime-Cam
address@hidden Hubble Space Telescope
+For raw image processing, a single tesselation/grid is not sufficient. Raw
+images are the unprocessed outputs of the camera detectors. Modern
+detectors usually have multiple readout channels each with its own
+amplifier. For example the Hubble Space Telescope Advanced Camera for
+Surveys (ACS) has four amplifiers over its full detector area dividing the
+square field of view to four smaller squares. Ground based image detectors
+are not exempt, for example each CCD of Subaru Telescope's Hyper
+Suprime-Cam camera (which has 104 CCDs) has four amplifiers, but they have
+the same height of the CCD and divide the width by four parts.
+
address@hidden Channel
+The bias current on each amplifier is different, and initial bias
+subtraction is not perfect. So even after subtracting the measured bias
+current, you can usually still identify the boundaries of different
+amplifiers by eye. See Figure 11(a) in Akhlaghi and Ichikawa (2015) for an
+example. This results in the final reduced data to have non-uniform
+amplifier-shaped regions with higher or lower background flux values. Such
+systematic biases will then propagate to all subsequent measurements we do
+on the data (for example photometry and subsequent stellar mass and star
+formation rate measurements in the case of galaxies).
+
+Therefore an accurate analysis requires a lower-level tesselation: with
+larger tiles, each large tile covering one amplifier channel. For clarity
+we'll call these larger tiles ``channels''. The number of channels along
+each dimension is defined through the @option{--numchannels}. Each channel
+will then be covered by its own individual smaller tessellation (with tile
+sizes determined by the @option{--tilesize} option). This will allow two
+adjacent pixels from different channels to never be considered together in
+the higher-level analysis. If the image is processed or the detector only
+has one amplifier, you can set the number of channels in both axes to 1.
+
+The final tesselation can be seen on the image with the
address@hidden option that is available to all programs which use
+tessellation for localized operations. When this option is called, a FITS
+file with a @file{_mesh.fits} suffix will be created along with the
+outputs, see @ref{Automatic output}. Each pixel in this image has the ID of
+the tile that covers it. If the number of channels in any dimension are
+larger than unity, you will notice that the tile IDs are defined such that
+the first channels is covered first, then the second and so on.
+
+
+
+
address@hidden Getting help, Automatic output, Tessellation, Common program 
behavior
 @section Getting help
 
 @cindex Help
@@ -5979,8 +6094,62 @@ list. We have other mailing lists and tools for those 
purposes, see
 
 
 
address@hidden Automatic output, Output headers, Getting help, Common program 
behavior
address@hidden Automatic output
+
address@hidden Automatic output file names
address@hidden Output file names, automatic
address@hidden Setting output file names automatically
+All the programs in Gnuastro are designed such that specifying an
+output file or directory (based on the program context) is optional.
+The outputs of most programs are automatically found based on the
+input and what the program does. For example when you are converting a
+FITS image named @file{FITSimage.fits} to a JPEG image, the JPEG image
+will be saved in @file{FITSimage.jpg}.
+
address@hidden --keepinputdir
+Another very important part of the automatic output generation is that
+all the directory information of the input file name is stripped off
+of it. This feature can be disabled with the @option{--keepinputdir}
+option, see @ref{Common options}. It is the default because
+astronomical data are usually very large and organized specially with
+special file names. In some cases, the user might not have write
+permissions in those directories. In fact, even if the data is stored
+on your own computer, it is advised to only grant write permissions to
+the super user or root. This way, you won't accidentally delete or
+modify your valuable data!
+
+Let's assume that we are working on a report and want to process the
+FITS images from two projects (ABC and DEF), which are stored in the
+sub-directories named @file{ABCproject/} and @file{DEFproject/} of our
+top data directory (@file{/mnt/data}). The following shell commands
+show how one image from the former is first converted to a JPEG image
+through ConvertType and then the objects from an image in the latter
+project are detected using NoiseChisel. The text after the @command{#}
+sign are comments (not typed!).
+
address@hidden
+$ pwd                                               # Current location
+/home/usrname/research/report
+$ ls                                         # List directory contents
+ABC01.jpg
+$ ls /mnt/data/ABCproject                                  # Archive 1
+ABC01.fits ABC02.fits ABC03.fits
+$ ls /mnt/data/DEFproject                                  # Archive 2
+DEF01.fits DEF02.fits DEF03.fits
+$ astconvertt /mnt/data/ABCproject/ABC02.fits --output=jpg    # Prog 1
+$ ls
+ABC01.jpg ABC02.jpg
+$ astnoisechisel /mnt/data/DEFproject/DEF01.fits              # Prog 2
+$ ls
+ABC01.jpg ABC02.jpg DEF01_labeled.fits
address@hidden example
+
+
+
+
 
address@hidden Output headers,  , Getting help, Common program behavior
address@hidden Output headers,  , Automatic output, Common program behavior
 @section Output headers
 
 @cindex Output FITS headers
@@ -6100,11 +6269,11 @@ first. From the start of the computer age, different 
formats have been
 difined to store data, optimized for pariticular applications, one
 format/container can never be useful for all applications. In astronomy,
 FITS is the most common format of data storage and transmission. It has
-many useful features, for example multiple data containers (also known as
+many useful features, for example multiple sub-containers (also known as
 extensions or header data units, HDUs) within one file. Each HDU can store
-independent data and its corresponding meta-data. Therefore, Gnuastro has
-one program (see @ref{Fits}) specifically designed to manipulate FITS HDUs
-and the meta-data (header keywords) in each HDU.
+independent dataset and its corresponding meta-data. Therefore, Gnuastro
+has one program (see @ref{Fits}) specifically designed to manipulate FITS
+HDUs and the meta-data (header keywords) in each HDU.
 
 Your astronomical research does not just involve data analysis (where the
 FITS format is very useful). For example you want to demonstrate your raw
@@ -6117,18 +6286,18 @@ along with EPS and PDF (which can only be created from 
FITS, not the other
 way round).
 
 Finally, the FITS format is not just for images, it can also store
-tables. Binary tables in particular can be very useful in storing catalogs
-that have more than a few tens of columns and rows. However, unlike images
-(where all elements/pixels have one data type), tables contain multiple
-columns and each column can have different properties: independent data
-types (see @ref{Numeric data types}) and meta-data. In practice, each
-column can be viewed as a separate container that is grouped with others in
-the table. The only shared property of the colums in a FITS table is thus
-the number of elements they contain. To allow easy inspection/manipulation
-of table columns, Gnuastro has the Table program (see @ref{Table}). It can
-be used to select certain table columns in a FITS table and see them as a
-human readable output on the command-line, or to save them into another
-plain text or FITS table.
+tables. Binary tables in particular can be very efficient in storing
+catalogs that have more than a few tens of columns and rows. However,
+unlike images (where all elements/pixels have one data type), tables
+contain multiple columns and each column can have different properties:
+independent data types (see @ref{Numeric data types}) and meta-data. In
+practice, each column can be viewed as a separate container that is grouped
+with others in the table. The only shared property of the colums in a table
+is thus the number of elements they contain. To allow easy
+inspection/manipulation of table columns, Gnuastro has the Table program
+(see @ref{Table}). It can be used to select certain table columns in a FITS
+table and see them as a human readable output on the command-line, or to
+save them into another plain text or FITS table.
 
 @menu
 * Fits::                        View and manipulate extensions and keywords.
@@ -6910,10 +7079,10 @@ In ConvertType, it is possible to call the HDU option 
multiple times for
 the different input FITS files (corresponding to different color channels)
 in the same order that they are called on the command-line. Except for the
 fact that multiple calls are possible, this option is identical to the
-common @option{--hdu} in @ref{Input output}. The number of calls to this
-option cannot be less than the number of input FITS files, but if there are
-more, the extra HDUs will be ignored, note that they will be read in the
-order described in @ref{Configuration file precedence}.
+common @option{--hdu} in @ref{Input output options}. The number of calls to
+this option cannot be less than the number of input FITS files, but if
+there are more, the extra HDUs will be ignored, note that they will be read
+in the order described in @ref{Configuration file precedence}.
 @end table
 
 @noindent
@@ -7043,7 +7212,7 @@ therefore be @mymath{2^8-1=255}. With this option you can 
change (decrease)
 the maximum value. By doing so you will decrease the dynamic range. It can
 be useful if you plan to use those values for other purposes.
 
address@hidden -i INT
address@hidden -A INT
 @itemx --flminbyte=INT
 If the lowest pixel value in the input channels is larger than the value to
 @option{--fluxlow}, then that input value will be redundant. In some
@@ -7052,7 +7221,7 @@ correspond to that flux even if the data do not reach 
that value. With this
 option you can do this. Note that if the minimum pixel value is smaller
 than @option{--fluxlow}, then this option is redundant.
 
address@hidden -a INT
address@hidden -B INT
 @itemx --fhmaxbyte=INT
 See @option{--flminbyte}.
 
@@ -7093,7 +7262,7 @@ are stored in the human readable ASCII format, but within 
the FITS file
 structure. These are mainly useful for keeping ASCII data along with images
 and possibly binary data as multiple (conceptually related) extensions
 within a FITS file. The acceptable table formats are fully described in
address@hidden in Gnuastro}.
address@hidden
 
 @cindex AWK
 @cindex GNU AWK
@@ -7130,7 +7299,7 @@ some simple examples.
 
 Table will read/write, select, convert, or show the information of the
 columns in FITS ASCII table, FITS binary table and plain text table files,
-see @ref{Tables in Gnuastro}. Output columns can also be determined by number 
or
+see @ref{Tables}. Output columns can also be determined by number or
 regular expression matching of column names, units, or comments. The
 executable name is @file{asttable} with the following general template
 
@@ -7580,7 +7749,7 @@ for more.
 
 @cindex Asynchronous thread allocation
 When in catalog mode, Crop will run in parallel unless you set
address@hidden, see @ref{Threads in Gnuastro}. Note that when
address@hidden, see @ref{Multi-threaded operations}. Note that when
 multiple threads are being used, in verbose mode, the outputs will not be
 in order. This is because the threads are asynchronous and thus not started
 in order. This has no effect on the output, see @ref{Hubble visually checks
@@ -7850,7 +8019,7 @@ with this option, see @ref{Blank pixels}.
 Operating mode options:
 @table @option
 
address@hidden -M STR
address@hidden -O STR
 @itemx --mode=STR
 Operate in Image mode or WCS mode when the input coordinates can be both
 image or WCS. The value must either be @option{img} or @option{wcs}, see
@@ -8452,8 +8621,8 @@ explained below:
 
 @item -h INT/STR
 @itemx --hdu INT/STR
-The header data unit of the input FITS images, see @ref{Input
-output}. Unlike most options in Gnuastro (which will ultimately only have
+The header data unit of the input FITS images, see @ref{Input output
+options}. Unlike most options in Gnuastro (which will ultimately only have
 one value for this option), Arithmetic allows @option{--hdu} to be called
 multiple times and the value of each invocation will be stored separately
 (for the unlimited number of input images you would like to use). Recall
@@ -10795,101 +10964,7 @@ are ultimately poor approximations.
 @cindex Mesh grid
 @cindex Tile grid
 @cindex Tessellation
-Some of the programs in Gnuastro will need to divide the pixels in an image
-into a grid of individual, non-overlapping tiles. In the arts and
-mathematics, this process is formally known as
address@hidden://en.wikipedia.org/wiki/Tessellation, tessellation}. Defining a
-tessellation over a dataset (image) is necessary in many contexts. Their
-most common application is to account for local variations over the dataset
-(for example background sky gradients, which are more common as we go to
-longer/redder wavelengths/filters).
-
-In this section we will explain the concept in detail and how you can check
-the grid. In the case of SubtractSky, if the image is completely uniform
-then one sky value will suffice for the whole image. See @ref{Sky value}
-for the definition of the sky value.  Unfortunately though, as discussed in
address@hidden, in most images taken with ground or space-based
-telescopes the sky value is not uniform. So we have to break the image up
-into small tiles on a grid, assume the Sky value is constant over them and
-find the sky value on those tiles.
-
-The size of the regular tiles (in units of data-elements, or pixels in an
-image) can be defined with the @option{--tilesize} option. It takes
-multiple numbers (separated by a comma) which will be the length along the
-respective dimension (in Fortran/FITS order). For example
address@hidden,40} can be used for an image (a 2D dataset). The
-regular tile size along the first FITS axis (horizontal when viewed in SAO
-ds9) will be 30 pixels and along the second it will be 40 pixels. Ideally,
address@hidden should be selected such that all tiles in the image
-have exactly the same size (in other words, that the dataset length in each
-dimension is divisible by the tile size in that dimension).
-
-However, this is not always possible: the dataset can be any size and every
-pixel in it is valuable. In such cases, Gnuastro will look at the
-significance of the remainder length, if it is not significant (for example
-one or two pixels), then it will just increase the size of the first tile
-in the respective dimension and allow the rest of the tiles to have the
-required size. When the remainder is significant (for example one pixel
-less than the size along that dimension), the remainder will be added to
-one regular tile's size and the large tile will be cut in half and put in
-the two ends of the grid/tessellation. In this way, all the tiles in the
-central regions of the dataset will have the regular tile sizes and the
-tiles on the edge will be slightly smaller. You can set the significance
-fraction with the @option{--remainderfrac} option.
-
-The best tile size is directly related to the spatial properties of the
-gradient on the image. In practice we assume that the gradient is not
-present over each tile. So if there is a strong gradient (for example in
-long wavelength ground based images) or the image is of a crowded area
-where there isn't too much blank area, you have to choose a smaller tile
-size. A larger mesh will give more pixels and so the scatter in the results
-will be less.
-
address@hidden CCD
address@hidden Amplifier
address@hidden Bias current
address@hidden Subaru Telescope
address@hidden Hyper Suprime-Cam
address@hidden Hubble Space Telescope
-For raw image processing, a single tesselation/grid is not sufficient. Raw
-images are the unprocessed outputs of the camera detectors. Modern
-detectors usually have multiple readout channels each with its own
-amplifier. For example the Hubble Space Telescope Advanced Camera for
-Surveys (ACS) has four amplifiers over its full detector area dividing the
-square field of view to four smaller squares. Ground based image detectors
-are not exempt, for example each CCD of Subaru Telescope's Hyper
-Suprime-Cam camera (which has 104 CCDs) has four amplifiers, but they have
-the same height of the CCD and divide the width by four parts.
-
address@hidden Channel
-The bias current on each amplifier is different, and initial bias
-subtraction is not perfect. So even after subtracting the measured bias
-current, you can usually still identify the boundaries of different
-amplifiers by eye. See Figure 11(a) in Akhlaghi and Ichikawa (2015) for an
-example. This results in the final reduced data to have non-uniform
-amplifier-shaped regions with higher or lower background flux values. Such
-systematic biases will then propagate to all subsequent measurements we do
-on the data (for example photometry and subsequent stellar mass and star
-formation rate measurements in the case of galaxies).
-
-Therefore an accurate analysis requires a lower-level tesselation: with
-larger tiles, each large tile covering one amplifier channel. For clarity
-we'll call these larger tiles ``channels''. The number of channels along
-each dimension is defined through the @option{--numchannels}. Each channel
-will then be covered by its own individual smaller tessellation (with tile
-sizes determined by the @option{--tilesize} option). This will allow two
-adjacent pixels from different channels to never be considered together in
-the higher-level analysis. If the image is processed or the detector only
-has one amplifier, you can set the number of channels in both axes to 1.
 
-The final tesselation can be seen on the image with the
address@hidden option that is available to all programs which use
-tessellation for localized operations. When this option is called, a FITS
-file with a @file{_mesh.fits} suffix will be created along with the
-outputs, see @ref{Automatic output}. Each pixel in this image has the ID of
-the tile that covers it. If the number of channels in any dimension are
-larger than unity, you will notice that the tile IDs are defined such that
-the first channels is covered first, then the second and so on.
 
 @menu
 * Quantifying signal in a mesh::  Good meshs for gradients.
@@ -11600,8 +11675,8 @@ programs including Statistics, see @ref{Common options} 
for those.
 @itemx --column=STR/INT
 The input column selector when the input file is a table. See
 @ref{Selecting table columns} for a full description of how to use this
-option. For more on how tables are read in Gnuastro, please see @ref{Tables
-in Gnuastro}.
+option. For more on how tables are read in Gnuastro, please see
address@hidden
 
 @item -r STR/INT
 @itemx --refcol=STR/INT
@@ -11685,7 +11760,7 @@ Print the mean (average) of all used elements.
 @itemx --std
 Print the standard deviation of all used elements.
 
address@hidden -M
address@hidden -E
 @itemx --median
 Print the median of all used elements.
 
@@ -14277,7 +14352,7 @@ $ astmkprof --individual --oversample 3 -x500 -y500 
catalog.txt
 @noindent
 If mock images are to be made, a catalog (which stores the parameters for
 each mock profile) is mandatory. The catalog can be in the FITS ASCII, FITS
-binary format, or plain text formats (see @ref{Tables in Gnuastro}). The
+binary format, or plain text formats (see @ref{Tables}). The
 columns related to each paramter can be determined both by number, or by
 match/search criteria using the column names, units, or comments. with the
 options ending in @option{col}, see below. Without any file given to the
@@ -14366,7 +14441,7 @@ all the information about the output image. Hence, the 
following options
 will be ignored: @option{--naxis1}, @option{--naxis2}, @option{--crpix1},
 @option{--crpix2}, @option{--crval1}, @option{--crval2},
 @option{--resolution}, @option{--oversample}, and data type (see
address@hidden in @ref{Input output}).
address@hidden in @ref{Input output options}).
 
 The image will act like a canvas to build the profiles on: profile pixel
 values will be summed with the background image pixel values. With the
@@ -14666,7 +14741,7 @@ radial parameter of the profile (the value in the 
@option{--rcol} of the
 catalog). If @option{--tunitinp} is given, this value is interpreted in
 units of pixels (prior to oversampling) irrespective of the profile.
 
address@hidden -F
address@hidden -f
 @itemx --mforflatpix
 When making fixed value profiles (flat and circumference, see
 address@hidden'), don't use the value in the column specified by
@@ -16570,8 +16645,8 @@ pointed to by @code{numhdu}.
 
 @deftypefun void gal_fits_read_hdu (char @code{*filename}, char @code{*hdu}, 
unsigned char @code{img0_tab1}, fitsfile @code{**outfptr})
 Open the HDU @code{hdu} (a string) of the @file{filename} FITS file into
-the @code{outfptr}. See @option{--hdu} option in @ref{Input output} for the
-accepted HDU formats.
+the @code{outfptr}. See @option{--hdu} option in @ref{Input output options}
+for the accepted HDU formats.
 @end deftypefun
 
 @deftypefun void gal_fits_read_keywords (char @code{*filename}, char 
@code{*hdu}, struct gal_fits_key @code{*keys}, size_t @code{num})
@@ -16678,7 +16753,7 @@ Read the FITS image (in the @code{hdu} extension of 
@code{filename}). The
 image array will be stored in @code{array} and the number of pixels in the
 first and second C axis will be stored in @code{s0} and @code{s1}. The type
 of the array will be kept in @code{bitpix}. See @option{--hdu} in
address@hidden output} for the acceptable formats of @code{hdu}.
address@hidden output options} for the acceptable formats of @code{hdu}.
 @end deftypefun
 
 @deftypefun void gal_fits_array_to_file (char @code{*filename}, char 
@code{*extname}, int @code{bitpix}, void @code{*array}, size_t @code{s0}, 
size_t @code{s1}, int @code{anyblank}, struct wcsprm @code{*wcs}, struct 
gal_fits_key_ll @code{*headers}, char @code{*spack_string})
diff --git a/lib/commonopts.h b/lib/commonopts.h
index 10f1eb8..84581c6 100644
--- a/lib/commonopts.h
+++ b/lib/commonopts.h
@@ -86,6 +86,83 @@ struct argp_option gal_commonopts_options[] =
 
 
 
+    /* Tile grid options. */
+    {
+      0, 0, 0, 0,
+      "Tessellation (tile grid):",
+      GAL_OPTIONS_GROUP_TESSELLATION
+    },
+    {
+      "tilesize",
+      GAL_OPTIONS_KEY_TILESIZE,
+      "INT[,INT]",
+      0,
+      "Size of regular tiles on each dim. (FITS order).",
+      GAL_OPTIONS_GROUP_TESSELLATION,
+      &cp->tilesize,
+      GAL_DATA_TYPE_SIZE_T,
+      GAL_OPTIONS_RANGE_GT_0,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+      gal_options_parse_sizes_reverse
+    },
+    {
+      "numchannels",
+      GAL_OPTIONS_KEY_NUMCHANNELS,
+      "INT[,..]",
+      0,
+      "No. of channels along each dim. (FITS order).",
+      GAL_OPTIONS_GROUP_TESSELLATION,
+      &cp->numchannels,
+      GAL_DATA_TYPE_STRING,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+      gal_options_parse_sizes_reverse
+    },
+    {
+      "remainderfrac",
+      GAL_OPTIONS_KEY_REMAINDERFRAC,
+      "FLT",
+      0,
+      "Fraction of remainder to split last tile.",
+      GAL_OPTIONS_GROUP_TESSELLATION,
+      &cp->remainderfrac,
+      GAL_DATA_TYPE_FLOAT32,
+      GAL_OPTIONS_RANGE_GT_0_LT_1,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+    },
+    {
+      "workoverch",
+      GAL_OPTIONS_KEY_WORKOVERCH,
+      0,
+      0,
+      "Convolve over channel borders.",
+      GAL_OPTIONS_GROUP_TESSELLATION,
+      &cp->workoverch,
+      GAL_OPTIONS_NO_ARG_TYPE,
+      GAL_OPTIONS_RANGE_0_OR_1,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET
+    },
+    {
+      "checktiles",
+      GAL_OPTIONS_KEY_CHECKTILES,
+      0,
+      0,
+      "Tile IDs in an image, the size of input.",
+      GAL_OPTIONS_GROUP_TESSELLATION,
+      &cp->checktiles,
+      GAL_OPTIONS_NO_ARG_TYPE,
+      GAL_OPTIONS_RANGE_0_OR_1,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET
+    },
+
+
+
+
     {
       0, 0, 0, 0,
       "Output:",
@@ -235,7 +312,8 @@ struct argp_option gal_commonopts_options[] =
       GAL_OPTIONS_NO_ARG_TYPE,
       GAL_OPTIONS_RANGE_0_OR_1,
       GAL_OPTIONS_NOT_MANDATORY,
-      GAL_OPTIONS_NOT_SET
+      GAL_OPTIONS_NOT_SET,
+      gal_options_print_citation
     },
     {
       "printparams",
@@ -255,13 +333,14 @@ struct argp_option gal_commonopts_options[] =
       GAL_OPTIONS_KEY_CONFIG,
       "STR",
       0,
-      "Read file STR before continuing.",
+      "Read configuration file STR immediately.",
       GAL_OPTIONS_GROUP_OPERATING_MODE,
       NULL,
       GAL_DATA_TYPE_STRING,
       GAL_OPTIONS_RANGE_ANY,
       GAL_OPTIONS_NOT_MANDATORY,
-      GAL_OPTIONS_NOT_SET
+      GAL_OPTIONS_NOT_SET,
+      gal_options_call_parse_config_file
     },
     {
       "setdirconf",
@@ -313,7 +392,8 @@ struct argp_option gal_commonopts_options[] =
       GAL_DATA_TYPE_STRING,
       GAL_OPTIONS_RANGE_0_OR_1,
       GAL_OPTIONS_NOT_MANDATORY,
-      GAL_OPTIONS_NOT_SET
+      GAL_OPTIONS_NOT_SET,
+      gal_options_check_version
     },
 
 
diff --git a/lib/gnuastro.conf b/lib/gnuastro.conf
index 9be17a9..ab2e5c6 100644
--- a/lib/gnuastro.conf
+++ b/lib/gnuastro.conf
@@ -22,6 +22,12 @@
  ignorecase     1
  searchin       name
 
+# Tessellation
+ tilesize       40,40
+ numchannels    1,1
+ remainderfrac  0.1
+ workoverch     0
+
 # Output:
  tableformat    fits-binary
 
diff --git a/lib/options.c b/lib/options.c
index 01d5393..a6e9ba8 100644
--- a/lib/options.c
+++ b/lib/options.c
@@ -48,25 +48,6 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
-/**********************************************************************/
-/************                Declarations               ***************/
-/**********************************************************************/
-/* Declaration of `option_parse_file' that is defined below, since it is
-   also needed in `options_immediate', but it fits into context below
-   better. */
-static void
-options_parse_file(char *filename,  struct gal_options_common_params *cp,
-                   int enoent_abort);
-
-
-
-
-
-
-
-
-
-
 
 
 
@@ -298,9 +279,121 @@ gal_options_parse_list_of_numbers(char *string, char 
*filename, size_t lineno)
 
 
 /**********************************************************************/
-/************     Parser functions for common options    ***************/
+/************     Parser functions for common options   ***************/
 /**********************************************************************/
 void *
+gal_options_check_version(struct argp_option *option, char *arg,
+                          char *filename, size_t lineno, void *junk)
+{
+  /* Check if the given value is different from this version. */
+  if( strcmp(arg, PACKAGE_VERSION) )
+    {
+      /* Print an error message and abort.  */
+      error_at_line(EXIT_FAILURE, 0, filename, lineno, "version mis-match: "
+                    "you are running GNU Astronomy Utilities (Gnuastro) "
+                    "version `%s'. However, the `onlyversion' option is set "
+                    "to version `%s'.\n\n"
+                    "This was probably done for reproducibility. Therefore, "
+                    "manually removing, or changing, the option value might "
+                    "produce errors or unexpected results. It is thus "
+                    "strongly advised to build Gnuastro %s and re-run this "
+                    "command/script.\n\n"
+                    "You can download previously released tar-balls from the "
+                    "following URLs respectively:\n\n"
+                    "    Stable (version format: X.Y):      "
+                    "http://ftpmirror.gnu.org/gnuastro\n";
+                    "    Alpha  (version format: X.Y.A-B):  "
+                    "http://alpha.gnu.org/gnu/gnuastro\n\n";
+                    "Alternatively, you can clone Gnuastro, checkout the "
+                    "respective commit (from the version number), then "
+                    "bootstrap and build it. Please run the following "
+                    "command for more information:\n\n"
+                    "    $ info gnuastro \"Version controlled source\"\n",
+                    PACKAGE_VERSION, arg, arg);
+
+      /* Just to avoid compiler warnings for unused variables. The program
+         will never reach this point! */
+      arg=filename=NULL; lineno=0; option=NULL; junk=NULL;
+    }
+  return NULL;
+}
+
+
+
+
+
+void *
+gal_options_print_citation(struct argp_option *option, char *arg,
+                           char *filename, size_t lineno, void *pa)
+{
+  struct gal_options_common_params *cp=(struct gal_options_common_params *)pa;
+  char *gnuastro_bibtex=
+    "Gnuastro package/infrastructure\n"
+    "-------------------------------\n"
+    "  @ARTICLE{2015ApJS..220....1A,\n"
+    "     author = {{Akhlaghi}, M. and {Ichikawa}, T.},\n"
+    "      title = \"{Noise-based Detection and Segmentation of Nebulous "
+    "Objects}\",\n"
+    "    journal = {\\apjs},\n"
+    "  archivePrefix = \"arXiv\",\n"
+    "     eprint = {1505.01664},\n"
+    "   primaryClass = \"astro-ph.IM\",\n"
+    "   keywords = {galaxies: irregular, galaxies: photometry, "
+    "galaxies: structure, methods: data analysis, "
+    "techniques: image processing, techniques: photometric},\n"
+    "       year = 2015,\n"
+    "      month = sep,\n"
+    "     volume = 220,\n"
+    "        eid = {1},\n"
+    "      pages = {1},\n"
+    "        doi = {10.1088/0067-0049/220/1/1},\n"
+    "     adsurl = {http://adsabs.harvard.edu/abs/2015ApJS..220....1A},\n";
+    "    adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n"
+    "  }";
+
+
+  /* Print the statements. */
+  printf("\nThank you for using %s (%s) %s.\n\n", cp->program_name,
+         PACKAGE_NAME, PACKAGE_VERSION);
+  printf("Citations are vital for the continued work on Gnuastro.\n\n"
+         "Please cite these BibTeX record(s) in your paper(s).\n"
+         "(don't forget to also include the version as shown above)\n\n"
+         "%s\n\n",
+         gnuastro_bibtex);
+
+
+  /* Only print the citation for the program if one exists. */
+  if(cp->program_bibtex[0]!='\0') printf("%s\n\n", cp->program_bibtex);
+
+
+  /* Print a thank you message. */
+  printf("                                               ,\n"
+         "                                              {|'--.\n"
+         "                                             {{\\    \\\n"
+         "      Many thanks from all                   |/`'--./=.\n"
+         "      Gnuastro developers!                   `\\.---' `\\\\\n"
+         "                                                  |\\  ||\n"
+         "                                                  | |//\n"
+         "                                                   \\//_/|\n"
+         "                                                   //\\__/\n"
+         "                                                  //\n"
+         "                   (http://www.chris.com/ascii/) |/\n");
+
+
+
+  /* Exit the program. */
+  exit(EXIT_SUCCESS);
+
+  /* Just to avoid compiler warnings for unused variables. The program
+     will never reach this point! */
+  arg=filename=NULL; lineno=0; option=NULL;
+}
+
+
+
+
+
+void *
 gal_options_read_type(struct argp_option *option, char *arg,
                       char *filename, size_t lineno, void *junk)
 {
@@ -423,7 +516,7 @@ gal_options_read_tableformat(struct argp_option *option, 
char *arg,
 #define PARSE_SIZES_STATICSTR_LEN 2000
 void *
 gal_options_parse_sizes_reverse(struct argp_option *option, char *arg,
-                                char *filename, size_t lineno, void *params)
+                                char *filename, size_t lineno, void *junk)
 {
   int i;
   double *v;
@@ -520,122 +613,6 @@ gal_options_parse_sizes_reverse(struct argp_option 
*option, char *arg,
 /**********************************************************************/
 /************              Option actions               ***************/
 /**********************************************************************/
-
-static void
-options_check_version(char *version_string)
-{
-  if( strcmp(version_string, PACKAGE_VERSION) )
-    error(EXIT_FAILURE, 0, "version mis-match: you are running GNU "
-          "Astronomy Utilities version %s, but this program was configured "
-          "to run with version %s (value to the `onlyversion' option, "
-          "either in a configuration file or on the command-line). This was "
-          "probably done for reproducibility. Therefore, removing, or "
-          "changing, the option value might produce errors or unexpected "
-          "results. It is hence strongly advised to build GNU Astronomy "
-          "Utilities version %s and re-run this command/script",
-          PACKAGE_VERSION, version_string, version_string);
-}
-
-
-
-
-
-static void
-options_print_citation_exit(struct gal_options_common_params *cp)
-{
-  char *gnuastro_bibtex=
-    "Gnuastro package/infrastructure\n"
-    "-------------------------------\n"
-    "  @ARTICLE{2015ApJS..220....1A,\n"
-    "     author = {{Akhlaghi}, M. and {Ichikawa}, T.},\n"
-    "      title = \"{Noise-based Detection and Segmentation of Nebulous "
-    "Objects}\",\n"
-    "    journal = {\\apjs},\n"
-    "  archivePrefix = \"arXiv\",\n"
-    "     eprint = {1505.01664},\n"
-    "   primaryClass = \"astro-ph.IM\",\n"
-    "   keywords = {galaxies: irregular, galaxies: photometry, "
-    "galaxies: structure, methods: data analysis, "
-    "techniques: image processing, techniques: photometric},\n"
-    "       year = 2015,\n"
-    "      month = sep,\n"
-    "     volume = 220,\n"
-    "        eid = {1},\n"
-    "      pages = {1},\n"
-    "        doi = {10.1088/0067-0049/220/1/1},\n"
-    "     adsurl = {http://adsabs.harvard.edu/abs/2015ApJS..220....1A},\n";
-    "    adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n"
-    "  }";
-
-
-  /* Print the statements. */
-  printf("\nThank you for using %s (%s) %s.\n\n", cp->program_name,
-         PACKAGE_NAME, PACKAGE_VERSION);
-  printf("Citations are vital for the continued work on Gnuastro.\n\n"
-         "Please cite these BibTeX record(s) in your paper(s).\n"
-         "(don't forget to also include the version as shown above)\n\n"
-         "%s\n\n",
-         gnuastro_bibtex);
-
-
-  /* Only print the citation for the program if one exists. */
-  if(cp->program_bibtex[0]!='\0') printf("%s\n\n", cp->program_bibtex);
-
-
-  /* Print a thank you message. */
-  printf("                                               ,\n"
-         "                                              {|'--.\n"
-         "                                             {{\\    \\\n"
-         "      Many thanks from all                   |/`'--./=.\n"
-         "      Gnuastro developers!                   `\\.---' `\\\\\n"
-         "                                                  |\\  ||\n"
-         "                                                  | |//\n"
-         "                                                   \\//_/|\n"
-         "                                                   //\\__/\n"
-         "                                                  //\n"
-         "                   (http://www.chris.com/ascii/) |/\n");
-
-
-
-  /* Exit the program. */
-  exit(EXIT_SUCCESS);
-}
-
-
-
-
-
-/* Some options need immediate attention/action before continuing to read
-   the rest of the options. In these cases we need to (maybe) check and
-   (possibly) abort immediately. */
-void
-options_immediate(int key, char *arg, struct gal_options_common_params *cp)
-{
-  switch(key)
-    {
-    /* We don't want later options that were set for the given version to
-       cause errors if this option was given. */
-    case GAL_OPTIONS_KEY_ONLYVERSION:
-      options_check_version(arg);
-      break;
-
-    /* This option is completely independent of anything and doesn't need
-       out attention later. */
-    case GAL_OPTIONS_KEY_CITE:
-      options_print_citation_exit(cp);
-      break;
-
-    /* Read the given configuration file. */
-    case GAL_OPTIONS_KEY_CONFIG:
-      options_parse_file(arg, cp, 1);
-      break;
-    }
-}
-
-
-
-
-
 /* The option value has been read and put into the `value' field of the
    `argp_option' structure. This function will use the `range' field to
    define a check and abort with an error if the value is not in the given
@@ -809,12 +786,29 @@ options_sanity_check(struct argp_option *option, char 
*arg,
 
 static void
 gal_options_read_check(struct argp_option *option, char *arg, char *filename,
-                       size_t lineno, void *program_struct)
+                       size_t lineno, struct gal_options_common_params *cp)
 {
-  /* If a function is defined to process the value, then use it. */
+  void *topass;
+
+  /* If a function is defined, leave everything to the function. */
   if(option->func)
     {
-      option->func(option, arg, filename, lineno, program_struct);
+      /* For the functions that are defined here (for all programs) and
+         need the last pointer, we must pass the `cp' pointer. For the
+         rest, we must pass the `cp->program_struct'. */
+      switch(option->key)
+        {
+        case GAL_OPTIONS_KEY_CITE:
+        case GAL_OPTIONS_KEY_CONFIG:
+          topass=cp;
+          break;
+        default:
+          topass=cp->program_struct;
+        }
+
+      /* Call the function to parse the value, flag the option as set and
+         return. */
+      option->func(option, arg, filename, lineno, topass);
       option->set=GAL_OPTIONS_SET;
       return;
     }
@@ -916,9 +910,6 @@ gal_options_set_from_key(int key, char *arg, struct 
argp_option *options,
       /* Check if the key corresponds to this option. */
       if( options[i].key==key )
         {
-          /* For options that need immediate attention. */
-          options_immediate(key, arg, cp);
-
           /* When options are read from keys (by this function), they are
              read from the command-line. On the commandline, the last
              invokation of the option is important. Especially in contexts
@@ -934,9 +925,7 @@ gal_options_set_from_key(int key, char *arg, struct 
argp_option *options,
             options[i].set=GAL_OPTIONS_NOT_SET;
 
           /* Parse the value. */
-          gal_options_read_check(&options[i], arg, NULL, 0,
-                                 cp->program_struct);
-
+          gal_options_read_check(&options[i], arg, NULL, 0, cp);
 
           /* We have found and set the value given to this option, so just
              return success (an error_t of 0 means success). */
@@ -1098,17 +1087,23 @@ options_set_from_name(char *name, char *arg,  struct 
argp_option *options,
       /* Check if the key corresponds to this option. */
       if( options[i].name && !strcmp(options[i].name, name) )
         {
-          /* If the option already has a value and it isn't a linked list,
-             or it is not relevant to this program, then ignore it. */
-          if( options[i].set && !gal_data_is_linked_list(options[i].type ) )
+          /* Ignore this option and its value. This can happen in several
+             situations:
+
+               - Not all common options are used by all programs. When a
+                 program doesn't use an option, it will be given an
+                 `OPTION_HIDDEN' flag. There is no point in reading the
+                 values of such options.
+
+               - When the option already has a value AND it ISN'T a linked
+                 list. */
+          if( options[i].flags==OPTION_HIDDEN
+              || ( options[i].set
+                   && !gal_data_is_linked_list(options[i].type ) ) )
             return 0;
 
-          /* For options that need immediate attention. */
-          options_immediate(options[i].key, arg, cp);
-
           /* Read the value into the option and do a sanity check. */
-          gal_options_read_check(&options[i], arg, filename, lineno,
-                                 cp->program_struct);
+          gal_options_read_check(&options[i], arg, filename, lineno, cp);
 
           /* We have found and set the value given to this option, so just
              return success (an error_t of 0 means success). */
@@ -1116,7 +1111,9 @@ options_set_from_name(char *name, char *arg,  struct 
argp_option *options,
         }
       else
         {
-          /* The last option has all its values set to zero. */
+          /* The last option has all its values set to zero. If we get to
+             this point then the given name was not recognized and this
+             function will return a 1. */
           if(gal_options_is_last(&options[i]))
             return 1;
         }
@@ -1224,6 +1221,23 @@ options_parse_file(char *filename,  struct 
gal_options_common_params *cp,
 
 
 
+/* This function will be used when the `--config' option is called. */
+void *
+gal_options_call_parse_config_file(struct argp_option *option, char *arg,
+                                   char *filename, size_t lineno, void *cp)
+{
+  /* Call the confguration file parser. */
+  options_parse_file(arg, cp, 1);
+
+  /* Just to avoid compiler warnings, then return, note that all pointers
+     are just copies. */
+  option=NULL; filename=NULL; lineno=0;
+  return NULL;
+}
+
+
+
+
 
 /* Read the configuration files and put the values of the options not given
    into it. The directories containing the configuration files are fixed
diff --git a/lib/options.h b/lib/options.h
index 1685052..448a495 100644
--- a/lib/options.h
+++ b/lib/options.h
@@ -58,6 +58,7 @@ enum options_standard_groups
 {
   GAL_OPTIONS_GROUP_OPERATING_MODE = -1,
   GAL_OPTIONS_GROUP_INPUT=1,
+  GAL_OPTIONS_GROUP_TESSELLATION,
   GAL_OPTIONS_GROUP_OUTPUT,
 
   GAL_OPTIONS_GROUP_AFTER_COMMON,
@@ -73,22 +74,25 @@ enum options_standard_groups
    is also removed from this list.
 
    a b c d e f g i j k l m n p r s t u v w x y z
-   A B C E F G H J L M O Q R W X Y Z
+   A B C E G H J L O Q R W X Y
 */
 enum options_common_keys
 {
   /* With short-option version */
-  GAL_OPTIONS_KEY_HDU          = 'h',
-  GAL_OPTIONS_KEY_OUTPUT       = 'o',
-  GAL_OPTIONS_KEY_TYPE         = 'T',
-  GAL_OPTIONS_KEY_DONTDELETE   = 'D',
-  GAL_OPTIONS_KEY_KEEPINPUTDIR = 'K',
-  GAL_OPTIONS_KEY_QUIET        = 'q',
-  GAL_OPTIONS_KEY_NUMTHREADS   = 'N',
-  GAL_OPTIONS_KEY_PRINTPARAMS  = 'P',
-  GAL_OPTIONS_KEY_SETDIRCONF   = 'S',
-  GAL_OPTIONS_KEY_SETUSRCONF   = 'U',
-  GAL_OPTIONS_KEY_IGNORECASE   = 'I',
+  GAL_OPTIONS_KEY_HDU           = 'h',
+  GAL_OPTIONS_KEY_OUTPUT        = 'o',
+  GAL_OPTIONS_KEY_TYPE          = 'T',
+  GAL_OPTIONS_KEY_DONTDELETE    = 'D',
+  GAL_OPTIONS_KEY_KEEPINPUTDIR  = 'K',
+  GAL_OPTIONS_KEY_QUIET         = 'q',
+  GAL_OPTIONS_KEY_NUMTHREADS    = 'N',
+  GAL_OPTIONS_KEY_PRINTPARAMS   = 'P',
+  GAL_OPTIONS_KEY_SETDIRCONF    = 'S',
+  GAL_OPTIONS_KEY_SETUSRCONF    = 'U',
+  GAL_OPTIONS_KEY_IGNORECASE    = 'I',
+  GAL_OPTIONS_KEY_TILESIZE      = 'Z',
+  GAL_OPTIONS_KEY_NUMCHANNELS   = 'M',
+  GAL_OPTIONS_KEY_REMAINDERFRAC = 'F',
 
   /* Only long option (integers for keywords). */
   GAL_OPTIONS_KEY_MINMAPSIZE   = 500,
@@ -99,6 +103,8 @@ enum options_common_keys
   GAL_OPTIONS_KEY_LASTCONFIG,
   GAL_OPTIONS_KEY_TABLEFORMAT,
   GAL_OPTIONS_KEY_ONLYVERSION,
+  GAL_OPTIONS_KEY_WORKOVERCH,
+  GAL_OPTIONS_KEY_CHECKTILES,
 };
 
 
@@ -153,41 +159,49 @@ enum gal_options_set_values
 struct gal_options_common_params
 {
   /* Input. */
-  char                    *hdu; /* Image extension.                      */
-  uint8_t             searchin; /* Column meta-data to match/search.     */
-  uint8_t           ignorecase; /* Ignore case when matching col info.   */
+  char                    *hdu; /* Image extension.                       */
+  uint8_t             searchin; /* Column meta-data to match/search.      */
+  uint8_t           ignorecase; /* Ignore case when matching col info.    */
+
+  /* Tessellation. */
+  size_t             *tilesize; /* Tile size along each dim. (C order).   */
+  size_t          *numchannels; /* Channel no. along each dim. (C order). */
+  float          remainderfrac; /* Frac. of remainers in each dim to cut. */
+  uint8_t           workoverch; /* Convolve over channel borders.         */
+  uint8_t           checktiles; /* Tile IDs in an img, the size of input. */
 
   /* Output. */
-  char                 *output; /* Directory containg output.            */
-  uint8_t                 type; /* Data type of output.                  */
-  uint8_t           dontdelete; /* ==1: Don't delete existing file.      */
-  uint8_t         keepinputdir; /* Keep input directory for auto output. */
-  uint8_t          tableformat; /* Internal code for output table format.*/
+  char                 *output; /* Directory containg output.             */
+  uint8_t                 type; /* Data type of output.                   */
+  uint8_t           dontdelete; /* ==1: Don't delete existing file.       */
+  uint8_t         keepinputdir; /* Keep input directory for auto output.  */
+  uint8_t          tableformat; /* Internal code for output table format. */
 
   /* Operating modes. */
-  uint8_t                quiet; /* Only print errors.                    */
-  size_t            numthreads; /* Number of threads to use.             */
-  size_t            minmapsize; /* Minimum bytes necessary to use mmap.  */
-  uint8_t                  log; /* Make a log file.                      */
+  uint8_t                quiet; /* Only print errors.                     */
+  size_t            numthreads; /* Number of threads to use.              */
+  size_t            minmapsize; /* Minimum bytes necessary to use mmap.   */
+  uint8_t                  log; /* Make a log file.                       */
 
   /* Configuration files. */
-  uint8_t          printparams; /* To print the full list of parameters. */
-  uint8_t           setdirconf; /* To write the directory config file.   */
-  uint8_t           setusrconf; /* To write teh user config config file. */
-  uint8_t           lastconfig; /* This is the last configuration file.  */
+  uint8_t          printparams; /* To print the full list of parameters.  */
+  uint8_t           setdirconf; /* To write the directory config file.    */
+  uint8_t           setusrconf; /* To write teh user config config file.  */
+  uint8_t           lastconfig; /* This is the last configuration file.   */
 
   /* For internal (to option processing) purposes. */
-  uint8_t                 keep; /* Output file can exist.                */
-  void         *program_struct; /* Host program's main variable struct.  */
-  char           *program_name; /* Official name to be used in text.     */
-  char           *program_exec; /* Program's executable name.            */
-  char         *program_bibtex; /* BibTeX record for this program.       */
-  char        *program_authors; /* List of the program authors.          */
-  struct argp_option *coptions; /* Common options to all programs.       */
-  struct argp_option *poptions; /* Program specific options.             */
-  struct gal_linkedlist_ill   *mand_common; /* Common mandatory options. */
-  struct gal_linkedlist_stll  *novalue_doc; /* Mandatory opts, no value  */
-  struct gal_linkedlist_stll *novalue_name; /* Mandatory opts, no value  */
+  uint8_t                 keep; /* Output file can exist.                 */
+  size_t          *channelsize; /* Size of channels along each dimension. */
+  void         *program_struct; /* Host program's main variable struct.   */
+  char           *program_name; /* Official name to be used in text.      */
+  char           *program_exec; /* Program's executable name.             */
+  char         *program_bibtex; /* BibTeX record for this program.        */
+  char        *program_authors; /* List of the program authors.           */
+  struct argp_option *coptions; /* Common options to all programs.        */
+  struct argp_option *poptions; /* Program specific options.              */
+  struct gal_linkedlist_ill   *mand_common; /* Common mandatory options.  */
+  struct gal_linkedlist_stll  *novalue_doc; /* Mandatory opts, no value   */
+  struct gal_linkedlist_stll *novalue_name; /* Mandatory opts, no value   */
 };
 
 
@@ -218,9 +232,17 @@ gal_options_parse_list_of_numbers(char *string, char 
*filename,
 
 
 /**********************************************************************/
-/************                Convert values             ***************/
+/************     Parser functions for common options   ***************/
 /**********************************************************************/
 void *
+gal_options_check_version(struct argp_option *option, char *arg,
+                          char *filename, size_t lineno, void *junk);
+
+void *
+gal_options_print_citation(struct argp_option *option, char *arg,
+                           char *filename, size_t lineno, void *pa);
+
+void *
 gal_options_read_type(struct argp_option *option, char *arg,
                       char *filename, size_t lineno, void *junk);
 
@@ -255,6 +277,10 @@ gal_options_common_argp_parse(int key, char *arg, struct 
argp_state *state);
 /**********************************************************************/
 /************            Configuration files            ***************/
 /**********************************************************************/
+void *
+gal_options_call_parse_config_file(struct argp_option *option, char *arg,
+                                   char *filename, size_t lineno, void *cp);
+
 void
 gal_options_read_config_set(struct gal_options_common_params *cp);
 



reply via email to

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