source: Sophya/trunk/SophyaProg/Tests/tsphereecp.cc@ 4038

Last change on this file since 4038 was 3615, checked in by cmv, 16 years ago

Modifs relatives a l'introduction de RandomGeneratorInterface + delete de srandgen.c, cmv 01/05/2009

File size: 4.0 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include "sopnamsp.h"
4#include "math.h"
5#include <iostream>
6#include <string>
7
8#include "sambainit.h"
9#include "pexceptions.h"
10#include <typeinfo>
11#include "timing.h"
12#include "resusage.h"
13
14#include "randr48.h"
15#include "sphereecp.h"
16#include "fiosphereecp.h"
17#include "array.h"
18#include "samba.h"
19
20int main(int narg, char* arg[])
21{
22 cout << " ---- Programme tsphereecp.cc - Test SphereECP --- " << endl;
23 int rc = 0;
24 try {
25 SophyaInit();
26 ResourceUsage ru;
27
28 InitTim();
29 SphereECP<r_8> ecp(M_PI/2.-0.05, M_PI/2.+0.05, 10, 0., 0.2, 10);
30 ecp.SetPixels(15.);
31 cout << ecp ;
32
33 SphereECP<r_8> ecp2;
34 ecp2 = ecp;
35 ecp2 += 4.;
36 cout << " ecp2 = ecp+4. = \n " << ecp2 ;
37
38 {
39 cout << " Writing ecp ecp2 to POutPersist sphecp.ppf " << endl;
40 POutPersist po("sphecp.ppf");
41 po << ecp << ecp2;
42 }
43 {
44 SphereECP<r_8> recp, recp2;
45 cout << " Reading from sphecp.ppf " << endl;
46 PInPersist pi("sphecp.ppf");
47 pi >> recp >> recp2;
48 cout << " recp recp2 from PInPersist " << endl;
49 cout << recp;
50 cout << recp2;
51 }
52
53 // On cree une carte complete et on la remplit
54 SphereECP<r_4> ecpf(200);
55 for(int_4 kk=0; kk<ecpf.NbPixels(); kk++) {
56 double tet, phi;
57 ecpf.PixThetaPhi(kk, tet, phi);
58 ecpf(kk) = sin(tet)*cos(phi);
59 }
60 // Extraction d'une carte partielle de ecpf
61 SphereECP<r_4> ecpex = ecpf.ExtractPartial(M_PI/2.-M_PI/12., M_PI/2.+M_PI/12, 0.23, 0.23+M_PI/2.5);
62 cout << " ecpf (full) and ecpex (extracted partiel) created ... " << endl;
63 cout << ecpf << ecpex ;
64 {
65 cout << " Writing ecpf ecpex to POutPersist sphecpfp.ppf " << endl;
66 POutPersist po("sphecpfp.ppf");
67 po << PPFNameTag("ecpf") << ecpf << PPFNameTag("ecpex") << ecpex;
68 }
69
70 // Test avec transforme Ylm
71 int lmax = 92;
72 Vector clin(lmax);
73 for(int l=0; l<lmax; l++) {
74 double xx = (l-50.)/10.;
75 clin(l) = 1.e-2 -1.e-4*l + 0.1*exp(-xx*xx);
76 }
77 // Compute map from spectra
78 ThSDR48RandGen rg;
79 SphericalTransformServer<r_8> ylmserver(rg);
80 SphereECP<r_8> map(256);
81 cout << " Generating map from Cl " << endl;
82 ylmserver.GenerateFromCl(map, -1, clin, 0.);
83 cout << " Computing Cl from map " << endl;
84 Vector clout = ylmserver.DecomposeToCl(map, lmax, 0.);
85
86 SphereECP<r_8> mappar(0.25*M_PI, 0.75*M_PI, 128, 0.25*M_PI, 1.25*M_PI, 256);
87 cout << " Generating partial map from Cl " << endl;
88 ylmserver.GenerateFromCl(mappar, -1, clin, 0.);
89 cout << " Computing Cl from partialmap " << endl;
90 Vector cloutpar = ylmserver.DecomposeToCl(mappar, lmax, 0.);
91
92 cout << " Extracting partial map and Computing Cl from mapex " << endl;
93 SphereECP<r_8> mapex = map.ExtractPartial(0.25*M_PI, 0.75*M_PI, 0.25*M_PI, 1.25*M_PI);
94 Vector clmex = ylmserver.DecomposeToCl(mapex, lmax, 0.);
95
96 cout << " Writing clin, map, clout to ecpylm.ppf" << endl;
97 POutPersist so("ecpylm.ppf");
98 so << PPFNameTag("clin") << clin << PPFNameTag("map") << map
99 << PPFNameTag("clout") << clout ;
100 cout << " Writing mapex, clmex to ecpylm.ppf" << endl;
101 so << PPFNameTag("clmex") << clmex << PPFNameTag("mapex") << mapex;
102 cout << " Writing mappar, cloutpar to ecpylm.ppf" << endl;
103 so << PPFNameTag("mappar") << mappar
104 << PPFNameTag("cloutpar") << cloutpar ;
105
106 cout << " --> End of tsphereecp computations \n" << ru;
107
108 }
109 catch (PThrowable & exc) {
110 cerr << " tsphereecp.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name()
111 << " - Msg= " << exc.Msg() << endl;
112 rc = 99;
113 }
114 catch (std::exception & e) {
115 cerr << " tsphereecp.cc: Catched std::xception "
116 << " - what()= " << e.what() << endl;
117 rc = 98;
118 }
119 catch (...) {
120 cerr << " ssphereecp.cc: some other exception (...) was caught ! " << endl;
121 rc = 97;
122 }
123 PrtTim("End tsphereecp " );
124 cout << " ---- Programme tsphereecp.cc - FIN (Rc=" << rc << ") --- " << endl;
125 return rc;
126}
Note: See TracBrowser for help on using the repository browser.