| [1232] | 1 | #include <stdio.h> | 
|---|
|  | 2 | #include <stdlib.h> | 
|---|
|  | 3 | #include <math.h> | 
|---|
|  | 4 | #include <iostream.h> | 
|---|
|  | 5 |  | 
|---|
|  | 6 | #include "histinit.h" | 
|---|
|  | 7 | #include "dvlist.h" | 
|---|
|  | 8 | #include "ntuple.h" | 
|---|
|  | 9 | #include "xntuple.h" | 
|---|
|  | 10 | #include "fitsxntuple.h" | 
|---|
|  | 11 | #include "fitsntuple.h" | 
|---|
|  | 12 | #include "fitstarray.h" | 
|---|
|  | 13 | #include "array.h" | 
|---|
|  | 14 |  | 
|---|
|  | 15 | int main(int narg, char *arg[]) | 
|---|
|  | 16 | { | 
|---|
|  | 17 | if (narg < 3) { | 
|---|
| [1240] | 18 | cout << "obj_fits/Erreur arg - Usage obj_fits r/r2/w/w2 fitsfilename " << endl; | 
|---|
|  | 19 | cout << "  w : Create a FITS file with a matrix and an NTuple " << endl; | 
|---|
|  | 20 | cout << "  r : Read a matrix and an NTuple from a Fits File " << endl; | 
|---|
|  | 21 | cout << "  2 : Image on secondary header " << endl; | 
|---|
| [1232] | 22 | exit(1); | 
|---|
|  | 23 | } | 
|---|
|  | 24 | try { | 
|---|
|  | 25 | SophyaInit(); | 
|---|
|  | 26 | string flnm = arg[2]; | 
|---|
| [1240] | 27 | bool imgonph = true; | 
|---|
|  | 28 | if (*(arg[1]+1) == '2')  imgonph = false; | 
|---|
| [1232] | 29 | if (*arg[1] == 'r') { | 
|---|
|  | 30 | cout << " obj_fits/Info: Opening input FitsFile " << endl; | 
|---|
|  | 31 | FitsInFile fiis(flnm); | 
|---|
| [1240] | 32 | fiis.firstImageOnPrimaryHeader(imgonph); | 
|---|
|  | 33 |  | 
|---|
| [1232] | 34 | cout << " Reading Matrix m from FITS " << endl; | 
|---|
| [1240] | 35 | Matrix m; | 
|---|
| [1232] | 36 | fiis >> m; | 
|---|
|  | 37 | cout << m << endl; | 
|---|
|  | 38 |  | 
|---|
|  | 39 | cout << " Reading NTuple from FITS " << endl; | 
|---|
|  | 40 | NTuple nt; | 
|---|
|  | 41 | fiis >> nt ; | 
|---|
|  | 42 | nt.Show(); | 
|---|
|  | 43 | } | 
|---|
|  | 44 | else { | 
|---|
|  | 45 | cout << " obj_fits/Info: Opening output FitsFile " << endl; | 
|---|
|  | 46 | FitsOutFile fios(flnm); | 
|---|
| [1240] | 47 | fios.firstImageOnPrimaryHeader(imgonph); | 
|---|
|  | 48 |  | 
|---|
| [1232] | 49 | cout << " Creating Matrix m " << endl; | 
|---|
|  | 50 | Matrix m(50,70); | 
|---|
|  | 51 | m = RegularSequence(35., 0.2); | 
|---|
| [1240] | 52 | m.Info()["SVERSION"] = SophyaVersion(); | 
|---|
|  | 53 | m.Info().SetComment("SVERSIO", "Sophya Version"); | 
|---|
|  | 54 | m.Info()["OBJ_FITS"] = "Test Matrix" ; | 
|---|
| [1232] | 55 | cout << m << endl; | 
|---|
|  | 56 |  | 
|---|
|  | 57 | cout << " Writing Matrix m to FITS " << endl; | 
|---|
|  | 58 | fios << m ; | 
|---|
|  | 59 |  | 
|---|
|  | 60 | cout << " Creating NTuple " << endl; | 
|---|
|  | 61 | char * names[3] = {"XPos", "YPos", "Val"}; | 
|---|
|  | 62 | int i,j, k; | 
|---|
|  | 63 | float xnt[3]; | 
|---|
|  | 64 |  | 
|---|
|  | 65 | NTuple  nt1(3, names, 20); | 
|---|
|  | 66 |  | 
|---|
|  | 67 | k = 0; | 
|---|
|  | 68 | for(j=0; j<8; j++) | 
|---|
|  | 69 | for(i=0; i<12; i++) | 
|---|
|  | 70 | { xnt[0] = i+0.5;  xnt[1] = j+0.5;  xnt[2] = k; | 
|---|
|  | 71 | nt1.Fill(xnt); k++; } | 
|---|
|  | 72 |  | 
|---|
|  | 73 | nt1.Info().Comment() = "NTuple de Test - Cree par obj_fits.cc"; | 
|---|
|  | 74 | nt1.Info()["Version"] = SophyaVersion(); | 
|---|
|  | 75 | nt1.Show(); | 
|---|
|  | 76 |  | 
|---|
|  | 77 | cout << " Writing NTuple to FITS " << endl; | 
|---|
|  | 78 | fios << nt1 ; | 
|---|
|  | 79 | } | 
|---|
|  | 80 | } | 
|---|
|  | 81 | catch (PThrowable & exc) { | 
|---|
|  | 82 | cerr << " Catched Exception " << (string)typeid(exc).name() | 
|---|
|  | 83 | << " - Msg= " << exc.Msg() << endl; | 
|---|
|  | 84 | } | 
|---|
|  | 85 | catch (...) { | 
|---|
|  | 86 | cerr << " some other exception was caught ! " << endl; | 
|---|
|  | 87 | } | 
|---|
|  | 88 |  | 
|---|
|  | 89 | } | 
|---|