[2609] | 1 | #include <stdio.h>
|
---|
| 2 | #include <stdlib.h>
|
---|
[2615] | 3 | #include "sopnamsp.h"
|
---|
[2609] | 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"
|
---|
[3507] | 12 | #include "resusage.h"
|
---|
| 13 |
|
---|
[2609] | 14 | #include "sphereecp.h"
|
---|
| 15 | #include "fiosphereecp.h"
|
---|
| 16 | #include "array.h"
|
---|
| 17 | #include "samba.h"
|
---|
| 18 |
|
---|
| 19 | int main(int narg, char* arg[])
|
---|
| 20 | {
|
---|
| 21 | cout << " ---- Programme tsphereecp.cc - Test SphereECP --- " << endl;
|
---|
| 22 | int rc = 0;
|
---|
| 23 | try {
|
---|
| 24 | SophyaInit();
|
---|
[3507] | 25 | ResourceUsage ru;
|
---|
[2609] | 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 ;
|
---|
[3507] | 36 |
|
---|
[2609] | 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 | }
|
---|
[3507] | 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 |
|
---|
[2609] | 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
|
---|
[3511] | 77 | RandomGenerator rg;
|
---|
| 78 | SphericalTransformServer<r_8> ylmserver(rg);
|
---|
[2609] | 79 | SphereECP<r_8> map(256);
|
---|
| 80 | cout << " Generating map from Cl " << endl;
|
---|
| 81 | ylmserver.GenerateFromCl(map, -1, clin, 0.);
|
---|
| 82 | cout << " Computing Cl from map " << endl;
|
---|
| 83 | Vector clout = ylmserver.DecomposeToCl(map, lmax, 0.);
|
---|
[3507] | 84 |
|
---|
[2609] | 85 | SphereECP<r_8> mappar(0.25*M_PI, 0.75*M_PI, 128, 0.25*M_PI, 1.25*M_PI, 256);
|
---|
| 86 | cout << " Generating partial map from Cl " << endl;
|
---|
| 87 | ylmserver.GenerateFromCl(mappar, -1, clin, 0.);
|
---|
| 88 | cout << " Computing Cl from partialmap " << endl;
|
---|
| 89 | Vector cloutpar = ylmserver.DecomposeToCl(mappar, lmax, 0.);
|
---|
| 90 |
|
---|
[3507] | 91 | cout << " Extracting partial map and Computing Cl from mapex " << endl;
|
---|
| 92 | SphereECP<r_8> mapex = map.ExtractPartial(0.25*M_PI, 0.75*M_PI, 0.25*M_PI, 1.25*M_PI);
|
---|
| 93 | Vector clmex = ylmserver.DecomposeToCl(mapex, lmax, 0.);
|
---|
| 94 |
|
---|
[2609] | 95 | cout << " Writing clin, map, clout to ecpylm.ppf" << endl;
|
---|
| 96 | POutPersist so("ecpylm.ppf");
|
---|
| 97 | so << PPFNameTag("clin") << clin << PPFNameTag("map") << map
|
---|
| 98 | << PPFNameTag("clout") << clout ;
|
---|
[3507] | 99 | cout << " Writing mapex, clmex to ecpylm.ppf" << endl;
|
---|
| 100 | so << PPFNameTag("clmex") << clmex << PPFNameTag("mapex") << mapex;
|
---|
[2609] | 101 | cout << " Writing mappar, cloutpar to ecpylm.ppf" << endl;
|
---|
| 102 | so << PPFNameTag("mappar") << mappar
|
---|
| 103 | << PPFNameTag("cloutpar") << cloutpar ;
|
---|
[3507] | 104 |
|
---|
| 105 | cout << " --> End of tsphereecp computations \n" << ru;
|
---|
| 106 |
|
---|
[2609] | 107 | }
|
---|
| 108 | catch (PThrowable & exc) {
|
---|
| 109 | cerr << " tsphereecp.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name()
|
---|
| 110 | << " - Msg= " << exc.Msg() << endl;
|
---|
| 111 | rc = 99;
|
---|
| 112 | }
|
---|
| 113 | catch (std::exception & e) {
|
---|
| 114 | cerr << " tsphereecp.cc: Catched std::xception "
|
---|
| 115 | << " - what()= " << e.what() << endl;
|
---|
| 116 | rc = 98;
|
---|
| 117 | }
|
---|
| 118 | catch (...) {
|
---|
| 119 | cerr << " ssphereecp.cc: some other exception (...) was caught ! " << endl;
|
---|
| 120 | rc = 97;
|
---|
| 121 | }
|
---|
| 122 | PrtTim("End tsphereecp " );
|
---|
| 123 | cout << " ---- Programme tsphereecp.cc - FIN (Rc=" << rc << ") --- " << endl;
|
---|
| 124 | return rc;
|
---|
| 125 | }
|
---|