source: Sophya/trunk/SophyaProg/Tests/tswfits.cc@ 2877

Last change on this file since 2877 was 2866, checked in by ansari, 20 years ago

Ajout appel initialisation FitsIOServerInit() ds tnfits.cc tswfits.cc - Reza 2 Jan 2006

File size: 2.9 KB
Line 
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#include "fiosinit.h"
13
14void test_fdtable() ;
15
16int main(int narg, char *arg[])
17{
18 SophyaInit();
19 FitsIOServerInit();
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 << "tswfits-main() , Catched exception: \n" << exc.Msg() << endl;
31 }
32 catch(std::exception ex) {
33 cerr << "tswfits-main() , Catched exception ! " << (string)(ex.what()) << endl;
34 }
35 catch(...) {
36 cerr << "tswfits-main() , Catched ... ! " << endl;
37 }
38}
39
40
41void 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 vector<string> ttype, tform, tunit;
49 ttype.push_back("D-Col1");
50 tform.push_back("D");
51 tunit.push_back("");
52 // ttype.push_back("I-Col2");
53 // tform.push_back("J");
54 // tunit.push_back("");
55 string tblnm = "SwapMyExt";
56 FitsInOutFile fiosc("!swseg.fits", FitsInOutFile::Fits_Create);
57 // fiosc.MoveAbsToHDU(2);
58 cout << " DBG-Appel CreateTable ... " << endl;
59 fiosc.CreateTable(BINARY_TBL, "rzbintbl", ttype, tform, tunit);
60 cout << " ---- Appel a FITSDataSwapper<double> --- " << endl;
61 FITSDataSwapper<double> swout(fiosc, 1);
62 SwSegDataBlock<double> swsd(swout, SWSEGSZ, 3);
63 // FITSDataSwapper<int_4> swout(&fiosc, 1);
64 // SwSegDataBlock<int_4> swsd(swout, SWSEGSZ, 3);
65 double * fp = swsd.GetSegment(0);
66 fp[0] = 6.54321; fp[1] = 65.4321; fp[2] = 654.321; fp[3] = 6543.21;
67 fp = swsd.GetSegment(1);
68 fp[0] = 2.56789; fp[1] = 25.6789; fp[2] = 256.789; fp[3] = 2567.89;
69 fp = swsd.GetSegment(2);
70 fp[0] = 12.567; fp[1] = 225.67; fp[2] = 3256.7; fp[3] = 42567.;
71 tags = swsd.GetSwapPosTagTable();
72 cout << " Les pos-tags du FITS NbTag=" << tags.size() << endl;
73 for (int kk=0; kk<tags.size(); kk++) cout << tags[kk] << " ," ;
74 cout << endl;
75 }
76 {
77 cout << "6/ Creation PPFDataSwapper<float> avec lecture depuis swseg.ppf " << endl;
78 FitsInOutFile si("swseg.fits", FitsInOutFile::Fits_RO);
79 si.MoveAbsToHDU(2);
80 FITSDataSwapper<double> swin(si, 1);
81 SwSegDataBlock<double> swsd(swin, tags, SWSEGSZ);
82 cout <<"7/ Recopie ds SegDataBlock<float> depuis SwSegDataBlock<float> et print" << endl;
83 SegDataBlock<double> segd;
84 segd = swsd;
85 segd.Print(cout, 4, " ");
86 }
87
88 cout << "============ FIN test_fdtable ======== ======= " << endl;
89}
90
91
92
93
Note: See TracBrowser for help on using the repository browser.