[2783] | 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 "fitsswapper.h"
|
---|
[2866] | 10 | #include "fiosinit.h"
|
---|
[2890] | 11 | #include "swfitsdtable.h"
|
---|
[2783] | 12 |
|
---|
| 13 | void test_fdtable() ;
|
---|
| 14 |
|
---|
| 15 | int main(int narg, char *arg[])
|
---|
| 16 | {
|
---|
| 17 | SophyaInit();
|
---|
[2866] | 18 | FitsIOServerInit();
|
---|
[2783] | 19 | try {
|
---|
| 20 | /*
|
---|
| 21 | if (*arg[1] == 'd') test_dvl();
|
---|
| 22 | else if (*arg[1] == 'n') test_ntuple();
|
---|
| 23 | // else if (*arg[1] == 'x') test_xntuple();
|
---|
| 24 | else if (*arg[1] == 'X') test_Xntuple();
|
---|
| 25 | */
|
---|
| 26 | test_fdtable();
|
---|
| 27 | }
|
---|
| 28 | catch(PThrowable exc ) {
|
---|
[2858] | 29 | cerr << "tswfits-main() , Catched exception: \n" << exc.Msg() << endl;
|
---|
[2783] | 30 | }
|
---|
| 31 | catch(std::exception ex) {
|
---|
[2858] | 32 | cerr << "tswfits-main() , Catched exception ! " << (string)(ex.what()) << endl;
|
---|
[2783] | 33 | }
|
---|
| 34 | catch(...) {
|
---|
[2858] | 35 | cerr << "tswfits-main() , Catched ... ! " << endl;
|
---|
[2783] | 36 | }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | void test_fdtable()
|
---|
| 41 | {
|
---|
| 42 | cout << "======= test_fdtable: simple DataTable+FITS test ======= " << endl;
|
---|
| 43 | int SWSEGSZ = 4;
|
---|
| 44 | vector<int_8> tags;
|
---|
| 45 | {
|
---|
| 46 | cout << " Creation FITSDataSwapper<double> swout(so) avec swseg.fits " << endl;
|
---|
[2858] | 47 | vector<string> ttype, tform, tunit;
|
---|
| 48 | ttype.push_back("D-Col1");
|
---|
| 49 | tform.push_back("D");
|
---|
| 50 | tunit.push_back("");
|
---|
| 51 | // ttype.push_back("I-Col2");
|
---|
| 52 | // tform.push_back("J");
|
---|
| 53 | // tunit.push_back("");
|
---|
| 54 | string tblnm = "SwapMyExt";
|
---|
| 55 | FitsInOutFile fiosc("!swseg.fits", FitsInOutFile::Fits_Create);
|
---|
| 56 | // fiosc.MoveAbsToHDU(2);
|
---|
| 57 | cout << " DBG-Appel CreateTable ... " << endl;
|
---|
| 58 | fiosc.CreateTable(BINARY_TBL, "rzbintbl", ttype, tform, tunit);
|
---|
[2783] | 59 | cout << " ---- Appel a FITSDataSwapper<double> --- " << endl;
|
---|
[2866] | 60 | FITSDataSwapper<double> swout(fiosc, 1);
|
---|
[2783] | 61 | SwSegDataBlock<double> swsd(swout, SWSEGSZ, 3);
|
---|
[2858] | 62 | // FITSDataSwapper<int_4> swout(&fiosc, 1);
|
---|
| 63 | // SwSegDataBlock<int_4> swsd(swout, SWSEGSZ, 3);
|
---|
[2783] | 64 | double * fp = swsd.GetSegment(0);
|
---|
| 65 | fp[0] = 6.54321; fp[1] = 65.4321; fp[2] = 654.321; fp[3] = 6543.21;
|
---|
| 66 | fp = swsd.GetSegment(1);
|
---|
| 67 | fp[0] = 2.56789; fp[1] = 25.6789; fp[2] = 256.789; fp[3] = 2567.89;
|
---|
| 68 | fp = swsd.GetSegment(2);
|
---|
| 69 | fp[0] = 12.567; fp[1] = 225.67; fp[2] = 3256.7; fp[3] = 42567.;
|
---|
| 70 | tags = swsd.GetSwapPosTagTable();
|
---|
| 71 | cout << " Les pos-tags du FITS NbTag=" << tags.size() << endl;
|
---|
| 72 | for (int kk=0; kk<tags.size(); kk++) cout << tags[kk] << " ," ;
|
---|
| 73 | cout << endl;
|
---|
| 74 | }
|
---|
| 75 | {
|
---|
| 76 | cout << "6/ Creation PPFDataSwapper<float> avec lecture depuis swseg.ppf " << endl;
|
---|
[2858] | 77 | FitsInOutFile si("swseg.fits", FitsInOutFile::Fits_RO);
|
---|
| 78 | si.MoveAbsToHDU(2);
|
---|
[2866] | 79 | FITSDataSwapper<double> swin(si, 1);
|
---|
[2783] | 80 | SwSegDataBlock<double> swsd(swin, tags, SWSEGSZ);
|
---|
| 81 | cout <<"7/ Recopie ds SegDataBlock<float> depuis SwSegDataBlock<float> et print" << endl;
|
---|
| 82 | SegDataBlock<double> segd;
|
---|
| 83 | segd = swsd;
|
---|
| 84 | segd.Print(cout, 4, " ");
|
---|
| 85 | }
|
---|
[2890] | 86 |
|
---|
| 87 | {
|
---|
| 88 | cout << "8/ Creation SwFitsDataTable sur myswtable.fits " << endl;
|
---|
| 89 | FitsInOutFile so("!myswtable.fits", FitsInOutFile::Fits_Create);
|
---|
| 90 | SwFitsDataTable dt(so, 16);
|
---|
| 91 | // define table columns
|
---|
| 92 | dt.AddFloatColumn("X0_f");
|
---|
| 93 | dt.AddFloatColumn("X1_f");
|
---|
| 94 | dt.AddDoubleColumn("X0X0pX1X1_d");
|
---|
| 95 | cout << "8.b/ start fill " << endl;
|
---|
| 96 | // Fill the table
|
---|
| 97 | r_8 x[5];
|
---|
| 98 | for(int i=0; i<63; i++) {
|
---|
| 99 | if (i < 5) cout << " DBG - i= " << i << endl;
|
---|
| 100 | x[0] = (i%9)-4.; x[1] = (i/9)-3.; x[2] = x[0]*x[0]+x[1]*x[1];
|
---|
| 101 | dt.AddLine(x);
|
---|
| 102 | }
|
---|
| 103 | cout << "8.c/ End fill " << endl;
|
---|
| 104 |
|
---|
| 105 | // Printing table info
|
---|
| 106 | cout << dt ;
|
---|
| 107 | }
|
---|
[2783] | 108 | cout << "============ FIN test_fdtable ======== ======= " << endl;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 |
|
---|