gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 6ee5c936: Arithmetic: --append will not write


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 6ee5c936: Arithmetic: --append will not write any value in the 0th HDU
Date: Sun, 8 Jun 2025 15:59:10 -0400 (EDT)

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

    Arithmetic: --append will not write any value in the 0th HDU
    
    Until now, when Arithmetic was called with the '--append' option, it would
    continue to write its metadata (all the option values given to it) in the
    0-th HDU. However, when appending to the output, we just want to add new
    HDUs, not edit the existing ones.
    
    With this commit, with the '--append' option, Arithmetic will not update
    the 0th HDU of the already existing file.
---
 NEWS                        | 3 +++
 bin/arithmetic/arithmetic.c | 6 ++++--
 doc/gnuastro.texi           | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 187c39af..57ee20d6 100644
--- a/NEWS
+++ b/NEWS
@@ -151,6 +151,9 @@ See the end of the file for license conditions.
       integer datasets with small scatter (where the median can be repeated
       a lot).
 
+  --append: when called with this option, Arithmetic will not write its
+    run-time option values in the 0-th HDU.
+
   --metaname: can now accept multiple values (names of each HDU for
     multi-output calls of Arithmetic).
 
diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index 14c395bf..4422a01c 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -1953,7 +1953,7 @@ arithmetic_out_metadata(struct arithmeticparams *p, 
gal_data_t *data)
       gal_checkset_allocate_copy(s->v, &d->unit);
     }
 
-  /* Similar to 'metaname' but for meta comments. */
+  /* Similar to 'metacomment' but for meta comments. */
   d=data;
   for(s=p->metacomment; s!=NULL && d!=NULL; s=s->next, d=d->next)
     {
@@ -2104,7 +2104,9 @@ reversepolish(struct arithmeticparams *p)
         }
       else
         {
-          gal_fits_key_write(p->cp.ckeys, p->cp.output, "0", "NONE", 1, 1);
+          if(p->append==0) /* 0-HDU metadata only when not appending. */
+            gal_fits_key_write(p->cp.ckeys, p->cp.output, "0",
+                               "NONE", 1, 1);
           for(tmp=data; tmp!=NULL; tmp=tmp->next)
             gal_fits_img_write(tmp, p->cp.output, NULL, 0);
         }
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 5ea07251..874be58a 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -24650,6 +24650,7 @@ This is very important for obtaining reproducible 
results, for more see @ref{Gen
 @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).
+When this option is given, the 0th HDU of the existing file will not be 
updated to add Arithmetic's option values at run-time (because the existing 
file must already have values there).
 
 @item -n STR[,STR,[...]]
 @itemx --metaname=STR[,STR,[...]]



reply via email to

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