summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-07-25 17:27:37 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-07-25 17:27:37 (GMT)
commit8a8d15275a15fbdb49d7877b4461697820a2b020 (patch)
tree9c74f12e8f5d3434578b9e942a5d47612da71b53
parentdbbc1d6983d6e55754ff8cd125945ad86e4b8855 (diff)
downloadblt-8a8d15275a15fbdb49d7877b4461697820a2b020.zip
blt-8a8d15275a15fbdb49d7877b4461697820a2b020.tar.gz
blt-8a8d15275a15fbdb49d7877b4461697820a2b020.tar.bz2
update new wcs template
-rw-r--r--tksao/frame/fitsimage.C97
-rw-r--r--tksao/frame/fitsimage.h9
2 files changed, 76 insertions, 30 deletions
diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C
index 4bc32b6..5fc3f3c 100644
--- a/tksao/frame/fitsimage.C
+++ b/tksao/frame/fitsimage.C
@@ -113,12 +113,18 @@ FitsImage::FitsImage(Context* cx, Tcl_Interp* pp)
wcsx_ =NULL;
#else
ast_ =NULL;
- astSav_ =NULL;
astInv_ =0;
wcs_ =NULL;
wcsCel_ =NULL;
wcs3D_ =NULL;
wcsHPX_ =0;
+
+ astSav_ =NULL;
+ astInvSav_ =0;
+ wcsSav_ =NULL;
+ wcsCelSav_ =NULL;
+ wcs3DSav_ =NULL;
+ wcsHPXSav_ =0;
#endif
wcsHeader_ =NULL;
altHeader_ =NULL;
@@ -1367,20 +1373,26 @@ void FitsImage::initWCS0(const Vector& pix)
}
}
}
+
+void FitsImage::resetWCS0()
+{
+ int ii = Coord::WCS0-Coord::WCS;
+ if (wcs_[ii])
+ wcsfree(wcs_[ii]);
+ wcs_[ii] = NULL;
+
+ if (ast_[ii])
+ astAnnul(ast_[ii]);
+ ast_[ii] = NULL;
+}
+
#else
+
void FitsImage::initWCS0(const Vector& pix)
{
if (!ast_)
return;
- FitsHead* hd =NULL;
- if (wcsHeader_)
- hd = wcsHeader_;
- else if (altHeader_)
- hd = altHeader_;
- else
- hd = image_->head();
-
// read wcs struct into astChannel
// we may have an error, just reset
astClearStatus;
@@ -1448,8 +1460,29 @@ void FitsImage::initWCS0(const Vector& pix)
strncmp(astGetC(frameSet,"Class"), "FrameSet", 8))
return;
+ // save current wcs
astSav_ = ast_;
+ astInvSav_ = astInv_;
+ wcsSav_ = wcs_;
+ wcsCelSav_ = wcsCel_;
+ wcs3DSav_ = wcs3D_;
+ wcsHPXSav_ = wcsHPX_;
+
+ // set up temp wcs
ast_ = frameSet;
+ astInv_ = 1;
+ wcs_ = new int[MULTWCS];
+ for (int ii=0; ii<MULTWCS; ii++)
+ wcs_[ii] =0;
+ wcs_[0] =1;
+ wcsCel_ = new int[MULTWCS];
+ for (int ii=0; ii<MULTWCS; ii++)
+ wcsCel_[ii] =0;
+ wcsCel_[0] = 1;
+ wcs3D_ = new int[MULTWCS];
+ for (int ii=0; ii<MULTWCS; ii++)
+ wcs3D_[ii] =0;
+ wcsHPX_ = 0;
if (DebugWCS)
astShow(frameSet);
@@ -1457,6 +1490,32 @@ void FitsImage::initWCS0(const Vector& pix)
// cleanup
astAnnul(chan);
}
+
+void FitsImage::resetWCS0()
+{
+ if (wcs_)
+ delete [] wcs_;
+ if (wcsCel_)
+ delete [] wcsCel_;
+ if (wcs3D_)
+ delete [] wcs3D_;
+
+ // restore current wcs
+ ast_ = astSav_;
+ astInv_ = astInvSav_;
+ wcs_ = wcsSav_;
+ wcsCel_ = wcsCelSav_;
+ wcs3D_ = wcs3DSav_;
+ wcsHPX_ = wcsHPXSav_;
+
+ // reset temp wcs
+ astSav_ =NULL;
+ astInvSav_ =0;
+ wcsSav_ =NULL;
+ wcsCelSav_ =NULL;
+ wcs3DSav_ =NULL;
+ wcsHPXSav_ =0;
+}
#endif
#ifdef OLDWCS
@@ -2483,26 +2542,6 @@ void FitsImage::resetWCS()
image_->primary() && image_->inherit() ? image_->primary() : NULL);
}
-#ifdef OLDWCS
-void FitsImage::resetWCS0()
-{
- int ii = Coord::WCS0-Coord::WCS;
- if (wcs_[ii])
- wcsfree(wcs_[ii]);
- wcs_[ii] = NULL;
-
- if (ast_[ii])
- astAnnul(ast_[ii]);
- ast_[ii] = NULL;
-}
-#else
-void FitsImage::resetWCS0()
-{
- ast_ = astSav_;
- astSav_ =NULL;
-}
-#endif
-
char* FitsImage::root(const char* fn)
{
if (fn) {
diff --git a/tksao/frame/fitsimage.h b/tksao/frame/fitsimage.h
index bae04f2..781a9c2 100644
--- a/tksao/frame/fitsimage.h
+++ b/tksao/frame/fitsimage.h
@@ -120,6 +120,14 @@ class FitsImage {
int* wcsCel_;
int* wcs3D_;
int wcsHPX_;
+
+ // used for templates
+ AstFrameSet* astSav_;
+ int astInvSav_;
+ int* wcsSav_;
+ int* wcsCelSav_;
+ int* wcs3DSav_;
+ int wcsHPXSav_;
#endif
FitsHead* wcsHeader_; // alt wcs header
FitsHead* altHeader_; // wcs header for wfpc2
@@ -131,7 +139,6 @@ class FitsImage {
AstFrameSet** ast_; // ast frameset;
#else
AstFrameSet* ast_; // ast frameset;
- AstFrameSet* astSav_; // ast frameset;
#endif
private: