gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 1d37c33: Fits: --keyvalue option only doesn't


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 1d37c33: Fits: --keyvalue option only doesn't print name with --quiet
Date: Wed, 24 Mar 2021 19:01:55 -0400 (EDT)

branch: master
commit 1d37c3375c75d09577aaeb545d86db3f006170b6
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Fits: --keyvalue option only doesn't print name with --quiet
    
    Until now, '--keyvalue' wouldn't include the file name as a first column
    with only one input. When there was more than one input, it would always
    print the file names as a first column. As a result, in a general script
    (that needs consistancy and you don't know the number of inputs a-priori),
    if the input was only a single file it would require extra work by the
    script writer (which is not good!).
    
    With this commit, '--keyvalue' will also print the file name when there is
    only one file to be consistent. To avoid printing the filename (when there
    is only a single file: the previous behavior), you should use '--quiet'.
---
 bin/fits/keywords.c | 6 +++---
 doc/gnuastro.texi   | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/bin/fits/keywords.c b/bin/fits/keywords.c
index 9b48fd7..852858f 100644
--- a/bin/fits/keywords.c
+++ b/bin/fits/keywords.c
@@ -782,10 +782,10 @@ keywords_value(struct fitsparams *p)
   size_t i, ii=0, ninput, nkeys;
   gal_data_t *out=NULL, *keysll=NULL;
 
-  /* Count how many inputs there are and allocate the first column with the
-     name. */
+  /* Count how many inputs there are, and allocate the first column with
+     the name. */
   ninput=gal_list_str_number(p->input);
-  if(ninput>1)
+  if(ninput>1 || p->cp.quiet==0)
     out=gal_data_alloc(NULL, GAL_TYPE_STRING, 1, &ninput, NULL, 0,
                        p->cp.minmapsize, p->cp.quietmmap, "FILENAME",
                        "name", "Name of input file.");
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index ec5d28f..61b9503 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -9128,7 +9128,7 @@ Also, unlike the rest of the options in this section, 
with @option{--keyvalue},
 @item -l STR[,STR[,...]
 @itemx --keyvalue=STR[,STR[,...]
 Only print the value of the requested keyword(s): the @code{STR}s.
-@option{--keyvalue} can be called multiple times, and each call can contain 
multiple comma-separated values.
+@option{--keyvalue} can be called multiple times, and each call can contain 
multiple comma-separated keywords.
 If more than one file is given, this option uses the same HDU/extension for 
all of them (value to @option{--hdu}).
 For example, you can get the number of dimensions of the three FITS files in 
the running directory, as well as the length along each dimension, with this 
command:
 
@@ -9139,11 +9139,11 @@ image-b.fits 2      774    672
 image-c.fits 2      387    336
 @end example
 
-If a single dataset is given, its name is not printed on the first column, 
only the values of the requested keywords.
+If only one input is given, and the @option{--quiet} option is activated, the 
file name is not printed on the first column, only the values of the requested 
keywords.
 
 @example
 $ astfits image-a.fits --keyvalue=NAXIS,NAXIS1 \
-          --keyvalue=NAXIS2
+          --keyvalue=NAXIS2 --quiet
 2      774    672
 @end example
 
@@ -9179,7 +9179,7 @@ image-a.fits
 image-b.fits
 @end example
 
-Note that @option{--colinfoinstdout} is necessary to use column names in the 
subsequent @command{asttable} command.
+Note that @option{--colinfoinstdout} is necessary to use column names when 
piping to other programs (like @command{asttable} above).
 Also, with the @option{-cFILENAME} option, we are asking Table to only print 
the final file names (we don't need the sizes any more).
 
 The commands with multiple files above used @file{*.fits}, which is only 
useful when all your FITS files are in the same directory.



reply via email to

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