[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 06f72e6: Library (wcs.h): correcting for unrec
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 06f72e6: Library (wcs.h): correcting for unrecognized angstroms units |
Date: |
Mon, 18 Jan 2021 18:31:39 -0500 (EST) |
branch: master
commit 06f72e6ad06f13efef90902ddefd879f00170598
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Library (wcs.h): correcting for unrecognized angstroms units
Until now, immediately after reading the WCS structure from the file
header, we would pass it to WCSLIB's 'wcsfix' function. However, this
function doesn't recognize the 'angstroms' units, only 'angstrom' (note the
differing 's')! As a result, it would hit a segmentation fault within
WCSLIB and the program would crash.
With this commit, we now check the value to the 'CUNIT3' keyword. If its
value is 'angstroms' (not case sensitive), we manually remove the 's' and
this fixes the issue in WCSLIB.
This issue was found with the help of Alireza Molaeinezhad.
---
THANKS | 3 ++-
doc/announce-acknowledge.txt | 1 +
lib/wcs.c | 47 +++++++++++++++++++++++++++++++++-----------
3 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/THANKS b/THANKS
index 69d1ca7..d341069 100644
--- a/THANKS
+++ b/THANKS
@@ -64,9 +64,10 @@ support in Gnuastro. The list is ordered alphabetically (by
family name).
Sebastián Luna Valero sluna@iaa.es
Alberto Madrigal brt.madrigal@gmail.com
Guillaume Mahler guillaume.mahler@univ-lyon1.fr
- Raphael Morales rmorales@iaa.es
+ Alireza Molaeinezhad amolaei@gmail.com
Juan Molina Tobar juan.a.molina.t@gmail.com
Francesco Montanari francesco.montanari@openmailbox.org
+ Raphael Morales rmorales@iaa.es
Dmitrii Oparin doparin2@gmail.com
Bertrand Pain bertrand.pain@inserm.fr
William Pence william.pence@nasa.gov
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 0e78c30..d3d1636 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -6,6 +6,7 @@ Andrés García-Serra Romero
Bruno Haible
Martin Kuemmel
Javier Licandro
+Alireza Molaeinezhad
Sebastian Luna Valero
Samane Raji
Alberto Madrigal
diff --git a/lib/wcs.c b/lib/wcs.c
index 06a8295..028e2ab 100644
--- a/lib/wcs.c
+++ b/lib/wcs.c
@@ -261,20 +261,45 @@ gal_wcs_read_fitsptr(fitsfile *fptr, size_t hstartwcs,
size_t hendwcs,
}
else
{
- /* For a check.
+ /* For a check (we can't use 'wcsprt(wcs)' because this WCS isn't
+ yet initialized).
printf("flag: %d\n", wcs->flag);
- printf("naxis: %d\n", wcs->naxis);
- printf("crpix: %f, %f\n", wcs->crpix[0], wcs->crpix[1]);
- printf("pc: %f, %f, %f, %f\n", wcs->pc[0], wcs->pc[1], wcs->pc[2],
- wcs->pc[3]);
- printf("cdelt: %f, %f\n", wcs->cdelt[0], wcs->cdelt[1]);
- printf("crval: %f, %f\n", wcs->crval[0], wcs->crval[1]);
- printf("cunit: %s, %s\n", wcs->cunit[0], wcs->cunit[1]);
- printf("ctype: %s, %s\n", wcs->ctype[0], wcs->ctype[1]);
- printf("lonpole: %f\n", wcs->lonpole);
- printf("latpole: %f\n", wcs->latpole);
+ printf("NAXIS: %d\n", wcs->naxis);
+ printf("CRPIX: ");
+ for(i=0;i<wcs->naxis;++i)
+ { printf("%g, ", wcs->crpix[i]); } printf("\n");
+ printf("PC: ");
+ for(i=0;i<wcs->naxis*wcs->naxis;++i)
+ { printf("%g, ", wcs->pc[i]); } printf("\n");
+ printf("CDELT: ");
+ for(i=0;i<wcs->naxis;++i)
+ { printf("%g, ", wcs->cdelt[i]);} printf("\n");
+ printf("CD: ");
+ for(i=0;i<wcs->naxis*wcs->naxis;++i)
+ { printf("%g, ", wcs->cd[i]); } printf("\n");
+ printf("CRVAL: ");
+ for(i=0;i<wcs->naxis;++i)
+ { printf("%g, ", wcs->crval[i]); } printf("\n");
+ printf("CUNIT: ");
+ for(i=0;i<wcs->naxis;++i)
+ { printf("%s, ", wcs->cunit[i]); } printf("\n");
+ printf("CTYPE: ");
+ for(i=0;i<wcs->naxis;++i)
+ { printf("%s, ", wcs->ctype[i]); } printf("\n");
+ printf("LONPOLE: %f\n", wcs->lonpole);
+ printf("LATPOLE: %f\n", wcs->latpole);
*/
+ /* Some datasets may use 'angstroms' (not case-sensitive) in the
+ third dimension instead of the standard 'angstrom' (note the
+ differing 's'). In this case WCSLIB (atleast until version
+ 7.3) will not recognize it. We will therefore manually remove
+ the 's' before feeding the WCS structure to WCSLIB. */
+ if( wcs->naxis==3
+ && strlen(wcs->cunit[2])==9
+ && !strncasecmp(wcs->cunit[2], "angstroms", 9) )
+ wcs->cunit[2][8]='\0';
+
/* Fix non-standard WCS features. */
if( wcsfix(fixctrl, fixnaxis, wcs, fixstatus) )
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master 06f72e6: Library (wcs.h): correcting for unrecognized angstroms units,
Mohammad Akhlaghi <=