source: Sophya/trunk/AddOn/TAcq/tstminifits.cc@ 3538

Last change on this file since 3538 was 3538, checked in by ansari, 17 years ago

This commit was generated by cvs2svn to compensate for changes in r3537,
which included commits to RCS files with non-trunk default branches.

File size: 3.3 KB
Line 
1// Utilisation de SOPHYA pour faciliter les tests ...
2#include "sopnamsp.h"
3#include "machdefs.h"
4
5// include standard c/c++
6#include <math.h>
7#include <stdio.h>
8
9#include <iostream>
10#include <typeinfo>
11#include <string>
12
13
14#include "pexceptions.h" // les exceptions SOPHYA
15
16// Include sophya des tableaux
17#include "tvector.h" // Pour l'utilisation des classes TArray, TMatrix , TVector
18#include "fioarr.h" // Pour IO PPF TArray
19#include "sopemtx.h"
20#include "matharr.h"
21#include "tarrinit.h" // Pour l'utilisation des classes TArray, TMatrix , TVector
22
23// include sophya mesure ressource CPU/memoire ...
24#include "resusage.h"
25#include "ctimer.h"
26#include "timing.h"
27
28// include mini-fits lib
29#include "minifits.h"
30
31int main(int narg, char* arg[])
32{
33 // Sophya modules initialization
34 TArrayInitiator _inia;
35 //------- AU LIEU DE ------> SophyaInit();
36
37 InitTim(); // Initializing the CPU timer
38
39 cout << " ---------- tstminifits.cc Start ------------- " << endl;
40 int rc = 0;
41 try {
42 {
43 cout << "1/ Creation tableau " << endl;
44 size_t sx = 300;
45 size_t sy = 200;
46 TArray<int_2> ta(sx, sy);
47 ta = RegularSequence(0.,0.5);
48 ta.Show();
49 cout << "2/ ecriture tableau ds tmf.ppf " << endl;
50 POutPersist po("tmf.ppf");
51 po << ta;
52 cout << "3/ ecriture tableau ds tmf.fits " << endl;
53 MiniFITSFile mff;
54 mff.setDTypeNaxis(MF_Int16, sx, sy);
55 mff.Open("tmf.fits", MF_Write);
56 mff.WriteI(ta.Data(), sx*sy);
57 cout << "3.b/ FIN ecriture tableau ds tmf.fits " << endl;
58 }
59// -------------- Ecriture de bytes par morceaux
60 {
61 cout << "4/ Creation tableau uint_1" << endl;
62 size_t sx = 178;
63 size_t sy = 14;
64 uint_1* data = new uint_1[sx];
65 MiniFITSFile mff("tmfb.fits", MF_Write);
66
67 for(int k=0; k<sy; k++) {
68 for(int j=0; j<sx; j++) data[j] = (k%8)*3+j;
69 mff.WriteB(data, sx);
70 }
71 mff.setDTypeNaxis(MF_Byte, sx, sy);
72 delete [] data;
73 cout << "5/ FIN ecriture tableau ds tmfb.fits " << endl;
74 }
75// -------------- Lecture de bytes
76 {
77 cout << "6/ Ouverture/lecture tmfb.fits" << endl;
78 MiniFITSFile mff("tmfb.fits", MF_Read);
79 cout << "6.b/ Type=" << mff.DataTypeToString() << " NAxis1=" << mff.NAxis1()
80 << " NAxis2=" << mff.NAxis2() << endl;
81 size_t sx = mff.NAxis1();
82 size_t sy = mff.NAxis2();
83 uint_1* data = new uint_1[sx*sy];
84 mff.ReadB(data, sx*sy);
85 cout << "7/ FIN lecture depuis tmfb.fits " << endl;
86 TArray<int_2> ta(sx, sy);
87 for(int k=0; k<sy; k++)
88 for(int j=0; j<sx; j++) ta(j, k) = (int_2)data[j+k*sx];
89 POutPersist po("tmfb.ppf");
90 po << ta;
91 cout << "8/ FIN ecriture tableau ds tmfb.ppf " << endl;
92 delete[] data;
93 }
94 }
95 catch (MiniFITSException& exc) {
96 cerr << " tstminifits.cc catched MiniFITSException " << exc.Msg() << endl;
97 rc = 77;
98 }
99 catch (PThrowable& exc) {
100 cerr << " tstminifits.cc catched Exception " << exc.Msg() << endl;
101 rc = 76;
102 }
103 catch (std::exception& sex) {
104 cerr << "\n tstminifits.cc std::exception :"
105 << (string)typeid(sex).name() << "\n msg= "
106 << sex.what() << endl;
107 rc = 78;
108 }
109 catch (...) {
110 cerr << " tstminifits.cc catched unknown (...) exception " << endl;
111 rc = 79;
112 }
113
114 cout << ">>>> tstminifits.cc ------- FIN ----------- RC=" << rc << endl;
115 PrtTim("FIN tstminifits.cc");
116 return rc;
117
118}
Note: See TracBrowser for help on using the repository browser.