gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master c1dba50 070/125: Column I/O options are now co


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master c1dba50 070/125: Column I/O options are now common options
Date: Sun, 23 Apr 2017 22:36:40 -0400 (EDT)

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

    Column I/O options are now common options
    
    Thanks to the new `table.h' library, many programs will be able to benefit
    from the great new features (for example selecting columns by name
    match/search). So the three options related to column input/output have
    been moved to the common options for all Gnuastro's programs and the book
    was also updated to include this update.
    
    But not all three are necessary for all programs, so when they aren't
    necessary, Argp's `OPTION_HIDDEN' flag will be used to remove it from the
    `--help' output and also to avoid printing it in with the `--printparams'
    option.
    
    Various other changes in this commit:
    
     - Since MakeProfiles can now also accept FITS tables as input, the
       filename alone wasn't sufficient to separate the background image from
       the table. So a new `--background' option has been added to MakeProfiles
       and the only acceptable argument is the table.
    
     - The `Input', `Output' and `Operating mode' group headers have been moved
       to the common options, so they aren't repeated in each program and
       possibly cause bugs.
    
     - We are now parsing the `argp_option' arrays in `ui_initialize_options'
       before passing them to `argp_parse', so there was no more need for the
       `NOT_COMMON_HDU_PARSER' (until now, only used in Arithmetic) to define
       an alternative `argp_option'. We now change any values that must be
       changed from the defaults in `ui_initialize_options'.
    
     - Some further checks were added to MakeProfiles (like the previous
       commits, this commit was also part of the process of porting the new
       option management system in MakeProfiles, but slowly got too large and
       so it deserves its own commit before finishing that process).
    
     - The old `--tabletype' option is now called `--tableformat' to avoid
       confusion with data type.
    
     - Until now, only program specific options had linked lists (options that
       can be called multiple times). But with the usage of the `--hdu' option
       multiple times by Arithmetic, the common options also take linked lists,
       so to make the maximum length calculation (when printing the option
       values) more clear, a new `options_correct_max_lengths' was defined.
---
 bin/arithmetic/args.h             |  38 -----
 bin/arithmetic/astarithmetic.conf |   2 +-
 bin/arithmetic/ui.c               |  60 ++++----
 bin/mkprof/args.h                 |  35 +++--
 bin/mkprof/astmkprof.conf         |   6 +-
 bin/mkprof/main.h                 |   1 -
 bin/mkprof/ui.c                   |  71 +++++++++-
 bin/table/args.h                  |  57 --------
 bin/table/asttable.conf           |   2 +-
 bin/table/main.h                  |   5 -
 bin/table/table.c                 |   2 +-
 bin/table/ui.c                    |  39 +++---
 doc/gnuastro.texi                 | 282 +++++++++++++++++++++++++-------------
 lib/commonopts.h                  |  73 ++++++++--
 lib/fits.c                        |  22 +--
 lib/gnuastro/table.h              |  27 ++--
 lib/options.c                     | 153 +++++++++++++--------
 lib/options.h                     |  24 +++-
 lib/table.c                       | 127 ++++++++---------
 lib/txt.c                         |   2 +-
 tests/table/txt-to-fits-ascii.sh  |   2 +-
 tests/table/txt-to-fits-binary.sh |   2 +-
 22 files changed, 592 insertions(+), 440 deletions(-)

diff --git a/bin/arithmetic/args.h b/bin/arithmetic/args.h
index 041d93a..f6f73a8 100644
--- a/bin/arithmetic/args.h
+++ b/bin/arithmetic/args.h
@@ -28,44 +28,6 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Definition of program-specific options. */
 struct argp_option program_options[] =
   {
-    {
-      0, 0, 0, 0,
-      "Input:",
-      GAL_OPTIONS_GROUP_INPUT
-    },
-    {
-      "hdu",
-      ARGS_OPTION_KEY_HDU,
-      "STR",
-      0,
-      "Nth call of this option, used for Nth input FITS.",
-      GAL_OPTIONS_GROUP_INPUT,
-      &p->hdus,
-      GAL_DATA_TYPE_STRLL,
-      GAL_OPTIONS_RANGE_ANY,
-      GAL_OPTIONS_NOT_MANDATORY,
-      GAL_OPTIONS_NOT_SET
-    },
-
-
-
-
-    {
-      0, 0, 0, 0,
-      "Output:",
-      GAL_OPTIONS_GROUP_OUTPUT,
-    },
-
-
-
-
-    {
-      0, 0, 0, 0,
-      "Operating modes:",
-      GAL_OPTIONS_GROUP_OPERATING_MODE
-    },
-
-
     {0}
   };
 
diff --git a/bin/arithmetic/astarithmetic.conf 
b/bin/arithmetic/astarithmetic.conf
index ff8224f..f9db547 100644
--- a/bin/arithmetic/astarithmetic.conf
+++ b/bin/arithmetic/astarithmetic.conf
@@ -27,4 +27,4 @@
  hdu            0
 
 # Output:
- minmapsize    1000000000
\ No newline at end of file
+ minmapsize    1000000000
diff --git a/bin/arithmetic/ui.c b/bin/arithmetic/ui.c
index afadb03..65e8246 100644
--- a/bin/arithmetic/ui.c
+++ b/bin/arithmetic/ui.c
@@ -87,23 +87,6 @@ doc[] = GAL_STRINGS_TOP_HELP_INFO PROGRAM_NAME" will do 
arithmetic "
 
 
 
-/* Available letters for short options:
-
-   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 I J L M O Q R T U W X Y Z                */
-enum option_keys_enum
-{
-  /* With short-option version. */
-  ARGS_OPTION_KEY_HDU        = 'h',
-
-  /* Only with long version (start with a value 1000, the rest will be set
-     automatically). */
-};
-
-
-
-
-
 
 
 
