[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master faca4fc: Library (WCS): Added ability to read
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master faca4fc: Library (WCS): Added ability to read CROTAi rotation keywords |
Date: |
Wed, 6 Mar 2019 14:29:27 -0500 (EST) |
branch: master
commit faca4fc876a688bd09109ba550b08210b6d3262c
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Library (WCS): Added ability to read CROTAi rotation keywords
Until now, we weren't prepared for the `CROTAi' rotation keywords in the
FITS WCS standard. Although they are depreciated, older datasets, or
datasets produced by older tools, can still have them.
With this commit the necessary calculations are added in
`gal_wcs_warp_matrix' to enable proper treatment of such inputs in all of
Gnuastro.
This bug was reported by Elham Eftekhari.
This fixes bug #55844.
---
NEWS | 3 +++
THANKS | 1 +
doc/announce-acknowledge.txt | 1 +
lib/wcs.c | 29 ++++++++++++++++++++++++++++-
4 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 29a09bc..6e6fca6 100644
--- a/NEWS
+++ b/NEWS
@@ -139,6 +139,9 @@ GNU Astronomy Utilities NEWS -*-
outline -*-
bug #55544: Arithmetic's output WCS with where operator is not as expected.
bug #55740: Diamond shapes in nearst-ngb interpolation affecting NoiseChisel.
bug #55763: Crop not keeping Blank pixels on unsigned types.
+ bug #55844: WCS library (and thus all programs) can't deal with CROTAi
values.
+
+
diff --git a/THANKS b/THANKS
index c803745..b72268b 100644
--- a/THANKS
+++ b/THANKS
@@ -30,6 +30,7 @@ support in Gnuastro. The list is ordered alphabetically (by
family name).
Nima Dehdilani address@hidden
Antonio Diaz Diaz address@hidden
Pierre-Alain Duc address@hidden
+ Elham Eftekhari address@hidden
Gaspar Galaz address@hidden
Thérèse Godefroy address@hidden
Madusha Gunawardhana address@hidden
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 02c7b76..83b8dc9 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -2,6 +2,7 @@ Alphabetically ordered list to acknowledge in the next release.
Roberto Baena Gallé
Leindert Boogaard
+Elham Eftekhari
Raúl Infante Sainz
David Valls-Gabaud
Ignacio Trujillo
diff --git a/lib/wcs.c b/lib/wcs.c
index 8d0f768..23b5389 100644
--- a/lib/wcs.c
+++ b/lib/wcs.c
@@ -485,7 +485,7 @@ gal_wcs_on_tile(gal_data_t *tile)
double *
gal_wcs_warp_matrix(struct wcsprm *wcs)
{
- double *out;
+ double *out, crota2;
size_t i, j, size=wcs->naxis*wcs->naxis;
/* Allocate the necessary array. */
@@ -507,6 +507,33 @@ gal_wcs_warp_matrix(struct wcsprm *wcs)
for(i=0;i<size;++i)
out[i]=wcs->cd[i];
}
+ else if(wcs->altlin & 0x4) /* Has CROTAi array. */
+ {
+ /* Basic sanity checks. */
+ if(wcs->naxis!=2)
+ error(EXIT_FAILURE, 0, "%s: CROTAi currently on works in 2 "
+ "dimensions.", __func__);
+ if(wcs->crota[0]!=0.0)
+ error(EXIT_FAILURE, 0, "%s: CROTA1 is not zero", __func__);
+
+ /* CROTAi keywords are depreciated in the FITS standard. However, old
+ files may still use them. For a full description of CROTAi
+ keywords and their history (along with the conversion equations
+ here), please see the link below:
+
+ https://fits.gsfc.nasa.gov/users_guide/users_guide/node57.html
+
+ Just note that the equations of the link above convert CROTAi to
+ PC. But here we want the "final" matrix (after multiplication by
+ the `CDELT' values). So to speed things up, we won't bother
+ dividing and then multiplying by the same CDELT values in the
+ off-diagonal elements. */
+ crota2=wcs->crota[1];
+ out[0] = wcs->cdelt[0] * cos(crota2);
+ out[1] = -1 * wcs->cdelt[1] *sin(crota2);
+ out[2] = wcs->cdelt[0] * sin(crota2);
+ out[3] = wcs->cdelt[1] * cos(crota2);
+ }
else
error(EXIT_FAILURE, 0, "%s: currently only PCi_ja and CDi_ja keywords "
"are recognized", __func__);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master faca4fc: Library (WCS): Added ability to read CROTAi rotation keywords,
Mohammad Akhlaghi <=