summaryrefslogtreecommitdiffstats
path: root/tksao/frame
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2017-12-07 20:21:34 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2017-12-07 20:21:34 (GMT)
commit8acebcdabd19bc143ba8cf984fef03b6d991fd9f (patch)
treec8dd584fe0da026eca79b233b7a5d4a1e62a393b /tksao/frame
parentb4358f25f3c97148bccba5b52d92008fdced07e4 (diff)
downloadblt-8acebcdabd19bc143ba8cf984fef03b6d991fd9f.zip
blt-8acebcdabd19bc143ba8cf984fef03b6d991fd9f.tar.gz
blt-8acebcdabd19bc143ba8cf984fef03b6d991fd9f.tar.bz2
update AST WCS
Diffstat (limited to 'tksao/frame')
-rw-r--r--tksao/frame/fitsimage.C68
-rw-r--r--tksao/frame/fitsimage.h12
-rw-r--r--tksao/frame/grid25d.C4
-rw-r--r--tksao/frame/grid2d.C4
-rw-r--r--tksao/frame/grid3d.C6
5 files changed, 38 insertions, 56 deletions
diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C
index fdc9614..2ec940f 100644
--- a/tksao/frame/fitsimage.C
+++ b/tksao/frame/fitsimage.C
@@ -107,10 +107,10 @@ FitsImage::FitsImage(Context* cx, Tcl_Interp* pp)
refToImage3d = dataToImage3d;
manageWCS_ =1;
- wcsx_ =NULL;
#ifndef NEWWCS
wcs_ =NULL;
ast_ =NULL;
+ wcsx_ =NULL;
#else
newast_ =NULL;
#endif
@@ -169,13 +169,6 @@ FitsImage::~FitsImage()
delete analysisdata_;
}
- if (wcsx_) {
- for (int ii=0; ii<MULTWCS; ii++)
- if (manageWCS_ && wcsx_[ii])
- delete wcsx_[ii];
- delete [] wcsx_;
- }
-
#ifndef NEWWCS
if (wcs_) {
for (int ii=0; ii<MULTWCSA; ii++)
@@ -190,6 +183,13 @@ FitsImage::~FitsImage()
astAnnul(ast_[ii]);
delete [] ast_;
}
+
+ if (wcsx_) {
+ for (int ii=0; ii<MULTWCS; ii++)
+ if (manageWCS_ && wcsx_[ii])
+ delete wcsx_[ii];
+ delete [] wcsx_;
+ }
#else
if (manageWCS_ && newast_)
astAnnul(newast_);
@@ -1060,17 +1060,6 @@ void FitsImage::iisSetFileName(const char* fn)
void FitsImage::initWCS()
{
- // free up wcs and ast arrays
- if (wcsx_) {
- for (int ii=0; ii<MULTWCS; ii++)
- if (manageWCS_ && wcsx_[ii])
- delete wcsx_[ii];
- delete [] wcsx_;
- }
- wcsx_ = new WCSx*[MULTWCS];
- for (int ii=0; ii<MULTWCS; ii++)
- wcsx_[ii] = NULL;
-
#ifndef NEWWCS
if (wcs_) {
for (int ii=0; ii<MULTWCSA; ii++)
@@ -1091,6 +1080,16 @@ void FitsImage::initWCS()
ast_ = new AstFrameSet*[MULTWCSA];
for (int ii=0; ii<MULTWCSA; ii++)
ast_[ii] = NULL;
+
+ if (wcsx_) {
+ for (int ii=0; ii<MULTWCS; ii++)
+ if (manageWCS_ && wcsx_[ii])
+ delete wcsx_[ii];
+ delete [] wcsx_;
+ }
+ wcsx_ = new WCSx*[MULTWCS];
+ for (int ii=0; ii<MULTWCS; ii++)
+ wcsx_[ii] = NULL;
#else
if (manageWCS_ && newast_)
astAnnul(newast_);
@@ -1108,13 +1107,13 @@ void FitsImage::initWCS()
FitsImage* sptr = ptr->nextSlice();
while (sptr) {
if (sptr == this) {
- for (int ii=0; ii<MULTWCS; ii++)
- wcsx_[ii] = ptr->wcsx_[ii];
#ifndef NEWWCS
for (int ii=0; ii<MULTWCSA; ii++)
wcs_[ii] = ptr->wcs_[ii];
for (int ii=0; ii<MULTWCSA; ii++)
ast_[ii] = ptr->ast_[ii];
+ for (int ii=0; ii<MULTWCS; ii++)
+ wcsx_[ii] = ptr->wcsx_[ii];
#else
newast_ = ptr->newast_;
#endif
@@ -1219,7 +1218,6 @@ void FitsImage::initWCS()
}
}
}
-#endif
// WCSx
char scrpix[] = "CRPIX ";
@@ -1263,9 +1261,7 @@ void FitsImage::initWCS()
}
}
-#ifndef NEWWCS
initWCSPhysical();
-#endif
if (DebugWCS) {
for (int ii=0; ii<MULTWCS; ii++) {
@@ -1281,6 +1277,7 @@ void FitsImage::initWCS()
}
}
}
+#endif
}
#ifndef NEWWCS
@@ -3643,27 +3640,6 @@ int FitsImage::hasWCS3D(Coord::CoordSystem sys)
astEnd; // now, clean up memory
return 0;
}
-
-double FitsImage::pix2wcsx(double in, Coord::CoordSystem sys)
-{
- if (hasWCS3D(sys)) {
- int ss = sys-Coord::WCS;
- return (in-wcsx_[ss]->crpix)*wcsx_[ss]->cd + wcsx_[ss]->crval;
- }
- else
- return in;
-}
-
-double FitsImage::wcs2pixx(double in, Coord::CoordSystem sys)
-{
- if (hasWCS3D(sys)) {
- int ss = sys-Coord::WCS;
- return (in-wcsx_[ss]->crval)/wcsx_[ss]->cd + wcsx_[ss]->crpix;
- }
- else
- return in;
-}
-
#endif
// WCS/AST support
@@ -3933,7 +3909,7 @@ void FitsImage::setWCSSystem(AstFrameSet* ast, Coord::CoordSystem sys)
for (int ss=0; ss<nn; ss++) {
const char* id = astGetC(astGetFrame(ast,ss+1),"Ident");
if (cc == id[0]) {
- astSetI(ast,"current",ss+1);
+ astSetI(ast,"Current",ss+1);
break;
}
}
diff --git a/tksao/frame/fitsimage.h b/tksao/frame/fitsimage.h
index b5ffc17..2181a57 100644
--- a/tksao/frame/fitsimage.h
+++ b/tksao/frame/fitsimage.h
@@ -111,10 +111,10 @@ class FitsImage {
int address[FTY_MAXAXES];
int manageWCS_;
- WCSx** wcsx_; // xth Axis WCS
#ifndef NEWWCS
WorldCoor** wcs_; // wcs list
AstFrameSet** ast_; // ast frameset;
+ WCSx** wcsx_; // xth Axis WCS
#else
AstFrameSet* newast_; // ast frameset;
#endif
@@ -359,7 +359,6 @@ class FitsImage {
int hasDTMV() {return keyDTMV;}
FitsHead* wcsHeader() {return wcsHeader_;}
- WCSx** wcsx() {return wcsx_;}
int isIIS() {return iisMode_;}
Vector& iisz() {return iisz_;}
@@ -369,16 +368,17 @@ class FitsImage {
char* pix2wcs(const Vector&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, char*);
-#ifdef NEWWCS
+#ifndef NEWWCS
+ WCSx** wcsx() {return wcsx_;}
+ double pix2wcsx(double, Coord::CoordSystem);
+ double wcs2pixx(double, Coord::CoordSystem);
+#else
Vector3d pix2wcs(const Vector3d&, Coord::CoordSystem, Coord::SkyFrame);
Vector3d wcs2pix(const Vector3d&, Coord::CoordSystem, Coord::SkyFrame);
char* pix2wcs(const Vector3d&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, char*);
#endif
- double pix2wcsx(double, Coord::CoordSystem);
- double wcs2pixx(double, Coord::CoordSystem);
-
void altWCS(istream&);
void appendWCS(istream&);
void listWCS(ostream&, Coord::CoordSystem);
diff --git a/tksao/frame/grid25d.C b/tksao/frame/grid25d.C
index a495ef4..eb051ca 100644
--- a/tksao/frame/grid25d.C
+++ b/tksao/frame/grid25d.C
@@ -95,9 +95,11 @@ int Grid25d::doit(RenderMode rm)
#endif
// add wcs to frameset
// this will link frameset to wcs with unitMap
+ int id = astGetI(ast,"Current");
+ int nf = astGetI(frameSet,"NFrame");
astInvert(ast);
astAddFrame(frameSet, AST__CURRENT, astUnitMap(2,""), ast);
- astSetI(frameSet,"Current",astGetI(frameSet,"nframe"));
+ astSetI(frameSet,"Current",id+nf);
}
break;
}
diff --git a/tksao/frame/grid2d.C b/tksao/frame/grid2d.C
index 83b5d65..c12014a 100644
--- a/tksao/frame/grid2d.C
+++ b/tksao/frame/grid2d.C
@@ -95,9 +95,11 @@ int Grid2d::doit(RenderMode rm)
#endif
// add wcs to frameset
// this will link frameset to wcs with unitMap
+ int id = astGetI(ast,"Current");
+ int nf = astGetI(frameSet,"NFrame");
astInvert(ast);
astAddFrame(frameSet, AST__CURRENT, astUnitMap(2,""), ast);
- astSetI(frameSet,"Current",astGetI(frameSet,"nframe"));
+ astSetI(frameSet,"Current",id+nf);
}
break;
}
diff --git a/tksao/frame/grid3d.C b/tksao/frame/grid3d.C
index 830ec55..44e3b8b 100644
--- a/tksao/frame/grid3d.C
+++ b/tksao/frame/grid3d.C
@@ -153,9 +153,11 @@ int Grid3d::doit(RenderMode rm)
#endif
// add wcs to frameset
// this will link frameset to wcs with unitMap
+ int id = astGetI(ast,"Current");
+ int nf = astGetI(frameSet,"NFrame");
astInvert(ast);
- astAddFrame(frameSet, AST__CURRENT, astUnitMap(3,""), ast);
- astSetI(frameSet,"Current",astGetI(frameSet,"nframe"));
+ astAddFrame(frameSet, AST__CURRENT, astUnitMap(2,""), ast);
+ astSetI(frameSet,"Current",id+nf);
}
}