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

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

Adaptation prog test FitsSwapper aux modifs de la classe - Reza 13/12/2005

File size: 2.9 KB
RevLine 
[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"
[2858]9// #include "datatable.h"
10// #include "swppfdtable.h"
[2783]11#include "fitsswapper.h"
12
13void test_fdtable() ;
14
15int 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 ) {
[2858]28 cerr << "tswfits-main() , Catched exception: \n" << exc.Msg() << endl;
[2783]29 }
30 catch(std::exception ex) {
[2858]31 cerr << "tswfits-main() , Catched exception ! " << (string)(ex.what()) << endl;
[2783]32 }
33 catch(...) {
[2858]34 cerr << "tswfits-main() , Catched ... ! " << endl;
[2783]35 }
36}
37
38
39void 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;
[2858]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);
[2783]58 cout << " ---- Appel a FITSDataSwapper<double> --- " << endl;
[2858]59 FITSDataSwapper<double> swout(&fiosc, 1);
[2783]60 SwSegDataBlock<double> swsd(swout, SWSEGSZ, 3);
[2858]61 // FITSDataSwapper<int_4> swout(&fiosc, 1);
62 // SwSegDataBlock<int_4> swsd(swout, SWSEGSZ, 3);
[2783]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;
[2858]76 FitsInOutFile si("swseg.fits", FitsInOutFile::Fits_RO);
77 si.MoveAbsToHDU(2);
78 FITSDataSwapper<double> swin(&si, 1);
[2783]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
Note: See TracBrowser for help on using the repository browser.