@@ -127,6 +110,7 @@ ui_initialize_options(struct imgarithparams *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. */
@@ -136,6 +120,27 @@ ui_initialize_options(struct imgarithparams *p,
   cp->program_bibtex     = PROGRAM_BIBTEX;
   cp->program_authors    = PROGRAM_AUTHORS;
   cp->coptions           = gal_commonopts_options;
+
+  /* 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].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_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;
+      }
 }
 
 
@@ -203,17 +208,6 @@ parse_opt(int key, char *arg, struct argp_state *state)
 /**************************************************************/
 /***************       Sanity Check         *******************/
 /**************************************************************/
-/* Read and check ONLY the options. When arguments are involved, do the
-   check in `ui_check_options_and_arguments'. */
-static void
-ui_read_check_only_options(struct imgarithparams *p)
-{
-
-}
-
-
-
-
 
 /* Sanity check on options AND arguments. If only option values are to be
    checked, use `ui_read_check_only_options'. */
@@ -307,8 +301,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
imgarithparams *p)
      and for the common options to all Gnuastro (`commonopts.h'). We want
      to directly put the pointers to the fields in `p' and `cp', so we are
      simply including the header here to not have to use long macros in
-     those headers which make them hard to read. */
-#define NOT_COMMON_HDU_PARSER 1
+     those headers which make them hard to read and modify. This also helps
+     in having a clean environment: everything in those headers is only
+     available within the scope of this function. */
 #include <commonopts.h>
 #include "args.h"
 
@@ -336,11 +331,6 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
imgarithparams *p)
   gal_options_read_config_set(cp);
 
 
-  /* Read the options into the program's structure, and check them and
-     their relations prior to printing. */
-  ui_read_check_only_options(p);
-
-
   /* Print the option values if asked. Note that this needs to be done
      after the sanity check so un-sane values are not printed in the output
      state. */
diff --git a/bin/mkprof/args.h b/bin/mkprof/args.h
index cd7bb62..8d5bbbd 100644
--- a/bin/mkprof/args.h
+++ b/bin/mkprof/args.h
@@ -31,19 +31,17 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 struct argp_option program_options[] =
   {
     {
-      0, 0, 0, 0,
-      "Operating modes:",
-      -1
-    },
-
-
-
-
-
-    {
-      0, 0, 0, 0,
-      "Input:",
-      GAL_OPTIONS_GROUP_INPUT
+      "background",
+      ARGS_OPTION_KEY_BACKGROUND,
+      "STR",
+      0,
+      "A background image to make the profiles on.",
+      GAL_OPTIONS_GROUP_INPUT,
+      &p->backname,
+      GAL_DATA_TYPE_STRING,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET
     },
     {
       "backhdu",
@@ -61,11 +59,8 @@ struct argp_option program_options[] =
 
 
 
-    {
-      0, 0, 0, 0,
-      "Output:",
-      GAL_OPTIONS_GROUP_OUTPUT
-    },
+
+
     {
       "naxis1",
       ARGS_OPTION_KEY_NAXIS1,
@@ -330,7 +325,7 @@ struct argp_option program_options[] =
 
     {
       0, 0, 0, 0,
-      "Catalog (column name or number, starting from 1):",
+      "Columns by info (see `--searchin') or number (starting from 1):",
       ARGS_GROUP_CATALOG
     },
     {
@@ -567,6 +562,8 @@ struct argp_option program_options[] =
     },
 
 
+
+
     {0}
   };
 
diff --git a/bin/mkprof/astmkprof.conf b/bin/mkprof/astmkprof.conf
index 04b0050..66cb031 100644
--- a/bin/mkprof/astmkprof.conf
+++ b/bin/mkprof/astmkprof.conf
@@ -17,6 +17,11 @@
 # notice and this notice are preserved.  This file is offered as-is,
 # without any warranty.
 
+#input
+ hdu                   0
+ backhdu               0
+ searchin           name
+
 # Output:
  naxis1             1000
  naxis2             1000
@@ -52,5 +57,4 @@
  resolution         0.03
 
 # Common options
- hdu                   0
  minmapsize    100000000
diff --git a/bin/mkprof/main.h b/bin/mkprof/main.h
index e14eae8..3a8ca74 100644
--- a/bin/mkprof/main.h
+++ b/bin/mkprof/main.h
@@ -164,7 +164,6 @@ struct mkprofparams
   char           *wcsheader;  /* The WCS header information for main img. */
   int            wcsnkeyrec;  /* The number of keywords in the WCS header.*/
   char       *mergedimgname;  /* Name of merged image.                    */
-  struct gal_linkedlist_stll *allargs; /* Keep all input arguments.       */
 };
 
 #endif
diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index 46675fd..690abba 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -90,11 +90,12 @@ enum program_args_groups
 
    Available letters (-V which is used by GNU is also removed):
 
-   a d f g j k l u v
+   a d f g j l u v
    A E G H I J L M O Q U W Z     */
 enum option_keys_enum
 {
   /* With short-option version. */
+  ARGS_OPTION_KEY_BACKGROUND      = 'k',
   ARGS_OPTION_KEY_BACKHDU         = 'B',
   ARGS_OPTION_KEY_NAXIS1          = 'x',
   ARGS_OPTION_KEY_NAXIS2          = 'y',
@@ -175,10 +176,22 @@ ui_initialize_options(struct mkprofparams *p,
   cp->coptions           = gal_commonopts_options;
 
 
-  /* Set the mandatory common options. */
+  /* 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;
@@ -229,7 +242,7 @@ parse_opt(int key, char *arg, struct argp_state *state)
 
     /* Read the non-option tokens (arguments): */
     case ARGP_KEY_ARG:
-      gal_linkedlist_add_to_stll(&p->allargs, arg, 0);
+      p->catname=arg;
       break;
 
 
@@ -272,6 +285,24 @@ ui_read_check_only_options(struct mkprofparams *p)
   if( p->type==GAL_DATA_TYPE_INVALID && p->nomerged==0)
     error(EXIT_FAILURE, 0, "an output type `--type' is necessary when a "
           "merged image is to be built.");
+
+  /* Check if one of the coordinate columns has been given, the other is
+     also given. To simplify the job, we use the fact that conditions in C
+     return either a 0 (when failed) and 1 (when successful). Note that if
+     neighter coordinates are specified there is no problem, the user might
+     have input the other coordinate standard. We'll also check for that
+     after this.*/
+  if( ((p->xcol==NULL) + (p->ycol==NULL)) == 1 )
+    error(EXIT_FAILURE, 0, "only `%s' has been given, please also specify "
+          "a column for the position along the %s axis with the `%s' option",
+          p->xcol?"xcol":"ycol", p->xcol?"Y":"X", p->xcol?"ycol":"xcol");
+
+  if( ((p->racol==NULL) + (p->deccol==NULL)) == 1 )
+    error(EXIT_FAILURE, 0, "only `%s' has been given, please also specify "
+          "a column for the position along the %s axis with the `%s' option",
+          p->racol?"racol":"deccol", p->racol?"Dec":"RA",
+          p->xcol?"deccol":"racol");
+
 }
 
 
@@ -283,7 +314,20 @@ ui_read_check_only_options(struct mkprofparams *p)
 static void
 ui_check_options_and_arguments(struct mkprofparams *p)
 {
-
+  /* Make sure an input table is given, and if it is FITS, that the HDU is
+     also provided. */
+  if(p->catname)
+    {
+      if( gal_fits_name_is_fits(p->catname) && p->cp.hdu==NULL)
+        error(EXIT_FAILURE, 0, "no `hdu' specified for the input FITS table "
+              "'%s', to ", p->catname);
+    }
+  else
+    {
+      error(EXIT_FAILURE, 0, "no input catalog provided. To build profiles, "
+            "you need to give a catalog/table containing the information of "
+            "the profiles");
+    }
 }
 
 
@@ -311,7 +355,20 @@ ui_check_options_and_arguments(struct mkprofparams *p)
 static void
 ui_preparations(struct mkprofparams *p)
 {
-
+  struct gal_linkedlist_stll *cols=NULL;
+  char *ax1col=p->racol?p->racol:p->xcol;
+  char *ax2col=p->deccol?p->deccol:p->ycol;
+
+  /* Correct/set based on the given oversampling. */
+  p->naxes[0] *= p->oversample;
+  p->naxes[1] *= p->oversample;
+  p->halfpixel = 0.5f/p->oversample;
+
+  /* Read the columns.
+  gal_linkedlist_add_to_stll(cols, ax1col, 0);
+  gal_table_read(char *filename, char *hdu, struct gal_linkedlist_stll *cols,
+                 int searchin, int ignorecase, int minmapsize);
+  */
 }
 
 
@@ -346,7 +403,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
mkprofparams *p)
      and for the common options to all Gnuastro (`commonopts.h'). We want
      to directly put the pointers to the fields in `p' and `cp', so we are
      simply including the header here to not have to use long macros in
-     those headers which make them hard to read. */
+     those headers which make them hard to read and modify. This also helps
+     in having a clean environment: everything in those headers is only
+     available within the scope of this function. */
 #include <commonopts.h>
 #include "args.h"
 
diff --git a/bin/table/args.h b/bin/table/args.h
index 70fe0e0..a98750a 100644
--- a/bin/table/args.h
+++ b/bin/table/args.h
@@ -32,11 +32,6 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 struct argp_option program_options[] =
   {
     {
-      0, 0, 0, 0,
-      "Input:",
-      GAL_OPTIONS_GROUP_INPUT
-    },
-    {
       "column",
       ARGS_OPTION_KEY_COLUMN,
       "STR",
@@ -49,64 +44,12 @@ struct argp_option program_options[] =
       GAL_OPTIONS_NOT_MANDATORY,
       GAL_OPTIONS_NOT_SET
     },
-    {
-      "searchin",
-      ARGS_OPTION_KEY_SEARCHIN,
-      "STR",
-      0,
-      "Search in column `name', `units', or `comments'.",
-      GAL_OPTIONS_GROUP_INPUT,
-      &p->searchinstr,
-      GAL_DATA_TYPE_STRING,
-      GAL_OPTIONS_RANGE_ANY,
-      GAL_OPTIONS_MANDATORY,
-      GAL_OPTIONS_NOT_SET
-    },
-    {
-      "ignorecase",
-      ARGS_OPTION_KEY_IGNORECASE,
-      0,
-      0,
-      "Ignore case when matching column information.",
-      GAL_OPTIONS_GROUP_INPUT,
-      &p->ignorecase,
-      GAL_OPTIONS_NO_ARG_TYPE,
-      GAL_OPTIONS_RANGE_0_OR_1,
-      GAL_OPTIONS_NOT_MANDATORY,
-      GAL_OPTIONS_NOT_SET
-    },
-
-
 
 
-    {
-      0, 0, 0, 0,
-      "Output:",
-      2
-    },
-    {
-      "tabletype",
-      ARGS_OPTION_KEY_TABLETYPE,
-      "STR",
-      0,
-      "Output table type: `fits-ascii', `fits-binary'.",
-      GAL_OPTIONS_GROUP_OUTPUT,
-      &p->tabletypestr,
-      GAL_DATA_TYPE_STRING,
-      GAL_OPTIONS_RANGE_ANY,
-      GAL_OPTIONS_NOT_MANDATORY,
-      GAL_OPTIONS_NOT_SET
-    },
-
 
 
 
     {
-      0, 0, 0, 0,
-      "Operating modes:",
-      GAL_OPTIONS_GROUP_OPERATING_MODE
-    },
-    {
       "information",
       ARGS_OPTION_KEY_INFORMATION,
       0,
diff --git a/bin/table/asttable.conf b/bin/table/asttable.conf
index 5ae10ad..5c44c8a 100644
--- a/bin/table/asttable.conf
+++ b/bin/table/asttable.conf
@@ -23,7 +23,7 @@
  ignorecase       0
 
 # Output:
- tabletype        fits-binary
+ tableformat      fits-binary
 
 # Common options
  minmapsize       1000000000
\ No newline at end of file
diff --git a/bin/table/main.h b/bin/table/main.h
index 5fbab85..df9d193 100644
--- a/bin/table/main.h
+++ b/bin/table/main.h
@@ -46,14 +46,9 @@ struct tableparams
   struct gal_options_common_params cp; /* Common parameters.            */
   char              *filename;  /* Input filename.                      */
   struct gal_linkedlist_stll *columns; /* List of given columns.        */
-  char           *searchinstr;  /* Value to the `searchin' option.      */
-  unsigned char    ignorecase;  /* Ignore case matching column names.   */
-  char          *tabletypestr;  /* The type of the table as a string.   */
   unsigned char   information;  /* ==1, only print FITS information.    */
 
   /* Output: */
-  unsigned char      searchin;  /* Where to search in column info.      */
-  int               tabletype;  /* Type of output table (FITS, txt).    */
   gal_data_t           *table;  /* Linked list of output table columns. */
   gal_data_t      *allcolinfo;  /* Information of all the columns.      */
   time_t              rawtime;  /* Starting time of the program.        */
diff --git a/bin/table/table.c b/bin/table/table.c
index bae4f1e..17fbba6 100644
--- a/bin/table/table.c
+++ b/bin/table/table.c
@@ -44,6 +44,6 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 void
 table(struct tableparams *p)
 {
-  gal_table_write(p->table, NULL, p->tabletype, p->cp.output,
+  gal_table_write(p->table, NULL, p->cp.tableformat, p->cp.output,
                   p->cp.dontdelete);
 }
diff --git a/bin/table/ui.c b/bin/table/ui.c
index 6a9ab11..b96b6b9 100644
--- a/bin/table/ui.c
+++ b/bin/table/ui.c
@@ -80,15 +80,12 @@ doc[] = GAL_STRINGS_TOP_HELP_INFO PROGRAM_NAME" can be used 
to view the "
 
 /* Available letters for short options:
 
-   a b d e f g j k l m n p r u v w x y z
+   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  */
 enum option_keys_enum
 {
   /* With short-option version. */
   ARGS_OPTION_KEY_COLUMN      = 'c',
-  ARGS_OPTION_KEY_SEARCHIN    = 's',
-  ARGS_OPTION_KEY_IGNORECASE  = 'I',
-  ARGS_OPTION_KEY_TABLETYPE   = 't',
   ARGS_OPTION_KEY_INFORMATION = 'i',
 
   /* Only with long version (start with a value 1000, the rest will be set
@@ -138,7 +135,9 @@ ui_initialize_options(struct tableparams *p,
   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;
       }
@@ -218,14 +217,9 @@ static void
 ui_read_check_only_options(struct tableparams *p)
 {
 
-  /* Read the searchin and table type strings as internal codes. */
-  p->searchin=gal_table_string_to_searchin(p->searchinstr);
-  p->tabletype=gal_table_string_to_type(p->tabletypestr);
-
-
-  /* Check if the type of the output table is valid, given the type of the
-     output. */
-  gal_table_check_fits_type(p->cp.output, p->tabletype);
+  /* Check if the format of the output table is valid, given the type of
+     the output. */
+  gal_table_check_fits_format(p->cp.output, p->cp.tableformat);
 
 }
 
@@ -277,17 +271,18 @@ void
 ui_preparations(struct tableparams *p)
 {
   char *numstr;
-  int tabletype;
+  int tableformat;
   gal_data_t *allcols;
   size_t i, numcols, numrows;
+  struct gal_options_common_params *cp=&p->cp;
 
   /* If there were no columns specified, we want the full set of
      columns. */
   if(p->columns==NULL)
     {
       /* Read the table information for the number of columns and rows. */
-      allcols=gal_table_info(p->filename, p->cp.hdu, &numcols,
-                             &numrows, &tabletype);
+      allcols=gal_table_info(p->filename, cp->hdu, &numcols,
+                             &numrows, &tableformat);
 
       /* If there was no actual data in the file, then inform the user */
       if(allcols==NULL)
@@ -301,7 +296,7 @@ ui_preparations(struct tableparams *p)
           printf("--------\n");
           printf("%s", p->filename);
           if(gal_fits_name_is_fits(p->filename))
-            printf(" (hdu: %s)\n", p->cp.hdu);
+            printf(" (hdu: %s)\n", cp->hdu);
           else
             printf("\n");
 
@@ -338,8 +333,8 @@ ui_preparations(struct tableparams *p)
      elements were added to the list is the reverse of the order that they
      will be popped). */
   gal_linkedlist_reverse_stll(&p->columns);
-  p->table=gal_table_read(p->filename, p->cp.hdu, p->columns,
-                          p->searchin, p->ignorecase, p->cp.minmapsize);
+  p->table=gal_table_read(p->filename, cp->hdu, p->columns, cp->searchin,
+                          cp->ignorecase, cp->minmapsize);
 
   /* If there was no actual data in the file, then inform the user and
      abort. */
@@ -384,7 +379,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
tableparams *p)
      and for the common options to all Gnuastro (`commonopts.h'). We want
      to directly put the pointers to the fields in `p' and `cp', so we are
      simply including the header here to not have to use long macros in
-     those headers which make them hard to read. */
+     those headers which make them hard to read and modify. This also helps
+     in having a clean environment: everything in those headers is only
+     available within the scope of this function. */
 #include <commonopts.h>
 #include "args.h"
 
@@ -452,7 +449,7 @@ freeandreport(struct tableparams *p)
   /* Free the allocated arrays: */
   free(p->cp.hdu);
   free(p->cp.output);
-  free(p->searchinstr);
-  free(p->tabletypestr);
+  free(p->cp.searchinstr);
+  free(p->cp.tableformatstr);
   gal_data_free_ll(p->table);
 }
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 01572b0..f226da1 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -281,7 +281,7 @@ Common program behavior
 * Configuration files::         Values for unspecified variables.
 * Threads in Gnuastro::         How threads are managed in Gnuastro.
 * Automatic output::            About automatic output names.
-* Table formats::               Recognized table formats.
+* Tables in Gnuastro::          Recognized table formats.
 * Getting help::                Getting more information on the go.
 * Output headers::              Common headers to all FITS outputs.
 
@@ -312,7 +312,13 @@ Threads in Gnuastro
 * A note on threads::           Caution and suggestion on using threads.
 * How to run simultaneous operations::  How to run things simultaneously.
 
-Table formats
+Tables in Gnuastro
+
+* Recognized table formats::    Table formats that are recognized in Gnuastro.
+* Gnuastro text table format::  Gnuastro's convention plain text tables.
+* Selecting table columns::     Identify/select certain columns from a table
+
+Recognized table formats
 
 * Gnuastro text table format::  Reading plain text tables
 
@@ -3969,7 +3975,7 @@ command-line.
 * Configuration files::         Values for unspecified variables.
 * Threads in Gnuastro::         How threads are managed in Gnuastro.
 * Automatic output::            About automatic output names.
-* Table formats::               Recognized table formats.
+* Tables in Gnuastro::          Recognized table formats.
 * Getting help::                Getting more information on the go.
 * Output headers::              Common headers to all FITS outputs.
 @end menu
@@ -4093,7 +4099,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{Table formats}). In some cases, a program
+file (usually catalogs, see @ref{Tables in Gnuastro}). In some cases, a program
 can accept specific formats, for example @ref{ConvertType} also accepts
 @file{.jpg} images.
 
@@ -4328,6 +4334,20 @@ and the result is put in square brackets and appended to 
the FITS file name
 before calling CFITSIO to read the contents of the HDU for all the programs
 in Gnuastro.
 
address@hidden -s STR
address@hidden --searchin=STR
+Where to match/search for columns when the column identifier wasn't a
+number, see @ref{Selecting table columns}. The acceptable values are
address@hidden, @command{unit}, or @command{comment}. This option is only
+relevant for programs that take table columns as input.
+
address@hidden -I
address@hidden --ignorecase
+Ignore case while matching/searching column meta-data (in the field
+specified by the @option{--searchin}). The FITS standard suggests to treat
+the column names as case insensitive, which is strongly recommended here
+also but is not enforced. This option is only relevant for programs that
+take table columns as input.
 
 @item -o STR
 @itemx --output=STR
@@ -4353,6 +4373,29 @@ be in the same directory as the input (usually with a 
suffix added). Note
 that his is only relevant if you are running the program in a different
 directory than the input data.
 
address@hidden -t STR
address@hidden --tableformat=STR
+The output table's type. This option is only relevant when the output is a
+table and its format cannot be deduced from its filename. For example, if a
+name ending in @file{.fits} was given to @option{--output}, then the
+program knows you want a FITS table. But there are two types of FITS
+tables: FITS ASCII, and FITS binary. Thus, with this option, the program is
+able to identify which type you want. The currently recognized values to
+this option are:
+
address@hidden @command
address@hidden txt
+A plain text table with white-space characters between the columns (see
address@hidden text table format}). Setting @option{--tabletype} to this
+value is acceptable, but in many cases irrelevant, because the plain text
+table format is identified by filename, and currently there is only format
+to write plane text tables.
address@hidden fits-ascii
+A FITS ASCII table (see @ref{Recognized table formats}).
address@hidden fits-binary
+A FITS binary table (see @ref{Recognized table formats}).
address@hidden table
+
 @end vtable
 
 @node Operating mode options,  , Input output, Common options
@@ -5015,7 +5058,7 @@ your exciting science.} are very important.
 
 
 
address@hidden Automatic output, Table formats, Threads in Gnuastro, Common 
program behavior
address@hidden Automatic output, Tables in Gnuastro, Threads in Gnuastro, 
Common program behavior
 @section Automatic output
 
 @cindex Automatic output file names
@@ -5070,8 +5113,8 @@ ABC01.jpg ABC02.jpg DEF01_labeled.fits
 
 
 
address@hidden Table formats, Getting help, Automatic output, Common program 
behavior
address@hidden Table formats
address@hidden Tables in Gnuastro, Getting help, Automatic output, Common 
program behavior
address@hidden Tables in Gnuastro
 
 ``A table is a collection of related data held in a structured format
 within a database. It consists of columns, and rows.'' (from
@@ -5101,9 +5144,39 @@ other cases, you can feed a table into @ref{ImageCrop} 
and it will crop out
 regions centered on the positions within the table, see @ref{Hubble
 visually checks and classifies his catalog}. So to end this relatively long
 introduction, tables play a very important role in astronomy, or generally
-all branches of data analysis. Here, we will give a short review of the
-table formats that Gnuastro's programs and libraries can accept as input
-and output.
+all branches of data analysis.
+
+In @ref{Recognized table formats} the currently recognized table formats in
+Gnuastro are discussed. You can use any of these tables as input or ask for
+them to be built as output. The most common type of table format is a
+simple plain text file with each row on one line and columns separated by
+white space characters, this format is easy to read/write by eye/hand. To
+give it the full functionality of more specific table types like the FITS
+tables, Gnuastro has a special convention which you can use to give each
+column a name, type, unit, and comments, while still being readable by
+other plain text table readers. This convention is described in
address@hidden text table format}.
+
+When tables are input to a program, the program reading it needs to know
+which column(s) it should use for its desired purposes. Gnuastro's programs
+all follow a similar convention, on the way you can select columns in a
+table. They are thoroughly discussed in @ref{Selecting table columns}.
+
+
address@hidden
+* Recognized table formats::    Table formats that are recognized in Gnuastro.
+* Gnuastro text table format::  Gnuastro's convention plain text tables.
+* Selecting table columns::     Identify/select certain columns from a table
address@hidden menu
+
address@hidden Recognized table formats, Gnuastro text table format, Tables in 
Gnuastro, Tables in Gnuastro
address@hidden Recognized table formats
+
+The list of table formats that Gnuastro can currently read from and write
+to are decribed below. Each has their own advantage and disadvantages, so a
+short review of the format is also provided to help you make the best
+choice based on how you want to define your input tables or later use your
+output tables.
 
 @table @asis
 
@@ -5192,7 +5265,7 @@ also contain non-numerical columns.
 * Gnuastro text table format::  Reading plain text tables
 @end menu
 
address@hidden Gnuastro text table format,  , Table formats, Table formats
address@hidden Gnuastro text table format, Selecting table columns, Recognized 
table formats, Tables in Gnuastro
 @subsection Gnuastro text table format
 
 Plain text files are most generic, portable, and easiest way to (manually)
@@ -5363,7 +5436,7 @@ of the address@hidden|}'s.
 # Column 1: ID [label, uc]
 # Column 2: Notes [no unit, str50]
 1    leading and trailing white space is ignored here    2.3442e10
-2   |         but they will be preserved here        |   2.3442e10
+2   |         but they will be preserved here        |   8.2964e11
 @end example
 
 @end itemize
@@ -5380,9 +5453,73 @@ 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
+
+At the lowest level, the only defining aspect of a column in a table is its
+number, or position. But selecting columns purely by number is not very
+convenient and, especially when the tables are large it can be very
+frustrating and prone to errors. Hence, table file formats (for example see
address@hidden table formats}) have ways to store additional information
+about the columns (meta-data). Some of the most common pieces of
+information about each column are its name, the units of data in the it,
+and a comment for longer/informal description of the column's data.
+
+To facilitate research with Gnuastro, besides the low-level column number,
+you can also select columns by matching, or searching, in these three
+fields. To view this meta-data for all the columns in the table, you can
+use @ref{Table} with the command below (replace @file{table-file} with the
+filename of your table, if its FITS, you might also need to specify the
+HDU/extension which contains the table):
+
address@hidden
+$ asttable --information table-file
address@hidden example
 
+Gnuastro's programs need the columns for different purposes, for example in
+ImageCrop, you specify the column containing the Right Ascension of the
+crop centers with the @option{--racol} option and the column containing the
+Declination with @option{--deccol}. Thus, there is no unified common option
+name to select columns for all programs. However, when the program expects
+the column for a specific context (like the RA and Dec example above), the
+option names end in the @option{col} suffix (for example @option{--racol}
+and @option{--deccol}). These options accept both integer and string
+arguments.
+
+If the value can be parsed as a positive integer, it will be seen as the
+low-level column number. Note that column counting starts from 1, so if you
+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 field which the value will be compared with can be selected
+through the @option{--searchin} option, see @ref{Input output}. The
+matching will be done following this convention:
+
address@hidden
address@hidden
+If the value is enclosed in two slashes (for example @command{-r/RA_/}, or
address@hidden/RA_/}), then it is assumed to be a regular expression with
+the same convention as GNU AWK. GNU AWK has a
address@hidden://wwww.gnu.org/s/gawk/manual/html_node/Regexp.html,complete
+chapter} describing regular expressions, so we we will not continue
+discussing it here. Regular expressions are a very powerful tool in
+matching text and useful in many contexts.
 
