From e3865e3d9c9be3bd8d18ec8d41add99a4b162ff4 Mon Sep 17 00:00:00 2001 From: William Joye Date: Mon, 4 Dec 2017 11:50:59 -0500 Subject: update AST WCS --- tksao/frame/basecommand.C | 23 +++++++++++------------ tksao/frame/fitsimage.h | 2 ++ tksao/frame/fitsmap.C | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/tksao/frame/basecommand.C b/tksao/frame/basecommand.C index e39c90d..ace162e 100644 --- a/tksao/frame/basecommand.C +++ b/tksao/frame/basecommand.C @@ -567,9 +567,9 @@ void Base::crop3dCmd(double z0, double z1, Coord::CoordSystem sys) if (!ptr) return; - // ff/tt ranges 0-n - double ff = ptr->mapToRef3axis(z0,sys); - double tt = ptr->mapToRef3axis(z1,sys); + // ff/tt in data coords + double ff = ptr->mapToImage3axis(z0,sys)-.5; + double tt = ptr->mapToImage3axis(z1,sys)-.5; // params is a BBOX in DATA coords 0-n currentContext->setCrop3dParams(ff-.5,tt+.5); @@ -1384,9 +1384,10 @@ void Base::getCoord3axisCmd(double vv, Coord::CoordSystem in, printDouble(vv); else { // use first slice - double rr = currentContext->fits->mapToRef3axis(vv,in); - double tt = currentContext->fits->mapFromRef3axis(rr,out); - printDouble(tt); + if (out == Coord::IMAGE) + printDouble(currentContext->fits->mapToImage3axis(vv,in)); + else + printDouble(currentContext->fits->mapFromImage3axis(vv,out)); } } else @@ -1440,8 +1441,8 @@ void Base::getCrop3dCmd(Coord::CoordSystem sys) FitsZBound* zparams = currentContext->getDataParams(currentContext->secMode()); - double ff = ptr->mapFromRef3axis(zparams->zmin+.5,sys); - double tt = ptr->mapFromRef3axis(zparams->zmax-.5,sys); + double ff = ptr->mapFromImage3axis(zparams->zmin+.5+.5,sys); + double tt = ptr->mapFromImage3axis(zparams->zmax-.5+.5,sys); ostringstream str; str << ff << ' ' << tt << ends; @@ -1793,8 +1794,7 @@ void Base::getFitsSliceCmd(int id, Coord::CoordSystem sys) { if (currentContext->fits) { int ss = currentContext->slice(id); - double rr = currentContext->fits->mapFromRef3axis(ss,sys); - printDouble(rr); + printDouble(currentContext->fits->mapFromImage3axis(ss,sys)); } else Tcl_AppendResult(interp, "1", NULL); @@ -2826,8 +2826,7 @@ void Base::sliceCmd(int id, int ss) void Base::sliceCmd(int id, double vv, Coord::CoordSystem sys) { - double rr = currentContext->fits->mapToRef3axis(vv,sys); - int ss = currentContext->fits->mapFromRef3axis(rr,Coord::IMAGE); + int ss = currentContext->fits->mapToImage3axis(vv,sys); // IMAGE (ranges 1-n) setSlice(id,ss); diff --git a/tksao/frame/fitsimage.h b/tksao/frame/fitsimage.h index b7713bd..14333fc 100644 --- a/tksao/frame/fitsimage.h +++ b/tksao/frame/fitsimage.h @@ -458,6 +458,8 @@ class FitsImage { #endif double mapFromRef3axis(double, Coord::CoordSystem); double mapToRef3axis(double, Coord::CoordSystem); + double mapFromImage3axis(double, Coord::CoordSystem); + double mapToImage3axis(double, Coord::CoordSystem); double mapLenFromRef(double, Coord::CoordSystem, Coord::DistFormat =Coord::DEGREE); Vector mapLenFromRef(const Vector&, Coord::CoordSystem, Coord::DistFormat =Coord::DEGREE); double mapLenToRef(double, Coord::CoordSystem, Coord::DistFormat =Coord::DEGREE); diff --git a/tksao/frame/fitsmap.C b/tksao/frame/fitsmap.C index 17d2369..f75a54c 100644 --- a/tksao/frame/fitsmap.C +++ b/tksao/frame/fitsmap.C @@ -543,3 +543,19 @@ double FitsImage::mapToRef3axis(double vv, Coord::CoordSystem in) return wcs2pixx(vv,in) -.5; } } + +double FitsImage::mapFromImage3axis(double vv, Coord::CoordSystem sys) +{ + if (sys >= Coord::WCS) + return pix2wcsx(vv,sys); + else + return vv; +} + +double FitsImage::mapToImage3axis(double vv, Coord::CoordSystem sys) +{ + if (sys >= Coord::WCS) + return wcs2pixx(vv,sys); + else + return vv; +} -- cgit v0.12