1 | #include <iostream.h>
|
---|
2 | #include "sambainit.h"
|
---|
3 | #include "spheregorski.h"
|
---|
4 |
|
---|
5 | #include "tod.h"
|
---|
6 | #include "timing.h"
|
---|
7 |
|
---|
8 |
|
---|
9 | int main(int narg, char* arg[])
|
---|
10 | {
|
---|
11 | double teta,phi;
|
---|
12 | PeidaInit();
|
---|
13 | InitTim(); // Initializing the CPU timer
|
---|
14 | if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) {
|
---|
15 | cout << " tspm [Gorski_M=32] : Gorski Spherical Map Test " << endl;
|
---|
16 | exit(0);
|
---|
17 | }
|
---|
18 |
|
---|
19 | int m=32;
|
---|
20 | if (narg >1) m = atoi(arg[1]);
|
---|
21 | cout << " ===== Gorski Spherical Map Test M= " << m << endl;
|
---|
22 |
|
---|
23 | SphereGorski<double> sph(m);
|
---|
24 |
|
---|
25 | cout << "Filling spherical map NPixels= " << sph.NbPixels() << endl;
|
---|
26 | for (int j=0;j<sph.NbPixels();j++)
|
---|
27 | {
|
---|
28 | sph.PixThetaPhi(j,teta,phi);
|
---|
29 | sph(j)= 0.2* cos(3.*teta)*sin(8*phi);
|
---|
30 | }
|
---|
31 | PrtTim("End of Fill ");
|
---|
32 |
|
---|
33 | // Computing mean and sigma on the sphere
|
---|
34 | double gmoy=0. , gsig = 0.;
|
---|
35 | double valok;
|
---|
36 | for(int k=0; k<sph.NbPixels(); k++) {
|
---|
37 | valok = sph(k);
|
---|
38 | gmoy += valok; gsig += valok*valok;
|
---|
39 | }
|
---|
40 | cout << "SphMap Mean= " << gmoy << " Sigma = " << gsig << endl;
|
---|
41 | PrtTim("End of Mean-Sig ");
|
---|
42 |
|
---|
43 | // Writing to a PPF file
|
---|
44 | {
|
---|
45 | POutPersist s("sphg.ppf");
|
---|
46 | FIO_SphereGorski<double> fiog(sph) ;
|
---|
47 | fiog.Write(s);
|
---|
48 | cout << "SphMap written to sphg.ppf " << endl;
|
---|
49 | }
|
---|
50 |
|
---|
51 | // Reading from the file
|
---|
52 | {
|
---|
53 | FIO_SphereGorski<double> fiog("sphg.ppf");
|
---|
54 | double gmoy=0. , gsig = 0.;
|
---|
55 | double valok;
|
---|
56 | SphereGorski<double> sph2 = fiog;
|
---|
57 | PrtTim("End of Write/Read ");
|
---|
58 |
|
---|
59 | int ndiff = 0;
|
---|
60 | for(int k=0; k<sph2.NbPixels(); k++) {
|
---|
61 | valok = sph2(k);
|
---|
62 | gmoy += valok; gsig += valok*valok;
|
---|
63 | if ((sph2(k)-sph(k)) > 1.e-49) ndiff++;
|
---|
64 | }
|
---|
65 | cout << "SphMapFromFile Mean= " << gmoy << " Sigma = " << gsig << endl;
|
---|
66 | cout << " NDiff = " << ndiff << " (should be zero = 0) " << endl;
|
---|
67 | PrtTim("End of Mean-Sig ");
|
---|
68 | }
|
---|
69 |
|
---|
70 | cout << " ===== Fin de TSPM_Test ======== " << endl;
|
---|
71 | return 0;
|
---|
72 | }
|
---|