gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master bb4f0eed: Arithmetic: --append adds output to


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master bb4f0eed: Arithmetic: --append adds output to new HDU of existing output
Date: Sun, 18 Feb 2024 14:31:24 -0500 (EST)

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

    Arithmetic: --append adds output to new HDU of existing output
    
    Until now, when you wanted to write the output of Arithmetic as a HDU of an
    already existing FITS file, you had to make a temporary file, then use the
    Fits program to add the HDU to that file. This would make your pipeline
    code complex and be slow. Previously in the Crop program, we had a similar
    problem, and as a solution, we added the '--append' option.
    
    With this commit, this option is also implemented in Arithmetic.
---
 NEWS                  |  5 +++++
 bin/arithmetic/args.h | 13 +++++++++++++
 bin/arithmetic/main.h |  1 +
 bin/arithmetic/ui.c   |  3 ++-
 bin/arithmetic/ui.h   |  3 ++-
 developer-build       |  4 ++--
 doc/gnuastro.texi     |  4 ++++
 7 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 51c25ab4..5ba99dc8 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,11 @@ See the end of the file for license conditions.
 ** New publications
 ** New features
 *** Arithmetic
+
+  --append: if the output file already exists, don't delete it, add the
+    outputs as extra HDUs (by default, the output file is deleted). If the
+    output does not exist, then this option has no affect.
+
   - New operators:
 
     - madclip-maskfilled: mask (set to NaN) all input elements that are
diff --git a/bin/arithmetic/args.h b/bin/arithmetic/args.h
index 4702c912..015372d5 100644
--- a/bin/arithmetic/args.h
+++ b/bin/arithmetic/args.h
@@ -180,6 +180,19 @@ struct argp_option program_options[] =
       GAL_OPTIONS_NOT_MANDATORY,
       GAL_OPTIONS_NOT_SET
     },
+    {
+      "append",
+      UI_KEY_APPEND,
+      0,
+      0,
+      "If output exists, append crop to existing HDUs.",
+      GAL_OPTIONS_GROUP_OUTPUT,
+      &p->append,
+      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/main.h b/bin/arithmetic/main.h
index 663a9cc0..8b446634 100644
--- a/bin/arithmetic/main.h
+++ b/bin/arithmetic/main.h
@@ -87,6 +87,7 @@ struct arithmeticparams
   char           *metaunit;  /* FITS name (BUNIT keyword) of output.    */
   char        *metacomment;  /* FITS comment of output.                 */
   uint8_t         writeall;  /* Write all outputs.                      */
+  uint8_t           append;  /* Don't delete output file.               */
 
   /* Operating mode: */
   int        wcs_collapsed;  /* If the internal WCS is already collapsed.*/
diff --git a/bin/arithmetic/ui.c b/bin/arithmetic/ui.c
index d58786b9..765214ba 100644
--- a/bin/arithmetic/ui.c
+++ b/bin/arithmetic/ui.c
@@ -350,8 +350,9 @@ ui_check_options_and_arguments(struct arithmeticparams *p)
     }
 
   /* In case no output name has been given (can happen with operators like
-     'makenew' when the user doesn't set an output name explicity), use a
+     'makenew' when the user doesn't set an input name explicity), use a
      default name. */
+  if(p->append) cp->keep=1;
   if(cp->output)
     gal_checkset_writable_remove(cp->output, basename, cp->keep,
                                  cp->dontdelete);
diff --git a/bin/arithmetic/ui.h b/bin/arithmetic/ui.h
index 5658e886..a3044f93 100644
--- a/bin/arithmetic/ui.h
+++ b/bin/arithmetic/ui.h
@@ -50,7 +50,8 @@ enum option_keys_enum
 
   /* Only with long version (start with a value 1000, the rest will be set
      automatically). */
-  UI_KEY_ENVSEED         = 1000,
+  UI_KEY_APPEND          = 1000,
+  UI_KEY_ENVSEED,
   UI_KEY_ARGUMENTS,
 };
 
diff --git a/developer-build b/developer-build
index d670e907..c2771a50 100755
--- a/developer-build
+++ b/developer-build
@@ -162,7 +162,7 @@ Options:
  -o, --prefix STR         Install architecture-independent files here.
                           Current value: $prefix
 
-     --confopts "STR"     Add extra configure options manually.
+ -O, --confopts "STR"     Add extra configure options manually.
                           Please note that all of the options must
                           be wrapped between double quotations '"',
                           so that the script does not confuse them
@@ -238,7 +238,7 @@ while [[ $# -gt 0 ]]
 do
     key="$1"
     case $key in
-        --confopts)
+        -O|--confopts)
             confopts="$2"
             if [ x"$confopts" = x ]; then
                 echo "No argument given to '--confopts'."
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 40e9e331..87eb562d 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -24218,6 +24218,10 @@ For more, see the description of @option{--wcsfile}.
 Use the environment for the random number generator settings in operators that 
need them (for example, @code{mknoise-sigma}).
 This is very important for obtaining reproducible results, for more see 
@ref{Generating random numbers}.
 
+@item --append
+If the output file already exists, do not delete it; add the output data to 
new HDUs at the end of that file.
+You can use the @option{--meta*} options below to give a name, unit or 
comments to this HDUs (to easily distinguish it from other HDUs).
+
 @item -n STR
 @itemx --metaname=STR
 Metadata (name) of the output dataset.



reply via email to

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