source: Sophya/trunk/ArchTOIPipe/TestPipes/map_comp.cc@ 4005

Last change on this file since 4005 was 2219, checked in by cecile, 23 years ago

bete petit soft qui prend 2 cartes, fait la difference et un peu de stat

File size: 3.4 KB
Line 
1//#define TOISEQBUFFERED
2
3#include <unistd.h>
4#include "toi.h"
5#include "fitstoirdr.h"
6#include "fitstoiwtr.h"
7#include "fitsspherehealpix.h"
8#include "sambainit.h"
9#include <stdexcept>
10
11void usage(void);
12void usage(void) {
13 cout<<"map_comp [-h] fitsphere1 fitshere2 fitsphere2w fitsout"<<endl;
14 return;
15}
16
17////////////////////////////////////////////////////////////////
18int main(int narg, char** arg) {
19
20
21//-- Decodage arguments
22
23if(optind+3>=narg) {usage(); exit(2);}
24string const fitsphere1 = arg[optind];
25string const fitsphere2 = arg[optind+1];
26string const fitsphere2w = arg[optind+2];
27string const fitsphout = arg[optind+3];
28
29cout<<">>>> map_comp:"<<endl
30 <<"Fits OutFile "<<fitsphout<<endl
31 <<"Fits Healpix Spheres "<<fitsphere1<< " " <<fitsphere2<< " " << fitsphere2w <<endl;
32
33SophyaInit();
34
35//--------------------------------------------------------------------
36try {
37//--------------------------------------------------------------------
38
39
40 // Lecture de la sphere Healpix
41 SphereHEALPix<r_8> sph1,sph2,sph2w,sphdiff;
42 FitsInFile sfits1(fitsphere1);
43 sfits1 >> sph1;
44 cout<<"SphereHEALPix: Type de map : "<<sph1.TypeOfMap()<<endl
45 <<" Nombre de pixels : "<<sph1.NbPixels()<<endl;
46 FitsInFile sfits2(fitsphere2);
47 sfits2 >> sph2;
48 cout<<"SphereHEALPix: Type de map : "<<sph2.TypeOfMap()<<endl
49 <<" Nombre de pixels : "<<sph2.NbPixels()<<endl;
50
51 if((sph1.TypeOfMap() != sph2.TypeOfMap()) || (sph1.NbPixels() !=sph2.NbPixels())) {
52 cout << " Maps differ " << endl;
53 exit(-1);
54 }
55 FitsInFile sfits2w(fitsphere2w);
56 sfits2w >> sph2w;
57 cout<<"SphereHEALPix: Type de map : "<<sph2w.TypeOfMap()<<endl
58 <<" Nombre de pixels : "<<sph2w.NbPixels()<<endl;
59 if((sph2w.TypeOfMap() != sph2.TypeOfMap()) || (sph2w.NbPixels() !=sph2.NbPixels())) {
60 cout << " Maps differ" << endl;
61 exit(-1);
62 }
63 int nlat = sph1.SizeIndex();
64 int npix = sph1.NbPixels();
65 // Creation de la sphere Healpix
66 SphereHEALPix<r_8>* sph = new SphereHEALPix<r_8>(nlat);
67 cout<<"SphereHEALPix: Type de map : "<<sph->TypeOfMap()<<endl
68 <<" Nombre de pixels : "<<sph->NbPixels()<<endl
69 <<" Nlat : "<<sph->SizeIndex()<<endl;
70
71
72 TArray<r_8> diff(npix);
73 // for (int j=0;j<npix;j++) {cout << j << " " << sph1.PixVal(j)<<endl;}
74 int nok=0;
75
76 for (int i=0;i<npix;i++) if ((sph2w.PixVal(i) > 0) && (sph1.PixVal(i) > -999.)) {
77 diff[i] = sph1.PixVal(i) - sph2.PixVal(i);
78 sph->PixVal(i)=diff[i];
79 nok ++;
80 } else sph->PixVal(i)=-99999999.;
81
82 r_8 min,max;
83 diff.MinMax(min,max);
84 cout << " MinMax = " << min << " " << max << endl;
85 cout << " Mean = " << diff.Sum()/npix << endl;
86 cout << " Var = " << diff.SumX2()/npix << endl;
87 cout << "Values computed on " << double(nok)/npix*100. << "% of the map" << endl;
88
89 // Ecriture de la sphere Healpix sur fits
90 {
91 FitsOutFile sfits(fitsphout,FitsFile::clear);
92 cout<<"tsttoi2map: Creating sphere fits file "<<fitsphout<<endl;
93 sfits << *sph;
94 }
95
96
97//--------------------------------------------------------------------
98} catch (PThrowable & exc) {
99 cout<<"\ntstmap2toi: Catched Exception \n"<<(string)typeid(exc).name()
100 <<" - Msg= "<<exc.Msg()<<endl;
101} catch (const std::exception & sex) {
102 cout<<"\ntstmap2toi: Catched std::exception \n"
103 <<(string)typeid(sex).name()<<endl;
104} catch (...) {
105 cout<<"\ntstmap2toi: some other exception was caught ! "<<endl;
106}
107//--------------------------------------------------------------------
108
109exit(0);
110}
Note: See TracBrowser for help on using the repository browser.