1 | #include <stdio.h>
|
---|
2 | #include <stdlib.h>
|
---|
3 | #include "math.h"
|
---|
4 | #include <iostream>
|
---|
5 | #include <string>
|
---|
6 |
|
---|
7 | #include "sambainit.h"
|
---|
8 | #include "pexceptions.h"
|
---|
9 | #include <typeinfo>
|
---|
10 | #include "timing.h"
|
---|
11 | #include "sphereecp.h"
|
---|
12 | #include "fiosphereecp.h"
|
---|
13 | #include "array.h"
|
---|
14 | #include "samba.h"
|
---|
15 |
|
---|
16 | int main(int narg, char* arg[])
|
---|
17 | {
|
---|
18 | cout << " ---- Programme tsphereecp.cc - Test SphereECP --- " << endl;
|
---|
19 | int rc = 0;
|
---|
20 | try {
|
---|
21 | SophyaInit();
|
---|
22 |
|
---|
23 | InitTim();
|
---|
24 | SphereECP<r_8> ecp(M_PI/2.-0.05, M_PI/2.+0.05, 10, 0., 0.2, 10);
|
---|
25 | ecp.SetPixels(15.);
|
---|
26 | cout << ecp ;
|
---|
27 |
|
---|
28 | SphereECP<r_8> ecp2;
|
---|
29 | ecp2 = ecp;
|
---|
30 | ecp2 += 4.;
|
---|
31 | cout << " ecp2 = ecp+4. = \n " << ecp2 ;
|
---|
32 | {
|
---|
33 | cout << " Writing ecp ecp2 to POutPersist sphecp.ppf " << endl;
|
---|
34 | POutPersist po("sphecp.ppf");
|
---|
35 | po << ecp << ecp2;
|
---|
36 | }
|
---|
37 | {
|
---|
38 | SphereECP<r_8> recp, recp2;
|
---|
39 | cout << " Reading from sphecp.ppf " << endl;
|
---|
40 | PInPersist pi("sphecp.ppf");
|
---|
41 | pi >> recp >> recp2;
|
---|
42 | cout << " recp recp2 from PInPersist " << endl;
|
---|
43 | cout << recp;
|
---|
44 | cout << recp2;
|
---|
45 | }
|
---|
46 | // Test avec transforme Ylm
|
---|
47 | int lmax = 92;
|
---|
48 | Vector clin(lmax);
|
---|
49 | for(int l=0; l<lmax; l++) {
|
---|
50 | double xx = (l-50.)/10.;
|
---|
51 | clin(l) = 1.e-2 -1.e-4*l + 0.1*exp(-xx*xx);
|
---|
52 | }
|
---|
53 | // Compute map from spectra
|
---|
54 | SphericalTransformServer<r_8> ylmserver;
|
---|
55 | SphereECP<r_8> map(256);
|
---|
56 | cout << " Generating map from Cl " << endl;
|
---|
57 | ylmserver.GenerateFromCl(map, -1, clin, 0.);
|
---|
58 | cout << " Computing Cl from map " << endl;
|
---|
59 | Vector clout = ylmserver.DecomposeToCl(map, lmax, 0.);
|
---|
60 | SphereECP<r_8> mappar(0.25*M_PI, 0.75*M_PI, 128, 0.25*M_PI, 1.25*M_PI, 256);
|
---|
61 | cout << " Generating partial map from Cl " << endl;
|
---|
62 | ylmserver.GenerateFromCl(mappar, -1, clin, 0.);
|
---|
63 | cout << " Computing Cl from partialmap " << endl;
|
---|
64 | Vector cloutpar = ylmserver.DecomposeToCl(mappar, lmax, 0.);
|
---|
65 |
|
---|
66 | cout << " Writing clin, map, clout to ecpylm.ppf" << endl;
|
---|
67 | POutPersist so("ecpylm.ppf");
|
---|
68 | so << PPFNameTag("clin") << clin << PPFNameTag("map") << map
|
---|
69 | << PPFNameTag("clout") << clout ;
|
---|
70 | cout << " Writing mappar, cloutpar to ecpylm.ppf" << endl;
|
---|
71 | so << PPFNameTag("mappar") << mappar
|
---|
72 | << PPFNameTag("cloutpar") << cloutpar ;
|
---|
73 | }
|
---|
74 | catch (PThrowable & exc) {
|
---|
75 | cerr << " tsphereecp.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name()
|
---|
76 | << " - Msg= " << exc.Msg() << endl;
|
---|
77 | rc = 99;
|
---|
78 | }
|
---|
79 | catch (std::exception & e) {
|
---|
80 | cerr << " tsphereecp.cc: Catched std::xception "
|
---|
81 | << " - what()= " << e.what() << endl;
|
---|
82 | rc = 98;
|
---|
83 | }
|
---|
84 | catch (...) {
|
---|
85 | cerr << " ssphereecp.cc: some other exception (...) was caught ! " << endl;
|
---|
86 | rc = 97;
|
---|
87 | }
|
---|
88 | PrtTim("End tsphereecp " );
|
---|
89 | cout << " ---- Programme tsphereecp.cc - FIN (Rc=" << rc << ") --- " << endl;
|
---|
90 | return rc;
|
---|
91 | }
|
---|