Last change
on this file since 1232 was 1232, checked in by ansari, 25 years ago |
Programmes de test de FitsIO , Reza 12/10/2000
|
File size:
2.0 KB
|
Rev | Line | |
---|
[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) {
|
---|
| 18 | cout << "obj_fits/Erreur arg - Usage obj_fits r/w fitsfilename \n" << endl;
|
---|
| 19 | cout << " w : Create a FITS file with a matrix and an NTuple \n" << endl;
|
---|
| 20 | cout << " r : Read a matrix and an NTuple from a Fits File \n" << endl;
|
---|
| 21 | exit(1);
|
---|
| 22 | }
|
---|
| 23 | try {
|
---|
| 24 | SophyaInit();
|
---|
| 25 | string flnm = arg[2];
|
---|
| 26 | if (*arg[1] == 'r') {
|
---|
| 27 | cout << " obj_fits/Info: Opening input FitsFile " << endl;
|
---|
| 28 | FitsInFile fiis(flnm);
|
---|
| 29 | cout << " Reading Matrix m from FITS " << endl;
|
---|
| 30 | Matrix m(1,1);
|
---|
| 31 | fiis >> m;
|
---|
| 32 | cout << m << endl;
|
---|
| 33 |
|
---|
| 34 | cout << " Reading NTuple from FITS " << endl;
|
---|
| 35 | NTuple nt;
|
---|
| 36 | fiis >> nt ;
|
---|
| 37 | nt.Show();
|
---|
| 38 | }
|
---|
| 39 | else {
|
---|
| 40 | cout << " obj_fits/Info: Opening output FitsFile " << endl;
|
---|
| 41 | FitsOutFile fios(flnm);
|
---|
| 42 | fios.firstImageOnPrimaryHeader();
|
---|
| 43 | cout << " Creating Matrix m " << endl;
|
---|
| 44 | Matrix m(50,70);
|
---|
| 45 | m = RegularSequence(35., 0.2);
|
---|
| 46 | cout << m << endl;
|
---|
| 47 |
|
---|
| 48 | cout << " Writing Matrix m to FITS " << endl;
|
---|
| 49 | fios << m ;
|
---|
| 50 |
|
---|
| 51 | cout << " Creating NTuple " << endl;
|
---|
| 52 | char * names[3] = {"XPos", "YPos", "Val"};
|
---|
| 53 | int i,j, k;
|
---|
| 54 | float xnt[3];
|
---|
| 55 |
|
---|
| 56 | NTuple nt1(3, names, 20);
|
---|
| 57 |
|
---|
| 58 | k = 0;
|
---|
| 59 | for(j=0; j<8; j++)
|
---|
| 60 | for(i=0; i<12; i++)
|
---|
| 61 | { xnt[0] = i+0.5; xnt[1] = j+0.5; xnt[2] = k;
|
---|
| 62 | nt1.Fill(xnt); k++; }
|
---|
| 63 |
|
---|
| 64 | nt1.Info().Comment() = "NTuple de Test - Cree par obj_fits.cc";
|
---|
| 65 | nt1.Info()["Version"] = SophyaVersion();
|
---|
| 66 | nt1.Show();
|
---|
| 67 |
|
---|
| 68 | cout << " Writing NTuple to FITS " << endl;
|
---|
| 69 | fios << nt1 ;
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 | catch (PThrowable & exc) {
|
---|
| 73 | cerr << " Catched Exception " << (string)typeid(exc).name()
|
---|
| 74 | << " - Msg= " << exc.Msg() << endl;
|
---|
| 75 | }
|
---|
| 76 | catch (...) {
|
---|
| 77 | cerr << " some other exception was caught ! " << endl;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.