[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 5d9c30e 1/2: -i option in Table takes preceden
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 5d9c30e 1/2: -i option in Table takes precedence over -c |
Date: |
Wed, 17 May 2017 10:35:52 -0400 (EDT) |
branch: master
commit 5d9c30eefbfddf24855f1127bc64312e6c98fa30
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
-i option in Table takes precedence over -c
Previously, if a column was requested, the `-i' option would be
ignored. But it often happens that the users forget a column name after
already typing several of their desired columns. So the opposite behavior
is preferred. Because when more than a couple of columns are needed, you
will probably forget the column identifiers of the last few and having to
retype everything is very frustrating. Something like how `--help' takes
precedence over all other options.
Also, when printing a table to a text file, we were mistakenly using the
same precision for float32 and float64! This has been corrected now.
---
bin/table/ui.c | 6 +++---
doc/gnuastro.texi | 16 ++++++++++++----
lib/tableintern.c | 31 ++++++++++++++++++++++++-------
3 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/bin/table/ui.c b/bin/table/ui.c
index ef92b91..806b307 100644
--- a/bin/table/ui.c
+++ b/bin/table/ui.c
@@ -271,9 +271,9 @@ ui_preparations(struct tableparams *p)
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)
+ /* If there were no columns specified or the user has asked for
+ information on the columns, we want the full set of columns. */
+ if(p->columns==NULL || p->information)
{
/* Read the table information for the number of columns and rows. */
allcols=gal_table_info(p->filename, cp->hdu, &numcols,
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index e767421..52f00de 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -7571,14 +7571,22 @@ tools like AWK or sort, similar to the examples above.
@item -i
@itemx --information
Only print the column information in the specified table on the
-command-line and exit. Each columns information (number, name, units, data
+command-line and exit. Each column's information (number, name, units, data
type, and comments) will be printed as a row on the command-line. Note that
the FITS standard only requires the data type (see @ref{Numeric data
-types}) and in plain text tables, no meta-data/information is
+types}), and in plain text tables, no meta-data/information is
mandatory. Gnuastro has its own convention in the comments of a plain text
table to store and transfer this information as described in @ref{Gnuastro
-text table format}. Note that if columns have been requested with the
address@hidden option (below), this option will be ignored if given.
+text table format}.
+
+This option will take precedence over the @option{--column} option, so when
+it is called along with requested columns, the latter will be ignored. This
+can be useful if you forget the identifier of a column after you have
+already typed some on the command-line. You can simply add a @option{-i}
+and run Table to see the whole list and remember. Then you can use the
+shell history (with the up arrow key on the keyboard), and retrieve the
+last command with all the previously typed columns present, delete
address@hidden and add the identifier you had forgot.
@cindex AWK
@cindex GNU AWK
diff --git a/lib/tableintern.c b/lib/tableintern.c
index fded702..f7c0590 100644
--- a/lib/tableintern.c
+++ b/lib/tableintern.c
@@ -348,6 +348,7 @@ gal_tableintern_col_print_info(gal_data_t *col, int
tableformat,
/* We need a default value (because in most cases, it won't be set. */
case GAL_TYPE_FLOAT32:
case GAL_TYPE_FLOAT64:
+ /* Set the format. */
switch(col->disp_fmt)
{
case GAL_TABLE_DISPLAY_FMT_FLOAT:
@@ -359,13 +360,29 @@ gal_tableintern_col_print_info(gal_data_t *col, int
tableformat,
default:
fmt[0] = tableformat==GAL_TABLE_FORMAT_TXT ? 'g' : 'E'; break;
}
- width = ( col->disp_width<=0
- ? ( col->type==GAL_TYPE_FLOAT32
- ? GAL_TABLE_DEF_WIDTH_FLT
- : GAL_TABLE_DEF_WIDTH_DBL )
- : col->disp_width );
- precision = ( col->disp_precision<=0 ? GAL_TABLE_DEF_PRECISION_FLT
- : col->disp_precision );
+
+ /* Set the width and precision */
+ switch(col->type)
+ {
+ case GAL_TYPE_FLOAT32:
+ width = ( col->disp_width<=0
+ ? GAL_TABLE_DEF_WIDTH_FLT : col->disp_width );
+ precision = ( col->disp_precision<=0
+ ? GAL_TABLE_DEF_PRECISION_FLT : col->disp_precision );
+ break;
+ case GAL_TYPE_FLOAT64:
+ width = ( col->disp_width<=0
+ ? GAL_TABLE_DEF_WIDTH_DBL : col->disp_width );
+
+ /* CFITSIO doesn't recognize the double precision defined here
+ for ASCII FITS tables. */
+ precision = ( col->disp_precision<=0
+ ? ( tableformat==GAL_TABLE_FORMAT_TXT
+ ? GAL_TABLE_DEF_PRECISION_DBL
+ : GAL_TABLE_DEF_PRECISION_FLT )
+ : col->disp_precision );
+ break;
+ }
break;