| 1 | 
 | 
|---|
| 2 | // include standard c/c++
 | 
|---|
| 3 | #include <math.h>
 | 
|---|
| 4 | #include <stdio.h>
 | 
|---|
| 5 | 
 | 
|---|
| 6 | #include <iostream>
 | 
|---|
| 7 | #include <string>
 | 
|---|
| 8 | 
 | 
|---|
| 9 | 
 | 
|---|
| 10 | // include mini-fits lib 
 | 
|---|
| 11 | #include "minifits.h"
 | 
|---|
| 12 | 
 | 
|---|
| 13 | int main(int narg, char* arg[])
 | 
|---|
| 14 | {
 | 
|---|
| 15 |   if (narg < 2) {
 | 
|---|
| 16 |     cout << " Usage: tstrdfits file1.fits [file2.fits ...] " << endl;
 | 
|---|
| 17 |     return 1;
 | 
|---|
| 18 |   }
 | 
|---|
| 19 |   cout << " ---------- tstrdfits.cc Start ------------- " << endl;
 | 
|---|
| 20 |   int rc = 0;
 | 
|---|
| 21 |   try {
 | 
|---|
| 22 |     for(int ifile=1; ifile<narg; ifile++) {
 | 
|---|
| 23 |       string ffname = arg[ifile];
 | 
|---|
| 24 | // -------------- Lecture de bytes      
 | 
|---|
| 25 |       cout << ifile <<"-Ouverture/lecture fichier " << ffname << endl;
 | 
|---|
| 26 |       MiniFITSFile mff(ffname, MF_Read);
 | 
|---|
| 27 |       cout << "... Type=" << mff.DataTypeToString() << " NAxis1=" << mff.NAxis1() 
 | 
|---|
| 28 |            << " NAxis2=" << mff.NAxis2() << endl;
 | 
|---|
| 29 |       if (mff.DataType() != MF_Byte) {
 | 
|---|
| 30 |         cout << " PB : DataType!=MF_Byte --> skipping " << endl;
 | 
|---|
| 31 |       }
 | 
|---|
| 32 |       size_t sx = mff.NAxis1(); 
 | 
|---|
| 33 |       size_t sy = mff.NAxis2();
 | 
|---|
| 34 |       Byte* data = new Byte[sx];
 | 
|---|
| 35 |       for(int j=0; j<sy; j++) {
 | 
|---|
| 36 |         mff.ReadB(data, sx, j*sx);
 | 
|---|
| 37 |         cout << " j=" << j << " data[0...3]=" << (int)data[0] << " , " 
 | 
|---|
| 38 |              << (int)data[1] << " , " <<  (int)data[2] << endl;
 | 
|---|
| 39 |       }
 | 
|---|
| 40 |       cout << "---- FIN lecture " << ffname << endl;
 | 
|---|
| 41 |     }   
 | 
|---|
| 42 |   }
 | 
|---|
| 43 |   catch (MiniFITSException& exc) {
 | 
|---|
| 44 |     cerr << " tstrdfits.cc catched MiniFITSException " << exc.Msg() << endl;
 | 
|---|
| 45 |     rc = 77;
 | 
|---|
| 46 |   }  
 | 
|---|
| 47 |   catch (std::exception& sex) {
 | 
|---|
| 48 |     cerr << "\n tstrdfits.cc std::exception :" 
 | 
|---|
| 49 |          << (string)typeid(sex).name() << "\n msg= " 
 | 
|---|
| 50 |          << sex.what() << endl;
 | 
|---|
| 51 |     rc = 78;
 | 
|---|
| 52 |   }
 | 
|---|
| 53 |   catch (...) {
 | 
|---|
| 54 |     cerr << " tstrdfits.cc catched unknown (...) exception  " << endl; 
 | 
|---|
| 55 |     rc = 79; 
 | 
|---|
| 56 |   } 
 | 
|---|
| 57 | 
 | 
|---|
| 58 |   cout << ">>>> tstrdfits.cc ------- FIN ----------- RC=" << rc << endl;
 | 
|---|
| 59 |   return rc;
 | 
|---|
| 60 | 
 | 
|---|
| 61 | }
 | 
|---|