#include #include #include #include #include "sopnamsp.h" #include "histinit.h" #include "dvlist.h" #include "fitsswapper.h" #include "fiosinit.h" #include "swfitsdtable.h" void test_fdtable() ; int main(int narg, char *arg[]) { SophyaInit(); FitsIOServerInit(); try { /* if (*arg[1] == 'd') test_dvl(); else if (*arg[1] == 'n') test_ntuple(); // else if (*arg[1] == 'x') test_xntuple(); else if (*arg[1] == 'X') test_Xntuple(); */ test_fdtable(); } catch(PThrowable exc ) { cerr << "tswfits-main() , Catched exception: \n" << exc.Msg() << endl; } catch(std::exception ex) { cerr << "tswfits-main() , Catched exception ! " << (string)(ex.what()) << endl; } catch(...) { cerr << "tswfits-main() , Catched ... ! " << endl; } } void test_fdtable() { cout << "======= test_fdtable: simple DataTable+FITS test ======= " << endl; int SWSEGSZ = 4; vector tags; { cout << " Creation FITSDataSwapper swout(so) avec swseg.fits " << endl; vector ttype, tform, tunit; ttype.push_back("D-Col1"); tform.push_back("D"); tunit.push_back(""); // ttype.push_back("I-Col2"); // tform.push_back("J"); // tunit.push_back(""); string tblnm = "SwapMyExt"; FitsInOutFile fiosc("!swseg.fits", FitsInOutFile::Fits_Create); // fiosc.MoveAbsToHDU(2); cout << " DBG-Appel CreateTable ... " << endl; fiosc.CreateTable(BINARY_TBL, "rzbintbl", ttype, tform, tunit); cout << " ---- Appel a FITSDataSwapper --- " << endl; FITSDataSwapper swout(fiosc, 1); SwSegDataBlock swsd(swout, SWSEGSZ, 3); // FITSDataSwapper swout(&fiosc, 1); // SwSegDataBlock swsd(swout, SWSEGSZ, 3); double * fp = swsd.GetSegment(0); fp[0] = 6.54321; fp[1] = 65.4321; fp[2] = 654.321; fp[3] = 6543.21; fp = swsd.GetSegment(1); fp[0] = 2.56789; fp[1] = 25.6789; fp[2] = 256.789; fp[3] = 2567.89; fp = swsd.GetSegment(2); fp[0] = 12.567; fp[1] = 225.67; fp[2] = 3256.7; fp[3] = 42567.; tags = swsd.GetSwapPosTagTable(); cout << " Les pos-tags du FITS NbTag=" << tags.size() << endl; for (int kk=0; kk avec lecture depuis swseg.ppf " << endl; FitsInOutFile si("swseg.fits", FitsInOutFile::Fits_RO); si.MoveAbsToHDU(2); FITSDataSwapper swin(si, 1); SwSegDataBlock swsd(swin, tags, SWSEGSZ); cout <<"7/ Recopie ds SegDataBlock depuis SwSegDataBlock et print" << endl; SegDataBlock segd; segd = swsd; segd.Print(cout, 4, " "); } { cout << "8/ Creation SwFitsDataTable sur myswtable.fits " << endl; FitsInOutFile so("!myswtable.fits", FitsInOutFile::Fits_Create); SwFitsDataTable dt(so, 16); // define table columns dt.AddFloatColumn("X0_f"); dt.AddFloatColumn("X1_f"); dt.AddDoubleColumn("X0X0pX1X1_d"); cout << "8.b/ start fill " << endl; // Fill the table r_8 x[5]; for(int i=0; i<63; i++) { if (i < 5) cout << " DBG - i= " << i << endl; x[0] = (i%9)-4.; x[1] = (i/9)-3.; x[2] = x[0]*x[0]+x[1]*x[1]; dt.AddLine(x); } cout << "8.c/ End fill " << endl; // Printing table info cout << dt ; } cout << "============ FIN test_fdtable ======== ======= " << endl; }