address@hidden Getting help, Output headers, Table formats, Common program 
behavior
address@hidden
+When the string isn't inclosed between address@hidden/}'s, any column that 
exactly
+matches the given value in the given field will be selected.
address@hidden 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
+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.
+
+
+
+
address@hidden Getting help, Output headers, Tables in Gnuastro, Common program 
behavior
 @section Getting help
 
 @cindex Help
@@ -6586,7 +6723,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 formats}.
address@hidden in Gnuastro}.
 
 @cindex AWK
 @cindex GNU AWK
@@ -6623,7 +6760,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{Table formats}. Output columns can also be determined by number or
+see @ref{Tables in Gnuastro}. 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
 
@@ -6691,78 +6828,15 @@ that if columns have been requested with the 
@option{--column} option
 @cindex GNU AWK
 @item -c STR/INT
 @itemx --column=STR/INT
-Specify the columns to output for this table. If the value to this option
-is an integer number, the column number will be used (counting from 1,
-Table will abort with an error if zero or negative values are given). When
-the value can't be interpretted as an a integer number, the value's string
-of characters will be used to match one of the pieces of information for
-the columns. See the @option{--searchin} option description for more on
-where the matching/searching will take place. The matching will be done
-following this convention (similar to AWK):
-
address@hidden
address@hidden
-If the value is enclosed in two slashes (for example @command{-c/MAG_/}, or
address@hidden/MAG_/}), then it is assumed to be a regular expression
-with the same convention as GNU AWK. GNU AWK has a
address@hidden://wwww.gnu.org/s/gawk/manual/html_node/Regexp.html,complete
-chapter} describing regular expressions, so we we will not continue
-discussing it here. Regular expressions are a very powerful tool in
-matching text and since FITS binary tables usually have a large number of
-columns, this feature can greatly simply the selection of the output
-columns.
-
address@hidden
-Only columns that exactly match the given string (the case can be ignored
-with the @option{--ignorecase} option) in the given piece of column in
-formation will be selected.
address@hidden itemize
-
-Note that in both cases, it is possible to select multiple columns with one
-call to this function. The order of the selected columns (with one call to
-this option) will be the same order as they appear in the table.
-
-To select several output columns, this option can also be called any number
+Specify the columns to output, see @ref{Selecting table columns} for a
+thorough explanation on how the value to this option is interpretted. To
+select several output columns, this option can also be called any number
 times in one call to Table. The order of the output columns will be the
