Changeset 3906 in Sophya for trunk/SophyaProg/Tests


Ignore:
Timestamp:
Nov 2, 2010, 5:08:33 PM (15 years ago)
Author:
ansari
Message:

Codage test extensive de DataTable (mem/swPPF/swFITS) ds tfitsdt.cc, Reza 2/11/2010

Location:
trunk/SophyaProg/Tests
Files:
2 edited

Legend:

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

    r2890 r3906  
    99#include "fitshdtable.h"
    1010#include "swfitsdtable.h"
    11 
    12 /*
     11#include "swppfdtable.h"
     12#include "ctimer.h"
     13
     14/* ----------------------------------------------------------
    1315   Programme de test lecture-ecriture FITS de DataTable
    1416    + test classe SwFitsDataTable
    1517      Oct 2005 - Jan 2006
    16 */
    17 
    18 void test_fdtable() ;
    19 
     18
     19   --- This code is part of the SOPHYA library ---
     20  (C) Univ. Paris-Sud   (C) LAL-IN2P3/CNRS   (C) IRFU-CEA
     21  (C) R. Ansari, C.Magneville    2005 - 2010   
     22
     23    ----------------------------------------------------------    */
     24
     25//-----------------------------------------------------------
     26int test_fdtable() ;
     27void tdfill_dtable(BaseDataTable& dtr, uint_8 sz);
     28void tdcheck_dtable(BaseDataTable& dtr, uint_8& errcntI, uint_8& errcntF);
     29int test_memdtable(uint_8 sz, bool fgppf=true) ;
     30int test_swppfdtable(uint_8 sz) ;
     31int test_swfitsdtable(uint_8 sz) ;
     32#define _TDTSEGSIZ_  8192
     33//------------------------------------------------------------
     34
     35//--------------   MAIN PROGRAM  ------------
    2036int main(int narg, char *arg[])
    2137{
    2238  SophyaInit();
     39// 0 -> test_fdtable , 1 -> test_memdtable/PPF , 2 ->  test_memdtable/FITS
     40// 3 -> test_swppfdtable , 4 -> test_swfitsdtable
     41  int opt = 0;   
     42  if (narg<2) {
     43    cout << " Usage: tfitsdt OPT=0/1/2/3/4 [ Size=NRows in units of 1000] \n"
     44         << "  0 -> test_fdtable \n  1 -> test_memdtable/PPF , 2 ->  test_memdtable/FITS \n"
     45         << "  3 -> test_swppfdtable , 4 -> test_swfitsdtable \n"
     46         << "  Rc=0 OK for 1/2/3/4 , Def.Size=2048 (*1000) " << endl;
     47    return 1;
     48  }
     49  opt = atoi(arg[1]);
     50  uint_8 sz = 2048*1000;
     51  if (narg>2)  sz = (uint_8)(atof(arg[2])*1000.); 
     52  int rc=0;
    2353  try {
    24     test_fdtable();
     54    if (opt==1) rc=test_memdtable(sz,true);
     55    else if (opt==2) rc=test_memdtable(sz,false);
     56    else if (opt==3) rc=test_swppfdtable(sz);
     57    else if (opt==4) rc=test_swfitsdtable(sz);
     58    else test_fdtable();
    2559  }
    2660  catch(PThrowable exc ) {
     
    3367    cerr << "tfitsdt-main() , Catched ... ! " << endl;
    3468  }
    35 }
    36 
    37 
    38 void test_fdtable()
     69  cout << " ========== End of tfitsdt.cc , Rc= " << rc << " ============= " << endl;
     70  return rc;
     71}
     72
     73
     74/* --Nouvelle-Fonction-- */
     75int test_fdtable()
    3976{
    4077  int NL = 600;
     
    116153  }
    117154  cout << "============ FIN  test_fdtable =============== " << endl; 
    118 }
    119 
    120 
    121 
    122 
     155  return 0;
     156}
     157
     158
     159
     160/* --Nouvelle-Fonction-- */
     161void tdfill_dtable(BaseDataTable& dt, uint_8 sz)
     162{
     163  dt.AddIntegerColumn("ic1");
     164  dt.AddFloatColumn("fc2");
     165  int ic1,ric1;
     166  float fc2,rfc2;
     167  MuTyV rec[5];
     168  uint_8 modprt=sz/10;
     169  for(uint_8 k=0; k<sz; k++) {
     170    ic1 = (int)(k%1000000000LL);
     171    fc2 = (float)ic1+0.5;  fc2 *= (fc2+0.2);
     172    rec[0]=ic1;  rec[1]=fc2;
     173    dt.AddLine(rec);
     174    if (k%modprt==0)  cout << " tdfill_dtable/ done k=" << k << " : max=" << sz << endl;
     175  }
     176  return;
     177}
     178
     179/* --Nouvelle-Fonction-- */
     180void tdcheck_dtable(BaseDataTable& dtr, uint_8& errcntI, uint_8& errcntF)
     181{
     182  errcntI=0;
     183  errcntF=0;
     184  int ic1,ric1;
     185  float fc2,rfc2;
     186  MuTyV rec[5];
     187  uint_8 modprt=dtr.NRows()/10;
     188
     189  for(sa_size_t k=0; k<dtr.NRows(); k++) {
     190    ic1 = (int)(k%1000000000LL);
     191    fc2 = (float)ic1+0.5;  fc2 *= (fc2+0.2);
     192    dtr.GetRow(k,rec);
     193    ric1=rec[0];  rfc2=rec[1];
     194    if (ric1!=ic1)  errcntI++;
     195    if (fabs(fc2-rfc2)>1.e-9) errcntF++;
     196    if (k%modprt==0) 
     197      cout << " tdcheck_dtable/ done k=" << k << " : max=" << dtr.NRows()
     198           << " ErrCntI=" << errcntI << " ErrCntF=" << errcntF << endl;
     199  }
     200  return;
     201}
     202
     203/* --Nouvelle-Fonction-- */
     204int test_memdtable(uint_8 sz, bool fgppf)
     205{
     206  Timer tm("Tst_MEM_DataTable"); 
     207  cout << " ------------------- Tst_MEM_DataTable -------------------------- " << endl;
     208  cout << " --- test_memdtable[1]: creating DataTable with " << sz << " rows (=" << sz/1000 << " kilo) ... " << endl;
     209  string dtfilename="tstmemdtable.ppf";
     210  {
     211    DataTable dt(_TDTSEGSIZ_);
     212    tdfill_dtable(dt, sz);
     213    cout << dt;
     214    tm.Split();
     215    if (fgppf)   {
     216      POutPersist po(dtfilename);
     217      po << dt;
     218      cout << " --- test_memdtable[2]: datatable written to PPF file " << dtfilename << endl;
     219    }
     220    else {
     221      dtfilename="!tstmemdtable.fits";
     222      FitsInOutFile fios(dtfilename, FitsInOutFile::Fits_Create);
     223      fios << dt;
     224      cout << " --- test_memdtable[2]: datatable written to FITS file " << dtfilename << endl;
     225    }
     226  }
     227
     228  uint_8 errcntI=0;
     229  uint_8 errcntF=0;
     230  {
     231    DataTable dtr;
     232    if (fgppf)   {
     233      cout << " --- test_memdtable[3]: reading DataTable from PPF file " << dtfilename << endl;
     234      PInPersist pin(dtfilename);
     235      pin >> dtr;
     236    }
     237    else {
     238      dtfilename="tstmemdtable.fits";
     239      FitsInOutFile fios(dtfilename, FitsInOutFile::Fits_RO);
     240      fios.MoveToNextHDU();
     241      cout << " --- test_memdtable[3]: reading DataTable from FITS file " << dtfilename << endl;
     242      fios >> dtr;
     243    }
     244    tm.Split();
     245    tdcheck_dtable(dtr, errcntI, errcntF);
     246  }
     247  cout << " --- test_memdtable[4]: End Read/Check ErrCntI=" << errcntI << " ErrCntF=" << errcntF << endl;
     248  if ((errcntI==0)&&(errcntF==0))  return 0;
     249  else if (errcntI==0)  return 5;
     250  else return 9;
     251}
     252
     253/* --Nouvelle-Fonction-- */
     254int test_swppfdtable(uint_8 sz)
     255{
     256  Timer tm("Tst_SwPPF_DataTable"); 
     257  cout << " ------------------- Tst_SwPPF_DataTable ------------------------- " << endl;
     258  cout << " --- test_swppfdtable[1]: creating DataTable with " << sz << " rows (=" << sz/1000 << " kilo) ... " << endl;
     259  string dtswfilename="tstswppfdtable.ppf";
     260  {
     261    POutPersist po(dtswfilename);
     262    SwPPFDataTable dt(po, _TDTSEGSIZ_);
     263    tdfill_dtable(dt, sz);   
     264    po << dt;
     265    cout << " --- test_swppfdtable[2]: SwPPFDataTable written to PPF file " << dtswfilename << endl;
     266    tm.Split();
     267  }
     268
     269  uint_8 errcntI=0;
     270  uint_8 errcntF=0;
     271  {
     272    PInPersist pin(dtswfilename);
     273    SwPPFDataTable dtr;
     274    cout << " --- test_swppfdtable[3]: reading SwPPFDataTable from PPF file " << dtswfilename << endl;
     275    pin >> dtr;
     276    tdcheck_dtable(dtr, errcntI, errcntF);
     277  }
     278  cout << " --- test_swppfdtable[4]: End Read/Check ErrCntI=" << errcntI << " ErrCntF=" << errcntF << endl;
     279  if ((errcntI==0)&&(errcntF==0))  return 0;
     280  else if (errcntI==0)  return 5;
     281  else return 9;
     282}
     283
     284/* --Nouvelle-Fonction-- */
     285int test_swfitsdtable(uint_8 sz)
     286{
     287  Timer tm("Tst_SwFITS_DataTable"); 
     288  cout << " ------------------- Tst_SwFITS_DataTable ----------------------- " << endl;
     289  cout << " --- test_swfitstable[1]: creating SwFitsDataTable with " << sz << " rows (=" << sz/1000 << " kilo) ... " << endl;
     290  string dtswfilename="!tstswfitsdtable.fits";
     291  {
     292    FitsInOutFile swf(dtswfilename, FitsInOutFile::Fits_Create);
     293    SwFitsDataTable swdt(swf, _TDTSEGSIZ_);
     294    tdfill_dtable(swdt, sz);   
     295    swf << swdt;
     296    cout << " --- test_swfitstable[2]: SwFitsDataTable written to FITS file " << dtswfilename << endl;
     297    tm.Split();
     298  }
     299
     300  uint_8 errcntI=0;
     301  uint_8 errcntF=0;
     302  {
     303    dtswfilename="tstswfitsdtable.fits";
     304    SwFitsDataTable swdtr;
     305    FitsInOutFile swif(dtswfilename, FitsInOutFile::Fits_RO);   
     306    swif.MoveAbsToHDU(2); 
     307    cout << " --- test_swfitstable[3]: reading SwFitsDataTable from FITS file " << dtswfilename << endl;
     308    swif >> swdtr;
     309    tdcheck_dtable(swdtr, errcntI, errcntF);
     310  }
     311  cout << " --- test_swfitstable[4]: End Read/Check ErrCntI=" << errcntI << " ErrCntF=" << errcntF << endl;
     312  if ((errcntI==0)&&(errcntF==0))  return 0;
     313  else if (errcntI==0)  return 5;
     314  else return 9;
     315}
     316
     317
     318
  • trunk/SophyaProg/Tests/tnt.cc

    r3572 r3906  
    1212#include "swppfdtable.h"
    1313
    14 /*  Programme test des classes  DVList, NTuple,, XNTuple          */
    15 /*  DataTable et les handlers PPF                                 */
    16 /*  SOPHYA - R. Ansari (LAL)  -   2000 -  2005                    */
     14/* --- Programme de test des classes  DVList, NTuple,         
     15    DataTable et les handlers PPF 
     16                               
     17   --- This code is part of the SOPHYA library ---
     18  (C) Univ. Paris-Sud   (C) LAL-IN2P3/CNRS   (C) IRFU-CEA
     19  (C) R. Ansari, C.Magneville    2000 - 2010   
     20
     21   Appel:
     22   #  Verification de DVList
     23   csh> tnt d
     24   #  Verification de NTuple
     25   csh> tnt n
     26   #  Verification de DataTable 
     27   csh> tnt DT
     28   #  Verification de SwPPFDataTable 
     29   csh> tnt SWDT 
     30----------------------------------------------------------   */
    1731
    1832void test_dvl();
Note: See TracChangeset for help on using the changeset viewer.