[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 2d1b2dfe 1/2: Arithmetic: no extra FITS file c
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 2d1b2dfe 1/2: Arithmetic: no extra FITS file created when output is not FITS |
Date: |
Thu, 2 May 2024 14:37:37 -0400 (EDT) |
branch: master
commit 2d1b2dfe68ee4f9161261ea1c2627856d2cc3ebe
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Arithmetic: no extra FITS file created when output is not FITS
Until now, when the output of Arithmetic was a plain-text file or the
standard output, Arithmetic would also build an empty (only 0-th HDU with
metadata) file! This happened because the step to write the metadata in the
0th HDU was always executed, even when the output was not a FITS file.
With this commit, a check has been added to only write the metadata HDU
when there actually is an output FITS file.
This bug was reported by Sepideh Eskandarlou.
This fixes bug #65673.
---
NEWS | 4 ++++
bin/arithmetic/arithmetic.c | 24 ++++++++++++++++++------
doc/announce-acknowledge.txt | 1 +
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/NEWS b/NEWS
index 132424b7..467e73f6 100644
--- a/NEWS
+++ b/NEWS
@@ -169,6 +169,10 @@ See the end of the file for license conditions.
requested. Reported by Raul Infante-Sainz and fixed by Giacomo
Lorenzetti.
+ - bug #65673: Arithmetic creates a metadata FITS file a HDU with no data)
+ even when the output is not FITS (plain-text or on the standard
+ output). Reported by Sepideh Eskandarlou.
+
diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index 0fb1adc6..794cfa0a 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -2034,14 +2034,26 @@ reversepolish(struct arithmeticparams *p)
/* Put a copy of the WCS structure from the reference image, it will
be freed while freeing 'data'. But start the file with the 0-th
HDU keywords.*/
- gal_fits_key_write(p->cp.ckeys, p->cp.output, "0", "NONE", 1, 1);
+
if(data->ndim==1 && p->onedasimage==0)
- gal_table_write(data, NULL, NULL, p->cp.tableformat,
- p->onedonstdout ? NULL : p->cp.output,
- "ARITHMETIC", 0, 0);
+ {
+ /* The keywords HDU should only be created when a FITS file is to
+ be made; not when the output should go to a text file or the
+ standard output. */
+ if( p->onedonstdout==0
+ && gal_fits_name_is_fits(p->cp.output)==0 )
+ gal_fits_key_write(p->cp.ckeys, p->cp.output, "0", "NONE",
+ 1, 1);
+ gal_table_write(data, NULL, NULL, p->cp.tableformat,
+ p->onedonstdout ? NULL : p->cp.output,
+ "ARITHMETIC", 0, 0);
+ }
else
- for(tmp=data; tmp!=NULL; tmp=tmp->next)
- gal_fits_img_write(tmp, p->cp.output, NULL, 0);
+ {
+ 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);
+ }
/* Let the user know that the job is done. */
if(!p->cp.quiet)
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index b2ddc13c..2d0f3f99 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -10,6 +10,7 @@ Ooldooz Kabood
Phil Wyett
Rahna Payyasseri Thanduparackal
Raul Infante-Sainz
+Sepideh Eskandarlou
Zahra Sharbaf