summaryrefslogtreecommitdiffstats
path: root/tksao/frame
diff options
context:
space:
mode:
Diffstat (limited to 'tksao/frame')
-rw-r--r--tksao/frame/fitsimage.C1
-rw-r--r--tksao/frame/fitsmap.C176
-rw-r--r--tksao/frame/frmap.C34
3 files changed, 163 insertions, 48 deletions
diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C
index 78460b7..ae73e0e 100644
--- a/tksao/frame/fitsimage.C
+++ b/tksao/frame/fitsimage.C
@@ -2951,6 +2951,7 @@ Coord::Orientation FitsImage::getWCSOrientation(Coord::CoordSystem sys,
else
rr = ang<0 ? Coord::NORMAL : Coord::XX;
}
+
astEnd; // now, clean up memory
return rr;
}
diff --git a/tksao/frame/fitsmap.C b/tksao/frame/fitsmap.C
index 7b1a2d1..1dfcb8f 100644
--- a/tksao/frame/fitsmap.C
+++ b/tksao/frame/fitsmap.C
@@ -107,6 +107,7 @@ void FitsImage::listFromRef(ostream& str, const Vector& vv,
// Map Length
+#ifndef NEWWCS
double FitsImage::mapLenFromRef(double dd, Coord::CoordSystem sys,
Coord::DistFormat dist)
{
@@ -114,7 +115,6 @@ double FitsImage::mapLenFromRef(double dd, Coord::CoordSystem sys,
return rr[0];
}
-#ifndef NEWWCS
Vector FitsImage::mapLenFromRef(const Vector& vv, Coord::CoordSystem sys,
Coord::DistFormat dist)
{
@@ -154,72 +154,77 @@ Vector FitsImage::mapLenFromRef(const Vector& vv, Coord::CoordSystem sys,
return Vector();
}
#else
-Vector FitsImage::mapLenFromRef(const Vector& in, Coord::CoordSystem sys,
+double FitsImage::mapLenFromRef(double dd, Coord::CoordSystem sys,
Coord::DistFormat dist)
{
- Vector vv = in;
// really from image coords
switch (sys) {
case Coord::IMAGE:
- return mapLen(vv,refToImage);
+ return dd*refToImage[1].length();
case Coord::PHYSICAL:
- return mapLen(vv,refToPhysical);
+ return dd*refToPhysical[1].length();
case Coord::AMPLIFIER:
- return mapLen(vv,refToPhysical * physicalToAmplifier);
+ return dd*(refToPhysical * physicalToAmplifier)[1].length();
case Coord::DETECTOR:
- return mapLen(vv,refToPhysical * physicalToDetector);
+ return dd*(refToPhysical * physicalToDetector)[1].length();
default:
- if (hasWCS(sys)) {
+ {
int ss = sys-Coord::WCS;
- Vector out;
- Vector cc = center();
- double xx[3], wxx[3];
- xx[0] = cc[0];
- xx[1] = cc[0]+vv[0];
- xx[2] = cc[0];
- double yy[3], wyy[3];
- yy[0] = cc[1];
- yy[1] = cc[1];
- yy[2] = cc[1]+vv[1];
- astTran2(ast_[ss],3,xx,yy,1,wxx,wyy);
-
- double pt0[2];
- pt0[0] = wxx[0];
- pt0[1] = wyy[0];
- double pt1[2];
- pt1[0] = wxx[1];
- pt1[1] = wyy[1];
- double pt2[2];
- pt2[0] = wxx[2];
- pt2[1] = wyy[2];
- double rr1 = astDistance(ast_[ss],pt0,pt1);
- double rr2 = astDistance(ast_[ss],pt0,pt2);
-
- if (astIsASkyFrame(astGetFrame(ast_[ss], AST__CURRENT))) {
- out = Vector(radToDeg(rr1),radToDeg(rr2));
- switch (dist) {
- case Coord::DEGREE:
- break;
- case Coord::ARCMIN:
- out *= 60.;
- break;
- case Coord::ARCSEC:
- out *= 60.*60.;
- break;
+ if (sys>=Coord::WCS && ast_ && ast_[ss]) {
+ astClearStatus; // just to make sure
+ astBegin; // start memory management
+
+ Vector cc = center();
+ double xx[2], wxx[2];
+ xx[0] = cc[0];
+ xx[1] = cc[0];
+ double yy[2], wyy[2];
+ yy[0] = cc[1];
+ yy[1] = cc[1]+dd;
+ astTran2(ast_[ss],2,xx,yy,1,wxx,wyy);
+
+ double pt0[2];
+ pt0[0] = wxx[0];
+ pt0[1] = wyy[0];
+ double pt1[2];
+ pt1[0] = wxx[1];
+ pt1[1] = wyy[1];
+ double out = astDistance(ast_[ss],pt0,pt1);
+
+ if (astIsASkyFrame(astGetFrame(ast_[ss], AST__CURRENT))) {
+ out = radToDeg(out);
+ switch (dist) {
+ case Coord::DEGREE:
+ break;
+ case Coord::ARCMIN:
+ out *= 60.;
+ break;
+ case Coord::ARCSEC:
+ out *= 60.*60.;
+ break;
+ }
}
- }
- else
- out = Vector(rr1,rr2);
- return out;
+ astEnd; // now, clean up memory
+ return out;
+ }
}
}
maperr =1;
- return Vector();
+ return 0;
+}
+
+Vector FitsImage::mapLenFromRef(const Vector& vv, Coord::CoordSystem sys,
+ Coord::DistFormat dist)
+{
+ double rx = mapLenFromRef(((Vector)vv)[0],sys,dist);
+ double ry = mapLenFromRef(((Vector)vv)[1],sys,dist);
+ return Vector(rx,ry);
}
#endif
+#ifndef NEWWCS
double FitsImage::mapLenToRef(double dd, Coord::CoordSystem sys,
Coord::DistFormat dist)
{
@@ -264,6 +269,81 @@ Vector FitsImage::mapLenToRef(const Vector& vv, Coord::CoordSystem sys,
maperr =1;
return Vector();
}
+#else
+double FitsImage::mapLenToRef(double dd, Coord::CoordSystem sys,
+ Coord::DistFormat dist)
+{
+ switch (sys) {
+ case Coord::IMAGE:
+ return dd*imageToRef[1].length();
+ case Coord::PHYSICAL:
+ return dd*physicalToRef[1].length();
+ case Coord::AMPLIFIER:
+ return dd*(amplifierToPhysical * physicalToRef)[1].length();
+ case Coord::DETECTOR:
+ return dd*(detectorToPhysical * physicalToRef)[1].length();
+ default:
+ {
+ int ss = sys-Coord::WCS;
+ if (sys>=Coord::WCS && ast_ && ast_[ss]) {
+ astClearStatus; // just to make sure
+ astBegin; // start memory management
+
+ if (astIsASkyFrame(astGetFrame(ast_[ss], AST__CURRENT))) {
+ dd = degToRad(dd);
+ switch (dist) {
+ case Coord::DEGREE:
+ break;
+ case Coord::ARCMIN:
+ dd /= 60.;
+ break;
+ case Coord::ARCSEC:
+ dd /= 60.*60.;
+ break;
+ }
+ }
+
+ Vector cc = center();
+ Vector wcc;
+ astTran2(ast_[ss],1,cc.v,cc.v+1,1,wcc.v,wcc.v+1);
+
+ double wxx[2], xx[2];
+ wxx[0] = wcc[0];
+ wxx[1] = wcc[0];
+ double wyy[2], yy[2];
+ wyy[0] = wcc[1];
+ wyy[1] = wcc[1]+dd;
+ astTran2(ast_[ss],2,wxx,wyy,0,xx,yy);
+
+ double pt0[2];
+ pt0[0] = xx[0];
+ pt0[1] = yy[0];
+ double pt1[2];
+ pt1[0] = xx[1];
+ pt1[1] = yy[1];
+
+ astInvert(ast_[ss]);
+ double out = astDistance(ast_[ss],pt0,pt1);
+ astInvert(ast_[ss]);
+ astEnd; // now, clean up memory
+
+ return out;
+ }
+ }
+ }
+
+ maperr =1;
+ return 0;
+}
+
+Vector FitsImage::mapLenToRef(const Vector& vv, Coord::CoordSystem sys,
+ Coord::DistFormat dist)
+{
+ double rx = mapLenToRef(((Vector)vv)[0],sys,dist);
+ double ry = mapLenToRef(((Vector)vv)[1],sys,dist);
+ return Vector(rx,ry);
+}
+#endif
void FitsImage::listLenFromRef(ostream& str, double dd,
Coord::CoordSystem sys, Coord::DistFormat dist)
diff --git a/tksao/frame/frmap.C b/tksao/frame/frmap.C
index 7a8f537..9feec03 100644
--- a/tksao/frame/frmap.C
+++ b/tksao/frame/frmap.C
@@ -50,6 +50,7 @@ double Base::mapAngleToRef(double angle, Coord::CoordSystem sys,
return zeroTWOPI(rr);
}
+#ifndef NEWWCS
double Base::mapLenToRef(double d, Coord::InternalSystem sys)
{
Vector r = mapLenToRef(Vector(d,0),sys);
@@ -67,6 +68,39 @@ Vector Base::mapLenToRef(const Vector& v, Coord::InternalSystem sys)
return Vector();
}
}
+#else
+double Base::mapLenToRef(double dd, Coord::InternalSystem sys)
+{
+ switch (sys) {
+ case Coord::CANVAS:
+ return dd*canvasToRef[1].length();
+ case Coord::PANNER:
+ return dd*pannerToRef[1].length();
+ default:
+ return 0;
+ }
+}
+
+Vector Base::mapLenToRef(const Vector& v, Coord::InternalSystem sys)
+{
+ switch (sys) {
+ case Coord::CANVAS:
+ {
+ double rx = ((Vector)v)[0]*canvasToRef[0].length();
+ double ry = ((Vector)v)[1]*canvasToRef[1].length();
+ return Vector(rx,ry);
+ }
+ case Coord::PANNER:
+ {
+ double rx = ((Vector)v)[0]*pannerToRef[0].length();
+ double ry = ((Vector)v)[1]*pannerToRef[1].length();
+ return Vector(rx,ry);
+ }
+ default:
+ return Vector();
+ }
+}
+#endif
Vector FrameBase::mapFromRef(const Vector& vv, Coord::InternalSystem sys)
{