From 0ae906abc35c3c8616800f3cd2ef2ac280459e40 Mon Sep 17 00:00:00 2001 From: William Joye Date: Tue, 28 Aug 2018 15:20:36 -0400 Subject: fix issues with HPX --- tksao/frame/base.C | 6 +- tksao/frame/fitsimage.C | 156 ++++++++++++++++++------------------------------ tksao/frame/fitsimage.h | 7 +-- tksao/frame/framebase.C | 8 ++- tksao/frame/grid25d.C | 3 +- tksao/frame/grid2d.C | 3 +- tksao/frame/grid3d.C | 3 +- 7 files changed, 77 insertions(+), 109 deletions(-) diff --git a/tksao/frame/base.C b/tksao/frame/base.C index df69044..c02fa6f 100644 --- a/tksao/frame/base.C +++ b/tksao/frame/base.C @@ -390,12 +390,14 @@ Matrix Base::calcAlignWCS(FitsImage* fits1, FitsImage* fits2, AstFrameSet* wcs1 = (AstFrameSet*)astCopy(fits1->ast_); wcsSystem(wcs1,sys1); - wcsSkyFrame(wcs1,sky); + if (!fits1->hasWCSHPX()) + wcsSkyFrame(wcs1,sky); astInvert(wcs1); AstFrameSet* wcs2 = (AstFrameSet*)astCopy(fits2->ast_); wcsSystem(wcs2,sys2); - wcsSkyFrame(wcs2,sky); + if (!fits2->hasWCSHPX()) + wcsSkyFrame(wcs2,sky); astInvert(wcs2); AstFrameSet* cvt = (AstFrameSet*)astConvert(wcs2, wcs1, ""); diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C index 7031403..0ac4dae 100644 --- a/tksao/frame/fitsimage.C +++ b/tksao/frame/fitsimage.C @@ -1048,9 +1048,6 @@ void FitsImage::initWCS(FitsHead* hd) if (wcs_) delete [] wcs_; wcs_ =NULL; - if (wcs_) - delete [] wcs_; - wcs_ =NULL; if (wcsNaxes_) delete [] wcsNaxes_; wcsNaxes_ =NULL; @@ -1109,8 +1106,6 @@ void FitsImage::initWCS(FitsHead* hd) } } - int hasWCSAST = hd->find("BEGAST_A") ? 1 : 0; - if (ast_) astAnnul(ast_); ast_ =NULL; @@ -1127,22 +1122,25 @@ void FitsImage::initWCS(FitsHead* hd) astPermAxes(ast_,orr); } - wcsInit(hasWCSAST); - wcsCelInit(hasWCSAST); - wcsHPXInit(); + scanWCS(hd); // init wcsState if (wcsState_) delete wcsState_; wcsState_ = new WCSState(); + // need wcsHPX_ astBegin; wcsSystem(ast_,wcsState_->wcsSystem_); - wcsSkyFrame(ast_,wcsState_->wcsSkyFrame_); + if (!wcsHPX_) + wcsSkyFrame(ast_,wcsState_->wcsSkyFrame_); astEnd; // must wait until wcsState_ is realized - wcsSizeInit(); + wcsSize_ = new double[MULTWCS]; + for (int ii=0; ii2) ? 1 : 0; } -void FitsImage::wcsInit(int hasWCSAST) +void FitsImage::scanWCS(FitsHead* hd) { // init wcs_ array - if (wcs_) - delete [] wcs_; - wcs_ =NULL; - wcs_ = new int[MULTWCS]; for (int ii=0; iigetKeyword(key); + if (str) { + if (!strncmp(str+5,"HPX",3)) + wcsHPX_ =1; + delete [] str; + } + } + + int hasWCSAST = hd->find("BEGAST_A") ? 1 : 0; + astClearStatus; astBegin; - int nn = astGetI(ast_, "Nframe"); - // do we have a AST wcs? - if (hasWCSAST) { + // since we have ast_ + wcs_[0] =1; + wcsNaxes_[0] = astGetI(ast_,"Naxes"); + + if (!hasWCSAST && !wcsHPX_) { + // fill out wcs_ array + int nn = astGetI(ast_, "Nframe"); + for (int ii=0; iigetKeyword(key); - if (str) { - if (!strncmp(str+5,"HPX",3)) - wcsHPX_ =1; - delete [] str; - } - } -} - -void FitsImage::wcsSizeInit() -{ - // init wcsSize_ array - if (wcsSize_) - delete [] wcsSize_; - wcsSize_ =NULL; - - wcsSize_ = new double[MULTWCS]; - for (int ii=0; iiwcsSkyFrame_ != sky) { wcsSkyFrame(ast_,sky); wcsState_->wcsSkyFrame_ = sky; diff --git a/tksao/frame/fitsimage.h b/tksao/frame/fitsimage.h index 0d24152..2423e87 100644 --- a/tksao/frame/fitsimage.h +++ b/tksao/frame/fitsimage.h @@ -147,11 +147,7 @@ class FitsImage { void initHPX(); void initWCS(FitsHead*); - - void wcsInit(int); - void wcsCelInit(int); - void wcsHPXInit(); - void wcsSizeInit(); + void scanWCS(FitsHead*); void wcsPhyInit(); void initWCS0(const Vector&); @@ -433,6 +429,7 @@ class FitsImage { int hasWCSCel(Coord::CoordSystem); int hasWCSLinear(Coord::CoordSystem); int hasWCS3D(Coord::CoordSystem); + int hasWCSHPX() {return wcsHPX_;} void updateMatrices(Matrix&, Matrix&, Matrix&, Matrix&, Matrix&); void updateMatrices(Matrix3d&, Matrix3d&, Matrix3d&, Matrix3d&); diff --git a/tksao/frame/framebase.C b/tksao/frame/framebase.C index 3623f3f..6acfdb8 100644 --- a/tksao/frame/framebase.C +++ b/tksao/frame/framebase.C @@ -160,8 +160,12 @@ void FrameBase::getInfoWCS(char* var, Vector& rr, FitsImage* sptr) char* system = (char*)sptr->getWCSSystem(www); char* domain = (char*)sptr->getWCSDomain(www); - if (system) - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),system,0); + if (system) { + if (!strncmp(system,"Unknown",7)) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),"WCS",0); + else + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),system,0); + } else if (domain) Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),domain,0); else diff --git a/tksao/frame/grid25d.C b/tksao/frame/grid25d.C index 0fa8a2d..2e623ec 100644 --- a/tksao/frame/grid25d.C +++ b/tksao/frame/grid25d.C @@ -62,7 +62,8 @@ int Grid25d::doit(RenderMode rm) AstFrameSet* ast = (AstFrameSet*)astCopy(fits->ast_); wcsSystem(ast,system_); - wcsSkyFrame(ast,sky_); + if (!fits->hasWCSHPX()) + wcsSkyFrame(ast,sky_); int naxes = astGetI(ast,"Naxes"); switch (naxes) { diff --git a/tksao/frame/grid2d.C b/tksao/frame/grid2d.C index e6c4d02..65a363a 100644 --- a/tksao/frame/grid2d.C +++ b/tksao/frame/grid2d.C @@ -63,7 +63,8 @@ int Grid2d::doit(RenderMode rm) AstFrameSet* ast = (AstFrameSet*)astCopy(fits->ast_); wcsSystem(ast,system_); - wcsSkyFrame(ast,sky_); + if (!fits->hasWCSHPX()) + wcsSkyFrame(ast,sky_); int naxes = astGetI(ast,"Naxes"); switch (naxes) { diff --git a/tksao/frame/grid3d.C b/tksao/frame/grid3d.C index 7443f5c..74f0445 100644 --- a/tksao/frame/grid3d.C +++ b/tksao/frame/grid3d.C @@ -63,7 +63,8 @@ int Grid3d::doit(RenderMode rm) AstFrameSet* ast = (AstFrameSet*)astCopy(fits->ast_); wcsSystem(ast,system_); - wcsSkyFrame(ast,sky_); + if (!fits->hasWCSHPX()) + wcsSkyFrame(ast,sky_); int naxes = astGetI(ast,"Naxes"); switch (naxes) { -- cgit v0.12