gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master fc0bc9d3: Statistics: output of --oneline only


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master fc0bc9d3: Statistics: output of --oneline only writes keywords once in 0th HDU
Date: Sun, 9 Jun 2024 19:07:02 -0400 (EDT)

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

    Statistics: output of --oneline only writes keywords once in 0th HDU
    
    Until now, when Statistics was called with '--oneline' and more than one
    statistical operation, it would attempt to write the keywords in every
    HDU. But this is against the convention in Gnuastro (for such metadata to
    be in the 0th HDU) and would also cause a segmentation fault (because after
    writing the first round, it would free the keywords).
    
    With this commit, the keywords are written after all the HDUs are written,
    and into the 0th HDU.
---
 bin/statistics/statistics.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/bin/statistics/statistics.c b/bin/statistics/statistics.c
index d60f8ff0..cd37bd05 100644
--- a/bin/statistics/statistics.c
+++ b/bin/statistics/statistics.c
@@ -406,9 +406,6 @@ statistics_interpolate_and_write(struct statisticsparams *p,
   /* Write the values. */
   gal_tile_full_values_write(values, &cp->tl, !p->ignoreblankintiles,
                              output, NULL, 0);
-  gal_fits_key_write_filename("input", p->inputname, &p->cp.ckeys, 1,
-                              p->cp.quiet);
-  gal_fits_key_write(p->cp.ckeys, output, "0", "NONE", 1, 0);
 }
 
 
@@ -664,6 +661,11 @@ statistics_on_tile(struct statisticsparams *p)
       if(operation->v==UI_KEY_QUANTFUNC) gal_data_free(tmpv);
     }
 
+  /* Write the keywords in the 0-th extension. */
+  gal_fits_key_write_filename("input", p->inputname, &p->cp.ckeys, 1,
+                              p->cp.quiet);
+  gal_fits_key_write(p->cp.ckeys, output, "0", "NONE", 1, 0);
+
   /* Clean up. */
   free(output);
 }



reply via email to

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