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