[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 |
|
---|
[3615] | 14 | #include "randr48.h"
|
---|
[2609] | 15 | #include "sphereecp.h"
|
---|
| 16 | #include "fiosphereecp.h"
|
---|
| 17 | #include "array.h"
|
---|
| 18 | #include "samba.h"
|
---|
| 19 |
|
---|
| 20 | int main(int narg, char* arg[])
|
---|
| 21 | {
|
---|
| 22 | cout << " ---- Programme tsphereecp.cc - Test SphereECP --- " << endl;
|
---|
| 23 | int rc = 0;
|
---|
| 24 | try {
|
---|
| 25 | SophyaInit();
|
---|
[3507] | 26 | ResourceUsage ru;
|
---|
[2609] | 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 ;
|
---|
[3507] | 37 |
|
---|
[2609] | 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 | }
|
---|
[3507] | 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 |
|
---|
[2609] | 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
|
---|
[3615] | 78 | ThSDR48RandGen rg;
|
---|
[3511] | 79 | SphericalTransformServer<r_8> ylmserver(rg);
|
---|
[2609] | 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.);
|
---|
[3507] | 85 |
|
---|
[2609] | 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 |
|
---|
[3507] | 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 |
|
---|
[2609] | 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 ;
|
---|
[3507] | 100 | cout << " Writing mapex, clmex to ecpylm.ppf" << endl;
|
---|
| 101 | so << PPFNameTag("clmex") << clmex << PPFNameTag("mapex") << mapex;
|
---|
[2609] | 102 | cout << " Writing mappar, cloutpar to ecpylm.ppf" << endl;
|
---|
| 103 | so << PPFNameTag("mappar") << mappar
|
---|
| 104 | << PPFNameTag("cloutpar") << cloutpar ;
|
---|
[3507] | 105 |
|
---|
| 106 | cout << " --> End of tsphereecp computations \n" << ru;
|
---|
| 107 |
|
---|
[2609] | 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 | }
|
---|