| 1 | #include <stdio.h> | 
|---|
| 2 | #include <stdlib.h> | 
|---|
| 3 | #include <math.h> | 
|---|
| 4 | #include <iostream> | 
|---|
| 5 |  | 
|---|
| 6 | #include "sopnamsp.h" | 
|---|
| 7 | #include "histinit.h" | 
|---|
| 8 | #include "dvlist.h" | 
|---|
| 9 | // #include "datatable.h" | 
|---|
| 10 | // #include "swppfdtable.h" | 
|---|
| 11 | #include "fitsswapper.h" | 
|---|
| 12 |  | 
|---|
| 13 | void test_fdtable() ; | 
|---|
| 14 |  | 
|---|
| 15 | int main(int narg, char *arg[]) | 
|---|
| 16 | { | 
|---|
| 17 | SophyaInit(); | 
|---|
| 18 | try { | 
|---|
| 19 | /* | 
|---|
| 20 | if (*arg[1] == 'd')  test_dvl(); | 
|---|
| 21 | else if (*arg[1] == 'n')  test_ntuple(); | 
|---|
| 22 | //    else if (*arg[1] == 'x')  test_xntuple(); | 
|---|
| 23 | else if (*arg[1] == 'X')  test_Xntuple(); | 
|---|
| 24 | */ | 
|---|
| 25 | test_fdtable(); | 
|---|
| 26 | } | 
|---|
| 27 | catch(PThrowable exc ) { | 
|---|
| 28 | cerr << "tswfits-main() , Catched exception: \n" << exc.Msg() << endl; | 
|---|
| 29 | } | 
|---|
| 30 | catch(std::exception ex) { | 
|---|
| 31 | cerr << "tswfits-main() , Catched exception ! " << (string)(ex.what()) << endl; | 
|---|
| 32 | } | 
|---|
| 33 | catch(...) { | 
|---|
| 34 | cerr << "tswfits-main() , Catched ... ! " << endl; | 
|---|
| 35 | } | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 |  | 
|---|
| 39 | void test_fdtable() | 
|---|
| 40 | { | 
|---|
| 41 | cout << "======= test_fdtable:  simple DataTable+FITS test ======= " << endl; | 
|---|
| 42 | int SWSEGSZ = 4; | 
|---|
| 43 | vector<int_8> tags; | 
|---|
| 44 | { | 
|---|
| 45 | cout << " Creation FITSDataSwapper<double> swout(so) avec swseg.fits " << endl; | 
|---|
| 46 | vector<string> ttype, tform, tunit; | 
|---|
| 47 | ttype.push_back("D-Col1"); | 
|---|
| 48 | tform.push_back("D"); | 
|---|
| 49 | tunit.push_back(""); | 
|---|
| 50 | //      ttype.push_back("I-Col2"); | 
|---|
| 51 | //      tform.push_back("J"); | 
|---|
| 52 | //      tunit.push_back(""); | 
|---|
| 53 | string tblnm = "SwapMyExt"; | 
|---|
| 54 | FitsInOutFile fiosc("!swseg.fits", FitsInOutFile::Fits_Create); | 
|---|
| 55 | //      fiosc.MoveAbsToHDU(2); | 
|---|
| 56 | cout << " DBG-Appel CreateTable ... " << endl; | 
|---|
| 57 | fiosc.CreateTable(BINARY_TBL, "rzbintbl", ttype, tform, tunit); | 
|---|
| 58 | cout << " ---- Appel a FITSDataSwapper<double> --- " << endl; | 
|---|
| 59 | FITSDataSwapper<double> swout(&fiosc, 1); | 
|---|
| 60 | SwSegDataBlock<double> swsd(swout, SWSEGSZ, 3); | 
|---|
| 61 | //      FITSDataSwapper<int_4> swout(&fiosc, 1); | 
|---|
| 62 | //      SwSegDataBlock<int_4> swsd(swout, SWSEGSZ, 3); | 
|---|
| 63 | double * fp = swsd.GetSegment(0); | 
|---|
| 64 | fp[0] = 6.54321;   fp[1] = 65.4321;  fp[2] = 654.321;  fp[3] = 6543.21; | 
|---|
| 65 | fp = swsd.GetSegment(1); | 
|---|
| 66 | fp[0] = 2.56789;   fp[1] = 25.6789;  fp[2] = 256.789;  fp[3] = 2567.89; | 
|---|
| 67 | fp = swsd.GetSegment(2); | 
|---|
| 68 | fp[0] = 12.567;   fp[1] = 225.67;  fp[2] = 3256.7;  fp[3] = 42567.; | 
|---|
| 69 | tags = swsd.GetSwapPosTagTable(); | 
|---|
| 70 | cout << " Les pos-tags du FITS NbTag=" << tags.size() << endl; | 
|---|
| 71 | for (int kk=0; kk<tags.size(); kk++)  cout << tags[kk] << " ," ; | 
|---|
| 72 | cout << endl; | 
|---|
| 73 | } | 
|---|
| 74 | { | 
|---|
| 75 | cout << "6/ Creation PPFDataSwapper<float> avec lecture depuis swseg.ppf " << endl; | 
|---|
| 76 | FitsInOutFile si("swseg.fits", FitsInOutFile::Fits_RO); | 
|---|
| 77 | si.MoveAbsToHDU(2); | 
|---|
| 78 | FITSDataSwapper<double> swin(&si, 1); | 
|---|
| 79 | SwSegDataBlock<double> swsd(swin, tags, SWSEGSZ); | 
|---|
| 80 | cout <<"7/ Recopie ds SegDataBlock<float> depuis SwSegDataBlock<float> et print" << endl; | 
|---|
| 81 | SegDataBlock<double> segd; | 
|---|
| 82 | segd = swsd; | 
|---|
| 83 | segd.Print(cout, 4, "  "); | 
|---|
| 84 | } | 
|---|
| 85 |  | 
|---|
| 86 | cout << "============ FIN  test_fdtable ======== ======= " << endl; | 
|---|
| 87 | } | 
|---|
| 88 |  | 
|---|
| 89 |  | 
|---|
| 90 |  | 
|---|
| 91 |  | 
|---|