-same call order on the command-line. This option is not mandatory, if no
-specific columns are requested, all the input table columns are
-output. When this option is called multiple times, it is possible to output
-one column more than once.
-
address@hidden -s
address@hidden --searchin
-Where to match/search for columns (if the value to @option{--column} wasn't
-a number). The acceptable values are @command{name}, @command{units}, or
address@hidden
+same call order on the command-line.
 
address@hidden -I
address@hidden --ignorescase
-Ignore case while matching the column names with the value(s) of the
address@hidden option. The FITS standard suggests to treat the column
-names as case insensitive, which is recommended but not enforced here.
-
address@hidden -t STR
address@hidden --tabletype=STR
-The output file's table type when a filename is given to the
address@hidden option (see @ref{Common options}). This is ofcourse only
-relevant when the type of the table cannot be deduced from its
-filename. For example, if a name ending in @file{.fits} was given to
address@hidden, then Gnuastro knows you want a FITS table. But there are
-two types of FITS tables: FITS ASCII, and FITS binary. Thus, with this
-option, the program is able to identify which type you want. The currently
-recognized values to this option are:
-
address@hidden @command
address@hidden txt
-A plain text table with space characters between the columns. Setting
address@hidden to this value is acceptable, but irrelevant. Because a
-plain text table only currently has one format and is the default when the
-output filename wasn't recognized (see @ref{Gnuastro text table format}).
address@hidden fits-ascii
-A FITS ASCII table (see @ref{Table formats}).
address@hidden fits-binary
-A FITS binary table (see @ref{Table formats}).
address@hidden table
+This option is not mandatory, if no specific columns are requested, all the
+input table columns are output. When this option is called multiple times,
+it is possible to output one column more than once.
 
 
 @end table
@@ -13651,18 +13725,25 @@ $ astmkprof [OPTION ...] [BackgroundImage] Catalog
 One line examples:
 
 @example
-$ astmkprof background.fits catalog.txt
-$ astmkprof --xcol=0 --ycol=1 catalog.txt
+$ astmkprof --xcol=1 --ycol=2 catalog.txt
+$ astmkprof --background=img.fits catalog.txt
+$ astmkprof --racol=ra_center --ycol=dec_center catalog.txt
 $ astmkprof --individual --oversample 3 -x500 -y500 catalog.txt
 @end example
 
 @noindent
-If mock images are to be made, the catalog (which stores the parameters for
-each mock profile) is the mandatory argument. The input catalog has to be a
-text file formatted in a table with columns separated by space, tab or
-comma (@key{,}) characters. See @ref{Common program behavior} for a
-complete explanation of some common behaviour and options in all Gnuastro
-programs including MakeProfiles.
+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
+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
address@hidden option, Makeprofiles will make the fully zero-valued
+image and build the profiles on that (its size can be set with the
address@hidden and @option{--naxis2} options, and its main WCS paramters
+can also be defined). Besides the main image containing all the profiles it
+is also possible to build on individual images (only enclosing one full
+profile to its trucation radius) with the @option{--individual}.
 
 If a data image file (see @ref{Arguments}) is given, the pixels of
 that image are used as the background value for every pixel. The flux
@@ -13729,6 +13810,21 @@ Output:
 
 @table @option
 
address@hidden -k STR
address@hidden --background=STR
+A background image FITS file to build the profiles on, the extension that
+contains the image should be specified with the @option{--backhdu} option,
+see below. If this option is called, the profiles will be created on the
+background image specified and the @option{--naxis1} and @option{--naxis2}
+options will be ignored. If the image has WCS information, that information
+will also be used and the WCS related options (@option{--crpix1},
address@hidden, @option{--crval1}, @option{--crval2}, and
address@hidden) will also be ignored.
+
address@hidden -B STR/INT
address@hidden --backhdu=STR/INT
+The header data unit (HDU) of the file given to
+
 @item -x INT
 @itemx --naxis1=INT
 The number of pixels in the output image along the first FITS axis
