From b41feae138e42d9a93cc7999a812c0c08aae69e7 Mon Sep 17 00:00:00 2001 From: William Joye Date: Sun, 21 Jan 2018 13:46:54 -0500 Subject: support WCS-TAB --- tksao/frame/fitsimage.C | 11 +++++++++-- tksao/frame/fitsimage.h | 1 + tksao/frame/fitsmap.C | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C index 52d4994..1fd2ccf 100644 --- a/tksao/frame/fitsimage.C +++ b/tksao/frame/fitsimage.C @@ -113,6 +113,7 @@ FitsImage::FitsImage(Context* cx, Tcl_Interp* pp) wcsx_ =NULL; #else ast_ =NULL; + astInv_ =0; wcs_ =NULL; wcsEqu_ =NULL; wcsCel_ =NULL; @@ -1148,6 +1149,7 @@ void FitsImage::initWCS() wcsx_[ii] = ptr->wcsx_[ii]; #else ast_ = ptr->ast_; + astInv_ = ptr->astInv_; wcs_ = ptr->wcs_; wcsEqu_ = ptr->wcsEqu_; wcsCel_ = ptr->wcsCel_; @@ -3404,7 +3406,7 @@ Vector FitsImage::wcs2pix(const Vector& vv, Coord::CoordSystem sys, { astClearStatus; // just to make sure - if (hasWCS(sys)) { + if (hasWCS(sys) && astInv_) { setWCSSkyFrame(sys, sky); Vector in = hasWCSCel(sys) ? degToRad(vv) : vv; @@ -3422,7 +3424,7 @@ Vector3d FitsImage::wcs2pix(const Vector3d& vv, Coord::CoordSystem sys, { astClearStatus; // just to make sure - if (hasWCS(sys)) { + if (hasWCS(sys) && astInv_) { setWCSSkyFrame(sys, sky); Vector3d in = hasWCSCel(sys) ? degToRad(vv) : vv; @@ -4649,6 +4651,11 @@ AstFrameSet* FitsImage::fits2ast(FitsHead* hd) strncmp(astGetC(frameSet,"Class"), "FrameSet", 8)) return NULL; + // warn if no inverse + astInv_ = astGetI(frameSet, "TranInverse"); + if (!astInv_) + internalError("Warning: the WCS has no defined inverse. Some functionality may not be available."); + return frameSet; } diff --git a/tksao/frame/fitsimage.h b/tksao/frame/fitsimage.h index 2907854..48dae8d 100644 --- a/tksao/frame/fitsimage.h +++ b/tksao/frame/fitsimage.h @@ -117,6 +117,7 @@ class FitsImage { WCSx** wcsx_; // xth Axis WCS #else AstFrameSet* ast_; // ast frameset; + int astInv_; // can we inverse? int* wcs_; int* wcsEqu_; int* wcsCel_; diff --git a/tksao/frame/fitsmap.C b/tksao/frame/fitsmap.C index ecf425a..756b227 100644 --- a/tksao/frame/fitsmap.C +++ b/tksao/frame/fitsmap.C @@ -308,7 +308,7 @@ double FitsImage::mapLenToRef(double dd, Coord::CoordSystem sys, return dd*(detectorToPhysical * physicalToRef)[1].length(); default: { - if (!hasWCS(sys)) + if (!hasWCS(sys) || !astInv_) return 0; astClearStatus; // just to make sure -- cgit v0.12