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 "fabtwriter.h"
|
---|
12 | #include "fabtcolread.h"
|
---|
13 | #include "fitsswapper.h"
|
---|
14 |
|
---|
15 | void test_fdtable() ;
|
---|
16 |
|
---|
17 | int main(int narg, char *arg[])
|
---|
18 | {
|
---|
19 | SophyaInit();
|
---|
20 | try {
|
---|
21 | /*
|
---|
22 | if (*arg[1] == 'd') test_dvl();
|
---|
23 | else if (*arg[1] == 'n') test_ntuple();
|
---|
24 | // else if (*arg[1] == 'x') test_xntuple();
|
---|
25 | else if (*arg[1] == 'X') test_Xntuple();
|
---|
26 | */
|
---|
27 | test_fdtable();
|
---|
28 | }
|
---|
29 | catch(PThrowable exc ) {
|
---|
30 | cerr << "tnt-main() , Catched exception: \n" << exc.Msg() << endl;
|
---|
31 | }
|
---|
32 | catch(std::exception ex) {
|
---|
33 | cerr << "tnt-main() , Catched exception ! " << (string)(ex.what()) << endl;
|
---|
34 | }
|
---|
35 | catch(...) {
|
---|
36 | cerr << "tnt-main() , Catched ... ! " << endl;
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 | void test_fdtable()
|
---|
42 | {
|
---|
43 | cout << "======= test_fdtable: simple DataTable+FITS test ======= " << endl;
|
---|
44 | int SWSEGSZ = 4;
|
---|
45 | vector<int_8> tags;
|
---|
46 | {
|
---|
47 | cout << " Creation FITSDataSwapper<double> swout(so) avec swseg.fits " << endl;
|
---|
48 | FitsABTWriter so("!swseg.fits", BINARY_TBL, 0);
|
---|
49 | so.SetExtName("SwapMyExt");
|
---|
50 | int col = so.AddCol("SwapColD", NULL, "unit1", TDOUBLE);
|
---|
51 | so.Write(col, 0, 88888);
|
---|
52 | so.Print();
|
---|
53 | cout << " ---- Appel a FITSDataSwapper<double> --- " << endl;
|
---|
54 | FITSDataSwapper<double> swout(so.GetFitsPtr(),0 );
|
---|
55 | SwSegDataBlock<double> swsd(swout, SWSEGSZ, 3);
|
---|
56 | double * fp = swsd.GetSegment(0);
|
---|
57 | fp[0] = 6.54321; fp[1] = 65.4321; fp[2] = 654.321; fp[3] = 6543.21;
|
---|
58 | fp = swsd.GetSegment(1);
|
---|
59 | fp[0] = 2.56789; fp[1] = 25.6789; fp[2] = 256.789; fp[3] = 2567.89;
|
---|
60 | fp = swsd.GetSegment(2);
|
---|
61 | fp[0] = 12.567; fp[1] = 225.67; fp[2] = 3256.7; fp[3] = 42567.;
|
---|
62 | tags = swsd.GetSwapPosTagTable();
|
---|
63 | cout << " Les pos-tags du FITS NbTag=" << tags.size() << endl;
|
---|
64 | for (int kk=0; kk<tags.size(); kk++) cout << tags[kk] << " ," ;
|
---|
65 | cout << endl;
|
---|
66 | }
|
---|
67 | {
|
---|
68 | cout << "6/ Creation PPFDataSwapper<float> avec lecture depuis swseg.ppf " << endl;
|
---|
69 | FitsOpenFile si("swseg.fits");
|
---|
70 | si.MoveToFirst(BINARY_TBL);
|
---|
71 | FITSDataSwapper<double> swin(si.GetFitsPtr(), 0);
|
---|
72 | SwSegDataBlock<double> swsd(swin, tags, SWSEGSZ);
|
---|
73 | cout <<"7/ Recopie ds SegDataBlock<float> depuis SwSegDataBlock<float> et print" << endl;
|
---|
74 | SegDataBlock<double> segd;
|
---|
75 | segd = swsd;
|
---|
76 | segd.Print(cout, 4, " ");
|
---|
77 | }
|
---|
78 |
|
---|
79 | cout << "============ FIN test_fdtable ======== ======= " << endl;
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|