From 7ce8bdaf5b9bbc4a1b7a149ba68725dd9f9fbee9 Mon Sep 17 00:00:00 2001 From: William Joye Date: Fri, 10 Nov 2017 14:59:17 -0500 Subject: update AST WCS --- tksao/frame/base.C | 7 +--- tksao/frame/fitsimage.C | 109 ++++++++++++++++++++++++++---------------------- tksao/frame/fitsimage.h | 6 ++- tksao/frame/fitsmap.C | 6 +-- tksao/vector/vector.C | 4 +- 5 files changed, 72 insertions(+), 60 deletions(-) diff --git a/tksao/frame/base.C b/tksao/frame/base.C index 7667765..8f74b4b 100644 --- a/tksao/frame/base.C +++ b/tksao/frame/base.C @@ -642,7 +642,6 @@ Matrix Base::calcAlignWCS(FitsImage* fits1, FitsImage* fits2, Coord::CoordSystem sys1, Coord::CoordSystem sys2, Coord::SkyFrame sky) { - cerr << '*'; if ((!fits1 || !fits2) || (fits1 == fits2) || !(fits1->hasWCS(sys1)) || !(fits2->hasWCS(sys2))) return Matrix(); @@ -661,12 +660,10 @@ Matrix Base::calcAlignWCS(FitsImage* fits1, FitsImage* fits2, Matrix rr; if (cvt != AST__NULL) { astInvert(cvt); - Vector ll; Vector cc1 = fits1->center(); - fits1->astWCSTran(fits1->newast_, 1, cc1.v, cc1.v+1, 1, ll.v, ll.v+1); - Vector ur; + Vector ll = fits1->wcsTran(fits1->newast_, 1, cc1, 1); Vector cc2 = fits2->center(); - fits2->astWCSTran(fits2->newast_, 1, cc2.v, cc2.v+1, 1, ur.v, ur.v+1); + Vector ur = fits2->wcsTran(fits2->newast_, 1, cc2, 1); double fit[6]; double tol = 1; diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C index 8805e7e..11fb0c2 100644 --- a/tksao/frame/fitsimage.C +++ b/tksao/frame/fitsimage.C @@ -1474,7 +1474,7 @@ void FitsImage::match(const char* xxname1, const char* yyname1, ixx1[ii] *= M_PI/180.; iyy1[ii] *= M_PI/180.; } - astWCSTran(ast_[ss], nxx1, ixx1, iyy1, 0, oxx1, oyy1); + wcsTran(ast_[ss], nxx1, ixx1, iyy1, 0, oxx1, oyy1); } } @@ -1489,7 +1489,7 @@ void FitsImage::match(const char* xxname1, const char* yyname1, ixx2[ii] *= M_PI/180.; iyy2[ii] *= M_PI/180.; } - astWCSTran(ast_[ss], nxx2, ixx2, iyy2, 0, oxx2, oyy2); + wcsTran(ast_[ss], nxx2, ixx2, iyy2, 0, oxx2, oyy2); } } @@ -1648,7 +1648,7 @@ void FitsImage::match(const char* xxname1, const char* yyname1, AstFrameSet* cvt = (AstFrameSet*)astConvert(wcs1, wcs2, "SKY"); if (cvt != AST__NULL) - astWCSTran(cvt, nxx1, ixx1, iyy1, 1, xx1, yy1); + wcsTran(cvt, nxx1, ixx1, iyy1, 1, xx1, yy1); } else { memcpy(xx1,ixx1,nxx1*sizeof(double)); @@ -2913,7 +2913,9 @@ Vector FitsImage::getWCScdelt(Coord::CoordSystem sys) else return Vector(); } -#else +#endif + +#ifdef NEWWCS double FitsImage::getWCSPixelSize(Coord::CoordSystem sys) { if (!hasWCS(sys)) @@ -2931,7 +2933,7 @@ double FitsImage::getWCSPixelSize(Coord::CoordSystem sys) yy[0] = cc[1]; yy[1] = cc[1]+1; yy[2] = cc[1]+1; - astWCSTran(newast_,3,xx,yy,1,wxx,wyy); + wcsTran(newast_,3,xx,yy,1,wxx,wyy); double pt0[2]; pt0[0] = wxx[0]; @@ -2967,7 +2969,7 @@ double FitsImage::getWCSPixelArea(Coord::CoordSystem sys) yy[0] = cc[1]; yy[1] = cc[1]+1; yy[2] = cc[1]+1; - astWCSTran(newast_,3,xx,yy,1,wxx,wyy); + wcsTran(newast_,3,xx,yy,1,wxx,wyy); double pt0[2]; pt0[0] = wxx[0]; @@ -3038,7 +3040,7 @@ Coord::Orientation FitsImage::getWCSOrientation(Coord::CoordSystem sys, yy[0] = pp[1]; yy[1] = pp[1]+1; yy[2] = pp[1]; - astWCSTran(newast_,3,xx,yy,1,wx,wy); + wcsTran(newast_,3,xx,yy,1,wx,wy); double aa[2], bb[2], cc[2]; aa[0]= wx[0]; @@ -3100,7 +3102,7 @@ double FitsImage::getWCSRotation(Coord::CoordSystem sys, Coord::SkyFrame sky) xx[1] = pp[0]; yy[0] = pp[1]; yy[1] = pp[1]+1; - astWCSTran(newast_,2,xx,yy,1,wx,wy); + wcsTran(newast_,2,xx,yy,1,wx,wy); double aa[2], bb[2]; aa[0]= wx[0]; @@ -3133,27 +3135,23 @@ const char* FitsImage::getWCSName(Coord::CoordSystem sys) #endif #ifndef NEWWCS -Vector FitsImage::pix2wcs(Vector in, Coord::CoordSystem sys, +Vector FitsImage::pix2wcs(Vector in, Coord::CoordSystem sys, Coord::SkyFrame sky) { astClearStatus; int ss = sys-Coord::WCS; if (ss>=0 && ast_ && ast_[ss]) { - double xx =0; - double yy =0; if (astWCSIsASkyFrame(ast_[ss])) { setAstWCSSkyFrame(ast_[ss],sky); - astWCSTran(ast_[ss], 1, in.v, in.v+1, 1, &xx, &yy); - if (astOK) - if (checkAstWCS(xx,yy)) - return Vector(radToDeg(xx),yy*180./M_PI); + Vector out = wcsTran(ast_[ss], in, 1); + if (astOK && checkWCS(out)) + return out.radToDeg(); } else { - astWCSTran(ast_[ss], 1, in.v, in.v+1, 1, &xx, &yy); - if (astOK) - if (checkAstWCS(xx,yy)) - return Vector(xx,yy); + Vector out = wcsTran(ast_[ss], in, 1); + if (astOK && checkWCS(out)) + return out; } } @@ -3176,8 +3174,8 @@ Vector FitsImage::pix2wcs(Vector in, Coord::CoordSystem sys, double xx =0; double yy =0; - astWCSTran(newast_, 1, in.v, in.v+1, 1, &xx, &yy); - if (astOK && checkAstWCS(xx,yy)) { + wcsTran(newast_, 1, in.v, in.v+1, 1, &xx, &yy); + if (astOK && checkWCS(xx,yy)) { if (astWCSIsASkyFrame(newast_)) return Vector(radToDeg(xx),yy*180./M_PI); else @@ -3209,19 +3207,19 @@ Vector* FitsImage::pix2wcs(Vector* in, int num, Coord::CoordSystem sys, if (ss>=0 && ast_ && ast_[ss]) { if (astWCSIsASkyFrame(ast_[ss])) { setAstWCSSkyFrame(ast_[ss],sky); - astWCSTran(ast_[ss], num, xin, yin, 1, xout, yout); + wcsTran(ast_[ss], num, xin, yin, 1, xout, yout); if (astOK) { for (int ii=0; ii