Changeset 1119 in Sophya for trunk/SophyaProg
- Timestamp:
- Jul 31, 2000, 3:18:35 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/tspm2.cc
r857 r1119 5 5 6 6 #include "tod.h" 7 #include "fitsioserver.h" 7 #include "fitstarray.h" 8 #include "fitsspherehealpix.h" 8 9 #include "nbrandom.h" 9 10 … … 50 51 51 52 } 52 template <class T>53 void Project_Mol_Old(PixelMap<T> const & map, ImageR4 & img, float defval=-999.)54 {55 r_8 xa, yd, teta,phi, facteur;56 int_4 i,j,k,n;57 printf("Xsize= %d Ysize= %d NPix= %d\n",img.XSize(),img.YSize(),img.XSize()*img.YSize() );58 n = 0;59 img.Zero();60 for(j=0; j<img.YSize(); j++) {61 yd = (r_4)(j+0.5)/(r_4)img.YSize()-0.5;62 facteur=2.*M_PI/sin(acos((double)yd*2));63 teta = (yd+0.5)*M_PI;64 // teta = (0.5-yd)*M_PI;65 for(i=0; i<img.XSize(); i++) {66 xa = (r_4)(i+0.5)/(r_4)img.XSize()-0.5;67 phi = xa*facteur+M_PI;68 if ( (phi <= 2*M_PI) && (phi >= 0.) ) {69 k = map.PixIndexSph(teta, phi);70 img(i,j) = map(k);71 // if (n<20) {72 // printf("i,j= %d %d -> %g %g -> k=%d -> val= %g \n",73 // i,j,teta,phi,k,map(k)); n++; }74 }75 }76 }77 78 }79 53 80 54 int main(int narg, char* arg[]) … … 94 68 cout << " ===== HEALPix Spherical Map Test M= " << m << endl; 95 69 70 try { 71 96 72 POutPersist s("spheres.ppf"); 97 73 string nomobj; … … 115 91 } 116 92 117 FitsIoServer fios;118 // On projete dans un fichier FITS119 fios.sinus_picture_projection(sph, "gsin1.fits");120 fios.save(sph, "sph1.fits");121 93 122 94 TMatrix<double> mtx(3*m, 6*m); 95 cout << " Project_Mol(sph, mtx) " << endl; 123 96 Project_Mol(sph, mtx); 124 fios.save(mtx, "mtx1.fits"); 125 126 cout << " Project_Mol_Old(sph, img) " << endl; 127 ImageR4 img(6*m, 3*m); 128 Project_Mol_Old(sph, img); 129 img.CheckDyn(); 130 cout << img; 131 fios.save(img, "img1.fits"); 132 cout << " Apres writeFits " << endl; 133 img.CheckDyn(); 134 cout << img; 135 /* 136 ImageR4 imgr; 137 fios.load(imgr, "img1.fits"); 138 cout << " Apres readFits " << endl; 139 imgr.CheckDyn(); 140 cout << imgr; 141 */ 97 { 98 cout << " Writing to FITS prjmol1.fits " << endl; 99 FITS_TArray<double> fios(mtx); 100 fios.Write("prjmol1.fits"); 101 } 142 102 143 103 // Computing mean and sigma on the sphere … … 173 133 174 134 // On projete dans un fichier FITS 175 FitsIoServer fios;176 135 { 177 136 cout << "Test of Write/Read SphereHEALPix<float> to FITS (sphg_r4.fits) " << endl; 178 fios.save(sph, "sphg_r4.fits"); 179 180 SphereHEALPix<float> sphr(4); 181 fios.load(sphr, "sphg_r4.fits", 2); 137 FITS_SphereHEALPix<r_4> fiosw(sph); 138 fiosw.Write("sphg_r4.fits"); 139 } 140 141 142 SphereHEALPix<float> sphr; 143 { 144 FITS_SphereHEALPix<r_4> fiosr("sphg_r4.fits"); 145 sphr = fiosr; 182 146 cout << " Read from file - SphereHEALPix<float> NPixels= " << sphr.NbPixels() << endl; 183 147 int ndiff = 0; … … 193 157 194 158 195 fios.sinus_picture_projection(sph, "gsin2.fits");196 fios.save(sph, "sph2.fits");197 198 159 TMatrix<float> mtx(3*m, 6*m); 199 160 Project_Mol(sph, mtx); 200 fios.save(mtx, "mtx2.fits"); 201 202 203 cout << " Project_Mol_Old(sph, img) " << endl; 204 ImageR4 img(6*m, 3*m); 205 Project_Mol_Old(sph, img); 206 img.CheckDyn(); 207 cout << img; 208 fios.save(img, "img2.fits"); 209 cout << " Apres writeFits " << endl; 210 img.CheckDyn(); 211 cout << img; 161 { 162 cout << " Writing to FITS prjmol2.fits " << endl; 163 FITS_TArray<double> fios(mtx); 164 fios.Write("prjmol2.fits"); 165 } 212 166 213 167 // Computing mean and sigma on the sphere … … 241 195 } 242 196 } 197 } 198 catch (PThrowable & exc) { 199 cerr << "tspm2: Catched Exception " << (string)typeid(exc).name() 200 << " - Msg= " << exc.Msg() << endl; 201 } 202 catch (...) { 203 cerr << "tspm2: some other exception was caught ! " << endl; 204 } 205 243 206 cout << " ===== Fin de TSPM2_Test ======== " << endl; 244 207 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.