gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master a1729f8: PC to CDELT decomposition done if pc


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master a1729f8: PC to CDELT decomposition done if pc present
Date: Mon, 1 May 2017 09:55:24 -0400 (EDT)

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

    PC to CDELT decomposition done if pc present
    
    Until now, the decomposition of PC (for rotation) and CDELT (for scale)
    would only be done if WCSLB had marked the WCS structure as having a PCi_j
    matrix through its `wcs->altlin' bitflag.
    
    However, as noted by Alan Lefor, even when the input image only has CDi_j
    matrix elements, WCSLIB will write out the (un-decomposed) PCi_j matrix in
    the output. So apparently WCSLIB will have the pc matrix allocated and
    filled even if the input is in CDi_j format. Hence with this commit, we
    changed the condition for decomposig PC and CDELT matricese, from now on,
    if `wcs->pc!=NULL', we will do the decomposition and change the
    bit-flag. This worked on that example image.
    
    In the process, I noticed that in MakeProfiles, we weren't setting the
    `wcs->altlin' bitflag when making a WCS structure, this would cause issues
    later (seen in `make check'). So it now sets this bit flag.
---
 bin/mkprof/ui.c | 21 +++++++++++----------
 lib/wcs.c       |  5 ++---
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index 73c00d0..453e78c 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -549,7 +549,7 @@ ui_prepare_wcs(struct mkprofparams *p)
   /* Initialize the structure (allocate all its internal arrays). */
   wcs->flag=-1;
   if( (status=wcsini(1, 2, wcs)) )
-    error(EXIT_FAILURE, 0, "wcsinit error %d: %s",
+    error(EXIT_FAILURE, 0, "wcsini error %d: %s",
           status, wcs_errmsg[status]);
 
   /* Correct the CRPIX values based on oversampling and shifting. */
@@ -557,15 +557,16 @@ ui_prepare_wcs(struct mkprofparams *p)
   p->crpix[1] = p->crpix[1]*os + p->shift[1] - os/2;
 
   /* Fill in all the important WCS structure parameters. */
-  wcs->equinox=2000.0f;
-  wcs->crpix[0]=p->crpix[0];
-  wcs->crpix[1]=p->crpix[1];
-  wcs->crval[0]=p->crval[0];
-  wcs->crval[1]=p->crval[1];
-  wcs->pc[0]=-1.0f;
-  wcs->pc[3]=1.0f;
-  wcs->pc[1]=wcs->pc[2]=0.0f;
-  wcs->cdelt[0]=wcs->cdelt[1]=p->resolution/3600;
+  wcs->altlin   = 0x1;
+  wcs->equinox  = 2000.0f;
+  wcs->crpix[0] = p->crpix[0];
+  wcs->crpix[1] = p->crpix[1];
+  wcs->crval[0] = p->crval[0];
+  wcs->crval[1] = p->crval[1];
+  wcs->pc[0]    = -1.0f;
+  wcs->pc[3]    = 1.0f;
+  wcs->pc[1]    = wcs->pc[2]=0.0f;
+  wcs->cdelt[0] = wcs->cdelt[1]=p->resolution/3600;
   strcpy(wcs->cunit[0], "deg");
   strcpy(wcs->cunit[1], "deg");
   strcpy(wcs->ctype[0], "RA---TAN");
diff --git a/lib/wcs.c b/lib/wcs.c
index ecf9875..6c02d84 100644
--- a/lib/wcs.c
+++ b/lib/wcs.c
@@ -328,9 +328,8 @@ gal_wcs_decompose_pc_cdelt(struct wcsprm *wcs)
   double *ps;
   size_t i, j;
 
-  /* The correction is only needed when the matrix is internally stored
-     as PCi_j. */
-  if(wcs->altlin & 1)
+  /* The correction is only needed when the PC matrix is filled. */
+  if(wcs->pc)
     {
       /* Get the pixel scale. */
       ps=gal_wcs_pixel_scale_deg(wcs);



reply via email to

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