gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master cb7be2b: Crop: using library to write crop inf


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master cb7be2b: Crop: using library to write crop information FITS keywwords
Date: Wed, 4 Aug 2021 11:36:16 -0400 (EDT)

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

    Crop: using library to write crop information FITS keywwords
    
    Until now, Crop done the low-level writing of the the FITS keyword title
    for "Crop information" keywords itself! As a result, it didn't insert an
    empty line before the new title and it would be immediately in the line
    after the WCS! This makes it hard to notice and didn't follow the regular
    pattern of one empty lines between each titled group of keywords.
    
    With this commit, Crop now uses the proper Gnuastro library function for
    writing FITS keyword titles (that is also used by other programs). This
    fixes the problem above, and also simplified the coding (many extra lines
    have been removed).
---
 bin/crop/onecrop.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/bin/crop/onecrop.c b/bin/crop/onecrop.c
index d8a2566..59ae180 100644
--- a/bin/crop/onecrop.c
+++ b/bin/crop/onecrop.c
@@ -524,17 +524,9 @@ onecrop_make_array(struct onecropparams *crp, long 
*fpixel_i,
   char **strarr, cpname[FLEN_KEYWORD];
   gal_data_t *rkey=gal_data_array_calloc(1);
   size_t i, ndim=crp->p->imgs->ndim, totsize;
-  char *cp, *cpf, blankrec[80], titlerec[80];
   struct inputimgs *img=&crp->p->imgs[crp->in_ind];
 
 
-  /* Set the last element of the blank array. */
-  cpf=blankrec+79;
-  *cpf='\0';
-  titlerec[79]='\0';
-  cp=blankrec; do *cp=' '; while(++cp<cpf);
-
-
   /* Set the size of the output, in WCS mode, noblank==0. */
   if(crp->p->noblank && crp->p->mode==IMGCROP_MODE_IMG)
     for(i=0;i<ndim;++i)
@@ -626,12 +618,10 @@ onecrop_make_array(struct onecropparams *crp, long 
*fpixel_i,
     }
 
 
-  /* Add the Crop information. */
-  sprintf(titlerec, "%sCrop information", GAL_FITS_KEY_TITLE_START);
-  for(i=strlen(titlerec);i<79;++i)
-    titlerec[i]=' ';
-  if(fits_write_record(ofp, titlerec, &status))
-    gal_fits_io_error(status, NULL);
+  /* Add the Crop information title, the actual keywords will be written
+     later. The keywords will contain the pixels of the is cropped region
+     from input image(s): */
+  gal_fits_key_write_title_in_ptr("Crop information", ofp);
 }
 
 



reply via email to

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