Changeset 2890 in Sophya for trunk/SophyaProg


Ignore:
Timestamp:
Jan 9, 2006, 6:33:27 PM (20 years ago)
Author:
ansari
Message:

Modifs prog test FITS pour test classe SwFitsDataTable - Reza 9/01/2006

Location:
trunk/SophyaProg/Tests
Files:
2 edited

Legend:

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

    r2845 r2890  
    88#include "datatable.h"
    99#include "fitshdtable.h"
     10#include "swfitsdtable.h"
     11
     12/*
     13   Programme de test lecture-ecriture FITS de DataTable
     14    + test classe SwFitsDataTable
     15      Oct 2005 - Jan 2006
     16*/
    1017
    1118void test_fdtable() ;
     
    1825  }
    1926  catch(PThrowable exc ) {
    20     cerr << "tnt-main() , Catched exception: \n" << exc.Msg() << endl;
     27    cerr << "tfitsdt-main() , Catched exception: \n" << exc.Msg() << endl;
    2128  }
    2229  catch(std::exception ex) {
    23     cerr << "tnt-main() , Catched exception ! " << (string)(ex.what()) << endl;
     30    cerr << "tfitsdt-main() , Catched exception ! " << (string)(ex.what()) << endl;
    2431  }
    2532  catch(...) {
    26     cerr << "tnt-main() , Catched ... ! " << endl;
     33    cerr << "tfitsdt-main() , Catched ... ! " << endl;
    2734  }
    2835}
     
    3239{
    3340  int NL = 600;
    34   cout << "======= test_fdtable:  simple DataTable+FITS test ======= " << endl;
     41  DataTable refdt(100); // Reference DataTable - for tests
     42
     43  cout << "======= test_fdtable: Simple DataTable+FITS test ======= " << endl;
    3544  {
    3645    cout << "1/ Creating DataTable / Writing to FITS " << endl;
     
    6069    }
    6170    cout << dt;
     71    cout << " Copying dt to refdt (refdt = dt) " << endl;
     72    refdt = dt;
    6273    cout << " Writing dt to fits file dtable.fits ... " << endl;
    6374    FitsInOutFile fios("!dtable.fits", FitsInOutFile::Fits_Create);
     
    6778    fios.SetNextExtensionName("ASC_DTable");
    6879    fios << dt;   
     80    cout << "1.b/ Creating SwFitsDataTable (file swdtable.fits) " << endl;
     81    FitsInOutFile swf("!swdtable.fits", FitsInOutFile::Fits_Create);
     82    SwFitsDataTable swdt(swf, 64);
     83    cout << " Copying from DataTable dt ..." << endl;
     84    swdt = dt;
     85    cout << swdt;
    6986  }
    7087  {
     
    8097    for(int k = 0; k<NL; k+=NL/12)
    8198      cout << "Line[" << k << "] " << dtr.LineToString(k) << endl ; 
    82     cout << "2.c/  Reading from ASCII table   " << endl;
     99    cout << "2.b/  Reading from ASCII table   " << endl;
    83100    DataTable dtra;
    84101    fios >> dtra;
     
    87104    for(int k = 0; k<NL; k+=NL/12)
    88105      cout << "Line[" << k << "] " << dtra.LineToString(k) << endl ; 
    89    
     106
     107    cout << "2.c/  Reading SwFitsDataTable from  swdtable.fits  " << endl;   
     108    SwFitsDataTable swdtr;
     109    FitsInOutFile swf("swdtable.fits", FitsInOutFile::Fits_RO);   
     110    swf.MoveAbsToHDU(2); 
     111    swf >> swdtr;
     112    cout << swdtr;
     113    cout << swdtr.LineHeaderToString() << endl;
     114    for(int k = 0; k<NL; k+=NL/12)
     115      cout << "Line[" << k << "] " << swdtr.LineToString(k) << endl ; 
    90116  }
    91   cout << "============ FIN  test_fdtable ======== ======= " << endl; 
     117  cout << "============ FIN  test_fdtable =============== " << endl; 
    92118}
    93119
  • trunk/SophyaProg/Tests/tswfits.cc

    r2866 r2890  
    77#include "histinit.h"
    88#include "dvlist.h"
    9 // #include "datatable.h"
    10 // #include "swppfdtable.h"
    119#include "fitsswapper.h"
    1210#include "fiosinit.h"
     11#include "swfitsdtable.h"
    1312
    1413void test_fdtable() ;
     
    8584      segd.Print(cout, 4, "  ");
    8685    }
    87    
     86
     87    {
     88      cout << "8/ Creation SwFitsDataTable sur myswtable.fits " << endl;
     89      FitsInOutFile so("!myswtable.fits", FitsInOutFile::Fits_Create);
     90      SwFitsDataTable dt(so, 16);
     91      // define table columns
     92      dt.AddFloatColumn("X0_f");
     93      dt.AddFloatColumn("X1_f");
     94      dt.AddDoubleColumn("X0X0pX1X1_d");
     95      cout << "8.b/ start fill " << endl;
     96      // Fill the table
     97      r_8 x[5];
     98      for(int i=0; i<63; i++) {
     99        if (i < 5)  cout << " DBG - i= " << i << endl;
     100        x[0] = (i%9)-4.;  x[1] = (i/9)-3.;  x[2] = x[0]*x[0]+x[1]*x[1];
     101        dt.AddLine(x);
     102      }
     103      cout << "8.c/ End fill " << endl;
     104     
     105      // Printing table info
     106      cout << dt ;
     107    }
    88108  cout << "============ FIN  test_fdtable ======== ======= " << endl; 
    89109}
Note: See TracChangeset for help on using the changeset viewer.