#include #include #include "sopnamsp.h" #include "sambainit.h" #include "skymap.h" #include "tod.h" #include "fitstarray.h" #include "fitsspherehealpix.h" #include "srandgen.h" #include "timing.h" template void MeanSig(PixelMap const & map, double& gmoy, double& gsig) { gmoy=0.; gsig = 0.; double valok; for(int k=0; k= 0.) gsig = sqrt(gsig); } template void Project_Mol(PixelMap const & map, TMatrix & mtx, T defval=-999.) { r_8 xa, yd, teta,phi, facteur; int_4 l,c,k; int_4 nl = mtx.NRows(); int_4 nc = mtx.NCols(); mtx = defval; // On met tout a defval cout << " NRows= " << nl << " NCols= " << nc << endl; for(l=0; l= 0.) ) { k = map.PixIndexSph(teta, phi); mtx(l,c) = map(k); } } } } int main(int narg, char* arg[]) { double teta,phi; double gmoy=0., gsig=0.; SophyaInit(); InitTim(); // Initializing the CPU timer if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) { cout << " tspm [HEALPix_M=32] : HEALPix Spherical Map Test " << endl; exit(0); } int m=32; if (narg >1) m = atoi(arg[1]); cout << " ===== HEALPix Spherical Map Test M= " << m << endl; try { POutPersist s("spheres.ppf"); string nomobj; { SphereHEALPix sph(m); cout << "Filling spherical map NPixels= " << sph.NbPixels() << endl; for (int j=0;j fiog(&sph) ; nomobj = "sphg1"; fiog.Write(s, nomobj); cout << "SphMap SphereHEALPix written to POutPersist with name " << nomobj << endl; } TMatrix mtx(3*m, 6*m); cout << " Project_Mol(sph, mtx) " << endl; Project_Mol(sph, mtx); { cout << " Writing to FITS prjmol1.fits " << endl; FITS_TArray fios(mtx); fios.Write("prjmol1.fits"); } // Computing mean and sigma on the sphere MeanSig(sph, gmoy, gsig); cout << "SphMap Mean= " << gmoy << " Sigma = " << gsig << endl; PrtTim("End of Mean-Sig "); } { SphereHEALPix sph(m); cout << "Filling spherical map2 NPixels= " << sph.NbPixels() << endl; for (int j=0;j1.4) && (teta<1.6) ) sph(j) = 20.; else { if (phi < 2.) sph(j) = 2.; else if (phi > 3.) sph(j) = 5.; else sph(j) = 0.; } } PrtTim("End of Fill2 "); { FIO_SphereHEALPix fiog(&sph) ; nomobj = "sphg2"; fiog.Write(s, nomobj); cout << "SphMap SphereHEALPix written to POutPersist with name " << nomobj << endl; } // On projete dans un fichier FITS { cout << "Test of Write/Read SphereHEALPix to FITS (sphg_r4.fits) " << endl; FITS_SphereHEALPix fiosw(sph); fiosw.Write("sphg_r4.fits"); } SphereHEALPix sphr; { FITS_SphereHEALPix fiosr("sphg_r4.fits"); sphr = fiosr; cout << " Read from file - SphereHEALPix NPixels= " << sphr.NbPixels() << endl; int ndiff = 0; for(int k=0; k mtx(3*m, 6*m); Project_Mol(sph, mtx); { cout << " Writing to FITS prjmol2.fits " << endl; FITS_TArray fios(mtx); fios.Write("prjmol2.fits"); } // Computing mean and sigma on the sphere MeanSig(sph, gmoy, gsig); cout << "SphMap2 Mean= " << gmoy << " Sigma = " << gsig << endl; PrtTim("End of Mean-Sig2 "); } { SphereThetaPhi< complex > sphc(m*10); cout << "Filling spherical map3 SphereThetaPhi(complex) NPixels= " << sphc.NbPixels() << endl; for (int j=0;j1.4) && (teta<1.6) ) sphc(j) = (20., NorRand()); else { if (phi < 2.) sphc(j) = 2.; else if (phi > 3.) sphc(j) = 5.; else sphc(j) = 0.; } } PrtTim("End of Fill2 "); { FIO_SphereThetaPhi< complex > fio(&sphc) ; nomobj = "sphtp"; fio.Write(s, nomobj); cout << "SphMap written to POutPersist with name " << nomobj << endl; } } } catch (PThrowable & exc) { cerr << "tspm2: Catched Exception " << (string)typeid(exc).name() << " - Msg= " << exc.Msg() << endl; } catch (...) { cerr << "tspm2: some other exception was caught ! " << endl; } cout << " ===== Fin de TSPM2_Test ======== " << endl; return 0; }