diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2018-08-28 19:20:36 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2018-08-28 19:20:36 (GMT) |
commit | 0ae906abc35c3c8616800f3cd2ef2ac280459e40 (patch) | |
tree | 73ca8e17d6d8b2c9c6cfad6288a0adb544d43354 /tksao | |
parent | 72dc39ee1cf577ab13c09c9e065d6584ab0c0752 (diff) | |
download | blt-0ae906abc35c3c8616800f3cd2ef2ac280459e40.zip blt-0ae906abc35c3c8616800f3cd2ef2ac280459e40.tar.gz blt-0ae906abc35c3c8616800f3cd2ef2ac280459e40.tar.bz2 |
fix issues with HPX
Diffstat (limited to 'tksao')
-rw-r--r-- | tksao/frame/base.C | 6 | ||||
-rw-r--r-- | tksao/frame/fitsimage.C | 156 | ||||
-rw-r--r-- | tksao/frame/fitsimage.h | 7 | ||||
-rw-r--r-- | tksao/frame/framebase.C | 8 | ||||
-rw-r--r-- | tksao/frame/grid25d.C | 3 | ||||
-rw-r--r-- | tksao/frame/grid2d.C | 3 | ||||
-rw-r--r-- | 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; ii<MULTWCS; ii++) + wcsSize_[ii] = calcWCSSize((Coord::CoordSystem)(ii+Coord::WCS)); + wcsPhyInit(); if (DebugWCS && ast_) @@ -1359,11 +1357,13 @@ void FitsImage::match(const char* xxname1, const char* yyname1, if (sky1 != sky2) { AstFrameSet* wcs1 = (AstFrameSet*)astCopy(ast_); wcsSystem(wcs1,sys1); - wcsSkyFrame(wcs1,sky1); + if (!wcsHPX_) + wcsSkyFrame(wcs1,sky1); AstFrameSet* wcs2 = (AstFrameSet*)astCopy(ast_); wcsSystem(wcs2,sys2); - wcsSkyFrame(wcs2,sky2); + if (!wcsHPX_) + wcsSkyFrame(wcs2,sky2); AstFrameSet* cvt = (AstFrameSet*)astConvert(wcs1, wcs2, "SKY"); if (cvt != AST__NULL) { @@ -1378,7 +1378,8 @@ void FitsImage::match(const char* xxname1, const char* yyname1, if (ptr1 && ptr2) { AstFrameSet* wcs = (AstFrameSet*)astCopy(ast_); wcsSystem(wcs,sys2); - wcsSkyFrame(wcs,sky2); + if (!wcsHPX_) + wcsSkyFrame(wcs,sky2); Tcl_Obj* objrr = Tcl_NewListObj(0,NULL); for(int jj=0; jj<nxx2; jj++) { @@ -2969,67 +2970,18 @@ int FitsImage::hasWCS3D(Coord::CoordSystem sys) return (wcsNaxes_[sys-Coord::WCS]>2) ? 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; ii<MULTWCS; ii++) wcs_[ii] =0; - if (wcsNaxes_) - delete [] wcsNaxes_; - wcsNaxes_ =NULL; - wcsNaxes_ = new int[MULTWCS]; for (int ii=0; ii<MULTWCS; ii++) wcsNaxes_[ii] =0; - if (!ast_) - return; - - // since we have ast_ - wcs_[0] =1; - wcsNaxes_[0] = astGetI(ast_,"Naxes"); - - // do we have a AST wcs? - if (hasWCSAST) - return; - - // fill out wcs_ array - astClearStatus; - astBegin; - - int nn = astGetI(ast_, "Nframe"); - for (int ii=0; ii<nn; ii++) { - AstFrameSet* ff = (AstFrameSet*)astGetFrame(ast_,ii+1); - const char* id = astGetC(ff, "Ident"); - if (id && *id) { - int jj = (*id == ' ') ? 0 : *id-'@'; - wcs_[jj] = 1; - wcsNaxes_[jj] = astGetI(ff,"Naxes"); - } - } - - astEnd; -} - -void FitsImage::wcsCelInit(int hasWCSAST) -{ // init wcsCel_ array - if (wcsCel_) - delete [] wcsCel_; - wcsCel_ =NULL; - if (wcsCelLon_) - delete [] wcsCelLon_; - wcsCelLon_ =NULL; - if (wcsCelLat_) - delete [] wcsCelLat_; - wcsCelLat_ =NULL; - wcsCel_ = new int[MULTWCS]; for (int ii=0; ii<MULTWCS; ii++) wcsCel_[ii] =0; @@ -3039,16 +2991,50 @@ void FitsImage::wcsCelInit(int hasWCSAST) wcsCelLat_ = new int[MULTWCS]; for (int ii=0; ii<MULTWCS; ii++) wcsCelLat_[ii] =0; - + if (!ast_) return; + // easy one, HPX? + char key[] = "CTYPE1 "; + if (image_) { + const char* str = image_->getKeyword(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; ii<nn; ii++) { + AstFrameSet* ff = (AstFrameSet*)astGetFrame(ast_,ii+1); + const char* id = astGetC(ff, "Ident"); + if (id && *id) { + int jj = (*id == ' ') ? 0 : *id-'@'; + wcs_[jj] = 1; + wcsNaxes_[jj] = astGetI(ff,"Naxes"); + } + } + } + + if (wcsHPX_) { + wcsCel_[0] = 1; + wcsCelLon_[0] = 1; + wcsCelLat_[0] = 2; + } + else if (hasWCSAST) { AstFrameSet* fs = (AstFrameSet*)astFindFrame(ast_, astSkyFrame(" MaxAxes=4")," "); if (fs) { @@ -3073,6 +3059,8 @@ void FitsImage::wcsCelInit(int hasWCSAST) } } else { + int nn = astGetI(ast_, "Nframe"); + for (int kk=0; kk<nn; kk++) { AstFrame* ff = (AstFrame*)astGetFrame(ast_,kk+1); const char* id = astGetC(ff, "Ident"); @@ -3108,36 +3096,6 @@ void FitsImage::wcsCelInit(int hasWCSAST) astEnd; } -void FitsImage::wcsHPXInit() -{ - wcsHPX_ =0; - - if (!ast_) - return; - - char key[] = "CTYPE1 "; - if (image_) { - const char* str = image_->getKeyword(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; ii<MULTWCS; ii++) - wcsSize_[ii] = calcWCSSize((Coord::CoordSystem)(ii+Coord::WCS)); -} - void FitsImage::wcsPhyInit() { // now see if we have a 'physical' in WCSP, if so, set LTMV keywords @@ -3203,6 +3161,10 @@ void FitsImage::setWCSSystem(Coord::CoordSystem sys) void FitsImage::setWCSSkyFrame(Coord::SkyFrame sky) { + // not valid for HPX + if (wcsHPX_) + return; + if (wcsState_->wcsSkyFrame_ != 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) { |