Changeset 1119 in Sophya for trunk/SophyaProg


Ignore:
Timestamp:
Jul 31, 2000, 3:18:35 PM (25 years ago)
Author:
ansari
Message:

Remplacement des FitsIoServer par des FITS_XXX<T> ds tspm2.cc , Reza 31/7/2000

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/Tests/tspm2.cc

    r857 r1119  
    55
    66#include "tod.h"
    7 #include "fitsioserver.h"
     7#include "fitstarray.h"
     8#include "fitsspherehealpix.h"
    89#include "nbrandom.h"
    910
     
    5051
    5152}
    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 }
    7953
    8054int main(int narg, char* arg[])
     
    9468  cout <<  " ===== HEALPix Spherical Map Test M= " << m << endl;
    9569
     70  try {
     71
    9672  POutPersist s("spheres.ppf");
    9773  string nomobj;
     
    11591   }
    11692
    117   FitsIoServer fios;
    118   // On projete dans un fichier FITS
    119   fios.sinus_picture_projection(sph, "gsin1.fits");
    120   fios.save(sph, "sph1.fits");
    12193
    12294  TMatrix<double> mtx(3*m, 6*m);
     95  cout << " Project_Mol(sph, mtx) " << endl;
    12396  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  }
    142102
    143103  // Computing mean and sigma on the sphere
     
    173133
    174134  // On projete dans un fichier FITS
    175   FitsIoServer fios;
    176135   {
    177136   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;
    182146   cout << " Read from file - SphereHEALPix<float> NPixels= " << sphr.NbPixels() << endl;
    183147   int ndiff = 0;
     
    193157
    194158
    195   fios.sinus_picture_projection(sph, "gsin2.fits");
    196   fios.save(sph, "sph2.fits");
    197 
    198159  TMatrix<float> mtx(3*m, 6*m);
    199160  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  }
    212166
    213167  // Computing mean and sigma on the sphere
     
    241195   }
    242196  }
     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
    243206  cout <<  " ===== Fin de TSPM2_Test ======== " << endl;
    244207  return 0;
Note: See TracChangeset for help on using the changeset viewer.