[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master d5a2a10: Arithmetic: new --onedonstdout option
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master d5a2a10: Arithmetic: new --onedonstdout option to print 1D outputs on stdout |
Date: |
Fri, 16 Aug 2019 01:47:23 -0400 (EDT) |
branch: master
commit d5a2a104f414a5538422193929aaa4c54e924adc
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Arithmetic: new --onedonstdout option to print 1D outputs on stdout
Until now, if you wanted to use the outputs of the `unique' operator for
example in your shell script, it was necessary to save it as a file, then
read that file which is annoying.
With this commit, Arithmetic has a new `--onedonstdout' operator for this:
when it is called, any 1D output will be written directly to the standard
output.
---
NEWS | 4 ++++
bin/arithmetic/args.h | 13 +++++++++++++
bin/arithmetic/arithmetic.c | 3 ++-
bin/arithmetic/main.h | 1 +
bin/arithmetic/ui.h | 3 ++-
doc/gnuastro.texi | 14 +++++++++++---
6 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index 7baa5d2..7f58e34 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,10 @@ See the end of the file for license conditions.
** New features
+ Arithmetic:
+ --onedonstdout: when the output is one-dimensional, print the values on
+ the standard output, not into a file.
+
CosmicCalculator:
--lineatz: return the observed wavelength of a line if it was emitted at
the redshift given to CosmicCalculator. You can either use known line
diff --git a/bin/arithmetic/args.h b/bin/arithmetic/args.h
index 987148d..788a818 100644
--- a/bin/arithmetic/args.h
+++ b/bin/arithmetic/args.h
@@ -85,6 +85,19 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
+ {
+ "onedonstdout",
+ UI_KEY_ONEDONSTDOUT,
+ 0,
+ 0,
+ "Write 1D output on stdout, not in a table.",
+ GAL_OPTIONS_GROUP_OUTPUT,
+ &p->onedonstdout,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
{0}
};
diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index 2a370c5..6935036 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -1247,7 +1247,8 @@ reversepolish(struct arithmeticparams *p)
will be freed while freeing `data'. */
data->wcs=p->refdata.wcs;
if(data->ndim==1 && p->onedasimage==0)
- gal_table_write(data, NULL, p->cp.tableformat, p->cp.output,
+ gal_table_write(data, NULL, p->cp.tableformat,
+ p->onedonstdout ? NULL : p->cp.output,
"ARITHMETIC", 0);
else
gal_fits_img_write(data, p->cp.output, NULL, PROGRAM_NAME);
diff --git a/bin/arithmetic/main.h b/bin/arithmetic/main.h
index 92c9e9f..af1b9a0 100644
--- a/bin/arithmetic/main.h
+++ b/bin/arithmetic/main.h
@@ -81,6 +81,7 @@ struct arithmeticparams
gal_data_t refdata; /* Container for information of the data. */
char *globalhdu; /* Single HDU for all inputs. */
uint8_t onedasimage; /* Write 1D outputs as an image not table. */
+ uint8_t onedonstdout; /* Write 1D outputs on stdout, not table. */
gal_data_t *named; /* List containing variables. */
size_t tokencounter; /* Counter for finding place in tokens. */
diff --git a/bin/arithmetic/ui.h b/bin/arithmetic/ui.h
index 37bf97d..6bbe04c 100644
--- a/bin/arithmetic/ui.h
+++ b/bin/arithmetic/ui.h
@@ -32,7 +32,7 @@ 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 l m n p r s t u v x y z
+ a b c d e f i j k l m n p r t u v x y z
A B C E G H J L Q R X Y
*/
enum option_keys_enum
@@ -40,6 +40,7 @@ enum option_keys_enum
/* With short-option version. */
UI_KEY_GLOBALHDU = 'g',
UI_KEY_ONEDASIMAGE = 'O',
+ UI_KEY_ONEDONSTDOUT = 's',
UI_KEY_WCSFILE = 'w',
UI_KEY_WCSHDU = 'W',
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index d9bb8bd..f39fbe2 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -13267,8 +13267,9 @@ operand. The unique elements of the dataset will be
stored in a
single-dimensional dataset.
Recall that by default, single-dimensional datasets are stored as a table
-column in the output. But you can use @option{--onedasimage} to store them
-as a single-dimensional FITS array/image.
+column in the output. But you can use @option{--onedasimage} or
+@option{--onedonstdout} to respectively store them as a single-dimensional
+FITS array/image, or to print them on the standard output.
@item erode
@cindex Erosion
@@ -13720,7 +13721,8 @@ default, when the output is 1D, Arithmetic will write
it as a table, not an
image/array. The format of the output table (plain text or FITS ASCII or
binary) can be set with the @option{--tableformat} option, see @ref{Input
output options}). You can disable this feature (write 1D arrays as FITS
-images/arrays) with the @option{--onedasimage} option.
+images/arrays, or to the standard output) with the @option{--onedasimage}
+or @option{--onedonstdout} options.
See @ref{Common options} for a review of the options in all Gnuastro
programs. Arithmetic just redefines the @option{--hdu} and
@@ -13792,6 +13794,12 @@ When final dataset to write as output only has one
dimension, write it as a
FITS image/array. By default, if the output is 1D, it will be written as a
table, see above.
+@item -s
+@itemx --onedonstdout
+When final dataset to write as output only has one dimension, print it on
+the standard output, not in a file. By default, if the output is 1D, it
+will be written as a table, see above.
+
@item -D
@itemx --dontdelete
Don't delete the output file, or files given to the @code{tofile} or
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master d5a2a10: Arithmetic: new --onedonstdout option to print 1D outputs on stdout,
Mohammad Akhlaghi <=