summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-07-27 18:51:39 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-07-27 18:51:39 (GMT)
commit441ca548972a90b4495c9602214afaec13c6380d (patch)
treecb73e9a850398841659fd599db3c9518e3ecb8b1
parentcf5a14e2056c195269bc1eefa7553f7389aa13cf (diff)
downloadblt-441ca548972a90b4495c9602214afaec13c6380d.zip
blt-441ca548972a90b4495c9602214afaec13c6380d.tar.gz
blt-441ca548972a90b4495c9602214afaec13c6380d.tar.bz2
simplify mapLen code
-rw-r--r--tksao/frame/fitsmap.C115
-rw-r--r--tksao/frame/frmap.C44
-rw-r--r--tksao/util/util.C2
-rw-r--r--tksao/util/util.h3
4 files changed, 15 insertions, 149 deletions
diff --git a/tksao/frame/fitsmap.C b/tksao/frame/fitsmap.C
index 17352f1..3c5f052 100644
--- a/tksao/frame/fitsmap.C
+++ b/tksao/frame/fitsmap.C
@@ -143,18 +143,16 @@ void FitsImage::listFromRef(ostream& str, const Vector& vv,
// Map Length
-#ifdef OLDWCS
double FitsImage::mapLenFromRef(double dd, Coord::CoordSystem sys,
Coord::DistFormat dist)
{
- Vector rr = mapLenFromRef(Vector(dd,0),sys,dist);
- return rr[0];
+ Vector rr = mapLenFromRef(Vector(0,dd),sys,dist);
+ return rr[1];
}
Vector FitsImage::mapLenFromRef(const Vector& vv, Coord::CoordSystem sys,
Coord::DistFormat dist)
{
- // really from image coords
switch (sys) {
case Coord::IMAGE:
return mapLen(vv,refToImage);
@@ -166,10 +164,13 @@ Vector FitsImage::mapLenFromRef(const Vector& vv, Coord::CoordSystem sys,
return mapLen(vv,refToPhysical * physicalToDetector);
default:
if (hasWCS(sys)) {
+#ifdef OLDWCS
Vector cd = getWCScdelt(sys);
Vector in = mapLen(vv,refToImage);
Vector out = Vector(in[0]*cd[0], in[1]*cd[1]).abs();
-
+#else
+ Vector out = vv*getWCSSize(sys);
+#endif
if (hasWCSCel(sys)) {
switch (dist) {
case Coord::DEGREE:
@@ -188,64 +189,6 @@ Vector FitsImage::mapLenFromRef(const Vector& vv, Coord::CoordSystem sys,
return Vector();
}
-#else
-double FitsImage::mapLenFromRef(double dd, Coord::CoordSystem sys,
- Coord::DistFormat dist)
-{
- // really from image coords
- switch (sys) {
- case Coord::IMAGE:
- return dd*refToImage[1].length();
- case Coord::PHYSICAL:
- return dd*refToPhysical[1].length();
- case Coord::AMPLIFIER:
- return dd*(refToPhysical * physicalToAmplifier)[1].length();
- case Coord::DETECTOR:
- return dd*(refToPhysical * physicalToDetector)[1].length();
- default:
- {
- astClearStatus; // just to make sure
-
- if (!hasWCS(sys))
- return 0;
-
- setWCSSkyFrame(sys, Coord::FK5);
-
- Vector in[2];
- Vector out[2];
- in[0] = center();
- in[1] = center()+Vector(0,dd);
- wcsTran(2, in, 1, out);
- double rr = wcsDistance(out[0], out[1]);
-
- if (hasWCSCel(sys)) {
- rr = radToDeg(rr);
- switch (dist) {
- case Coord::DEGREE:
- break;
- case Coord::ARCMIN:
- rr *= 60.;
- break;
- case Coord::ARCSEC:
- rr *= 60.*60.;
- break;
- }
- }
- return rr;
- }
- }
-
- 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
double FitsImage::mapLenToRef(double dd, Coord::CoordSystem sys,
Coord::DistFormat dist)
@@ -254,7 +197,6 @@ double FitsImage::mapLenToRef(double dd, Coord::CoordSystem sys,
return rr[1];
}
-#ifdef OLDWCS
Vector FitsImage::mapLenToRef(const Vector& vv, Coord::CoordSystem sys,
Coord::DistFormat dist)
{
@@ -269,10 +211,13 @@ Vector FitsImage::mapLenToRef(const Vector& vv, Coord::CoordSystem sys,
return mapLen(vv,detectorToPhysical * physicalToRef);
default:
if (hasWCS(sys)) {
+#ifdef OLDWCS
Vector cd = getWCScdelt(sys);
Vector in = mapLen(vv,refToImage);
Vector out = Vector(in[0]/cd[0], in[1]/cd[1]).abs();
-
+#else
+ Vector out = vv/getWCSSize(sys);
+#endif
if (hasWCSCel(sys)) {
switch (dist) {
case Coord::DEGREE:
@@ -291,46 +236,6 @@ Vector FitsImage::mapLenToRef(const Vector& vv, Coord::CoordSystem sys,
return Vector();
}
-#else
-Vector FitsImage::mapLenToRef(const Vector& vv, Coord::CoordSystem sys,
- Coord::DistFormat dist)
-{
- // this is correct
- // we are looking for a length, so in image coords
- switch (sys) {
- case Coord::IMAGE:
- return vv;
- case Coord::PHYSICAL:
- return vv*physicalToImage;
- case Coord::AMPLIFIER:
- return vv*amplifierToPhysical*physicalToImage;
- case Coord::DETECTOR:
- return vv*detectorToPhysical*physicalToImage;
- default:
- {
- if (!hasWCS(sys) || !astInv_)
- return 0;
-
- Vector svv = vv;
- if (hasWCSCel(sys)) {
- switch (dist) {
- case Coord::DEGREE:
- break;
- case Coord::ARCMIN:
- svv /= 60.;
- break;
- case Coord::ARCSEC:
- svv /= 60.*60.;
- break;
- }
- }
- return svv/getWCSSize(sys);
- }
- }
-
- return Vector();
-}
-#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 cf1047c..3c8867b 100644
--- a/tksao/frame/frmap.C
+++ b/tksao/frame/frmap.C
@@ -64,57 +64,23 @@ double Base::mapAngleToRef(double angle, Coord::CoordSystem sys,
return zeroTWOPI(rr);
}
-#ifdef OLDWCS
-double Base::mapLenToRef(double d, Coord::InternalSystem sys)
-{
- Vector r = mapLenToRef(Vector(d,0),sys);
- return r[0];
-}
-
-Vector Base::mapLenToRef(const Vector& v, Coord::InternalSystem sys)
-{
- switch (sys) {
- case Coord::CANVAS:
- return mapLen(v,canvasToRef);
- case Coord::PANNER:
- return mapLen(v,pannerToRef);
- default:
- 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 rr = mapLenToRef(Vector(0,dd),sys);
+ return rr[1];
}
-Vector Base::mapLenToRef(const Vector& v, Coord::InternalSystem sys)
+Vector Base::mapLenToRef(const Vector& vv, 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);
- }
+ return mapLen(vv,canvasToRef);
case Coord::PANNER:
- {
- double rx = ((Vector)v)[0]*pannerToRef[0].length();
- double ry = ((Vector)v)[1]*pannerToRef[1].length();
- return Vector(rx,ry);
- }
+ return mapLen(vv,pannerToRef);
default:
return Vector();
}
}
-#endif
Vector FrameBase::mapFromRef(const Vector& vv, Coord::InternalSystem sys)
{
diff --git a/tksao/util/util.C b/tksao/util/util.C
index ebcd746..9351adb 100644
--- a/tksao/util/util.C
+++ b/tksao/util/util.C
@@ -520,7 +520,6 @@ int dCompare(const void* a, const void* b)
return 0;
}
-#ifndef NEWWCS
Vector mapLen(const Vector& v, const Matrix& mx)
{
// remove translation
@@ -534,7 +533,6 @@ Vector mapLen(const Vector& v, const Matrix& mx)
// all that is left is Scaling
return (v*s).abs();
}
-#endif
#if defined (MAC_OSX_TK) || (_WIN32)
diff --git a/tksao/util/util.h b/tksao/util/util.h
index 9eeb436..dc1d6bf 100644
--- a/tksao/util/util.h
+++ b/tksao/util/util.h
@@ -131,8 +131,5 @@ extern const char* psFontName(const char*, const char*, const char*);
extern int fCompare(const void*, const void*);
extern int dCompare(const void*, const void*);
-#ifndef NEWWCS
extern Vector mapLen(const Vector& v, const Matrix& mx);
#endif
-
-#endif