diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2017-11-10 20:29:30 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2017-11-10 20:29:30 (GMT) |
commit | 0a2c88db4f6da34fd982bb0caa8a8c3b9071eaae (patch) | |
tree | 40f900582ed9a146d80d278665b828abc7991984 /tksao | |
parent | 7ce8bdaf5b9bbc4a1b7a149ba68725dd9f9fbee9 (diff) | |
download | blt-0a2c88db4f6da34fd982bb0caa8a8c3b9071eaae.zip blt-0a2c88db4f6da34fd982bb0caa8a8c3b9071eaae.tar.gz blt-0a2c88db4f6da34fd982bb0caa8a8c3b9071eaae.tar.bz2 |
update AST WCS
Diffstat (limited to 'tksao')
-rw-r--r-- | tksao/frame/base.C | 4 | ||||
-rw-r--r-- | tksao/frame/fitsimage.C | 41 | ||||
-rw-r--r-- | tksao/frame/fitsimage.h | 3 | ||||
-rw-r--r-- | tksao/vector/vector.C | 19 | ||||
-rw-r--r-- | tksao/vector/vector.h | 5 |
5 files changed, 41 insertions, 31 deletions
diff --git a/tksao/frame/base.C b/tksao/frame/base.C index 8f74b4b..f6932a9 100644 --- a/tksao/frame/base.C +++ b/tksao/frame/base.C @@ -661,9 +661,9 @@ Matrix Base::calcAlignWCS(FitsImage* fits1, FitsImage* fits2, if (cvt != AST__NULL) { astInvert(cvt); Vector cc1 = fits1->center(); - Vector ll = fits1->wcsTran(fits1->newast_, 1, cc1, 1); + Vector ll = fits1->wcsTran(fits1->newast_, cc1, 1); Vector cc2 = fits2->center(); - Vector ur = fits2->wcsTran(fits2->newast_, 1, cc2, 1); + Vector ur = fits2->wcsTran(fits2->newast_, cc2, 1); double fit[6]; double tol = 1; diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C index 11fb0c2..f304441 100644 --- a/tksao/frame/fitsimage.C +++ b/tksao/frame/fitsimage.C @@ -3281,27 +3281,24 @@ char* FitsImage::pix2wcs(Vector in, Coord::CoordSystem sys, char* lbuf) { astClearStatus; - + maperr =0; + lbuf[0] = '\0'; + int ss = sys-Coord::WCS; if (ss>=0 && ast_ && ast_[ss]) { - double xx =0; - double yy =0; ostringstream str; if (astWCSIsASkyFrame(ast_[ss])) { setAstWCSSkyFrame(ast_[ss],sky); - wcsTran(ast_[ss], 1, in.v, in.v+1, 1, &xx, &yy); - if (!astOK || !checkWCS(xx,yy)) { + Vector out = wcsTran(ast_[ss], in, 1); + if (!(astOK && checkWCS(out))) { maperr =1; - lbuf[0] = '\0'; return lbuf; } switch (format) { case Coord::DEGREES: - xx =radToDeg(xx); // 0 to 360 - yy *=180./M_PI; - - str << setprecision(8) << xx << ' ' << yy + out.radToDeg(); + str << setprecision(8) << out[0] << ' ' << out[1] << ' ' << coord.skyFrameStr(sky) << ends; break; @@ -3311,7 +3308,7 @@ char* FitsImage::pix2wcs(Vector in, Coord::CoordSystem sys, case Coord::FK4_NO_E: case Coord::FK5: case Coord::ICRS: - xx = zeroTWOPI(xx); + out.zeroTWOPI(); setAstWCSFormat(ast_[ss],1,"hms.3"); setAstWCSFormat(ast_[ss],2,"+dms.3"); break; @@ -3319,24 +3316,25 @@ char* FitsImage::pix2wcs(Vector in, Coord::CoordSystem sys, case Coord::SUPERGALACTIC: case Coord::ECLIPTIC: case Coord::HELIOECLIPTIC: - xx = zeroTWOPI(xx); + out.zeroTWOPI(); setAstWCSFormat(ast_[ss],1,"+dms.3"); setAstWCSFormat(ast_[ss],2,"+dms.3"); break; } - str << astFormat(ast_[ss], 1, xx) << ' ' << astFormat(ast_[ss], 2, yy) - << ' ' << coord.skyFrameStr(sky) << ends; + str << astFormat(ast_[ss],1,out[0]) << ' ' + << astFormat(ast_[ss],2,out[1]) << ' ' + << coord.skyFrameStr(sky) << ends; break; } } else { - wcsTran(ast_[ss], 1, in.v, in.v+1, 1, &xx, &yy); - if (!astOK || !checkWCS(xx,yy)) { - maperr =1; - return lbuf; + Vector out = wcsTran(ast_[ss], in, 1); + if (astOK && checkWCS(out)) + if (!(astOK && checkWCS(out))) { + maperr =1; + return lbuf; } - str << setprecision(8) << xx << ' ' << yy << ends; } strncpy(lbuf, str.str().c_str(), str.str().length()); @@ -3398,8 +3396,9 @@ char* FitsImage::pix2wcs(Vector in, Coord::CoordSystem sys, break; } - str << astFormat(newast_, 1, xx) << ' ' << astFormat(newast_, 2, yy) - << ' ' << coord.skyFrameStr(sky) << ends; + str << astFormat(newast_, 1, xx) << ' ' + << astFormat(newast_, 2, yy) << ' ' + << coord.skyFrameStr(sky) << ends; break; } } diff --git a/tksao/frame/fitsimage.h b/tksao/frame/fitsimage.h index 2765681..ac46c2d 100644 --- a/tksao/frame/fitsimage.h +++ b/tksao/frame/fitsimage.h @@ -365,8 +365,7 @@ class FitsImage { Vector pix2wcs(Vector, Coord::CoordSystem, Coord::SkyFrame); Vector* pix2wcs(Vector*, int, Coord::CoordSystem, Coord::SkyFrame); - char* pix2wcs(Vector, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, - char*); + char* pix2wcs(Vector, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, char*); Vector wcs2pix(Vector, Coord::CoordSystem, Coord::SkyFrame); Vector* wcs2pix(Vector*, int, Coord::CoordSystem, Coord::SkyFrame); diff --git a/tksao/vector/vector.C b/tksao/vector/vector.C index 429fcc0..45832ac 100644 --- a/tksao/vector/vector.C +++ b/tksao/vector/vector.C @@ -45,15 +45,26 @@ Vector& Vector::clip(const BBox& bb) return *this; } -Vector Vector::radToDeg() +Vector& Vector::radToDeg() { // we want the first coord to be 0-360 - return Vector(::radToDeg(v[0]),v[1]*180./M_PI); + v[0] = ::radToDeg(v[0]); + v[1] *= 180./M_PI; + return *this; +} + +Vector& Vector::degToRad() +{ + v[0] *= M_PI/180.; + v[1] *= M_PI/180.; + return *this; } -Vector Vector::degToRad() +Vector& Vector::zeroTWOPI() { - return Vector(v[0]*M_PI/180.,v[1]*M_PI/180.); + // we want the first coord to be 0-2Pi + v[0] = ::zeroTWOPI(v[0]); + return *this; } Vector Vector::TkCanvasPs(void* canvas) diff --git a/tksao/vector/vector.h b/tksao/vector/vector.h index 2f6a90d..55efda8 100644 --- a/tksao/vector/vector.h +++ b/tksao/vector/vector.h @@ -75,8 +75,9 @@ class Vector { Vector normalize() {double d = sqrt(v[0]*v[0]+v[1]*v[1]); return d ? Vector(v[0]/d,v[1]/d) : Vector();} - Vector radToDeg(); - Vector degToRad(); + Vector& radToDeg(); + Vector& degToRad(); + Vector& zeroTWOPI(); // restrict vector by bbox Vector& clip(const BBox&); |