summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-07-26 18:47:37 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-07-26 18:47:37 (GMT)
commit7893a11b6dbc514d583a414577979b12226d58d9 (patch)
tree304dffce487636c335d6b6f720ed152be201a11b
parent1426a5fd1196e30b8e2eecbf01e34e36a787e287 (diff)
downloadblt-7893a11b6dbc514d583a414577979b12226d58d9.zip
blt-7893a11b6dbc514d583a414577979b12226d58d9.tar.gz
blt-7893a11b6dbc514d583a414577979b12226d58d9.tar.bz2
clean up template code
-rw-r--r--tksao/frame/fitsimage.C120
-rw-r--r--tksao/frame/fitsimage.h9
2 files changed, 24 insertions, 105 deletions
diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C
index 5e98a39..105f0b0 100644
--- a/tksao/frame/fitsimage.C
+++ b/tksao/frame/fitsimage.C
@@ -118,13 +118,6 @@ FitsImage::FitsImage(Context* cx, Tcl_Interp* pp)
wcsCel_ =NULL;
wcs3D_ =NULL;
wcsHPX_ =0;
-
- astSav_ =NULL;
- astInvSav_ =0;
- wcsSav_ =NULL;
- wcsCelSav_ =NULL;
- wcs3DSav_ =NULL;
- wcsHPXSav_ =0;
#endif
wcsAltHeader_ =NULL;
wfpc2Header_ =NULL;
@@ -1425,34 +1418,20 @@ void FitsImage::initWCS0(const Vector& pix)
if (!ast_)
return;
- // 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;
-
- // no warning messages
- astClear(chan,"Warnings");
-
- // basics (needed by fitschan.c)
- putFitsCard(chan, "NAXIS1", (int)naxis(0));
- putFitsCard(chan, "NAXIS2", (int)naxis(1));
+ FitsHead* hd = new FitsHead(naxis(0), naxis(1), 1, -32);
// CTYPE
- putFitsCard(chan, "CTYPE1", "RA---TAN");
- putFitsCard(chan, "CTYPE2", "DEC--TAN");
+ hd->appendString("CTYPE1", "RA---TAN", NULL);
+ hd->appendString("CTYPE2", "DEC--TAN", NULL);
// CRPIX
Vector cc = mapFromRef(pix, Coord::IMAGE, Coord::FK5);
- putFitsCard(chan, "CRPIX1", cc[1]);
- putFitsCard(chan, "CRPIX2", cc[0]);
+ hd->appendReal("CRPIX1", cc[1], 8, NULL);
+ hd->appendReal("CRPIX2", cc[0], 8, NULL);
// CRVAL
- putFitsCard(chan, "CRVAL1", 0);
- putFitsCard(chan, "CRVAL2", 0);
+ hd->appendReal("CRVAL1", 0, 8, NULL);
+ hd->appendReal("CRVAL2", 0, 8, NULL);
// CD
float ss = getWCSPixelSize(Coord::WCS);
@@ -1468,85 +1447,22 @@ void FitsImage::initWCS0(const Vector& pix)
break;
};
Matrix mx = flip*Rotate(ang)*Scale(ss);
- putFitsCard(chan, "CD1_1", mx[0][0]);
- putFitsCard(chan, "CD1_2", mx[0][1]);
- putFitsCard(chan, "CD2_1", mx[1][0]);
- putFitsCard(chan, "CD2_2", mx[1][1]);
+ hd->appendReal("CD1_1", mx[0][0], 8, NULL);
+ hd->appendReal("CD1_2", mx[0][1], 8, NULL);
+ hd->appendReal("CD2_1", mx[1][0], 8, NULL);
+ hd->appendReal("CD2_2", mx[1][1], 8, NULL);
// EPOCH, EQUINOX
- putFitsCard(chan, "EPOCH", 2000);
- putFitsCard(chan, "EQUINOX", 2000);
+ hd->appendReal("EPOCH", 2000, 8, NULL);
+ hd->appendReal("EQUINOX", 2000, 8, NULL);
// RADESYS
- putFitsCard(chan, "RADESYS", "FK5");
-
- // all done
- // 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;
+ hd->appendString("RADESYS", "FK5", NULL);
- // save current wcs
- astSav_ = ast_;
- astInvSav_ = astInv_;
- wcsSav_ = wcs_;
- wcsCelSav_ = wcsCel_;
- wcs3DSav_ = wcs3D_;
- wcsHPXSav_ = wcsHPX_;
-
- // set up temp wcs
- ast_ = frameSet;
- astInv_ = 1;
- wcs_ = new int[MULTWCS];
- for (int ii=0; ii<MULTWCS; ii++)
- wcs_[ii] =0;
- wcs_[0] =1;
- wcsCel_ = new int[MULTWCS];
- for (int ii=0; ii<MULTWCS; ii++)
- wcsCel_[ii] =0;
- wcsCel_[0] = 1;
- wcs3D_ = new int[MULTWCS];
- for (int ii=0; ii<MULTWCS; ii++)
- wcs3D_[ii] =0;
- wcsHPX_ = 0;
-
- if (DebugWCS)
- astShow(frameSet);
-
- // cleanup
- astAnnul(chan);
-}
-
-void FitsImage::resetWCS0()
-{
- if (wcs_)
- delete [] wcs_;
- if (wcsCel_)
- delete [] wcsCel_;
- if (wcs3D_)
- delete [] wcs3D_;
-
- // restore current wcs
- ast_ = astSav_;
- astInv_ = astInvSav_;
- wcs_ = wcsSav_;
- wcsCel_ = wcsCelSav_;
- wcs3D_ = wcs3DSav_;
- wcsHPX_ = wcsHPXSav_;
-
- // reset temp wcs
- astSav_ =NULL;
- astInvSav_ =0;
- wcsSav_ =NULL;
- wcsCelSav_ =NULL;
- wcs3DSav_ =NULL;
- wcsHPXSav_ =0;
+ if (wcs0Header_)
+ delete wcs0Header_;
+ wcs0Header_ = hd;
+ initWCS(wcs0Header_);
}
#endif
diff --git a/tksao/frame/fitsimage.h b/tksao/frame/fitsimage.h
index 6d778a1..acea52a 100644
--- a/tksao/frame/fitsimage.h
+++ b/tksao/frame/fitsimage.h
@@ -168,6 +168,9 @@ class FitsImage {
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*);
@@ -175,6 +178,9 @@ class FitsImage {
void wcsCelInit(int);
void wcs3DInit(int);
void wcsHPXInit();
+
+ 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);
@@ -410,9 +416,6 @@ class FitsImage {
void resetWCS();
void replaceWCS(istream&);
- void initWCS0(const Vector&);
- void resetWCS0();
-
void processKeywordsPhysical();
void processKeywordsParams();
void processKeywordsFitsSection();