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

Last change on this file since 3507 was 3507, checked in by ansari, 17 years ago

modif prog test pour appel a SphereECP::ExtractPartial() , Reza 08/08/2008

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