diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2018-08-01 18:21:12 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2018-08-01 18:21:12 (GMT) |
commit | 8da52eb965f95813fd58cf48ddb78acdc76cad15 (patch) | |
tree | 473f59696171a2727741918fb1a8fc5d2b4dbf27 | |
parent | ae4dd094bc60432a88a9176f96b89150394faef3 (diff) | |
download | blt-8da52eb965f95813fd58cf48ddb78acdc76cad15.zip blt-8da52eb965f95813fd58cf48ddb78acdc76cad15.tar.gz blt-8da52eb965f95813fd58cf48ddb78acdc76cad15.tar.bz2 |
remove old wcs code
-rw-r--r-- | tksao/frame/base.C | 273 | ||||
-rw-r--r-- | tksao/frame/base.h | 4 | ||||
-rw-r--r-- | tksao/frame/coord.h | 7 | ||||
-rw-r--r-- | tksao/frame/fitsimage.C | 1731 | ||||
-rw-r--r-- | tksao/frame/fitsimage.h | 52 | ||||
-rw-r--r-- | tksao/frame/fitsmap.C | 32 | ||||
-rw-r--r-- | tksao/frame/frame3dbase.C | 143 | ||||
-rw-r--r-- | tksao/frame/framebase.C | 65 | ||||
-rw-r--r-- | tksao/frame/framergb.C | 17 | ||||
-rw-r--r-- | tksao/frame/frblt.C | 35 | ||||
-rw-r--r-- | tksao/frame/frsave.C | 59 | ||||
-rw-r--r-- | tksao/frame/grid25d.C | 5 | ||||
-rw-r--r-- | tksao/frame/grid2d.C | 5 | ||||
-rw-r--r-- | tksao/frame/grid3d.C | 51 |
14 files changed, 5 insertions, 2474 deletions
diff --git a/tksao/frame/base.C b/tksao/frame/base.C index 3b99ba7..af3995b 100644 --- a/tksao/frame/base.C +++ b/tksao/frame/base.C @@ -313,20 +313,6 @@ void Base::alignWCS(Coord::CoordSystem sys, Coord::SkyFrame sky) &wcsOrientation, &wcsOrientationMatrix, &wcsRotation); } -#ifdef OLDWCS -void Base::alignWCS(FitsImage* ptr, Coord::CoordSystem sys) -{ - if (!wcsAlign_ || !ptr || !context->cfits || !hasWCS(wcsSystem_)) { - wcsOrientation = Coord::NORMAL; - wcsOrientationMatrix.identity(); - wcsRotation = 0; - return; - } - - calcAlignWCS(ptr, context->cfits, sys, wcsSystem_, wcsSky_, - &wcsOrientation, &wcsOrientationMatrix, &wcsRotation, &zoom_); -} -#else void Base::alignWCS(FitsImage* ptr, Coord::CoordSystem sys) { if (!wcsAlign_ || !ptr || !context->cfits || !hasWCS(wcsSystem_)) { @@ -346,7 +332,6 @@ void Base::alignWCS(FitsImage* ptr, Coord::CoordSystem sys) zoom_ *= (Vector(mm[0][0],mm[1][0]).length() + Vector(mm[0][1],mm[1][1]).length())/2.; } -#endif void Base::calcAlignWCS(FitsImage* fits1, Coord::CoordSystem sys1, Coord::SkyFrame sky, @@ -389,263 +374,6 @@ void Base::calcAlignWCS(FitsImage* fits1, } } -#ifdef OLDWCS -void Base::calcAlignWCS(FitsImage* fits1, FitsImage* fits2, - Coord::CoordSystem sys1, Coord::CoordSystem sys2, - Coord::SkyFrame sky, - Coord::Orientation* orientation, Matrix* oo, - double* rotation, Vector* zoom) -{ - // init - *orientation = Coord::NORMAL; - oo->identity(); - *rotation = 0; - - if ((!fits1 || !fits2) || - (fits1 == fits2) || - !(fits1->hasWCS(sys1)) || - !(fits2->hasWCS(sys2))) - return; - - Vector org1 = fits1->center(); - Vector orval1 = fits1->pix2wcs(org1,sys1,sky); - - // orientation - *orientation = fits2->getWCSOrientation(sys2,sky); - switch (*orientation) { - case Coord::NORMAL: - oo->identity(); - break; - case Coord::XX: - *oo = FlipX(); - break; - default: - // na - break; - } - - // rotation - Vector orpix = fits2->wcs2pix(orval1, sys2, sky); - Vector delta = fits2->getWCScdelt(sys2).abs(); - Vector npix = - fits2->wcs2pix(Vector(orval1[0],orval1[1]+delta[1]),sys2,sky); - Vector north = (npix-orpix).normalize(); - Vector epix = - fits2->wcs2pix(Vector(orval1[0]+delta[0],orval1[1]),sys2,sky); - Vector east = (epix-orpix).normalize(); - - // sanity check - Vector diff = (north-east).abs(); - if ((north[0]==0 && north[1]==0) || - (east[0]==0 && east[1]==0) || - (diff[0]<.01 && diff[1]<.01)) { - *rotation = 0; - *orientation = Coord::NORMAL; - oo->identity(); - return; - } - - switch (*orientation) { - case Coord::NORMAL: - *rotation = -(north.angle()-M_PI_2); - break; - case Coord::XX: - *rotation = (north.angle()-M_PI_2); - break; - default: - // na - break; - } - - // zoom - Vector cd1 = fits1->getWCScdelt(sys1); - Vector cd2 = fits2->getWCScdelt(sys2); - - *zoom = Vector((*zoom)[0]/fabs(cd1[0]/cd2[0]), - (*zoom)[1]/fabs(cd1[1]/cd2[1])); -} -#endif - -#ifdef OLDWCS -Matrix Base::calcAlignWCS(FitsImage* fits1, FitsImage* fits2, - Coord::CoordSystem sys1, Coord::CoordSystem sys2, - Coord::SkyFrame sky) -{ - if ((!fits1 || !fits2) || - (fits1 == fits2) || - !(fits1->hasWCS(sys1)) || - !(fits2->hasWCS(sys2))) - return Matrix(); - - Vector org1 = fits1->center(); - Vector orval1 = fits1->pix2wcs(org1,sys1,sky); - - Vector org2 = fits2->center(); - Vector orval2 = fits2->pix2wcs(org2,sys2,sky); - - // orientation - Coord::Orientation orientation =Coord::NORMAL; - Coord::Orientation o1 = fits1->getWCSOrientation(sys1,sky); - Coord::Orientation o2 = fits2->getWCSOrientation(sys2,sky); - { - switch (o1) { - case Coord::NORMAL: - { - switch (o2) { - case Coord::NORMAL: - orientation = Coord::NORMAL; - break; - case Coord::XX: - orientation = Coord::XX; - break; - default: - // na - break; - } - } - break; - case Coord::XX: - { - switch (o2) { - case Coord::NORMAL: - orientation = Coord::XX; - break; - case Coord::XX: - orientation = Coord::NORMAL; - break; - default: - // na - break; - } - } - break; - default: - // na - break; - } - } - - // zoom - Vector zoom =Vector(1,1); - { - Vector cd1 = fits1->getWCScdelt(sys1); - Vector cd2 = fits2->getWCScdelt(sys2); - zoom = Vector(cd2[0]/cd1[0], cd2[1]/cd1[1]).abs(); - } - - // rotation - double rotation =0; - { - double rr1=0; - { - Vector orpix = fits1->wcs2pix(orval1, sys1, sky); - Vector delta = fits1->getWCScdelt(sys1).abs(); - Vector npix = - fits1->wcs2pix(Vector(orval1[0],orval1[1]+delta[1]),sys1,sky); - Vector north = (npix-orpix).normalize(); - Vector epix = - fits1->wcs2pix(Vector(orval1[0]+delta[0],orval1[1]),sys1,sky); - Vector east = (epix-orpix).normalize(); - - // sanity check - Vector diff = (north-east).abs(); - if ((north[0]==0 && north[1]==0) || - (east[0]==0 && east[1]==0) || - (diff[0]<.01 && diff[1]<.01)) - return Matrix(); - - switch (o1) { - case Coord::NORMAL: - rr1 = -(north.angle()-M_PI_2); - break; - case Coord::XX: - rr1 = (north.angle()-M_PI_2); - break; - default: - // na - break; - } - } - - double rr2 =0; - { - Vector orpix = fits2->wcs2pix(orval1, sys2, sky); - Vector delta = fits2->getWCScdelt(sys2).abs(); - Vector npix = - fits2->wcs2pix(Vector(orval1[0],orval1[1]+delta[1]),sys2,sky); - Vector north = (npix-orpix).normalize(); - Vector epix = - fits2->wcs2pix(Vector(orval1[0]+delta[0],orval1[1]),sys2,sky); - Vector east = (epix-orpix).normalize(); - - // sanity check - Vector diff = (north-east).abs(); - if ((north[0]==0 && north[1]==0) || - (east[0]==0 && east[1]==0) || - (diff[0]<.01 && diff[1]<.01)) - return Matrix(); - - switch (o2) { - case Coord::NORMAL: - rr2 = -(north.angle()-M_PI_2); - break; - case Coord::XX: - rr2 = north.angle()-M_PI_2; - break; - default: - // na - break; - } - } - - switch (o1) { - case Coord::NORMAL: - rotation = rr1-rr2; - break; - case Coord::XX: - rotation = -(rr1-rr2); - break; - default: - // na - break; - } - } - - // origin - Vector origin; - { - Vector orpix1 = fits1->wcs2pix(orval2,sys1,sky) * imageToData; - Vector orpix2 = fits2->wcs2pix(orval2,sys2,sky) * imageToData; - origin = orpix1 - orpix2; - } - - // matrix - { - Matrix flip; - switch (orientation) { - case Coord::NORMAL: - break; - case Coord::XX: - flip = FlipX(); - break; - default: - // na - break; - } - - Vector orpix2 = fits2->wcs2pix(orval2,sys2,sky) * imageToData; - - Matrix rr = Translate(-orpix2) * - flip * - Scale(zoom) * - Rotate(rotation) * - Translate(orpix2) * - Translate(origin); - - return rr; - } -} -#else Matrix Base::calcAlignWCS(FitsImage* fits1, FitsImage* fits2, Coord::CoordSystem sys1, Coord::CoordSystem sys2, Coord::SkyFrame sky) @@ -706,7 +434,6 @@ Matrix Base::calcAlignWCS(FitsImage* fits1, FitsImage* fits2, return rr; } -#endif double Base::calcZoom(Vector src, Vector dest) { diff --git a/tksao/frame/base.h b/tksao/frame/base.h index 8808ff8..d3aa888 100644 --- a/tksao/frame/base.h +++ b/tksao/frame/base.h @@ -525,10 +525,6 @@ public: virtual FrameType frameType() =0; void calcAlignWCS(FitsImage*, Coord::CoordSystem, Coord::SkyFrame, Coord::Orientation*, Matrix*, double*); -#ifdef OLDWCS - void calcAlignWCS(FitsImage*, FitsImage*, Coord::CoordSystem, Coord::CoordSystem, Coord::SkyFrame, - Coord::Orientation*, Matrix*, double*, Vector*); -#endif Matrix calcAlignWCS(FitsImage*, FitsImage*, Coord::CoordSystem, Coord::CoordSystem, Coord::SkyFrame); Vector centroid(const Vector&); diff --git a/tksao/frame/coord.h b/tksao/frame/coord.h index e33ecdd..67a5701 100644 --- a/tksao/frame/coord.h +++ b/tksao/frame/coord.h @@ -19,17 +19,10 @@ class Coord { enum InternalSystem {WINDOW, CANVAS, WIDGET, USER, REF, PANNER, MAGNIFIER, PS}; -#ifdef OLDWCS - enum CoordSystem {DATA, IMAGE, PHYSICAL, AMPLIFIER, DETECTOR, WCS, - WCSA, WCSB, WCSC, WCSD, WCSE, WCSF, WCSG, WCSH, WCSI, - WCSJ, WCSK, WCSL, WCSM, WCSN, WCSO, WCSP, WCSQ, WCSR, - WCSS, WCST, WCSU, WCSV, WCSW, WCSX, WCSY, WCSZ, WCS0}; -#else enum CoordSystem {DATA, IMAGE, PHYSICAL, AMPLIFIER, DETECTOR, WCS, WCSA, WCSB, WCSC, WCSD, WCSE, WCSF, WCSG, WCSH, WCSI, WCSJ, WCSK, WCSL, WCSM, WCSN, WCSO, WCSP, WCSQ, WCSR, WCSS, WCST, WCSU, WCSV, WCSW, WCSX, WCSY, WCSZ, WCS0=5}; -#endif enum SkyFrame {FK4, FK4_NO_E, FK5, ICRS, GALACTIC, SUPERGALACTIC, ECLIPTIC, HELIOECLIPTIC}; diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C index b65152a..ef3dfa7 100644 --- a/tksao/frame/fitsimage.C +++ b/tksao/frame/fitsimage.C @@ -107,11 +107,6 @@ FitsImage::FitsImage(Context* cx, Tcl_Interp* pp) refToImage3d = dataToImage3d; manageWCS_ =1; -#ifdef OLDWCS - wcs_ =NULL; - ast_ =NULL; - wcsx_ =NULL; -#else ast_ =NULL; astInv_ =0; wcs_ =NULL; @@ -119,7 +114,7 @@ FitsImage::FitsImage(Context* cx, Tcl_Interp* pp) wcs3D_ =NULL; wcsHPX_ =0; wcsSize_ =NULL; -#endif + wcsAltHeader_ =NULL; wfpc2Header_ =NULL; wcs0Header_ =NULL; @@ -176,28 +171,6 @@ FitsImage::~FitsImage() delete analysisdata_; } -#ifdef OLDWCS - if (wcs_) { - for (int ii=0; ii<MULTWCSA; ii++) - if (manageWCS_ && wcs_[ii]) - wcsfree(wcs_[ii]); - delete [] wcs_; - } - - if (ast_) { - for (int ii=0; ii<MULTWCSA; ii++) - if (manageWCS_ && ast_[ii]) - 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_) { if (ast_) astAnnul(ast_); @@ -210,7 +183,6 @@ FitsImage::~FitsImage() if (wcsSize_) delete [] wcsSize_; } -#endif if (wcsAltHeader_) delete wcsAltHeader_; @@ -1074,198 +1046,6 @@ void FitsImage::iisSetFileName(const char* fn) iisFileName = dupstr(fn); } -#ifdef OLDWCS -void FitsImage::initWCS(FitsHead* hd, FitsHead* prim) -{ - if (wcs_) { - for (int ii=0; ii<MULTWCSA; ii++) - if (manageWCS_ && wcs_[ii]) - wcsfree(wcs_[ii]); - delete [] wcs_; - } - wcs_ = new WorldCoor*[MULTWCSA]; - for (int ii=0; ii<MULTWCSA; ii++) - wcs_[ii] = NULL; - - if (ast_) { - for (int ii=0; ii<MULTWCSA; ii++) - if (manageWCS_ && ast_[ii]) - astAnnul(ast_[ii]); - delete [] ast_; - } - 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; - - // shareWCS? - manageWCS_ =1; - if (context_->shareWCS()) { - FitsImage* ptr = context_->fits; - while (ptr) { - if (ptr == this) - break; - - FitsImage* sptr = ptr->nextSlice(); - while (sptr) { - if (sptr == this) { - 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]; - - initWCSPhysical(); - manageWCS_ =0; - return; - } - sptr = sptr->nextSlice(); - } - ptr = ptr->nextMosaic(); - } - } - - // wcsinit is sloooowwww! so try to figure it out first - // look first for default WCS. Let wcsinit figure it out since there can - // be many different non-standard wcs's present - wcshead = hd; - wcsprim = prim; - wcs_[0] = wcsinit(hd->cards()); - wcshead = NULL; - wcsprim = NULL; - - // now look for WCSA - WCSZ - // we can take a short cut here, since only valid FITS wcs's are available - for (int ii=1; ii<MULTWCS; ii++) { - char str[] = "CTYPE1 "; - str[6] = '@'+ii; - if (hd->find(str)) { - wcshead = hd; - wcsprim = prim; - wcs_[ii] = wcsinitc(hd->cards(),str+6); - wcshead = NULL; - wcsprim = NULL; - } - } - - // finally, look for AST def - if (!wcs_[0]) { - char str[] = "BEGAST_A"; - if (hd->find(str)) { - wcs_[0] = wcskinit(100, 100, (char*)"AST--WCS", (char*)"AST--WCS", - 0, 0, 0, 0, NULL, 1, 1, 0, 2000, 0); - wcs_[0]->longpole = 999; - wcs_[0]->latpole = 999; - } - } - - // AST - for (int ii=0; ii<MULTWCSA; ii++) { - if (wcs_[ii]) { - astinit(ii, hd, prim); - - if (DebugWCS) { - wcsShow(wcs_[ii]); - astShow(ast_[ii]); - } - } - } - - // WCSDEP - if (hd->find("WCSDEP")) { - char* str = hd->getString("WCSDEP"); - if (str) { - for (int ii=1; ii<MULTWCS; ii++) { - if (wcs_[ii]) { - if (wcs_[ii]->wcsname) { - if (!strncmp(str,wcs_[ii]->wcsname,strlen(wcs_[ii]->wcsname))) { - if (ast_[0] && ast_[ii]) { - AstFrameSet* dep = (AstFrameSet*)astCopy(ast_[ii]); - astInvert(ast_[0]); - astAddFrame(dep,2,astUnitMap(2,""),ast_[0]); - astSetI(dep,"current",4); - astAnnul(ast_[0]); - ast_[0] = dep; - } - } - } - } - } - } - } - - // WCSx - char scrpix[] = "CRPIX "; - char scrval[] = "CRVAL "; - char scd[] = "CD _ "; - char spc[] = "PC _ "; - char scdelt[] = "CDELT "; - for (int ii=0; ii<MULTWCS; ii++) { - int jj=2; - - scrpix[5] = '1'+jj; - scrpix[6] = !ii ? ' ' : '@'+jj; - scrval[5] = '1'+jj; - scrval[6] = !ii ? ' ' : '@'+jj; - scd[2] = '1'+jj; - scd[4] = '1'+jj; - scd[5] = !ii ? ' ' : '@'+jj; - spc[2] = '1'+jj; - spc[4] = '1'+jj; - spc[5] = !ii ? ' ' : '@'+jj; - scdelt[5] = '1'+jj; - scdelt[6] = !ii ? ' ' : '@'+jj; - - if (hd->find(scrpix) && hd->find(scrval)) { - if (!wcsx_[ii]) - wcsx_[ii] = new WCSx(); - wcsx_[ii]->crpix = hd->getReal(scrpix,0); - wcsx_[ii]->crval = hd->getReal(scrval,0); - - float cd = hd->getReal(scd,0); - float pc = hd->getReal(spc,0); - float cdelt = hd->getReal(scdelt,0); - if (cd) - wcsx_[ii]->cd = cd; - else if (pc && cdelt) - wcsx_[ii]->cd = pc * cdelt; - else if (cdelt) - wcsx_[ii]->cd = cdelt; - else - wcsx_[ii]->cd = 1; - } - } - - initWCSPhysical(); - - if (DebugWCS) { - for (int ii=0; ii<MULTWCS; ii++) { - if (wcsx_[ii]) { - if (wcsx_[ii]->cd) { - cerr << "wcsx" << (char)(!ii ? ' ' : '@'+ii) - << "[" << ii << "]->crpix=" << wcsx_[ii]->crpix << endl; - cerr << "wcsx" << (char)(!ii ? ' ' : '@'+ii) - << "[" << ii << "]->crval=" << wcsx_[ii]->crval << endl; - cerr << "wcsx" << (char)(!ii ? ' ' : '@'+ii) - << "[" << ii << "]->cd=" << wcsx_[ii]->cd << endl; - } - } - } - } -} - -#else - void FitsImage::initWCS(FitsHead* hd) { if (manageWCS_) { @@ -1333,7 +1113,6 @@ void FitsImage::initWCS(FitsHead* hd) if (DebugWCS && ast_) astShow(ast_); } -#endif void FitsImage::resetWCS() { @@ -1353,73 +1132,9 @@ void FitsImage::resetWCS() if (wfpc2Header_) initWCS(wfpc2Header_); else -#ifdef OLDWCS - initWCS(image_->head(), - image_->primary() && image_->inherit() ? image_->primary() : NULL); -#else initWCS(image_->head()); -#endif -} - -#ifdef OLDWCS -void FitsImage::initWCS0(const Vector& pix) -{ - FitsHead* hd =NULL; - FitsHead* prim =NULL; - if (wcsAltHeader_) - hd = wcsAltHeader_; - else if (wfpc2Header_) - hd = wfpc2Header_; - else { - hd = image_->head(); - prim = image_->primary() && image_->inherit() ? image_->primary() : NULL; - } - - int ii = Coord::WCS0-Coord::WCS; - if (wcs_[ii]) - wcsfree(wcs_[ii]); - wcs_[ii] = NULL; - - if (wcs_[0]) { - Vector cc = mapFromRef(pix, Coord::IMAGE, Coord::FK5); - WorldCoor* ww = wcs_[0]; - if (!ww->coorflip) - wcs_[ii] = wcskinit(ww->nxpix, ww->nypix, - (char*)"RA---TAN", (char*)"DEC--TAN", - cc[0], cc[1], 0, 0, ww->cd, 0, 0, 0, 2000, 2000); - else - wcs_[ii] = wcskinit(ww->nxpix, ww->nypix, - (char*)"DEC--TAN", (char*)"RA---TAN", - cc[0], cc[1], 0, 0, ww->cd, 0, 0, 0, 2000, 2000); - wcs_[ii]->longpole = 999; - wcs_[ii]->latpole = 999; - - if (ast_[ii]) - astAnnul(ast_[ii]); - ast_[ii] = NULL; - astinit0(ii, hd, prim); - - if (DebugWCS) { - wcsShow(wcs_[ii]); - astShow(ast_[ii]); - } - } -} - -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_) @@ -1471,35 +1186,7 @@ void FitsImage::initWCS0(const Vector& pix) wcs0Header_ = hd; initWCS(wcs0Header_); } -#endif - -#ifdef OLDWCS -void FitsImage::initWCSPhysical() -{ - // now see if we have a 'physical' wcs, if so, set LTMV keywords - keyLTMV =0; - for (int ii=1; ii<MULTWCS; ii++) { - if (wcs_[ii] && - wcs_[ii]->wcsname && - !strncmp(wcs_[ii]->wcsname, "PHYSICAL", 8)) { - keyLTMV = 1; - - double ltm11 = wcs_[ii]->cd[0] != 0 ? 1/wcs_[ii]->cd[0] : 0; - double ltm12 = wcs_[ii]->cd[1] != 0 ? 1/wcs_[ii]->cd[1] : 0; - double ltm21 = wcs_[ii]->cd[2] != 0 ? 1/wcs_[ii]->cd[2] : 0; - double ltm22 = wcs_[ii]->cd[3] != 0 ? 1/wcs_[ii]->cd[3] : 0; - - double ltv1 = wcs_[ii]->crpix[0] - - wcs_[ii]->crval[0]*ltm11 - wcs_[ii]->crval[1]*ltm21; - double ltv2 = wcs_[ii]->crpix[1] - - wcs_[ii]->crval[0]*ltm12 - wcs_[ii]->crval[1]*ltm22; - physicalToImage = Matrix(ltm11, ltm12, ltm21, ltm22, ltv1, ltv2); - imageToPhysical = physicalToImage.invert(); - } - } -} -#else void FitsImage::initWCSPhysical() { // now see if we have a 'physical' in WCSP, if so, set LTMV keywords @@ -1536,7 +1223,6 @@ void FitsImage::initWCSPhysical() } } } -#endif void FitsImage::load() { @@ -1589,142 +1275,6 @@ void FitsImage::load() data_ = analysisdata_; } -#ifdef OLDWCS -void FitsImage::match(const char* xxname1, const char* yyname1, - Coord::CoordSystem sys1, Coord::SkyFrame sky1, - const char* xxname2, const char* yyname2, - Coord::CoordSystem sys2, Coord::SkyFrame sky2, - double rad, Coord::CoordSystem sys, - Coord::DistFormat dist, - const char* rrname) -{ - // get lists - Tcl_Obj* listxx1 = - Tcl_GetVar2Ex(interp_, xxname1, NULL, TCL_LEAVE_ERR_MSG); - Tcl_Obj* listyy1 = - Tcl_GetVar2Ex(interp_, yyname1, NULL, TCL_LEAVE_ERR_MSG); - Tcl_Obj* listxx2 = - Tcl_GetVar2Ex(interp_, xxname2, NULL, TCL_LEAVE_ERR_MSG); - Tcl_Obj* listyy2 = - Tcl_GetVar2Ex(interp_, yyname2, NULL, TCL_LEAVE_ERR_MSG); - - // get objects - int nxx1; - Tcl_Obj **objxx1; - Tcl_ListObjGetElements(interp_, listxx1, &nxx1, &objxx1); - int nyy1; - Tcl_Obj **objyy1; - Tcl_ListObjGetElements(interp_, listyy1, &nyy1, &objyy1); - int nxx2; - Tcl_Obj **objxx2; - Tcl_ListObjGetElements(interp_, listxx2, &nxx2, &objxx2); - int nyy2; - Tcl_Obj **objyy2; - Tcl_ListObjGetElements(interp_, listyy2, &nyy2, &objyy2); - - // sanity check - if (nxx1 != nyy1 || nxx2 != nyy2) - return; - - int ss1 = sys1-Coord::WCS; - if (!(ss1>=0 && ast_ && ast_[ss1])) - return; - if (!wcsIsASkyFrame(ast_[ss1])) - return; - - int ss2 = sys2-Coord::WCS; - if (!(ss2>=0 && ast_ && ast_[ss2])) - return; - if (!wcsIsASkyFrame(ast_[ss2])) - return; - - // get doubles - double* ixx1 = new double[nxx1]; - for (int ii=0 ; ii<nxx1 ; ii++) - Tcl_GetDoubleFromObj(interp_, objxx1[ii], ixx1+ii); - double* iyy1 = new double[nyy1]; - for (int ii=0 ; ii<nyy1 ; ii++) - Tcl_GetDoubleFromObj(interp_, objyy1[ii], iyy1+ii); - double* ixx2 = new double[nxx2]; - for (int ii=0 ; ii<nxx2 ; ii++) - Tcl_GetDoubleFromObj(interp_, objxx2[ii], ixx2+ii); - double* iyy2 = new double[nyy2]; - for (int ii=0 ; ii<nyy2 ; ii++) - Tcl_GetDoubleFromObj(interp_, objyy2[ii], iyy2+ii); - - Vector* in1 = new Vector[nxx1]; - Vector* out1 = new Vector[nxx1]; - for (int ii=0; ii<nxx1; ii++) - in1[ii] = degToRad(Vector(ixx1[ii],iyy1[ii])); - - Vector* in2 = new Vector[nxx2]; - Vector* out2 = new Vector[nxx2]; - for (int ii=0; ii<nxx2; ii++) - in2[ii] = degToRad(Vector(ixx2[ii],iyy2[ii])); - - // map from image - setWCSSkyFrame(ast_[ss1],sky1); - wcsTran(ast_[ss1], nxx1, in1, 0, out1); - - setWCSSkyFrame(ast_[ss2],sky2); - wcsTran(ast_[ss2], nxx2, in2, 0, out2); - - // radius - Vector cd = getWCScdelt(sys); - switch (dist) { - case Coord::DEGREE: - break; - case Coord::ARCMIN: - rad /= 60; - break; - case Coord::ARCSEC: - rad /= 60*60; - break; - } - double rx = rad/cd[0]; - double ry = rad/cd[1]; - double rr = (rx*rx + ry*ry)/2; - - // now compare - int cnt=0; - Tcl_Obj* objrr = Tcl_NewListObj(0,NULL); - for(int jj=0; jj<nxx2; jj++) { - for (int ii=0; ii<nxx1; ii++) { - double dx = out2[jj][0]-out1[ii][0]; - double dy = out2[jj][1]-out1[ii][1]; - - if (dx*dx + dy*dy < rr) { - Tcl_Obj* obj[2]; - obj[0] = Tcl_NewIntObj(ii+1); - obj[1] = Tcl_NewIntObj(jj+1); - Tcl_Obj* list = Tcl_NewListObj(2,obj); - Tcl_ListObjAppendElement(interp_, objrr, list); - cnt++; - } - } - } - - Tcl_SetVar2Ex(interp_, rrname, NULL, objrr, TCL_LEAVE_ERR_MSG); - - // clean up - if (ixx1) - delete [] ixx1; - if (iyy1) - delete [] iyy1; - if (ixx2) - delete [] ixx2; - if (iyy2) - delete [] iyy2; - if (in1) - delete [] in1; - if (out1) - delete [] out1; - if (in2) - delete [] in2; - if (out2) - delete [] out2; -} -#else void FitsImage::match(const char* xxname1, const char* yyname1, Coord::CoordSystem sys1, Coord::SkyFrame sky1, const char* xxname2, const char* yyname2, @@ -1864,7 +1414,6 @@ void FitsImage::match(const char* xxname1, const char* yyname1, if (ptr2) delete [] ptr2; } -#endif Matrix& FitsImage::matrixToData(Coord::InternalSystem sys) { @@ -3032,37 +2581,6 @@ void FitsImage::updatePS(Matrix3d ps) // WCS -#ifdef OLDWCS -Vector FitsImage::getWCScdelt(Coord::CoordSystem sys) -{ - if (hasWCS(sys)) { - int ii = sys-Coord::WCS; - - // special case - if (wcs_[ii]->pc[0] != 1 && wcs_[ii]->cdelt[0] == 1) { - double pc1 = sqrt(wcs_[ii]->pc[0]*wcs_[ii]->pc[0] + - wcs_[ii]->pc[2]*wcs_[ii]->pc[2]); - double pc2 = sqrt(wcs_[ii]->pc[1]*wcs_[ii]->pc[1] + - wcs_[ii]->pc[3]*wcs_[ii]->pc[3]); - if (!wcs_[ii]->coorflip) - return Vector(pc1, pc2); - else - return Vector(pc2, pc1); - } - else { - // The scaling factor mag is in cdelt - if (!wcs_[ii]->coorflip) - return Vector(wcs_[ii]->cdelt[0], wcs_[ii]->cdelt[1]); - else - return Vector(wcs_[ii]->cdelt[1], wcs_[ii]->cdelt[0]); - } - } - else - return Vector(); -} -#endif - -#ifndef OLDWCS double FitsImage::getWCSSize(Coord::CoordSystem sys) { if (!wcsSize_ || sys<Coord::WCS) @@ -3089,40 +2607,7 @@ double FitsImage::calcWCSSize(Coord::CoordSystem sys) double dd = wcsDistance(out[0],out[1]); return hasWCSCel(sys) ? radToDeg(dd) : dd; } -#endif -#ifdef OLDWCS -Coord::Orientation FitsImage::getWCSOrientation(Coord::CoordSystem sys, - Coord::SkyFrame sky) -{ - if (hasWCS(sys)) { - Vector orpix = center(); - Vector orval = pix2wcs(orpix, sys, sky); - Vector delta = getWCScdelt(sys).abs(); - Vector npix = wcs2pix(Vector(orval[0],orval[1]+delta[1]), sys, sky); - Vector north = (npix-orpix).normalize(); - Vector epix = wcs2pix(Vector(orval[0]+delta[0],orval[1]), sys, sky); - Vector east = (epix-orpix).normalize(); - - // sanity check - Vector diff = (north-east).abs(); - if ((north[0]==0 && north[1]==0) || - (east[0]==0 && east[1]==0) || - (diff[0]<.01 && diff[1]<.01)) - return Coord::NORMAL; - - // take the cross product and see which way the 3rd axis is pointing - double w = east[0]*north[1]-east[1]*north[0]; - - if (!hasWCSCel(sys)) - return w>0 ? Coord::NORMAL : Coord::XX; - else - return w<0 ? Coord::NORMAL : Coord::XX; - } - - return Coord::NORMAL; -} -#else Coord::Orientation FitsImage::getWCSOrientation(Coord::CoordSystem sys, Coord::SkyFrame sky) { @@ -3148,32 +2633,7 @@ Coord::Orientation FitsImage::getWCSOrientation(Coord::CoordSystem sys, else return Coord::NORMAL; } -#endif -#ifdef OLDWCS -double FitsImage::getWCSRotation(Coord::CoordSystem sys, Coord::SkyFrame sky) -{ - if (hasWCS(sys)) { - Vector orpix = center(); - Vector orval = pix2wcs(orpix, sys, sky); - Vector delta = getWCScdelt(sys).abs(); - Vector npix = wcs2pix(Vector(orval[0],orval[1]+delta[1]), sys, sky); - Vector north = (npix-orpix).normalize(); - Vector epix = wcs2pix(Vector(orval[0]+delta[0],orval[1]), sys, sky); - Vector east = (epix-orpix).normalize(); - - // sanity check - Vector diff = (north-east).abs(); - if ((north[0]==0 && north[1]==0) || - (east[0]==0 && east[1]==0) || - (diff[0]<.01 && diff[1]<.01)) - return 0; - - return -(north.angle()-M_PI_2); - } - return 0; -} -#else double FitsImage::getWCSRotation(Coord::CoordSystem sys, Coord::SkyFrame sky) { if (!hasWCS(sys)) @@ -3218,15 +2678,7 @@ double FitsImage::getWCSRotation(Coord::CoordSystem sys, Coord::SkyFrame sky) return 0; } } -#endif -#ifdef OLDWCS -const char* FitsImage::getWCSName(Coord::CoordSystem sys) -{ - return (wcs_ && wcs_[sys-Coord::WCS]) ? - wcs_[sys-Coord::WCS]->wcsname : NULL; -} -#else const char* FitsImage::getWCSName(Coord::CoordSystem sys) { if (fits_->find("WCSNAME")) @@ -3234,25 +2686,7 @@ const char* FitsImage::getWCSName(Coord::CoordSystem sys) else return NULL; } -#endif -#ifdef OLDWCS -Vector FitsImage::pix2wcs(const Vector& in, Coord::CoordSystem sys, - Coord::SkyFrame sky) -{ - int ss = sys-Coord::WCS; - if (!(ss>=0 && ast_ && ast_[ss])) - return Vector(); - - setWCSSkyFrame(ast_[ss],sky); - - Vector out = wcsTran(ast_[ss], in, 1); - if (astOK && checkWCS(out)) - return wcsIsASkyFrame(ast_[ss]) ? zero360(radToDeg(out)) : out; - else - return Vector(); -} -#else Vector FitsImage::pix2wcs(const Vector& in, Coord::CoordSystem sys, Coord::SkyFrame sky) { @@ -3269,72 +2703,7 @@ Vector FitsImage::pix2wcs(const Vector& in, Coord::CoordSystem sys, else return Vector(); } -#endif - -#ifdef OLDWCS -char* FitsImage::pix2wcs(const Vector& in, Coord::CoordSystem sys, - Coord::SkyFrame sky, Coord::SkyFormat format, - char* lbuf) -{ - lbuf[0] = '\0'; - - int ss = sys-Coord::WCS; - if (!(ss>=0 && ast_ && ast_[ss])) - return lbuf; - - setWCSSkyFrame(ast_[ss],sky); - - ostringstream str; - Vector out = wcsTran(ast_[ss], in, 1); - if (astOK && checkWCS(out)) { - if (wcsIsASkyFrame(ast_[ss])) { - ostringstream hms; - hms << "hms." << context_->parent_->precHMS_; - ostringstream dms; - dms << "+dms." << context_->parent_->precDMS_; - - switch (format) { - case Coord::DEGREES: - out = zero360(radToDeg(out)); - str << setprecision(context_->parent_->precDeg_) - << out[0] << ' ' << out[1] << ' ' - << (hasWCSCel(sys) ? coord.skyFrameStr(sky) : "") << ends; - break; - - case Coord::SEXAGESIMAL: - out = zeroTWOPI(out); - switch (sky) { - case Coord::FK4: - case Coord::FK4_NO_E: - case Coord::FK5: - case Coord::ICRS: - setWCSFormat(ast_[ss],1,hms.str().c_str()); - setWCSFormat(ast_[ss],2,dms.str().c_str()); - break; - case Coord::GALACTIC: - case Coord::SUPERGALACTIC: - case Coord::ECLIPTIC: - case Coord::HELIOECLIPTIC: - setWCSFormat(ast_[ss],1,dms.str().c_str()); - setWCSFormat(ast_[ss],2,dms.str().c_str()); - break; - } - str << astFormat(ast_[ss],1,out[0]) << ' ' - << astFormat(ast_[ss],2,out[1]) << ' ' - << (hasWCSCel(sys) ? coord.skyFrameStr(sky) : "") << ends; - break; - } - } - else - str << setprecision(context_->parent_->precLinear_) - << out[0] << ' ' << out[1] << ends; - strncpy(lbuf, str.str().c_str(), str.str().length()); - } - - return lbuf; -} -#else char* FitsImage::pix2wcs(const Vector& in, Coord::CoordSystem sys, Coord::SkyFrame sky, Coord::SkyFormat format, char* lbuf) @@ -3398,9 +2767,7 @@ char* FitsImage::pix2wcs(const Vector& in, Coord::CoordSystem sys, return lbuf; } -#endif -#ifndef OLDWCS Vector3d FitsImage::pix2wcs(const Vector3d& in, Coord::CoordSystem sys, Coord::SkyFrame sky) { @@ -3480,26 +2847,7 @@ char* FitsImage::pix2wcs(const Vector3d& in, Coord::CoordSystem sys, return lbuf; } -#endif -#ifdef OLDWCS -Vector FitsImage::wcs2pix(const Vector& vv, Coord::CoordSystem sys, - Coord::SkyFrame sky) -{ - int ss = sys-Coord::WCS; - if (ss>=0 && ast_ && ast_[ss]) { - setWCSSkyFrame(ast_[ss],sky); - - Vector in = wcsIsASkyFrame(ast_[ss]) ? degToRad(vv) : vv; - Vector out = wcsTran(ast_[ss], in, 0); - if (astOK && checkWCS(out)) - return out; - } - - maperr =1; - return Vector(); -} -#else Vector FitsImage::wcs2pix(const Vector& vv, Coord::CoordSystem sys, Coord::SkyFrame sky) { @@ -3534,23 +2882,7 @@ Vector3d FitsImage::wcs2pix(const Vector3d& vv, Coord::CoordSystem sys, return Vector3d(); } -#endif -#ifdef OLDWCS -double FitsImage::getWCSDist(const Vector& vv1, const Vector& vv2, - Coord::CoordSystem sys) -{ - int ss = sys-Coord::WCS; - if (!(ss>=0 && ast_ && ast_[ss])) - return 0; - - astClearStatus; // just to make sure - - return wcsIsASkyFrame(ast_[ss]) ? - radToDeg(wcsDistance(ast_[ss], degToRad(vv1), degToRad(vv2))) : - wcsDistance(ast_[ss], vv1, vv2); -} -#else double FitsImage::getWCSDist(const Vector& vv1, const Vector& vv2, Coord::CoordSystem sys) { @@ -3564,31 +2896,6 @@ double FitsImage::getWCSDist(const Vector& vv1, const Vector& vv2, radToDeg(wcsDistance(degToRad(vv1), degToRad(vv2))) : wcsDistance(vv1, vv2); } -#endif - -#ifdef OLDWCS -int FitsImage::hasWCS(Coord::CoordSystem sys) -{ - int ss = sys-Coord::WCS; - return (sys>=Coord::WCS && ast_ && ast_[ss]) ? 1 : 0; -} - -int FitsImage::hasWCSCel(Coord::CoordSystem sys) -{ - int ss = sys-Coord::WCS; - if (ss>=0 && ast_ && ast_[ss]) - if (wcsIsASkyFrame(ast_[ss])) - return 1; - - return 0; -} - -int FitsImage::hasWCSLinear(Coord::CoordSystem sys) -{ - return hasWCS(sys) && !hasWCSCel(sys); -} - -#else int FitsImage::hasWCS(Coord::CoordSystem sys) { @@ -3614,40 +2921,6 @@ int FitsImage::hasWCSLinear(Coord::CoordSystem sys) return wcs_[sys-Coord::WCS] && !wcsCel_[sys-Coord::WCS]; } -#endif - -// WCSX - -#ifdef OLDWCS - -int FitsImage::hasWCS3D(Coord::CoordSystem sys) -{ - int ss = sys-Coord::WCS; - return (sys>=Coord::WCS && wcsx_[ss]) ? 1 : 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; -} - -#else - int FitsImage::hasWCS3D(Coord::CoordSystem sys) { if (!wcs3D_ || sys<Coord::WCS) @@ -3655,84 +2928,7 @@ int FitsImage::hasWCS3D(Coord::CoordSystem sys) else return wcs3D_[sys-Coord::WCS]; } -#endif - -// WCS/AST support - -#ifdef OLDWCS -void FitsImage::wcsShow(WorldCoor* ww) -{ - if (!ww) - return; - - int n = ww->naxes; - int nn = n*n; - - cerr << "wcs->wcsname=" << (ww->wcsname ? ww->wcsname : "") << endl; - cerr << "wcs->naxes=" << ww->naxes << endl; - cerr << "wcs->naxis=" << ww->naxis << endl; - - cerr << "wcs->radecsys=" << ww->radecsys << endl; - cerr << "wcs->equinox=" << ww->equinox << endl; - cerr << "wcs->epoch=" << ww->epoch << endl; - - cerr << "wcs->ctype[0]=" << ww->ctype[0] << endl; - cerr << "wcs->ctype[1]=" << ww->ctype[1] << endl; - cerr << "wcs->c1type=" << ww->c1type << endl; - cerr << "wcs->c2type=" << ww->c2type << endl; - cerr << "wcs->ptype=" << ww->ptype << endl; - - for (int jj=0; jj<n; jj++) - cerr << "wcs->crpix[" << jj << "]=" << ww->crpix[jj] << endl; - for (int jj=0; jj<n; jj++) - cerr << "wcs->crval[" << jj << "]=" << ww->crval[jj] << endl; - for (int jj=0; jj<n; jj++) - cerr << "wcs->cdelt[" << jj << "]=" << ww->cdelt[jj] << endl; - - for (int jj=0; jj<4; jj++) - cerr << "wcs->cd[" << jj << "]=" << ww->cd[jj] << endl; - for (int jj=0; jj<nn; jj++) - cerr << "wcs->pc[" << jj << "]=" << ww->pc[jj] << endl; - - cerr << "wcs->longpole=" << ww->longpole << endl; - cerr << "wcs->latpole=" << ww->latpole << endl; - cerr << "wcs->prjcode=" << ww->prjcode << endl; - - cerr << "wcs->rot=" << ww->rot << endl; - cerr << "wcs->coorflip=" << ww->coorflip << endl; - cerr << "wcs->distcode=" << ww->distcode << endl; -} - -void FitsImage::astinit(int ss, FitsHead* hd, FitsHead* prim) -{ - if (!wcs_[ss]) { - ast_[ss] = NULL; - return; - } - - // just in case - if (!hd) - return; - // DSS,PLT,LIN goes straight to AST - // we can't send 3D directly to AST - - if (wcs_[ss]->prjcode==WCS_DSS || - wcs_[ss]->prjcode==WCS_PLT || - (wcs_[ss]->prjcode==WCS_LIN && !strncmp(wcs_[ss]->ptype,"HPX",3)) || - (wcs_[ss]->prjcode==WCS_LIN && !strncmp(wcs_[ss]->ptype,"XPH",3)) || - (wcs_[ss]->prjcode==WCS_LIN && !strncmp(wcs_[ss]->ptype,"TAB",3)) || - (wcs_[ss]->prjcode==WCS_LIN && !strncmp(wcs_[ss]->c1type,"AST",3))) - ast_[ss] = fits2ast(hd); - else - ast_[ss] = buildast(ss, hd, prim); - - if (!ast_[ss]) - return; - // set default skyframe - setWCSSkyFrame(ast_[ss],Coord::FK5); -} -#else void FitsImage::astInit(FitsHead* hd) { if (ast_) @@ -3922,26 +3118,6 @@ void FitsImage::wcsSizeInit() wcsSize_[ii] = calcWCSSize((Coord::CoordSystem)(ii+Coord::WCS)); } -#endif - -#ifdef OLDWCS -void FitsImage::astinit0(int ss, FitsHead* hd, FitsHead* prim) -{ - if (!wcs_[ss]) { - ast_[ss] = NULL; - return; - } - - ast_[ss] = buildast0(ss, hd, prim); - - if (!ast_[ss]) - return; - - // set default skyframe - setWCSSkyFrame(ast_[ss],Coord::FK5); -} -#endif - int FitsImage::checkWCS(Vector& vv) { // check for reasonable values @@ -3957,24 +3133,6 @@ int FitsImage::checkWCS(Vector3d& vv) fabs(vv[2]) < FLT_MAX ) ? 1 : 0; } -#ifdef OLDWCS -void FitsImage::setWCSFormat(AstFrameSet* aa, int id, const char* format) -{ - // is it already set? - // ast is very slow when changing params - { - ostringstream str; - str << "Format(" << id << ")" << ends; - const char* out = astGetC(aa, str.str().c_str()); - if (!strcmp(out,format)) - return; - } - - ostringstream str; - str << "Format(" << id << ")=" << format << ends; - astSet(aa, str.str().c_str()); -} -#else void FitsImage::setWCSFormat(int id, const char* format) { // is it already set? @@ -3991,68 +3149,6 @@ void FitsImage::setWCSFormat(int id, const char* format) str << "Format(" << id << ")=" << format << ends; astSet(ast_, str.str().c_str()); } -#endif - -#ifdef OLDWCS -void FitsImage::setWCSSkyFrame(AstFrameSet* ast, Coord::SkyFrame sky) -{ - // is sky frame - if (!wcsIsASkyFrame(ast)) - return; - - const char* str = astGetC(ast, "System"); - - // TLON/XLON and HPX will do this - if (!strncmp(str,"Unknown",3)) - return; - - switch (sky) { - case Coord::FK4_NO_E: - if (!strncmp(str,"FK4-NO-E",8)) - return; - astSet(ast, "System=FK4-NO-E, Equinox=B1950"); - return; - case Coord::FK4: - if (!strncmp(str,"FK4",3)) - return; - astSet(ast, "System=FK4, Equinox=B1950"); - return; - case Coord::FK5: - if (!strncmp(str,"FK5",3)) - return; - astSet(ast, "System=FK5, Equinox=J2000"); - return; - case Coord::ICRS: - if (!strncmp(str,"ICRS",4)) - return; - astSet(ast, "System=ICRS"); - return; - case Coord::GALACTIC: - if (!strncmp(str,"GALACTIC",8)) - return; - astSet(ast, "System=GALACTIC"); - return; - case Coord::SUPERGALACTIC: - if (!strncmp(str,"SUPERGALACTIC",13)) - return; - astSet(ast, "System=SUPERGALACTIC"); - return; - case Coord::ECLIPTIC: - if (!strncmp(str,"ECLIPTIC",8)) - return; - astSet(ast, "System=ECLIPTIC"); - // get AST to agree with WCSSUBS - astSetD(ast, "EQUINOX", astGetD(ast, "EPOCH")); - return; - case Coord::HELIOECLIPTIC: - if (!strncmp(str,"HELIOECLIPTIC",13)) - return; - astSet(ast, "System=HELIOECLIPTIC"); - return; - } -} - -#else void FitsImage::setWCSSkyFrame(Coord::CoordSystem sys, Coord::SkyFrame sky) { @@ -4136,54 +3232,7 @@ void FitsImage::setWCSSkyFrame(Coord::CoordSystem sys, Coord::SkyFrame sky) return; } } -#endif - -#ifdef OLDWCS -int FitsImage::wcsIsASkyFrame(AstFrameSet* ast) -{ - astClearStatus; - astBegin; - int rr = astIsASkyFrame(astGetFrame(ast,AST__CURRENT)); - astEnd; - return rr; -} -#endif - -#ifdef OLDWCS -Vector FitsImage::wcsTran(AstFrameSet* ast, const Vector& in, int forward) -{ - double xout, yout; - astTran2(ast, 1, in.v, in.v+1, forward, &xout, &yout); - return Vector(xout, yout); -} - -void FitsImage::wcsTran(AstFrameSet* ast, int npoint, - Vector* in, int forward, Vector* out) -{ - double* xin = new double[npoint]; - double* yin = new double[npoint]; - double* xout = new double[npoint]; - double* yout = new double[npoint]; - - for (int ii=0; ii<npoint; ii++) { - xin[ii] = in[ii][0]; - yin[ii] = in[ii][1]; - } - astTran2(ast, npoint, xin, yin, forward, xout, yout); - for (int ii=0; ii<npoint; ii++) - out[ii] = Vector(xout[ii],yout[ii]); - - if (xin) - delete [] xin; - if (yin) - delete [] yin; - if (xout) - delete [] xout; - if (yout) - delete [] yout; -} -#else Vector FitsImage::wcsTran(const Vector& in, int forward) { int naxes = astGetI(ast_,"Naxes"); @@ -4375,15 +3424,6 @@ Vector3d FitsImage::wcsTran(const Vector3d& in, int forward) return Vector3d(); } -#endif - -#ifdef OLDWCS -double FitsImage::wcsDistance(AstFrameSet* ast, const Vector& vv1, - const Vector& vv2) -{ - return astDistance(ast, vv1.v, vv2.v); -} -#else double FitsImage::wcsDistance(const Vector& vv1, const Vector& vv2) { int naxes = astGetI(ast_,"Naxes"); @@ -4426,9 +3466,6 @@ double FitsImage::wcsDistance(const Vector& vv1, const Vector& vv2) return 0; } -#endif - -#ifndef OLDWCS double FitsImage::wcsAngle(const Vector& vv1, const Vector& vv2, const Vector& vv3) { @@ -4522,60 +3559,7 @@ double FitsImage::wcsAxAngle(const Vector& vv1, const Vector& vv2) return 0; } -#endif - -#ifdef OLDWCS -AstFrameSet* FitsImage::fits2ast(FitsHead* hd) -{ - // we may have an error, just reset - astClearStatus; - - // new fitschan - AstFitsChan* chan = astFitsChan(NULL, NULL, ""); - if (!astOK || chan == AST__NULL) - return NULL; - // no warning messages - astClear(chan,"Warnings"); - - // fill up chan - char* cards =NULL; - int ncards =0; - - if (hd) { - cards = hd->cards(); - ncards = hd->ncard(); - } - - if (cards == NULL || ncards == 0) - return NULL; - - for (int i=0; i<ncards; i++) { - char buf[81]; - strncpy(buf,cards+(i*80),80); - buf[80] = '\0'; - - astPutFits(chan, buf, 0); - // sometimes, we get a bad parse, just ignore - if (!astOK) - astClearStatus; - } - - // we may have an error, just reset - astClearStatus; - astClear(chan, "Card"); - - // parse header - AstFrameSet* frameSet = (AstFrameSet*)astRead(chan); - - // do we have anything? - if (!astOK || frameSet == AST__NULL || - strncmp(astGetC(frameSet,"Class"), "FrameSet", 8)) - return NULL; - - return frameSet; -} -#else static void fits2TAB(AstFitsChan* chan, const char* extname, int extver, int extlevel, int* status) { @@ -4751,716 +3735,3 @@ AstFrameSet* FitsImage::fits2ast(FitsHead* hd) return frameSet; } -#endif - -#ifdef OLDWCS -AstFrameSet* FitsImage::buildast(int ss, FitsHead* hd, FitsHead* prim) -{ - if (DebugWCS) - cerr << endl << "buildast("<< ss << ")" << endl; - - // read wcs struct into astChannel - // we may have an error, just reset - astClearStatus; - - // new fitschan - AstFitsChan* chan = astFitsChan(NULL, NULL, ""); - if (!astOK || chan == AST__NULL) - return NULL; - - // no warning messages - astClear(chan,"Warnings"); - - // basics (needed by fitschan.c) - putFitsCard(chan, "NAXIS1", (int)naxis(0)); - putFitsCard(chan, "NAXIS2", (int)naxis(1)); - - // simple test to see if we have complete WCS - // if not (as in 3d cube reorder), wcs[] can be very unreliable - int fromwcs =0; - - char alt = (ss==0) ? ' ' : (char)('@'+ss); - char ctype1[8], ctype2[8]; - strcpy(ctype1, "CTYPE1 "); - strcpy(ctype2, "CTYPE2 "); - ctype1[6] = ctype2[6] = alt; - - if (hd->find(ctype1) && hd->find(ctype2)) { - wcs2ast(ss,hd,prim,chan); - fromwcs =1; - } - else - header2ast(ss,hd,chan); - - // rewind chan - astClear(chan, "Card"); - - // parse header - AstFrameSet* frameSet = (AstFrameSet*)astRead(chan); - - // do we have anything? - if (!astOK || frameSet == AST__NULL || - strncmp(astGetC(frameSet,"Class"), "FrameSet", 8)) - return NULL; - - if (fromwcs && wcs_[ss]->coorflip) { - int orr[] = {2,1}; - astPermAxes(frameSet,orr); - } - - // cleanup - astAnnul(chan); - - return frameSet; -} - -AstFrameSet* FitsImage::buildast0(int ss, FitsHead* hd, FitsHead* prim) -{ - // read wcs struct into astChannel - // we may have an error, just reset - astClearStatus; - - // new fitschan - AstFitsChan* chan = astFitsChan(NULL, NULL, ""); - if (!astOK || chan == AST__NULL) - return NULL; - - // no warning messages - astClear(chan,"Warnings"); - - // basics (needed by fitschan.c) - putFitsCard(chan, "NAXIS1", (int)naxis(0)); - putFitsCard(chan, "NAXIS2", (int)naxis(1)); - - wcs2ast0(ss,hd,prim,chan); - - // rewind chan - astClear(chan, "Card"); - - // parse header - AstFrameSet* frameSet = (AstFrameSet*)astRead(chan); - - // do we have anything? - if (!astOK || frameSet == AST__NULL || - strncmp(astGetC(frameSet,"Class"), "FrameSet", 8)) - return NULL; - - if (wcs_[ss]->coorflip) { - int orr[] = {2,1}; - astPermAxes(frameSet,orr); - } - - // cleanup - astAnnul(chan); - - return frameSet; -} - -void FitsImage::header2ast(int ss, FitsHead* hd, void* chan) -{ - if (DebugWCS) - cerr << endl << "header2ast(" << ss << ")" << endl; - - char alt = (ss==0) ? ' ' : (char)('@'+ss); - - char key1[8]; - char key2[8]; - - // CTYPE - // We can't have RA/DEC without DEC/RA or GLON/GLAT without GLAT/GLON - const char* linear = "LINEAR"; - strcpy(key1, "CTYPE1 "); - strcpy(key2, "CTYPE2 "); - key1[6] = key2[6] = alt; - - // do we have WCSa? - if (!hd->find(key1) && !hd->find(key2)) - return; - - char* c1ptr = dupstr(hd->getString(key1)); - char* c2ptr = dupstr(hd->getString(key2)); - char* ctype1 = c1ptr; - char* ctype2 = c2ptr; - - if (ctype1 && !strncmp(ctype1,"GLON",4)) { - if (!ctype2 || strncmp(ctype2,"GLAT",4)) { - ctype1 = (char*)linear; - ctype2 = (char*)linear; - } - } - else if (ctype2 && !strncmp(ctype2,"GLON",4)) { - if (!ctype1 || strncmp(ctype1,"GLAT",4)) { - ctype1 = (char*)linear; - ctype2 = (char*)linear; - } - } - else if (ctype1 && !strncmp(ctype1,"GLAT",4)) { - if (!ctype2 || strncmp(ctype2,"GLON",4)) { - ctype1 = (char*)linear; - ctype2 = (char*)linear; - } - } - else if (ctype2 && !strncmp(ctype2,"GLAT",4)) { - if (!ctype1 || strncmp(ctype1,"GLON",4)) { - ctype1 = (char*)linear; - ctype2 = (char*)linear; - } - } - else if (ctype1 && !strncmp(ctype1,"RA",2)) { - if (!ctype2 || strncmp(ctype2,"DEC",3)) { - ctype1 = (char*)linear; - ctype2 = (char*)linear; - } - } - else if (ctype2 && !strncmp(ctype2,"RA",2)) { - if (!ctype1 || strncmp(ctype1,"DEC",3)) { - ctype1 = (char*)linear; - ctype2 = (char*)linear; - } - } - else if (ctype1 && !strncmp(ctype1,"DEC",3)) { - if (!ctype2 || strncmp(ctype2,"RA",2)) { - ctype1 = (char*)linear; - ctype2 = (char*)linear; - } - } - else if (ctype2 && !strncmp(ctype2,"DEC",3)) { - if (!ctype1 || strncmp(ctype1,"RA",2)) { - ctype1 = (char*)linear; - ctype2 = (char*)linear; - } - } - else { - if (!ctype1) - ctype1 =(char*)linear; - if (!ctype2) - ctype2 =(char*)linear; - } - - putFitsCard(chan, key1, ctype1); - putFitsCard(chan, key2, ctype2); - - if (c1ptr) - delete [] c1ptr; - if (c2ptr) - delete [] c2ptr; - - // CRPIX - strcpy(key1, "CRPIX1 "); - strcpy(key2, "CRPIX2 "); - key1[6] = key2[6] = alt; - putFitsCard(chan, key1, hd->getReal(key1,0)); - putFitsCard(chan, key2, hd->getReal(key2,0)); - - // CRVAL - strcpy(key1, "CRVAL1 "); - strcpy(key2, "CRVAL2 "); - key1[6] = key2[6] = alt; - putFitsCard(chan, key1, hd->getReal(key1,0)); - putFitsCard(chan, key2, hd->getReal(key2,0)); - - // CDELT/CD/PC - strcpy(key1, "CDELT1 "); - strcpy(key2, "CDELT2 "); - key1[6] = key2[6] = alt; - - char pkey1[8]; - char pkey2[8]; - char pkey3[8]; - char pkey4[8]; - strcpy(pkey1, "PC1_1 "); - strcpy(pkey2, "PC1_2 "); - strcpy(pkey3, "PC2_1 "); - strcpy(pkey4, "PC2_2 "); - pkey1[5] = pkey2[5] = pkey3[5] = pkey4[5] = alt; - - char ckey1[8]; - char ckey2[8]; - char ckey3[8]; - char ckey4[8]; - strcpy(ckey1, "CD1_1 "); - strcpy(ckey2, "CD1_2 "); - strcpy(ckey3, "CD2_1 "); - strcpy(ckey4, "CD2_2 "); - ckey1[5] = ckey2[5] = ckey3[5] = ckey4[5] = alt; - - // Give CD priority over CDELT - if (hd->find(ckey1) || - hd->find(ckey2) || - hd->find(ckey3) || - hd->find(ckey4)) { - putFitsCard(chan, ckey1, hd->getReal(ckey1,1)); - putFitsCard(chan, ckey2, hd->getReal(ckey2,0)); - putFitsCard(chan, ckey3, hd->getReal(ckey3,0)); - putFitsCard(chan, ckey4, hd->getReal(ckey4,1)); - } - else if (hd->find(key1) || hd->find(key2)) { - putFitsCard(chan, key1, hd->getReal(key1,1)); - putFitsCard(chan, key2, hd->getReal(key2,1)); - - if (hd->find(pkey1) || - hd->find(pkey2) || - hd->find(pkey3) || - hd->find(pkey4)) { - putFitsCard(chan, pkey1, hd->getReal(pkey1,1)); - putFitsCard(chan, pkey2, hd->getReal(pkey2,1)); - putFitsCard(chan, pkey3, hd->getReal(pkey3,1)); - putFitsCard(chan, pkey4, hd->getReal(pkey4,1)); - } - } -} - -void FitsImage::wcs2ast(int ww, FitsHead* hd, FitsHead* prim, void* chan) -{ - if (DebugWCS) - cerr << endl << "wcs2ast(" << ww << ")" << endl; - - // Alt WCS - char alt = (ww==0) ? ' ' : (char)('@'+ww); - - // CTYPE - if ( - // special case (reorder 3D cube) - (!strncmp(wcs_[ww]->ctype[0],"GLON",4) && - strncmp(wcs_[ww]->ctype[1],"GLAT",4)) || - (strncmp(wcs_[ww]->ctype[0],"GLON",4) && - !strncmp(wcs_[ww]->ctype[1],"GLAT",4)) || - (!strncmp(wcs_[ww]->ctype[0],"GLAT",4) && - strncmp(wcs_[ww]->ctype[1],"GLON",4)) || - (strncmp(wcs_[ww]->ctype[0],"GLAT",4) && - !strncmp(wcs_[ww]->ctype[1],"GLON",4)) || - (!strncmp(wcs_[ww]->ctype[0],"RA",2) && - strncmp(wcs_[ww]->ctype[1],"DEC",3)) || - (strncmp(wcs_[ww]->ctype[0],"RA",2) && - !strncmp(wcs_[ww]->ctype[1],"DEC",3)) || - (!strncmp(wcs_[ww]->ctype[0],"DEC",3) && - strncmp(wcs_[ww]->ctype[1],"RA",2)) || - (strncmp(wcs_[ww]->ctype[0],"DEC",3) && - !strncmp(wcs_[ww]->ctype[1],"RA",2))) - { - putFitsCard(chan, "CTYPE1", "LINEAR"); - putFitsCard(chan, "CTYPE2", "LINEAR"); - } - else if (wcs_[ww]->prjcode == WCS_TAN && wcs_[ww]->distcode) { - // SIP - { - ostringstream str; - str << wcs_[ww]->ctype[0] << "-SIP" << ends; - putFitsCard(chan, "CTYPE1", str.str().c_str()); - } - { - ostringstream str; - str << wcs_[ww]->ctype[1] << "-SIP" << ends; - putFitsCard(chan, "CTYPE2", str.str().c_str()); - } - } - else { - putFitsCard(chan, "CTYPE1", wcs_[ww]->ctype[0]); - putFitsCard(chan, "CTYPE2", wcs_[ww]->ctype[1]); - } - - // CRPIX/CRVAL - putFitsCard(chan, "CRPIX1", wcs_[ww]->crpix[0]); - putFitsCard(chan, "CRPIX2", wcs_[ww]->crpix[1]); - putFitsCard(chan, "CRVAL1", wcs_[ww]->crval[0]); - putFitsCard(chan, "CRVAL2", wcs_[ww]->crval[1]); - - // CD/CDELT/PC - // This is very complicated. AST is very, very, very picky as to which - // keywords it use... - { - ostringstream cd; - cd << "CD1_1" << alt << ends; - ostringstream cdelt; - cdelt << "CDELT1" << alt << ends; - ostringstream pc; - pc << "PC1_1" << alt << ends; - - if (hd->find(cd.str().c_str()) || - (prim && prim->find(cd.str().c_str()))) { - // simple case CD - // no rotation, no poles, no LIN, no inner cd values - if (!wcs_[ww]->cd[1] && !wcs_[ww]->cd[2] && - !wcs_[ww]->rot && - !wcs_[ww]->coorflip && - wcs_[ww]->latpole == 999 && - wcs_[ww]->longpole == 999 && - wcs_[ww]->prjcode != WCS_PIX && - wcs_[ww]->prjcode != WCS_LIN) { - putFitsCard(chan, "CDELT1", wcs_[ww]->cdelt[0]); - putFitsCard(chan, "CDELT2", wcs_[ww]->cdelt[1]); - } - else { - putFitsCard(chan, "CD1_1", wcs_[ww]->cd[0]); - putFitsCard(chan, "CD1_2", wcs_[ww]->cd[1]); - putFitsCard(chan, "CD2_1", wcs_[ww]->cd[2]); - putFitsCard(chan, "CD2_2", wcs_[ww]->cd[3]); - } - } - // CDELT - else if (hd->find(cdelt.str().c_str()) || - (prim && prim->find(cdelt.str().c_str()))) { - putFitsCard(chan, "CDELT1", wcs_[ww]->cdelt[0]); - putFitsCard(chan, "CDELT2", wcs_[ww]->cdelt[1]); - - if (hd->find(pc.str().c_str()) || - (prim && prim->find(pc.str().c_str()))) { - putFitsCard(chan, "PC1_1", wcs_[ww]->pc[0]); - putFitsCard(chan, "PC1_2", wcs_[ww]->pc[1]); - putFitsCard(chan, "PC2_1", wcs_[ww]->pc[2]); - putFitsCard(chan, "PC2_2", wcs_[ww]->pc[3]); - } - else if (!ww && - (hd->find("PC001001") || (prim && prim->find("PC001001")))) { - putFitsCard(chan, "PC001001", wcs_[ww]->pc[0]); - putFitsCard(chan, "PC001002", wcs_[ww]->pc[1]); - putFitsCard(chan, "PC002001", wcs_[ww]->pc[2]); - putFitsCard(chan, "PC002002", wcs_[ww]->pc[3]); - } - else { - if (!ww && - (hd->find("CROTA1") || (prim && prim->find("CROTA1")))) - putFitsCard(chan, "CROTA1", wcs_[ww]->rot); - if (!ww && - (hd->find("CROTA2") || (prim && prim->find("CROTA2")))) - putFitsCard(chan, "CROTA2", wcs_[ww]->rot); - } - } - // sanity check - else if (!wcs_[ww]->cd[0] && - !wcs_[ww]->cd[1] && - !wcs_[ww]->cd[2] && - !wcs_[ww]->cd[3]) { - putFitsCard(chan, "CDELT1", wcs_[ww]->cdelt[0]); - putFitsCard(chan, "CDELT2", wcs_[ww]->cdelt[1]); - putFitsCard(chan, "PC1_1", wcs_[ww]->pc[0]); - putFitsCard(chan, "PC1_2", wcs_[ww]->pc[1]); - putFitsCard(chan, "PC2_1", wcs_[ww]->pc[2]); - putFitsCard(chan, "PC2_2", wcs_[ww]->pc[3]); - } - // fall back - else { - putFitsCard(chan, "CD1_1", wcs_[ww]->cd[0]); - putFitsCard(chan, "CD1_2", wcs_[ww]->cd[1]); - putFitsCard(chan, "CD2_1", wcs_[ww]->cd[2]); - putFitsCard(chan, "CD2_2", wcs_[ww]->cd[3]); - } - } - - // equatorial keywords - if (wcs_[ww]->prjcode>0 && wcs_[ww]->prjcode<34) { - // equiniox - putFitsCard(chan, "EQUINOX", wcs_[ww]->equinox); - - // from wcssub/wcsinit.c line 800 - // wcs[ww]->epoch = 1900.0 + (mjd - 15019.81352) / 365.242198781; - // only set if MJD-OBS or DATE-OBS is present - if (hd->find("MJD-OBS") || hd->find("DATE-OBS") || - (prim && prim->find("MJD-OBS")) || (prim && prim->find("DATE-OBS"))) - putFitsCard(chan, "MJD-OBS", - (wcs_[ww]->epoch-1900)*365.242198781+15019.81352); - - ostringstream radesys; - radesys << "RADESYS" << alt << ends; - if (hd->find(radesys.str().c_str())) { - // if RADESYS present, use it - putFitsCard(chan, "RADESYS", hd->getString(radesys.str().c_str())); - } - else if (prim && prim->find(radesys.str().c_str())) { - // if RADESYS present, use it - putFitsCard(chan, "RADESYS", prim->getString(radesys.str().c_str())); - } - else if (hd->find("RADECSYS")) { - // look for old RADECSYS - putFitsCard(chan, "RADESYS", hd->getString("RADECSYS")); - } - else if (prim && prim->find("RADECSYS")) { - // look for old RADECSYS - putFitsCard(chan, "RADESYS", prim->getString("RADECSYS")); - } - else { - // fall back on wcssubs - if (!strncmp("RA",wcs_[ww]->ctype[0],2) || - !strncmp("RA",wcs_[ww]->ctype[1],2)) { - if (!strncmp("FK4",wcs_[ww]->radecsys,3) || - !strncmp("FK4-NO-E",wcs_[ww]->radecsys,8) || - !strncmp("FK5",wcs_[ww]->radecsys,3) || - !strncmp("ICRS",wcs_[ww]->radecsys,4)) - putFitsCard(chan, "RADESYS", wcs_[ww]->radecsys); - } - } - } - - // ast is picky about latpole/longpole - if ((wcs_[ww]->latpole == 999 && wcs_[ww]->longpole == 999) || - (wcs_[ww]->latpole == 0 && wcs_[ww]->longpole == 0)) - ; - else { - if (wcs_[ww]->latpole != 999) - putFitsCard(chan, "LATPOLE", wcs_[ww]->latpole); - if (wcs_[ww]->longpole != 999) - putFitsCard(chan, "LONPOLE", wcs_[ww]->longpole); - } - - // Projection parameters- PV, QV, WAT - // TAN+PV (old SCAMP-backward compatibility) - // TPV+PV (new SCAMP) - // xxx+PV (ZPN generic) - // xxx+QV (TAN AUTOASTROM) - // TNX/ZPX+WAT (IRAF) - // TAN/LIN-SIP (SIP) - - // PVx_y (old SCAMP, SCAMP, generic) - // MAXPV defined in wcs.h - for (int ii=1; ii<=2; ii++) { - for (int mm=0; mm<=MAXPV; mm++) { - ostringstream str,str2; - str << "PV" << ii << '_' << mm << alt << ends; - str2 << "PV" << ii << '_' << mm << ends; - if (hd->find(str.str().c_str())) { - double val = hd->getReal(str.str().c_str(),0); - putFitsCard(chan, str2.str().c_str(), val); - } - else if (prim && prim->find(str.str().c_str())) { - double val = prim->getReal(str.str().c_str(),0); - putFitsCard(chan, str2.str().c_str(), val); - } - } - } - - // QVx_y (Autoastrom) - for (int ii=1; ii<=2; ii++) { - for (int mm=0; mm<=MAXPV; mm++) { - ostringstream str,str2; - str << "QV" << ii << '_' << mm << alt << ends; - str2 << "QV" << ii << '_' << mm << ends; - if (hd->find(str.str().c_str())) { - double val = hd->getReal(str.str().c_str(),0); - putFitsCard(chan, str2.str().c_str(), val); - } - else if (prim && prim->find(str.str().c_str())) { - double val = prim->getReal(str.str().c_str(),0); - putFitsCard(chan, str2.str().c_str(), val); - } - } - } - - // WATx_ (IRAF) (primary only) - if ((wcs_[ww]->prjcode == WCS_TNX || wcs_[ww]->prjcode == WCS_ZPX) && !ww) { - for (int jj=0; jj<=2; jj++) { - for (int ii=1; ii<=9; ii++) { - ostringstream str; - str << "WAT" << jj << "_00" << ii << ends; - if (hd->find(str.str().c_str())) { - char* val = hd->getString(str.str().c_str()); - if (val) { - putFitsCard(chan, str.str().c_str(), val); - } - } - else if (prim && prim->find(str.str().c_str())) { - char* val = prim->getString(str.str().c_str()); - if (val) { - putFitsCard(chan, str.str().c_str(), val); - } - } - } - } - } - - // SIP (TAN-SIP/LIN-SIP) (primary only) - if ((wcs_[ww]->prjcode == WCS_TAN || wcs_[ww]->prjcode == WCS_LIN) && - !ww && wcs_[ww]->distcode) { - if (hd->find("A_ORDER")) { - int val = hd->getInteger("A_ORDER",0); - putFitsCard(chan, "A_ORDER", val); - } - else if (prim && prim->find("A_ORDER")) { - int val = prim->getInteger("A_ORDER",0); - putFitsCard(chan, "A_ORDER", val); - } - - if (hd->find("AP_ORDER")) { - int val = hd->getInteger("AP_ORDER",0); - putFitsCard(chan, "AP_ORDER", val); - } - else if (prim && prim->find("AP_ORDER")) { - int val = prim->getInteger("AP_ORDER",0); - putFitsCard(chan, "AP_ORDER", val); - } - - if (hd->find("A_DMAX")) { - double val = hd->getReal("A_DMAX",0); - putFitsCard(chan, "A_DMAX", val); - } - else if (prim && prim->find("A_DMAX")) { - double val = prim->getReal("A_DMAX",0); - putFitsCard(chan, "A_DMAX", val); - } - - if (hd->find("B_ORDER")) { - int val = hd->getInteger("B_ORDER",0); - putFitsCard(chan, "B_ORDER", val); - } - else if (prim && prim->find("B_ORDER")) { - int val = prim->getInteger("B_ORDER",0); - putFitsCard(chan, "B_ORDER", val); - } - - if (hd->find("BP_ORDER")) { - int val = hd->getInteger("BP_ORDER",0); - putFitsCard(chan, "BP_ORDER", val); - } - else if (prim && prim->find("BP_ORDER")) { - int val = prim->getInteger("BP_ORDER",0); - putFitsCard(chan, "BP_ORDER", val); - } - - if (hd->find("B_DMAX")) { - double val = hd->getReal("B_DMAX",0); - putFitsCard(chan, "B_DMAX", val); - } - else if (prim && prim->find("B_DMAX")) { - double val = prim->getReal("B_DMAX",0); - putFitsCard(chan, "B_DMAX", val); - } - - for (int jj=0; jj<=9; jj++) { - for (int ii=0; ii<=9; ii++) { - { - ostringstream str; - str << "A_" << jj << "_" << ii << ends; - if (hd->find(str.str().c_str())) { - double val = hd->getReal(str.str().c_str(),0); - putFitsCard(chan, str.str().c_str(), val); - } - else if (prim && prim->find(str.str().c_str())) { - double val = prim->getReal(str.str().c_str(),0); - putFitsCard(chan, str.str().c_str(), val); - } - } - { - ostringstream str; - str << "AP_" << jj << "_" << ii << ends; - if (hd->find(str.str().c_str())) { - double val = hd->getReal(str.str().c_str(),0); - putFitsCard(chan, str.str().c_str(), val); - } - else if (prim && prim->find(str.str().c_str())) { - double val = prim->getReal(str.str().c_str(),0); - putFitsCard(chan, str.str().c_str(), val); - } - } - { - ostringstream str; - str << "B_" << jj << "_" << ii << ends; - if (hd->find(str.str().c_str())) { - double val = hd->getReal(str.str().c_str(),0); - putFitsCard(chan, str.str().c_str(), val); - } - else if (prim && prim->find(str.str().c_str())) { - double val = prim->getReal(str.str().c_str(),0); - putFitsCard(chan, str.str().c_str(), val); - } - } - { - ostringstream str; - str << "BP_" << jj << "_" << ii << ends; - if (hd->find(str.str().c_str())) { - double val = hd->getReal(str.str().c_str(),0); - putFitsCard(chan, str.str().c_str(), val); - } - else if (prim && prim->find(str.str().c_str())) { - double val = prim->getReal(str.str().c_str(),0); - putFitsCard(chan, str.str().c_str(), val); - } - } - } - } - } -} - -void FitsImage::wcs2ast0(int ww, FitsHead* hd, FitsHead* prim, void* chan) -{ - putFitsCard(chan, "CTYPE1", wcs_[ww]->ctype[0]); - putFitsCard(chan, "CTYPE2", wcs_[ww]->ctype[1]); - - // CRPIX/CRVAL - putFitsCard(chan, "CRPIX1", wcs_[ww]->crpix[0]); - putFitsCard(chan, "CRPIX2", wcs_[ww]->crpix[1]); - putFitsCard(chan, "CRVAL1", wcs_[ww]->crval[0]); - putFitsCard(chan, "CRVAL2", wcs_[ww]->crval[1]); - - putFitsCard(chan, "CD1_1", wcs_[ww]->cd[0]); - putFitsCard(chan, "CD1_2", wcs_[ww]->cd[1]); - putFitsCard(chan, "CD2_1", wcs_[ww]->cd[2]); - putFitsCard(chan, "CD2_2", wcs_[ww]->cd[3]); - - putFitsCard(chan, "EQUINOX", wcs_[ww]->equinox); - - // from wcssub/wcsinit.c line 800 - // wcs[ww]->epoch = 1900.0 + (mjd - 15019.81352) / 365.242198781; - // only set if MJD-OBS or DATE-OBS is present - if (hd->find("MJD-OBS") || hd->find("DATE-OBS") || - (prim && prim->find("MJD-OBS")) || (prim && prim->find("DATE-OBS"))) - putFitsCard(chan, "MJD-OBS", - (wcs_[ww]->epoch-1900)*365.242198781+15019.81352); - - putFitsCard(chan, "RADESYS", wcs_[ww]->radecsys); -} -#endif - -void FitsImage::putFitsCard(void* chan, const char* key, const char* value) -{ - char buf[80]; - memset(buf,'\0', 80); - - ostringstream str; - str.setf(ios::left,ios::adjustfield); - str.width(8); - str << key << "= '" << value << "'"; - memcpy(buf,str.str().c_str(),str.str().length()); - - astPutFits(chan, buf, 0); - astClearStatus; - - if (DebugWCS) - cerr << str.str().c_str() << endl; -} - -void FitsImage::putFitsCard(void* chan, const char* key, int value) -{ - char buf[80]; - memset(buf,'\0', 80); - - ostringstream str; - str.setf(ios::left,ios::adjustfield); - str.width(8); - str << key << "= " << value; - memcpy(buf,str.str().c_str(),str.str().length()); - - astPutFits(chan, buf, 0); - astClearStatus; - - if (DebugWCS) - cerr << str.str().c_str() << endl; -} - -void FitsImage::putFitsCard(void* chan, const char* key, double value) -{ - char buf[80]; - memset(buf,'\0', 80); - - ostringstream str; - str.setf(ios::left,ios::adjustfield); - str.setf(ios::scientific,ios::floatfield); - str.width(8); - str.precision(16); - str << key << "= " << value; - memcpy(buf,str.str().c_str(),str.str().length()); - - astPutFits(chan, buf, 0); - astClearStatus; - - if (DebugWCS) - cerr << str.str().c_str() << endl; -} diff --git a/tksao/frame/fitsimage.h b/tksao/frame/fitsimage.h index 88a1969..e25e574 100644 --- a/tksao/frame/fitsimage.h +++ b/tksao/frame/fitsimage.h @@ -111,10 +111,6 @@ class FitsImage { int address[FTY_MAXAXES]; int manageWCS_; -#ifdef OLDWCS - WorldCoor** wcs_; // wcs list - WCSx** wcsx_; // xth Axis WCS -#else int astInv_; // can we inverse? int* wcs_; int* wcsCel_; @@ -129,7 +125,7 @@ class FitsImage { int* wcsCelSav_; int* wcs3DSav_; int wcsHPXSav_; -#endif + FitsHead* wcsAltHeader_; // alt wcs header FitsHead* wfpc2Header_; // wcs header for wfpc2 FitsHead* wcs0Header_; @@ -137,11 +133,7 @@ class FitsImage { Matrix wcsToRef_; // iraf/wcs matrix public: -#ifdef OLDWCS - AstFrameSet** ast_; // ast frameset; -#else AstFrameSet* ast_; // ast frameset; -#endif private: char* root(const char*); @@ -159,20 +151,6 @@ class FitsImage { void initHPX(); void initWCSPhysical(); -#ifdef OLDWCS - void initWCS(FitsHead*, FitsHead* =NULL); - void wcsShow(WorldCoor*); - void astinit(int, FitsHead*, FitsHead*); - AstFrameSet* buildast(int, FitsHead*, FitsHead*); - AstFrameSet* buildast0(int, FitsHead*, FitsHead*); - void wcs2ast(int, FitsHead*, FitsHead*, void*); - void wcs2ast0(int, FitsHead*, FitsHead*, void*); - void header2ast(int,FitsHead*, void*); - void astinit0(int, FitsHead*, FitsHead*); - - void initWCS0(const Vector&); - void resetWCS0(); -#else void initWCS(FitsHead*); void astInit(FitsHead*); void wcsInit(int); @@ -183,10 +161,7 @@ class FitsImage { void initWCS0(const Vector&); void resetWCS0() {resetWCS();} -#endif - void putFitsCard(void* chan, const char* key, const char* value); - void putFitsCard(void* chan, const char* key, int value); - void putFitsCard(void* chan, const char* key, double value); + int checkWCS(Vector&); int checkWCS(Vector3d&); AstFrameSet* fits2ast(FitsHead*); @@ -402,17 +377,11 @@ class FitsImage { char* pix2wcs(const Vector&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, char*); -#ifdef OLDWCS - WCSx** wcsx() {return wcsx_;} - double pix2wcsx(double, Coord::CoordSystem); - double wcs2pixx(double, Coord::CoordSystem); -#else int astInv() {return astInv_;} 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 void wfpc2WCS(istream&); void appendWCS(istream&); @@ -430,19 +399,6 @@ class FitsImage { double getWCSDist(const Vector&, const Vector&, Coord::CoordSystem); const char* getWCSName(Coord::CoordSystem); -#ifdef OLDWCS - WorldCoor* getWCS(Coord::CoordSystem sys) - {return (wcs_ && wcs_[sys-Coord::WCS]) ? wcs_[sys-Coord::WCS] : NULL;} - Vector getWCScdelt(Coord::CoordSystem); - - Vector wcsTran(AstFrameSet*, const Vector&, int); - void wcsTran(AstFrameSet*, int, Vector*, int, Vector*); - double wcsDistance(AstFrameSet*, const Vector&, const Vector&); - - int wcsIsASkyFrame(AstFrameSet*); - void setWCSSkyFrame(AstFrameSet*, Coord::SkyFrame); - void setWCSFormat(AstFrameSet*, int, const char*); -#else Vector wcsTran(const Vector&, int); Vector3d wcsTran(const Vector3d&, int); void wcsTran(int num, Vector* in, int forward, Vector* out) @@ -457,7 +413,6 @@ class FitsImage { double getWCSSize(Coord::CoordSystem); double calcWCSSize(Coord::CoordSystem); -#endif int hasWCS(Coord::CoordSystem); int hasWCSCel(Coord::CoordSystem); @@ -484,10 +439,9 @@ class FitsImage { Vector mapFromRef(const Vector&, Coord::CoordSystem, Coord::SkyFrame =Coord::FK5); void mapFromRef(const Vector&, Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, char*); Vector mapToRef(const Vector&, Coord::CoordSystem, Coord::SkyFrame =Coord::FK5); -#ifndef OLDWCS Vector3d mapFromRef(const Vector3d&, Coord::CoordSystem, Coord::SkyFrame =Coord::FK5); Vector3d mapToRef(const Vector3d&, Coord::CoordSystem, Coord::SkyFrame =Coord::FK5); -#endif + double mapFromImage3d(double, Coord::CoordSystem); double mapToImage3d(double, Coord::CoordSystem); diff --git a/tksao/frame/fitsmap.C b/tksao/frame/fitsmap.C index 8b34f35..432fdba 100644 --- a/tksao/frame/fitsmap.C +++ b/tksao/frame/fitsmap.C @@ -59,7 +59,6 @@ Vector FitsImage::mapToRef(const Vector& vv, Coord::CoordSystem in, return Vector(); } -#ifndef OLDWCS Vector3d FitsImage::mapFromRef(const Vector3d& vv, Coord::CoordSystem out, Coord::SkyFrame sky) { @@ -93,7 +92,6 @@ Vector3d FitsImage::mapToRef(const Vector3d& vv, Coord::CoordSystem in, return Vector3d(); } -#endif void FitsImage::listFromRef(ostream& str, const Vector& vv, Coord::CoordSystem sys, Coord::SkyFrame sky, @@ -182,13 +180,7 @@ 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: @@ -229,13 +221,7 @@ 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: @@ -421,23 +407,6 @@ void FitsImage::listDistFromRef(ostream& str, // 3D -#ifdef OLDWCS -double FitsImage::mapFromImage3d(double dd, Coord::CoordSystem sys) -{ - if (sys >= Coord::WCS) - return pix2wcsx(dd,sys); - else - return dd; -} - -double FitsImage::mapToImage3d(double dd, Coord::CoordSystem sys) -{ - if (sys >= Coord::WCS) - return wcs2pixx(dd,sys); - else - return dd; -} -#else double FitsImage::mapFromImage3d(double dd, Coord::CoordSystem sys) { if (hasWCS(sys)) { @@ -460,4 +429,3 @@ double FitsImage::mapToImage3d(double dd, Coord::CoordSystem sys) else return dd; } -#endif diff --git a/tksao/frame/frame3dbase.C b/tksao/frame/frame3dbase.C index 9f9dd2f..74818ed 100644 --- a/tksao/frame/frame3dbase.C +++ b/tksao/frame/frame3dbase.C @@ -152,57 +152,6 @@ void Frame3dBase::getInfoCmd(const Vector& vv, Coord::InternalSystem ref, getInfoClearValue(var); } -#ifdef OLDWCS -void Frame3dBase::getInfoWCS(char* var, Vector3d& rr, FitsImage* ptr, - FitsImage* sptr) -{ - Vector3d img = rr * sptr->refToImage3d; - - for (int ii=0; ii<MULTWCS; ii++) { - char buf[64]; - char ww = !ii ? '\0' : '`'+ii; - Coord::CoordSystem www = (Coord::CoordSystem)(Coord::WCS+ii); - - if (hasWCS(www)) { - char buff[128]; - sptr->pix2wcs(Vector(img), www, wcsSky_, wcsSkyFormat_, buff); - - int argc; - const char** argv; - Tcl_SplitList(interp, buff, &argc, &argv); - - if (argc > 0 && argv && argv[0]) - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),argv[0],0); - else - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),"",0); - - if (argc > 1 && argv && argv[1]) - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),argv[1],0); - else - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),"",0); - - char* wcsname = (char*)sptr->getWCSName(www); - if (wcsname) - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),wcsname,0); - else if (argc > 2 && argv && argv[2]) - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),argv[2],0); - else - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),"",0); - - double ss = ptr->mapFromImage3d(img[2],www); - doubleToTclArray(ss,var,varcat(buf,(char*)"wcs",ww,(char*)""),"z"); - - Tcl_Free((char*)argv); - } - else { - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),"",0); - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),"",0); - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",z"),"",0); - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),"",0); - } - } -} -#else void Frame3dBase::getInfoWCS(char* var, Vector3d& rr, FitsImage* ptr, FitsImage* sptr) { @@ -254,21 +203,7 @@ void Frame3dBase::getInfoWCS(char* var, Vector3d& rr, FitsImage* ptr, } } } -#endif - -#ifdef OLDWCS -void Frame3dBase::coordToTclArray(FitsImage* ptr, const Vector3d& vv, - Coord::CoordSystem out, - const char* var, const char* base) -{ - Vector rr = ptr->mapFromRef(vv, out); - doubleToTclArray(rr[0], var, base, "x"); - doubleToTclArray(rr[1], var, base, "y"); - double ss = ptr->mapFromImage3d(((Vector3d&)vv)[2]+.5,out); - doubleToTclArray(ss, var, base, "z"); -} -#else void Frame3dBase::coordToTclArray(FitsImage* ptr, const Vector3d& vv, Coord::CoordSystem out, const char* var, const char* base) @@ -278,7 +213,6 @@ void Frame3dBase::coordToTclArray(FitsImage* ptr, const Vector3d& vv, doubleToTclArray(rr[1], var, base, "y"); doubleToTclArray(rr[2], var, base, "z"); } -#endif void Frame3dBase::calcBorder(Coord::InternalSystem sys, FrScale::SecMode mode, Vector3d* vv, int* dd) @@ -1010,82 +944,6 @@ void Frame3dBase::updatePannerMatrices() Base::updatePannerMatrices(); } -#ifdef OLDWCS -void Frame3dBase::updatePanner() -{ - // do this first - Base::updatePanner(); - - // always render (to update panner background color) - if (usePanner) { - if (keyContext->fits) { - XSetForeground(display, pannerGC, getColor("black")); - x11Border(Coord::PANNER,FrScale::IMGSEC,pannerGC,pannerPixmap); - } - - ostringstream str; - str << pannerName << " update " << (void*)pannerPixmap << ';'; - - // calculate bbox - Vector ll = Vector(0,0) * widgetToPanner3d; - Vector lr = Vector(options->width,0) * widgetToPanner3d; - Vector ur = Vector(options->width,options->height) * widgetToPanner3d; - Vector ul = Vector(0,options->height) * widgetToPanner3d; - - str << pannerName << " update bbox " - << ll << ' ' << lr << ' ' << ur << ' ' << ul << ';'; - - // calculate image compass vectors - Matrix3d mm = - Matrix3d(wcsOrientationMatrix) * - Matrix3d(orientationMatrix) * - RotateZ3d(wcsRotation) * - RotateZ3d(rotation) * - RotateY3d(az_) * - RotateX3d(-el_) * - FlipY3d(); - - Vector xx = (Vector3d(1,0,0)*mm).normalize(); - Vector yy = (Vector3d(0,1,0)*mm).normalize(); - Vector zz = (Vector3d(0,0,1)*mm).normalize(); - - str << pannerName << " update image compass " - << xx << ' ' << yy << ' ' << zz << ';'; - - if (keyContext->fits && keyContext->fits->hasWCS(wcsSystem_)) { - Vector orpix = keyContext->fits->center(); - Vector orval=keyContext->fits->pix2wcs(orpix, wcsSystem_, wcsSky_); - Vector orpix2 = keyContext->fits->wcs2pix(orval, wcsSystem_,wcsSky_); - Vector delta = keyContext->fits->getWCScdelt(wcsSystem_).abs(); - - // find normalized north - Vector npix = keyContext->fits->wcs2pix(Vector(orval[0],orval[1]+delta[1]), wcsSystem_,wcsSky_); - Vector north = (Vector3d(npix-orpix2)*mm).normalize(); - - // find normalized east - Vector epix = keyContext->fits->wcs2pix(Vector(orval[0]+delta[0],orval[1]), wcsSystem_,wcsSky_); - Vector east = (Vector3d(epix-orpix2)*mm).normalize(); - - // sanity check - Vector diff = (north-east).abs(); - if ((north[0]==0 && north[1]==0) || - (east[0]==0 && east[1]==0) || - (diff[0]<.01 && diff[1]<.01)) { - north = (Vector3d(0,1)*mm).normalize(); - east = (Vector3d(-1,0)*mm).normalize(); - } - - // and update the panner - str << pannerName << " update wcs compass " - << north << ' ' << east << ends; - } - else - str << pannerName << " update wcs compass invalid" << ends; - - Tcl_Eval(interp, str.str().c_str()); - } -} -#else void Frame3dBase::updatePanner() { // do this first @@ -1154,7 +1012,6 @@ void Frame3dBase::updatePanner() Tcl_Eval(interp, str.str().c_str()); } } -#endif void Frame3dBase::x11Graphics() { diff --git a/tksao/frame/framebase.C b/tksao/frame/framebase.C index d4be1d7..075de88 100644 --- a/tksao/frame/framebase.C +++ b/tksao/frame/framebase.C @@ -284,70 +284,6 @@ void FrameBase::updateBin(const Matrix& mx) Base::updateBin(mx); } -#ifdef OLDWCS -void FrameBase::updatePanner() -{ - Base::updatePanner(); - - if (usePanner) { - ostringstream str; - - str << pannerName << " update " << (void*)pannerPixmap << ';'; - - // calculate bbox - Vector ll = Vector(0,0) * widgetToPanner; - Vector lr = Vector(options->width,0) * widgetToPanner; - Vector ur = Vector(options->width,options->height) * widgetToPanner; - Vector ul = Vector(0,options->height) * widgetToPanner; - - str << pannerName << " update bbox " - << ll << ' ' << lr << ' ' << ur << ' ' << ul << ';'; - - // calculate image compass vectors - Matrix mm = - FlipY() * - irafMatrix_ * - wcsOrientationMatrix * - Rotate(wcsRotation) * - orientationMatrix * - Rotate(rotation); - - Vector xx = (Vector(1,0)*mm).normalize(); - Vector yy = (Vector(0,1)*mm).normalize(); - - str << pannerName << " update image compass " - << xx << ' ' << yy << ';'; - - if (keyContext->fits && keyContext->fits->hasWCS(wcsSystem_)) { - Vector orpix = keyContext->fits->center(); - Vector orval=keyContext->fits->pix2wcs(orpix, wcsSystem_, wcsSky_); - Vector orpix2 = keyContext->fits->wcs2pix(orval, wcsSystem_,wcsSky_); - Vector delta = keyContext->fits->getWCScdelt(wcsSystem_).abs(); - - Vector npix = keyContext->fits->wcs2pix(Vector(orval[0],orval[1]+delta[1]), wcsSystem_,wcsSky_); - Vector north = ((npix-orpix2)*mm).normalize(); - Vector epix = keyContext->fits->wcs2pix(Vector(orval[0]+delta[0],orval[1]), wcsSystem_,wcsSky_); - Vector east = ((epix-orpix2)*mm).normalize(); - - // sanity check - Vector diff = (north-east).abs(); - if ((north[0]==0 && north[1]==0) || - (east[0]==0 && east[1]==0) || - (diff[0]<.01 && diff[1]<.01)) { - north = (Vector(0,1)*mm).normalize(); - east = (Vector(-1,0)*mm).normalize(); - } - - str << pannerName << " update wcs compass " - << north << ' ' << east << ends; - } - else - str << pannerName << " update wcs compass invalid" << ends; - - Tcl_Eval(interp, str.str().c_str()); - } -} -#else void FrameBase::updatePanner() { Base::updatePanner(); @@ -408,7 +344,6 @@ void FrameBase::updatePanner() Tcl_Eval(interp, str.str().c_str()); } } -#endif void FrameBase::x11MagnifierCursor(const Vector& vv) { diff --git a/tksao/frame/framergb.C b/tksao/frame/framergb.C index b197f05..cee716f 100644 --- a/tksao/frame/framergb.C +++ b/tksao/frame/framergb.C @@ -90,22 +90,6 @@ void FrameRGB::alignWCS(Coord::CoordSystem sys, Coord::SkyFrame sky) updateRGBMatrices(); } -#ifdef OLDWCS -void FrameRGB::alignWCS(FitsImage* ptr, Coord::CoordSystem sys) -{ - if (!wcsAlign_ || !(keyContext->fits) || !ptr || - !keyContext->fits->hasWCS(wcsSystem_)) { - wcsOrientation = Coord::NORMAL; - wcsOrientationMatrix.identity(); - wcsRotation = 0; - } - else - calcAlignWCS(ptr, keyContext->fits, wcsSystem_, sys, wcsSky_, - &wcsOrientation, &wcsOrientationMatrix, &wcsRotation, &zoom_); - - updateRGBMatrices(); -} -#else void FrameRGB::alignWCS(FitsImage* ptr, Coord::CoordSystem sys) { if (!wcsAlign_ || !(keyContext->fits) || !ptr || @@ -128,7 +112,6 @@ void FrameRGB::alignWCS(FitsImage* ptr, Coord::CoordSystem sys) updateRGBMatrices(); } -#endif int FrameRGB::doRender() { diff --git a/tksao/frame/frblt.C b/tksao/frame/frblt.C index f79df87..00356bc 100644 --- a/tksao/frame/frblt.C +++ b/tksao/frame/frblt.C @@ -372,12 +372,7 @@ int Base::markerAnalysisRadial(Marker* pp, double** x, double** y, double** e, int unit =0; double xaxis =1; if (ptr->hasWCS(sys)) { -#ifdef OLDWCS - Vector cdelt= ptr->getWCScdelt(sys); - double ll = fabs(cdelt[0]); -#else double ll = ptr->getWCSSize(sys); -#endif if (ptr->hasWCSCel(sys)) { unit =1; @@ -389,13 +384,8 @@ int Base::markerAnalysisRadial(Marker* pp, double** x, double** y, double** e, } } -#ifdef OLDWCS - Vector cdelt= ptr->getWCScdelt(sys); - double aa = fabs(cdelt[0]*cdelt[1]); -#else double rr = ptr->getWCSSize(sys); double aa = rr*rr; -#endif for (int kk=0; kk<num; kk++) { double err = sqrt(fabs(sum[kk])); @@ -496,12 +486,7 @@ int Base::markerAnalysisPanda(Marker* pp, double** x, double** y, double** e, int unit =0; double xaxis =1; if (ptr->hasWCS(sys)) { -#ifdef OLDWCS - Vector cdelt= ptr->getWCScdelt(sys); - double ll = fabs(cdelt[0]); -#else double ll = ptr->getWCSSize(sys); -#endif if (ptr->hasWCSCel(sys)) { unit =1; @@ -513,13 +498,8 @@ int Base::markerAnalysisPanda(Marker* pp, double** x, double** y, double** e, } } -#ifdef OLDWCS - Vector cdelt= ptr->getWCScdelt(sys); - double aa = fabs(cdelt[0]*cdelt[1]); -#else double rr = ptr->getWCSSize(sys); double aa = rr*rr; -#endif for (int qq=0; qq<aa; qq++) { for (int kk=0; kk<num; kk++) { @@ -834,12 +814,7 @@ int Base::markerAnalysisStats1(Marker* pp,FitsImage* ptr, ostream& str, return 0; default: { -#ifdef OLDWCS - Vector cdelt= ptr->getWCScdelt(sys); - double ll = fabs(cdelt[0]); -#else double ll = ptr->getWCSSize(sys); -#endif if (ptr->hasWCSCel(sys)) { str << "1 pixel = "<< ll*60*60 << " arcsec"; str << endl << endl; @@ -880,26 +855,16 @@ void Base::markerAnalysisStats2(FitsImage* ptr, ostream& str, case 1: { // Cel WCS -#ifdef OLDWCS - Vector cdelt= ptr->getWCScdelt(sys); - double aa = fabs(cdelt[0]*cdelt[1]); -#else double rr = ptr->getWCSSize(sys); double aa = rr*rr; -#endif area = aa*60*60*60*60*cnt; } break; case 2: { // Linear WCS -#ifdef OLDWCS - Vector cdelt= ptr->getWCScdelt(sys); - double aa = fabs(cdelt[0]*cdelt[1]); -#else double rr = ptr->getWCSSize(sys); double aa = rr*rr; -#endif area = aa*cnt; } break; diff --git a/tksao/frame/frsave.C b/tksao/frame/frsave.C index b14a9b1..b0f854e 100644 --- a/tksao/frame/frsave.C +++ b/tksao/frame/frsave.C @@ -438,64 +438,6 @@ void FrameBase::saveFitsResampleKeyword(OutFitsStream& str, FitsHead& dst) // WCS if (currentContext->fits->hasWCS(Coord::WCS)) { - -#ifdef OLDWCS - WorldCoor* wcs = currentContext->fits->getWCS(Coord::WCS); - - // abort if this is a DSS, ZPN, TNX - if (!strncmp(wcs->ptype,"DSS",3) || - !strncmp(wcs->ptype,"ZPN",3) || - !strncmp(wcs->ptype,"TNX",3)) - return; - - dst.appendString("RADESYS", wcs->radecsys, NULL); - dst.appendReal("EQUINOX", wcs->equinox, 9, NULL); - - dst.appendString("CTYPE1", wcs->ctype[0], NULL); - dst.appendString("CTYPE2", wcs->ctype[1], NULL); - dst.appendReal("CRVAL1", wcs->crval[0], 9, NULL); - dst.appendReal("CRVAL2", wcs->crval[1], 9, NULL); - - char* cunit1 = src->getString("CUNIT1"); - if (cunit1) - dst.appendString("CUNIT1", cunit1, NULL); - - char* cunit2 = src->getString("CUNIT2"); - if (cunit2) - dst.appendString("CUNIT2", cunit2, NULL); - - // crpix - Vector crpix = Vector(wcs->crpix[0],wcs->crpix[1]) * - currentContext->fits->imageToWidget * - Translate(-center) * - Translate(1,0) * - FlipY() * - Translate(center); - - dst.appendReal("CRPIX1", crpix[0], 9, NULL); - dst.appendReal("CRPIX2", crpix[1], 9, NULL); - - // cd matrix - Matrix cd = Matrix(wcs->cd[0],wcs->cd[1],wcs->cd[2],wcs->cd[3],0,0) * - currentContext->fits->imageToRef * refToUser * - wcsOrientationMatrix * - Rotate(wcsRotation) * - orientationMatrix * - Scale(zoom_.invert()) * - Rotate(rotation) * - Translate(center) * - Translate(-center) * - Translate(1,0) * - FlipY() * - Translate(center); - - dst.appendReal("CD1_1", cd.matrix(0,0), 9, NULL); - dst.appendReal("CD1_2", cd.matrix(0,1), 9, NULL); - dst.appendReal("CD2_1", cd.matrix(1,0), 9, NULL); - dst.appendReal("CD2_2", cd.matrix(1,1), 9, NULL); - -#else - if (src->find("RADESYS")) dst.appendString("RADESYS", src->getString("RADESYS"), NULL); if (src->find("EQUINOX")) @@ -612,7 +554,6 @@ void FrameBase::saveFitsResampleKeyword(OutFitsStream& str, FitsHead& dst) dst.appendReal("CD2_1", cd.matrix(1,0), 9, NULL); dst.appendReal("CD2_2", cd.matrix(1,1), 9, NULL); } -#endif } } diff --git a/tksao/frame/grid25d.C b/tksao/frame/grid25d.C index f3a698f..ae5a428 100644 --- a/tksao/frame/grid25d.C +++ b/tksao/frame/grid25d.C @@ -58,10 +58,6 @@ int Grid25d::doit(RenderMode rm) default: { // set desired skyformat -#ifdef OLDWCS - AstFrameSet* ast = (AstFrameSet*)astCopy(fits->ast_[system_-Coord::WCS]); - fits->setWCSSkyFrame(ast, sky_); -#else if (!fits->astInv()) { astEnd; // now, clean up memory return 1; @@ -96,7 +92,6 @@ int Grid25d::doit(RenderMode rm) } break; } -#endif // add wcs to frameset // this will link frameset to wcs with unitMap int id = astGetI(ast,"Current"); diff --git a/tksao/frame/grid2d.C b/tksao/frame/grid2d.C index b247648..567a3f8 100644 --- a/tksao/frame/grid2d.C +++ b/tksao/frame/grid2d.C @@ -59,10 +59,6 @@ int Grid2d::doit(RenderMode rm) { // set desired skyformat -#ifdef OLDWCS - AstFrameSet* ast = (AstFrameSet*)astCopy(fits->ast_[system_-Coord::WCS]); - fits->setWCSSkyFrame(ast, sky_); -#else if (!fits->astInv()) { astEnd; // now, clean up memory return 1; @@ -97,7 +93,6 @@ int Grid2d::doit(RenderMode rm) } break; } -#endif // add wcs to frameset // this will link frameset to wcs with unitMap int id = astGetI(ast,"Current"); diff --git a/tksao/frame/grid3d.C b/tksao/frame/grid3d.C index 09c3557..e36b36d 100644 --- a/tksao/frame/grid3d.C +++ b/tksao/frame/grid3d.C @@ -22,27 +22,6 @@ Grid3d::Grid3d(Widget* p, Coord::CoordSystem sys, Coord::SkyFrame sky, Grid3d::~Grid3d() {} -#ifdef OLDWCS -static FitsImage* foobar; - -void bar(AstMapping* that, int npoint, int ncoord_in, const double* ptr_in[], - int forward, int ncoord_out, double* ptr_out[]) -{ - WCSx** wcsx = foobar->wcsx(); - - if (forward) { - for (int ii=0; ii<npoint; ii++) - (*ptr_out)[ii] = (.5 + (*ptr_in)[ii] - wcsx[0]->crpix) * - wcsx[0]->cd + wcsx[0]->crval; - } - else { - for (int ii=0; ii<npoint; ii++) - (*ptr_out)[ii] = ((*ptr_in)[ii] - wcsx[0]->crval) / - wcsx[0]->cd + wcsx[0]->crpix -.5; - } -} -#endif - int Grid3d::doit(RenderMode rm) { Frame3dBase* pp = (Frame3dBase*)parent_; @@ -80,34 +59,6 @@ int Grid3d::doit(RenderMode rm) break; default: { - -#ifdef OLDWCS - foobar = fits; - AstFrameSet* ast = (AstFrameSet*)astCopy(fits->ast_[system_-Coord::WCS]); - fits->setWCSSkyFrame(ast, sky_); - - AstFrame* zbase = astFrame(1,""); - AstFrame* zcurr = astFrame(1,""); - AstMapping* zmap; - if (fits->hasWCS3D(system_)) { - astIntraReg("foo",1,1,bar,0,"testing","me","you"); - if (!(zmap = (AstMapping*)astIntraMap("foo",1,1,""))) - return 0; - } - else - zmap = (AstMapping*)astUnitMap(1,""); - - AstFrame* wcsbase = (AstFrame*)astGetFrame(ast,AST__BASE); - AstFrame* wcscurr = (AstFrame*)astGetFrame(ast,AST__CURRENT); - AstMapping* wcsmap = (AstMapping*)astGetMapping(ast,AST__BASE,AST__CURRENT); - AstCmpFrame* cmpwcsbase = astCmpFrame(wcsbase,zbase,""); - AstCmpFrame* cmpwcscurr = astCmpFrame(wcscurr,zcurr,""); - - AstCmpMap* cmpwcsmap = astCmpMap(wcsmap,zmap,0,""); - - ast = astFrameSet(cmpwcsbase,""); - astAddFrame(ast, AST__CURRENT, cmpwcsmap, cmpwcscurr); -#else if (!fits->astInv()) { astEnd; // now, clean up memory return 1; @@ -155,7 +106,7 @@ int Grid3d::doit(RenderMode rm) } break; } -#endif + // add wcs to frameset // this will link frameset to wcs with unitMap int id = astGetI(ast,"Current"); |