gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 799c1ac 1/2: No extra blank keyword line after


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 799c1ac 1/2: No extra blank keyword line after writing WCS keywords
Date: Sun, 30 Dec 2018 18:05:58 -0500 (EST)

branch: master
commit 799c1aced0d812e2dfde622016db635f932b9a69
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    No extra blank keyword line after writing WCS keywords
    
    After writing all the WCS keywords, WCSLIB writes a blank keyword record
    and a `COMMENT' to mention its version. But Gnuastro writes the version of
    WCSLIB afterwards, so to keep things clean we would remove the last line.
    
    However, WCSLIB also writes a blank line before the `COMMENT' which would
    cause unequal spacing between the groups of keywords. So with this commit,
    instead of just ignoring the last line, we won't write those that are blank
    or those that have a `COMMENT' keyword.
---
 lib/fits.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib/fits.c b/lib/fits.c
index 5f724c0..901a130 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -1319,14 +1319,28 @@ gal_fits_key_write_filename(char *keynamebase, char 
*filename,
 void
 gal_fits_key_write_wcsstr(fitsfile *fptr, char *wcsstr, int nkeyrec)
 {
-  int h, status=0;
+  size_t i;
+  int status=0;
+  char *keystart;
 
   /* Write the title. */
   gal_fits_key_write_title_in_ptr("World Coordinate System (WCS)", fptr);
 
   /* Write the keywords one by one: */
-  for(h=0;h<nkeyrec-1;++h)
-    fits_write_record(fptr, &wcsstr[h*80], &status);
+  for(i=0;i<nkeyrec;++i)
+    {
+      /* Set the start of this header. */
+      keystart=&wcsstr[i*80];
+
+      /* Write it if it isn't blank (first character is a space), or not a
+         comment (first 7 characters equal to `COMMENT'). The reason is
+         that WCSLIB adds a blank line and a `COMMENT' keyword saying its
+         own version. But Gnuastro writes the version of WCSLIB as a
+         separate keyword along with all other important software, so it is
+         redundant and just makes the keywrods hard to read by eye.*/
+      if( keystart[0]!=' ' && strncmp(keystart, "COMMENT", 7) )
+        fits_write_record(fptr, keystart, &status);
+    }
   gal_fits_io_error(status, NULL);
 }
 



reply via email to

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