diff --git a/lib/commonopts.h b/lib/commonopts.h
index 7bbff58..067c7f9 100644
--- a/lib/commonopts.h
+++ b/lib/commonopts.h
@@ -37,12 +37,15 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
      programs. */
 struct argp_option gal_commonopts_options[] =
   {
-    /* Input/output. */
-#ifndef NOT_COMMON_HDU_PARSER
-    {                           /* Some utilities need to parse `hdu' them-*/
-      "hdu",                    /* selves. In this case, they will define  */
-      GAL_OPTIONS_KEY_HDU,      /* `NOT_COMMON_HDU_PARSER' and set their   */
-      "STR",                    /* own `hdu' option structure. */
+    {
+      0, 0, 0, 0,
+      "Input:",
+      GAL_OPTIONS_GROUP_INPUT
+    },
+    {
+      "hdu",
+      GAL_OPTIONS_KEY_HDU,
+      "STR/INT",
       0,
       "Extension name or number of input data.",
       GAL_OPTIONS_GROUP_INPUT,
@@ -52,7 +55,42 @@ struct argp_option gal_commonopts_options[] =
       GAL_OPTIONS_NOT_MANDATORY,
       GAL_OPTIONS_NOT_SET
     },
-#endif
+    {
+      "searchin",
+      GAL_OPTIONS_KEY_SEARCHIN,
+      "STR",
+      0,
+      "Col. selection field: `name', `unit', `comment'.",
+      GAL_OPTIONS_GROUP_INPUT,
+      &cp->searchinstr,
+      GAL_DATA_TYPE_STRING,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET
+    },
+    {
+      "ignorecase",
+      GAL_OPTIONS_KEY_IGNORECASE,
+      0,
+      0,
+      "Ignore case when matching/searching col. info.",
+      GAL_OPTIONS_GROUP_INPUT,
+      &cp->ignorecase,
+      GAL_OPTIONS_NO_ARG_TYPE,
+      GAL_OPTIONS_RANGE_0_OR_1,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET
+    },
+
+
+
+
+
+    {
+      0, 0, 0, 0,
+      "Output:",
+      GAL_OPTIONS_GROUP_OUTPUT
+    },
     {
       "output",
       GAL_OPTIONS_KEY_OUTPUT,
@@ -67,6 +105,19 @@ struct argp_option gal_commonopts_options[] =
       GAL_OPTIONS_NOT_SET
     },
     {
+      "tableformat",
+      GAL_OPTIONS_KEY_TABLEFORMAT,
+      "STR",
+      0,
+      "Output table format: `fits-ascii', `fits-binary'.",
+      GAL_OPTIONS_GROUP_OUTPUT,
+      &cp->tableformatstr,
+      GAL_DATA_TYPE_STRING,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET
+    },
+    {
       "dontdelete",
       GAL_OPTIONS_KEY_DONTDELETE,
       0,
@@ -95,7 +146,13 @@ struct argp_option gal_commonopts_options[] =
 
 
 
-    /* Operating mode. */
+
+
+    {
+      0, 0, 0, 0,
+      "Operating modes:",
+      GAL_OPTIONS_GROUP_OPERATING_MODE
+    },
     {
       "quiet",
       GAL_OPTIONS_KEY_QUIET,
diff --git a/lib/fits.c b/lib/fits.c
index 19ab01d..c3b35eb 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -1620,9 +1620,9 @@ gal_fits_table_type(fitsfile *fptr)
   if(status==0)
     {
       if(!strcmp(value, "TABLE"))
-        return GAL_TABLE_TYPE_AFITS;
+        return GAL_TABLE_FORMAT_AFITS;
       else if(!strcmp(value, "BINTABLE"))
-        return GAL_TABLE_TYPE_BFITS;
+        return GAL_TABLE_FORMAT_BFITS;
       else
         error(EXIT_FAILURE, 0, "The `XTENSION' keyword of this FITS file "
               "doesn't have a standard value (`%s')", value);
@@ -1882,7 +1882,7 @@ gal_fits_table_info(char *filename, char *hdu, size_t 
*numcols,
             {
               /* The FITS standard's value to this option for FITS ASCII
                  and binary files differ. */
-              if(*tabletype==GAL_TABLE_TYPE_AFITS)
+              if(*tabletype==GAL_TABLE_FORMAT_AFITS)
                 fits_ascii_tform(val, &datatype, NULL, NULL, &status);
               else
                 fits_binary_tform(val, &datatype, &repeat, NULL, &status);
@@ -1894,7 +1894,7 @@ gal_fits_table_info(char *filename, char *hdu, size_t 
*numcols,
                  number of bytes in both cases for printing later. */
               if( allcols[index].type==GAL_DATA_TYPE_STRING )
                 {
-                  if(*tabletype==GAL_TABLE_TYPE_AFITS)
+                  if(*tabletype==GAL_TABLE_FORMAT_AFITS)
                     {
                       repeat=strtol(val+1, &tailptr, 0);
                       if(*tailptr!='\0')
@@ -2121,10 +2121,10 @@ fits_table_prepare_arrays(gal_data_t *cols, size_t 
numcols, int tabletype,
       switch(tabletype)
         {
         /* FITS ASCII table. */
-        case GAL_TABLE_TYPE_AFITS:
+        case GAL_TABLE_FORMAT_AFITS:
 
             /* Fill the printing format. */
-            gal_table_col_print_info(col, GAL_TABLE_TYPE_AFITS, fmt, lng);
+            gal_table_col_print_info(col, GAL_TABLE_FORMAT_AFITS, fmt, lng);
 
             /* We need to check if the blank value needs is larger than the
                expected width or not. Its initial width is set the output
@@ -2172,7 +2172,7 @@ fits_table_prepare_arrays(gal_data_t *cols, size_t 
numcols, int tabletype,
 
 
         /* FITS binary table. */
-        case GAL_TABLE_TYPE_BFITS:
+        case GAL_TABLE_FORMAT_BFITS:
 
           /* If this is a string column, set all the strings to same size,
              then write the value of tform depending on the type. */
@@ -2214,7 +2214,7 @@ fits_write_tnull_tcomm(fitsfile *fptr, gal_data_t *col, 
int tabletype,
   /* Write the NULL value */
   switch(tabletype)
     {
-    case GAL_TABLE_TYPE_AFITS:
+    case GAL_TABLE_FORMAT_AFITS:
       asprintf(&keyname, "TNULL%zu", colnum);
       blank=gal_data_blank_as_string(col->type, col->disp_width);
       fits_write_key(fptr, TSTRING, keyname, blank,
@@ -2223,7 +2223,7 @@ fits_write_tnull_tcomm(fitsfile *fptr, gal_data_t *col, 
int tabletype,
       free(blank);
       break;
 
-    case GAL_TABLE_TYPE_BFITS:
+    case GAL_TABLE_FORMAT_BFITS:
       /* FITS binary tables don't accept NULL values for floating point or
          string columns. For floating point is must be NaN and for strings
          it is a blank string. */
@@ -2306,7 +2306,7 @@ gal_fits_table_write(gal_data_t *cols, char *comments, 
int tabletype,
 
   /* Make the FITS file pointer. Note that tabletype was checked in
      `fits_table_prepare_arrays'. */
-  tbltype = tabletype==GAL_TABLE_TYPE_AFITS ? ASCII_TBL : BINARY_TBL;
+  tbltype = tabletype==GAL_TABLE_FORMAT_AFITS ? ASCII_TBL : BINARY_TBL;
   fits_create_tbl(fptr, tbltype, numrows, numcols, ttype, tform, tunit,
                   "table", &status);
   gal_fits_io_error(status, NULL);
@@ -2325,7 +2325,7 @@ gal_fits_table_write(gal_data_t *cols, char *comments, 
int tabletype,
          need a blank pointer in a FITS ASCII table.*/
       blank = ( gal_data_has_blank(col)
                 ? gal_data_alloc_blank(col->type) : NULL );
-      if(tabletype==GAL_TABLE_TYPE_AFITS && col->type==GAL_DATA_TYPE_STRING)
+      if(tabletype==GAL_TABLE_FORMAT_AFITS && col->type==GAL_DATA_TYPE_STRING)
         blank=NULL;
 
       /* Write the full column into the table. */
diff --git a/lib/gnuastro/table.h b/lib/gnuastro/table.h
index 2f2e811..b334c24 100644
--- a/lib/gnuastro/table.h
+++ b/lib/gnuastro/table.h
@@ -68,17 +68,18 @@ __BEGIN_C_DECLS  /* From C++ preparations */
 
 
 
-/* Types of table storage for input or output, as strings and integers. */
-#define GAL_TABLE_STRING_TYPE_TXT "txt"
-#define GAL_TABLE_STRING_TYPE_AFITS "fits-ascii"
-#define GAL_TABLE_STRING_TYPE_BFITS "fits-binary"
+/* Formats of table storage for input or output, as strings and
+   integers. */
+#define GAL_TABLE_STRING_FORMAT_TXT   "txt"
+#define GAL_TABLE_STRING_FORMAT_AFITS "fits-ascii"
+#define GAL_TABLE_STRING_FORMAT_BFITS "fits-binary"
 enum gal_table_types
 {
-  GAL_TABLE_TYPE_INVALID,       /* Invalid (=0 by C standard).       */
+  GAL_TABLE_FORMAT_INVALID,       /* Invalid (=0 by C standard).       */
 
-  GAL_TABLE_TYPE_TXT,           /* Plain text table.                 */
-  GAL_TABLE_TYPE_AFITS,         /* FITS ASCII table.                 */
-  GAL_TABLE_TYPE_BFITS,         /* FITS binary table.                */
+  GAL_TABLE_FORMAT_TXT,           /* Plain text table.                 */
+  GAL_TABLE_FORMAT_AFITS,         /* FITS ASCII table.                 */
+  GAL_TABLE_FORMAT_BFITS,         /* FITS binary table.                */
 };
 
 
@@ -128,10 +129,10 @@ enum gal_table_diplay_formats
 
 /* Functions */
 int
-gal_table_string_to_type(char *string);
+gal_table_string_to_format(char *string);
 
 void
-gal_table_check_fits_type(char *filename, int tabletype);
+gal_table_check_fits_format(char *filename, int tableformat);
 
 int
 gal_table_string_to_searchin(char *string);
@@ -140,7 +141,7 @@ void
 gal_table_print_info(gal_data_t *allcols, size_t numcols, size_t numrows);
 
 void
-gal_table_col_print_info(gal_data_t *col, int tabletype,
+gal_table_col_print_info(gal_data_t *col, int tableformat,
                          char *fmt, char *lng);
 
 void
@@ -148,14 +149,14 @@ gal_table_read_blank(gal_data_t *col, char *blank);
 
 gal_data_t *
 gal_table_info(char *filename, char *hdu, size_t *numcols,
-               size_t *numrows, int *tabletype);
+               size_t *numrows, int *tableformat);
 
 gal_data_t *
 gal_table_read(char *filename, char *hdu, struct gal_linkedlist_stll *cols,
                int searchin, int ignorecase, int minmapsize);
 
 void
-gal_table_write(gal_data_t *cols, char *comments, int tabletype,
+gal_table_write(gal_data_t *cols, char *comments, int tableformat,
                 char *filename, int dontdelete);
 
 
diff --git a/lib/options.c b/lib/options.c
index 413be9b..fea33d5 100644
--- a/lib/options.c
+++ b/lib/options.c
@@ -30,6 +30,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 #include <gnuastro/txt.h>
 #include <gnuastro/data.h>
+#include <gnuastro/table.h>
 #include <gnuastro/arithmetic.h>
 #include <gnuastro/linkedlist.h>
 
@@ -506,7 +507,7 @@ gal_options_set_from_key(int key, char *arg, struct 
argp_option *options,
   for(i=0;1;++i)
     {
       /* Check if the key corresponds to this option. */
-      if(options[i].key==key)
+      if( options[i].key==key )
         {
           /* For options that need immediate attention. */
           options_immediate(key, arg, cp);
@@ -709,11 +710,11 @@ options_set_from_name(char *name, char *arg,  struct 
argp_option *options,
   for(i=0;1;++i)
     {
       /* Check if the key corresponds to this option. */
-      if(options[i].name && !strcmp(options[i].name, name))
+      if( options[i].name && !strcmp(options[i].name, name) )
         {
-          /* If the option already has a value and it isn't a linked
-             list, then ignore it. */
-          if(options[i].set && !gal_data_is_linked_list(options[i].type))
+          /* 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 ) )
             return 0;
 
           /* For options that need immediate attention. */
@@ -746,6 +747,7 @@ static int
 options_lastconfig_has_been_called(struct argp_option *coptions)
 {
   size_t i;
+
   for(i=0; !gal_options_is_last(&coptions[i]); ++i)
     if( coptions[i].key == GAL_OPTIONS_KEY_LASTCONFIG
         && coptions[i].set
@@ -828,7 +830,6 @@ options_parse_file(char *filename,  struct 
gal_options_common_params *cp,
     error(EXIT_FAILURE, errno, "%s: couldn't close after reading as "
           "a configuration file", filename);
 
-
   /* Clean up and return. */
   free(line);
 }
@@ -934,6 +935,9 @@ options_reverse_lists_check_mandatory(struct 
gal_options_common_params *cp,
 void
 gal_options_read_config_set(struct gal_options_common_params *cp)
 {
+  size_t i;
+  struct argp_option *coptions=cp->coptions;
+
   /* Parse all the configuration files. */
   gal_options_parse_config_files(cp);
 
@@ -943,6 +947,21 @@ gal_options_read_config_set(struct 
gal_options_common_params *cp)
   options_reverse_lists_check_mandatory(cp, cp->poptions);
   options_reverse_lists_check_mandatory(cp, cp->coptions);
 
+  /* Some of the values that the user gives as strings should be stored
+     internally as integers. For the program-specific options, this is done
+     in the program's `ui.c', here, we do it for the common options. */
+  for(i=0; !gal_options_is_last(&coptions[i]); ++i)
+    if(coptions[i].set)
+      switch(coptions[i].key)
+      {
+      case GAL_OPTIONS_KEY_SEARCHIN:
+        cp->searchin=gal_table_string_to_searchin(cp->searchinstr);
+        break;
+      case GAL_OPTIONS_KEY_TABLEFORMAT:
+        cp->tableformat=gal_table_string_to_format(cp->tableformatstr);
+        break;
+      }
+
   /* Abort if any of the mandatory options are not set. */
   gal_options_abort_if_mandatory_missing(cp);
 }
@@ -976,6 +995,11 @@ gal_options_read_config_set(struct 
gal_options_common_params *cp)
 static int
 option_is_printable(struct argp_option *option)
 {
+  /* First check if option is hidden (not relevant to this program). */
+  if(option->flags & OPTION_HIDDEN)
+    return 0;
+
+  /* Then check if it is a pre-program option. */
   switch(option->key)
     {
     case GAL_OPTIONS_KEY_OUTPUT:
@@ -1076,49 +1100,65 @@ options_print_any_type(void *ptr, int type, int width, 
FILE *fp)
 
 
 
+/* An option structure is given, return its name and value print
+   lengths. */
+static void
+options_correct_max_lengths(struct argp_option *option, int *max_nlen,
+                            int *max_vlen)
+{
+  int vlen;
+  struct gal_linkedlist_stll *tmp;
+
+  /* Get the length of the value and save its length length if its
+     larger than the widest value. */
+  if(gal_data_is_linked_list(option->type))
+    {
+      /* A small sanity check. */
+      if(option->type!=GAL_DATA_TYPE_STRLL)
+        error(EXIT_FAILURE, 0, "currently only string linked lists "
+              "are acceptable for printing");
+
+      /* Check each node, one by one. */
+      for(tmp=*(struct gal_linkedlist_stll **)(option->value);
+          tmp!=NULL; tmp=tmp->next)
+        {
+          /* Get the length of this node: */
+          vlen=options_print_any_type(&tmp->v, GAL_DATA_TYPE_STRING, 0, NULL);
+
+          /* If its larger than the maximum length, then put it in. */
+          if( vlen > *max_vlen )
+            *max_vlen=vlen;
+        }
+    }
+  else
+    {
+      vlen=options_print_any_type(option->value, option->type, 0, NULL);
+      if( vlen > *max_vlen )
+        *max_vlen=vlen;
+    }
+
+  /* If the name of this option is larger than all existing, set its
+     length as the largest name length. */
+  if( strlen(option->name) > *max_nlen )
+    *max_nlen = strlen(option->name);
+}
+
+
+
+
+
 /* To print the options nicely, we need the maximum lengths of the options
    and their values. */
 static void
 options_set_lengths(struct argp_option *poptions,
                     struct argp_option *coptions, int *namelen, int *valuelen)
 {
-  int i, nlen=0, vlen=0, tvlen;
-  struct gal_linkedlist_stll *tmp;
+  int i, max_nlen=0, max_vlen=0;
 
   /* For program specific options. */
   for(i=0; !gal_options_is_last(&poptions[i]); ++i)
     if(poptions[i].name && poptions[i].set)
-      {
-        /* Get the length of the value and save its length length if its
-           larger than the widest value. */
-        if(gal_data_is_linked_list(poptions[i].type))
-          for(tmp=*(struct gal_linkedlist_stll **)(poptions[i].value);
-              tmp!=NULL; tmp=tmp->next)
-            {
-              /* A small sanity check. */
-              if(poptions[i].type!=GAL_DATA_TYPE_STRLL)
-                error(EXIT_FAILURE, 0, "currently only string linked lists "
-                      "are acceptable for printing");
-
-              /* Get the maximum lengths of each node: */
-              tvlen=options_print_any_type(&tmp->v, GAL_DATA_TYPE_STRING,
-                                           0, NULL);
-              if( tvlen>vlen )
-                vlen=tvlen;
-            }
-        else
-          {
-            tvlen=options_print_any_type(poptions[i].value, poptions[i].type,
-                                         0, NULL);
-            if( tvlen>vlen )
-              vlen=tvlen;
-          }
-
-        /* If the name of this option is larger than all existing, set its
-           length as the largest name length. */
-        if( strlen(poptions[i].name)>nlen )
-          nlen=strlen(poptions[i].name);
-      }
+      options_correct_max_lengths(&poptions[i], &max_nlen, &max_vlen);
 
   /* For common options. Note that the options that will not be printed are
      in this category, so we also need to check them. The detailed steps
@@ -1126,19 +1166,11 @@ options_set_lengths(struct argp_option *poptions,
   for(i=0; !gal_options_is_last(&coptions[i]); ++i)
     if( coptions[i].name && coptions[i].set
         && option_is_printable(&coptions[i]) )
-      {
-        tvlen=options_print_any_type(coptions[i].value, coptions[i].type,
-                                     0, NULL);
-        if( tvlen>vlen )
-          vlen=tvlen;
-
-        if(strlen(coptions[i].name)>nlen)
-          nlen=strlen(coptions[i].name);
-      }
+      options_correct_max_lengths(&coptions[i], &max_nlen, &max_vlen);
 
   /* Save the final values in the output pointers. */
-  *namelen=nlen;
-  *valuelen=vlen;
+  *namelen=max_nlen;
+  *valuelen=max_vlen;
 }
 
 
@@ -1237,16 +1269,23 @@ options_print_all(struct gal_options_common_params *cp, 
char *dirname,
     }
   else fp=stdout;
 
-  /* Parse all the options with a title, note that the title options
-     must only be in the `poptions'. We will only be dealing with the
-     `topics' linked list in this function and the strings in `poption' are
-     statically allocated, so its fine to not waste CPU cycles allocating
-     and freeing.*/
-  for(i=0; !gal_options_is_last(&cp->poptions[i]); ++i)
-    if(poptions[i].name==NULL && poptions[i].key==0 && poptions[i].doc)
+  /* Parse all the options with a title, note that the `Input', `Output'
+     and `Operating mode' options are defined in the common options, while
+     the (possible) other groups are in the program specific options. We
+     will only be dealing with the `topics' linked list in this function
+     and the strings in `poption' are statically allocated, so its fine to
+     not waste CPU cycles allocating and freeing.*/
+  for(i=0; !gal_options_is_last(&coptions[i]); ++i)
+    if(coptions[i].name==NULL && coptions[i].key==0 && coptions[i].doc)
       {
         /* The `(char *)' is because `.doc' is a constant and this helps
            remove the compiler warning. */
+        gal_linkedlist_add_to_ill(&group, coptions[i].group);
+        gal_linkedlist_add_to_stll(&topic, (char *)coptions[i].doc, 0);
+      }
+  for(i=0; !gal_options_is_last(&poptions[i]); ++i)
+    if(poptions[i].name==NULL && poptions[i].key==0 && poptions[i].doc)
+      {
         gal_linkedlist_add_to_ill(&group, poptions[i].group);
         gal_linkedlist_add_to_stll(&topic, (char *)poptions[i].doc, 0);
       }
diff --git a/lib/options.h b/lib/options.h
index b98d8de..b8a6483 100644
--- a/lib/options.h
+++ b/lib/options.h
@@ -57,7 +57,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 enum options_standard_groups
 {
   GAL_OPTIONS_GROUP_OPERATING_MODE = -1,
-  GAL_OPTIONS_GROUP_INPUT,
+  GAL_OPTIONS_GROUP_INPUT=1,
   GAL_OPTIONS_GROUP_OUTPUT,
 
   GAL_OPTIONS_GROUP_AFTER_COMMON,
@@ -73,7 +73,7 @@ enum options_standard_groups
    is also removed.
 
    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 I J L M O Q R T U W X Y Z
+   A B C E F G H J L M O Q R T W X Y Z
 */
 enum options_common_keys
 {
@@ -87,13 +87,16 @@ enum options_common_keys
   GAL_OPTIONS_KEY_PRINTPARAMS  = 'P',
   GAL_OPTIONS_KEY_SETDIRCONF   = 'S',
   GAL_OPTIONS_KEY_SETUSRCONF   = 'U',
+  GAL_OPTIONS_KEY_IGNORECASE   = 'I',
 
   /* Only long option (integers for keywords). */
   GAL_OPTIONS_KEY_MINMAPSIZE   = 500,
   GAL_OPTIONS_KEY_LOG,
   GAL_OPTIONS_KEY_CITE,
   GAL_OPTIONS_KEY_CONFIG,
+  GAL_OPTIONS_KEY_SEARCHIN,
   GAL_OPTIONS_KEY_LASTCONFIG,
+  GAL_OPTIONS_KEY_TABLEFORMAT,
   GAL_OPTIONS_KEY_ONLYVERSION,
 };
 
@@ -146,17 +149,22 @@ enum gal_options_set_values
    programs. */
 struct gal_options_common_params
 {
-  /* Input/Output. */
+  /* Input. */
   char                    *hdu; /* Image extension.                      */
+  unsigned char     ignorecase; /* Ignore case when matching col info.   */
+  char            *searchinstr; /* Column info to search (as a string).  */
+
+  /* Output. */
   char                 *output; /* Directory containg output.            */
-  int               dontdelete; /* ==1: Don't delete existing file.      */
-  int             keepinputdir; /* Keep input directory for auto output. */
+  unsigned char     dontdelete; /* ==1: Don't delete existing file.      */
+  unsigned char   keepinputdir; /* Keep input directory for auto output. */
+  char         *tableformatstr; /* Format of output table (as a string). */
 
   /* Operating modes. */
-  int                    quiet; /* Only print errors.                    */
+  unsigned char          quiet; /* Only print errors.                    */
   size_t            numthreads; /* Number of threads to use.             */
   size_t            minmapsize; /* Minimum bytes necessary to use mmap.  */
-  int                      log; /* Make a log file.                      */
+  unsigned char            log; /* Make a log file.                      */
 
   /* Configuration files. */
   unsigned char    printparams; /* To print the full list of parameters. */
@@ -165,6 +173,8 @@ struct gal_options_common_params
   unsigned char     lastconfig; /* This is the last configuration file.  */
 
   /* For internal purposes. */
+  int                 searchin; /* Internal code for user's input.       */
+  int              tableformat; /* Internal code for output table format.*/
   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.       */
diff --git a/lib/table.c b/lib/table.c
index 15b18f3..a4c5b10 100644
--- a/lib/table.c
+++ b/lib/table.c
@@ -45,24 +45,25 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /************************************************************************/
 /* Return the type of desired table based on a standard string. */
 int
-gal_table_string_to_type(char *string)
+gal_table_string_to_format(char *string)
 {
   if(string)
     {
-      if( !strcmp(string, GAL_TABLE_STRING_TYPE_TXT) )
-        return GAL_TABLE_TYPE_TXT;
+      if( !strcmp(string, GAL_TABLE_STRING_FORMAT_TXT) )
+        return GAL_TABLE_FORMAT_TXT;
 
-      else if( !strcmp(string, GAL_TABLE_STRING_TYPE_AFITS) )
-        return GAL_TABLE_TYPE_AFITS;
+      else if( !strcmp(string, GAL_TABLE_STRING_FORMAT_AFITS) )
+        return GAL_TABLE_FORMAT_AFITS;
 
-      else if( !strcmp(string, GAL_TABLE_STRING_TYPE_BFITS) )
-        return GAL_TABLE_TYPE_BFITS;
+      else if( !strcmp(string, GAL_TABLE_STRING_FORMAT_BFITS) )
+        return GAL_TABLE_FORMAT_BFITS;
 
       else
         error(EXIT_FAILURE, 0, "`%s' couldn't be interpretted as a valid "
-              "table type. The known types are `%s', `%s', and `%s'", string,
-              GAL_TABLE_STRING_TYPE_TXT, GAL_TABLE_STRING_TYPE_AFITS,
-              GAL_TABLE_STRING_TYPE_BFITS);
+              "table format. The known formats are `%s', `%s', and `%s'",
+              string, GAL_TABLE_STRING_FORMAT_TXT,
+              GAL_TABLE_STRING_FORMAT_AFITS,
+              GAL_TABLE_STRING_FORMAT_BFITS);
     }
 
   /* If string was not NULL, this function won't reach here. */
@@ -73,32 +74,32 @@ gal_table_string_to_type(char *string)
 
 
 
-/* For programs that output tables, the `--tabletype' option will be used
+/* For programs that output tables, the `--tableformat' option will be used
    to specify what format the output table should be in. When the output
-   file is a FITS file, there are multiple types, so to simplify the coding
-   in each program, this function will do a sanity check on the value given
-   to the `--tabletype' parameter. */
+   file is a FITS file, there are multiple formats, so to simplify the
+   coding in each program, this function will do a sanity check on the
+   value given to the `--tableformat' parameter. */
 void
-gal_table_check_fits_type(char *filename, int tabletype)
+gal_table_check_fits_format(char *filename, int tableformat)
 {
   if( filename && gal_fits_name_is_fits(filename) )
     {
-      /* When `--tabletype' was not given. */
-      if(tabletype==GAL_TABLE_TYPE_INVALID)
+      /* When `--tableformat' was not given. */
+      if(tableformat==GAL_TABLE_FORMAT_INVALID)
         error(EXIT_FAILURE, 0, "`%s' (output file) is a FITS file but the "
-              "desired type of the FITS table has not been specified with "
-              "the `--tabletype' option. For FITS tables, this option can "
+              "desired format of the FITS table has not been specified with "
+              "the `--tableformat' option. For FITS tables, this option can "
               "take two values: `%s', or `%s'", filename,
-              GAL_TABLE_STRING_TYPE_AFITS, GAL_TABLE_STRING_TYPE_BFITS);
+              GAL_TABLE_STRING_FORMAT_AFITS, GAL_TABLE_STRING_FORMAT_BFITS);
 
-      /* When `--tabletype' didn't have the correct value. */
-      if( tabletype != GAL_TABLE_TYPE_AFITS
-          && tabletype != GAL_TABLE_TYPE_BFITS )
+      /* When `--tableformat' didn't have the correct value. */
+      if( tableformat != GAL_TABLE_FORMAT_AFITS
+          && tableformat != GAL_TABLE_FORMAT_BFITS )
         error(EXIT_FAILURE, 0, "`%s' (output file) is a FITS file but "
-              "is not a recognized FITS table type. For FITS tables, "
-              "`--tabletype' can take two values: `%s', or `%s'",
-              filename, GAL_TABLE_STRING_TYPE_AFITS,
-              GAL_TABLE_STRING_TYPE_BFITS);
+              "is not a recognized FITS table format. For FITS tables, "
+              "`--tableformat' can take two values: `%s', or `%s'",
+              filename, GAL_TABLE_STRING_FORMAT_AFITS,
+              GAL_TABLE_STRING_FORMAT_BFITS);
     }
 }
 
@@ -106,7 +107,7 @@ gal_table_check_fits_type(char *filename, int tabletype)
 
 
 
-/* In programs, the `searchin' variable is much more easier to type in as a
+/* In programs, the `searchin' variable is much more easier to format in as a
    description than an integer (which is what `gal_table_read_cols'
    needs). This function will check the string value and give the
    corresponding integer value.*/
@@ -222,7 +223,8 @@ gal_table_print_info(gal_data_t *allcols, size_t numcols, 
size_t numrows)
    elements.
 */
 void
-gal_table_col_print_info(gal_data_t *col, int tabletype, char *fmt, char *lng)
+gal_table_col_print_info(gal_data_t *col, int tableformat, char *fmt,
+                         char *lng)
 {
   size_t j;
   char **strarr;
@@ -231,14 +233,14 @@ gal_table_col_print_info(gal_data_t *col, int tabletype, 
char *fmt, char *lng)
 
   /* First do a sanity check, so we can safly stop checking in the steps
      below. */
-  switch(tabletype)
+  switch(tableformat)
     {
-    case GAL_TABLE_TYPE_TXT:
-    case GAL_TABLE_TYPE_AFITS:
+    case GAL_TABLE_FORMAT_TXT:
+    case GAL_TABLE_FORMAT_AFITS:
       break;
     default:
-      error(EXIT_FAILURE, 0, "tabletype code %d not recognized in "
-            "`gal_table_col_print_info'", tabletype);
+      error(EXIT_FAILURE, 0, "tableformat code %d not recognized in "
+            "`gal_table_col_print_info'", tableformat);
     }
 
 
@@ -260,7 +262,7 @@ gal_table_col_print_info(gal_data_t *col, int tabletype, 
char *fmt, char *lng)
     case GAL_DATA_TYPE_STRING:
 
       /* Set the basic information. */
-      fmt[0] = tabletype==GAL_TABLE_TYPE_TXT ? 's' : 'A';
+      fmt[0] = tableformat==GAL_TABLE_FORMAT_TXT ? 's' : 'A';
 
       /* Go through all the strings in the column and find the maximum
          length to use as printing. If the user asked for a larger width
@@ -284,7 +286,7 @@ gal_table_col_print_info(gal_data_t *col, int tabletype, 
char *fmt, char *lng)
 
       /* For the FITS ASCII table, there is only one format for all
          integers.  */
-      if(tabletype==GAL_TABLE_TYPE_AFITS)
+      if(tableformat==GAL_TABLE_FORMAT_AFITS)
         fmt[0]='I';
       else
         switch(col->disp_fmt)
@@ -315,7 +317,7 @@ gal_table_col_print_info(gal_data_t *col, int tabletype, 
char *fmt, char *lng)
     case GAL_DATA_TYPE_LOGICAL:
     case GAL_DATA_TYPE_SHORT:
     case GAL_DATA_TYPE_INT:
-      fmt[0] = tabletype==GAL_TABLE_TYPE_TXT ? 'd' : 'I';
+      fmt[0] = tableformat==GAL_TABLE_FORMAT_TXT ? 'd' : 'I';
       width = ( col->disp_width<=0 ? GAL_TABLE_DEF_INT_WIDTH
                 : col->disp_width );
       precision = ( col->disp_precision<=0 ? GAL_TABLE_DEF_INT_PRECISION
@@ -328,7 +330,7 @@ gal_table_col_print_info(gal_data_t *col, int tabletype, 
char *fmt, char *lng)
     case GAL_DATA_TYPE_LONG:
     case GAL_DATA_TYPE_LONGLONG:
       lng[0] = 'l';
-      fmt[0] = tabletype==GAL_TABLE_TYPE_TXT ? 'd' : 'I';
+      fmt[0] = tableformat==GAL_TABLE_FORMAT_TXT ? 'd' : 'I';
       lng[1] = col->type==GAL_DATA_TYPE_LONGLONG ? 'l' : '\0';
       width=( col->disp_width<=0 ? GAL_TABLE_DEF_LINT_WIDTH
               : col->disp_width );
@@ -344,13 +346,13 @@ gal_table_col_print_info(gal_data_t *col, int tabletype, 
char *fmt, char *lng)
       switch(col->disp_fmt)
         {
         case GAL_TABLE_DISPLAY_FMT_FLOAT:
-          fmt[0] = tabletype==GAL_TABLE_TYPE_TXT ? 'f' : 'F'; break;
+          fmt[0] = tableformat==GAL_TABLE_FORMAT_TXT ? 'f' : 'F'; break;
         case GAL_TABLE_DISPLAY_FMT_EXP:
-          fmt[0] = tabletype==GAL_TABLE_TYPE_TXT ? 'e' : 'E'; break;
+          fmt[0] = tableformat==GAL_TABLE_FORMAT_TXT ? 'e' : 'E'; break;
         case GAL_TABLE_DISPLAY_FMT_GENERAL:
-          fmt[0] = tabletype==GAL_TABLE_TYPE_TXT ? 'g' : 'E'; break;
+          fmt[0] = tableformat==GAL_TABLE_FORMAT_TXT ? 'g' : 'E'; break;
         default:
-          fmt[0] = tabletype==GAL_TABLE_TYPE_TXT ? 'f' : 'F'; break;
+          fmt[0] = tableformat==GAL_TABLE_FORMAT_TXT ? 'f' : 'F'; break;
         }
       width = ( col->disp_width<=0
                 ? ( col->type==GAL_DATA_TYPE_FLOAT
@@ -436,21 +438,21 @@ gal_table_read_blank(gal_data_t *col, char *blank)
    structures (one data structure for each column). The number of rows is
    stored as the `size' element of each data structure. The type of the
    table (e.g., ascii text file, or FITS binary or ASCII table) will be put
-   in `tabletype' (macros defined in `gnuastro/table.h'.
+   in `tableformat' (macros defined in `gnuastro/table.h'.
 
    Note that other than the character strings (column name, units and
    comments), nothing in the data structure(s) will be allocated by this
    function for the actual data (e.g., the `array' or `dsize' elements). */
 gal_data_t *
 gal_table_info(char *filename, char *hdu, size_t *numcols, size_t *numrows,
-               int *tabletype)
+               int *tableformat)
 {
-  /* Get the table type and size (number of columns and rows). */
+  /* Get the table format and size (number of columns and rows). */
   if(gal_fits_name_is_fits(filename))
-    return gal_fits_table_info(filename, hdu, numcols, numrows, tabletype);
+    return gal_fits_table_info(filename, hdu, numcols, numrows, tableformat);
   else
     {
-      *tabletype=GAL_TABLE_TYPE_TXT;
+      *tableformat=GAL_TABLE_FORMAT_TXT;
       return gal_txt_table_info(filename, numcols, numrows);
     }
 
@@ -625,9 +627,9 @@ make_list_of_indexs(struct gal_linkedlist_stll *cols, 
gal_data_t *allcols,
             {
               /* Make sure the number is larger than zero! */
               if(tlong<=0)
-                error(EXIT_FAILURE, 0, "the column numbers given to the "
-                      "must not be zero, or negative. You have asked for "
-                      "column %ld", tlong);
+                error(EXIT_FAILURE, 0, "column numbers must be positive "
+                      "(not zero or negative). You have asked for column "
+                      "number %ld", tlong);
 
               /* Check if the given value is not larger than the number of
                  columns in the input catalog (note that the user is
@@ -728,7 +730,7 @@ gal_data_t *
 gal_table_read(char *filename, char *hdu, struct gal_linkedlist_stll *cols,
                int searchin, int ignorecase, int minmapsize)
 {
-  int tabletype;
+  int tableformat;
   size_t i, numcols, numrows;
   gal_data_t *allcols, *out=NULL;
   struct gal_linkedlist_sll *indexll;
@@ -737,7 +739,7 @@ gal_table_read(char *filename, char *hdu, struct 
gal_linkedlist_stll *cols,
   if(cols==NULL) return NULL;
 
   /* First get the information of all the columns. */
-  allcols=gal_table_info(filename, hdu, &numcols, &numrows, &tabletype);
+  allcols=gal_table_info(filename, hdu, &numcols, &numrows, &tableformat);
 
   /* If there was no actual data in the file, then return NULL. */
   if(allcols==NULL) return NULL;
@@ -746,7 +748,7 @@ gal_table_read(char *filename, char *hdu, struct 
gal_linkedlist_stll *cols,
   indexll=make_list_of_indexs(cols, allcols, numcols, searchin,
                               ignorecase, filename, hdu);
 
-  /* Depending on the table type, read the columns into the output
+  /* Depending on the table format, read the columns into the output
      structure. Note that the functions here pop each index, read/store the
      desired column and pop the next, so after these functions, the output
      linked list will have the opposite order of its input `indexll'
@@ -756,22 +758,22 @@ gal_table_read(char *filename, char *hdu, struct 
gal_linkedlist_stll *cols,
      functions, the `indexll' will be all freed (each popped element is
      actually freed).*/
   gal_linkedlist_reverse_sll(&indexll);
-  switch(tabletype)
+  switch(tableformat)
     {
-    case GAL_TABLE_TYPE_TXT:
+    case GAL_TABLE_FORMAT_TXT:
       out=gal_txt_table_read(filename, numrows, allcols, indexll,
                              minmapsize);
       break;
 
-    case GAL_TABLE_TYPE_AFITS:
-    case GAL_TABLE_TYPE_BFITS:
+    case GAL_TABLE_FORMAT_AFITS:
+    case GAL_TABLE_FORMAT_BFITS:
       out=gal_fits_table_read(filename, hdu, numrows, allcols, indexll,
                               minmapsize);
       break;
 
     default:
-      error(EXIT_FAILURE, 0, "table type code %d not recognized for "
-            "`tabletype' in `gal_table_read_cols'", tabletype);
+      error(EXIT_FAILURE, 0, "table format code %d not recognized for "
+            "`tableformat' in `gal_table_read_cols'", tableformat);
     }
 
   /* Clean up. */
@@ -807,16 +809,17 @@ gal_table_read(char *filename, char *hdu, struct 
gal_linkedlist_stll *cols,
 /***************              Write a table               ***************/
 /************************************************************************/
 void
-gal_table_write(gal_data_t *cols, char *comments, int tabletype,
+gal_table_write(gal_data_t *cols, char *comments, int tableformat,
                 char *filename, int dontdelete)
 {
-  /* If a filename was given, then the tabletype is relevant and must be
+  /* If a filename was given, then the tableformat is relevant and must be
      used. When the filename is empty, a text table must be printed on the
      standard output (on the command-line). */
   if(filename)
     {
       if(gal_fits_name_is_fits(filename))
-        gal_fits_table_write(cols, comments, tabletype, filename, dontdelete);
+        gal_fits_table_write(cols, comments, tableformat, filename,
+                             dontdelete);
       else
         gal_txt_table_write(cols, comments, filename, dontdelete);
     }
diff --git a/lib/txt.c b/lib/txt.c
index 76e0a9c..77f76a5 100644
--- a/lib/txt.c
+++ b/lib/txt.c
@@ -875,7 +875,7 @@ make_fmts_for_printf(gal_data_t *cols, size_t numcols, int 
leftadjust,
 
 
       /* Fill in the printing paramters. */
-      gal_table_col_print_info(col, GAL_TABLE_TYPE_TXT, fmt, lng);
+      gal_table_col_print_info(col, GAL_TABLE_FORMAT_TXT, fmt, lng);
 
 
       /* Adjust the width if a blank string was defined. */
diff --git a/tests/table/txt-to-fits-ascii.sh b/tests/table/txt-to-fits-ascii.sh
index 8d69c8c..12aaa5d 100755
--- a/tests/table/txt-to-fits-ascii.sh
+++ b/tests/table/txt-to-fits-ascii.sh
@@ -48,4 +48,4 @@ if [ ! -f $execname ] || [ ! -f $img ]; then exit 77; fi
 
 # Actual test script
 # ==================
-$execname $table --output=ascii-table.fits --tabletype=fits-ascii
+$execname $table --output=ascii-table.fits --tableformat=fits-ascii
diff --git a/tests/table/txt-to-fits-binary.sh 
b/tests/table/txt-to-fits-binary.sh
index e20bc0e..5708f35 100755
--- a/tests/table/txt-to-fits-binary.sh
+++ b/tests/table/txt-to-fits-binary.sh
@@ -48,4 +48,4 @@ if [ ! -f $execname ] || [ ! -f $img ]; then exit 77; fi
 
 # Actual test script
 # ==================
-$execname $table --output=binary-table.fits --tabletype=fits-binary
+$execname $table --output=binary-table.fits --tableformat=fits-binary



reply via email to

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