Index: trunk/ArchTOIPipe/TestPipes/fits2ascii.cc
===================================================================
--- trunk/ArchTOIPipe/TestPipes/fits2ascii.cc	(revision 1463)
+++ trunk/ArchTOIPipe/TestPipes/fits2ascii.cc	(revision 1463)
@@ -0,0 +1,87 @@
+#include <unistd.h>
+#include <stdexcept>
+#include "toi.h"
+#include "toiprocessor.h"
+#include "fitstoirdr.h"
+#include "fitstoiwtr.h"
+#include "toimanager.h"
+#include "toiseqbuff.h"
+#include "asciitoiwtr.h"
+
+void usage(void);
+void usage(void) {
+ cout<<"fits2ascii [-h] [-s samplemin,samplemax] [-w data_window_size]"
+     <<" fitsin asciiout"<<endl;
+ return;
+}
+
+////////////////////////////////////////////////////////////////
+int main(int narg, char** arg) {
+
+TOIManager* mgr = TOIManager::getManager();
+
+//-- Decodage arguments
+long sdeb,sfin;
+int width = 8192;
+char c;
+while((c = getopt(narg,arg,"hs:w:")) != -1) {
+  switch (c) {
+  case 's' :
+    sscanf(optarg,"%ld,%ld",&sdeb,&sfin);
+    cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
+    if(sfin>=sdeb) mgr->setRequestedSample(sdeb,sfin);
+    else {cout<<"Bad sample interval "<<endl; exit(-2);}
+    break;
+  case 'w' :
+    sscanf(optarg,"%d",&width);
+    if(width<=0) width=8192;
+    cout<<"Data window size "<<width<<endl;
+    break;
+  case 'h' :
+    usage(); exit(-1);
+  }
+}
+if(optind+1>=narg) {usage(); exit(-2);}
+
+/////////////////////////////////////
+try {
+  FITSTOIReader r(arg[optind]);
+  ASCIITOIWriter w(arg[optind+1]);
+
+  int ncol = r.getNOut();
+  cout<<"Number of columns in fits file : "<<ncol<<endl;
+  if(ncol<=0) exit(-3);
+
+  TOISeqBuffered **toi = new TOISeqBuffered *[ncol];
+
+  for(int i=0;i<ncol;i++) {
+    string col = r.getOutName(i);
+    toi[i] = new TOISeqBuffered(col,width);
+    cout<<"...got TOI "<<col<<endl;
+    r.addOutput(col,toi[i]);
+    w.addInput(col,toi[i]);
+  }
+
+  r.start();
+  w.start();
+
+  mgr->joinAll();
+
+  r.PrintStatus(cout);
+  w.PrintStatus(cout);
+
+  for(int i=0;i<ncol;i++) if(toi[i]) delete toi[i];
+  delete toi;
+
+} catch (PThrowable & exc) {
+  cout << "\nfits2ascii: Catched Exception \n" << (string)typeid(exc).name() 
+       << " - Msg= " << exc.Msg() << endl;
+} catch (const std::exception & sex) {
+  cout << "\nfits2ascii: Catched std::exception \n" 
+       << (string)typeid(sex).name() << endl; 
+} catch (...) {
+  cout << "\nfits2ascii: some other exception was caught ! " << endl;
+}
+
+return(0);
+}
Index: trunk/ArchTOIPipe/TestPipes/tstmap2toi.cc
===================================================================
--- trunk/ArchTOIPipe/TestPipes/tstmap2toi.cc	(revision 1463)
+++ trunk/ArchTOIPipe/TestPipes/tstmap2toi.cc	(revision 1463)
@@ -0,0 +1,165 @@
+#include <unistd.h>
+#include <stdexcept>
+
+#include "toi.h"
+#include "toiprocessor.h"
+#include "fitstoirdr.h"
+#include "fitstoiwtr.h"
+#include "toimanager.h"
+#include "toiseqbuff.h"
+
+#include "sambainit.h"
+#include "map2toi.h"
+#include "fitsspherehealpix.h" 
+#include "timing.h"
+
+void usage(void);
+void usage(void) {
+ cout<<"tstmap2toi [-h] [-p lp] [-s samplemin,samplemax] [-w data_window_size]"<<endl
+     <<"           [-a label_alpha] [-d label_delta] [-b label_bolomuv]"<<endl
+     <<"           fitsin fitsphere fitsout"<<endl;
+ return;
+}
+
+////////////////////////////////////////////////////////////////
+int main(int narg, char** arg) {
+
+TOIManager* mgr = TOIManager::getManager();
+
+//-- Decodage arguments
+int lp = 0, width = 8192;
+char *label_alpha = "alpha", *label_delta = "delta", *label_bolomuv = "boloMuV";
+long sdeb,sfin;
+char c;
+while((c = getopt(narg,arg,"hp:s:w:a:d:b:")) != -1) {
+  switch (c) {
+  case 's' :
+    sscanf(optarg,"%ld,%ld",&sdeb,&sfin);
+    cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
+    if(sfin>=sdeb) mgr->setRequestedSample(sdeb,sfin);
+    else {cout<<"Bad sample interval "<<endl; exit(-2);}
+    break;
+  case 'w' :
+    sscanf(optarg,"%d",&width);
+    if(width<=0) width=8192;
+    cout<<"Data window size "<<width<<endl;
+    break;
+  case 'p' :
+    sscanf(optarg,"%d",&lp);
+    if(lp<0) lp=0;
+    break;
+  case 'a' :
+    label_alpha = optarg;
+    break;
+  case 'd' :
+    label_delta = optarg;
+    break;
+  case 'b' :
+    label_bolomuv = optarg;
+    break;
+  case 'h' :
+    usage(); exit(-1);
+    break;
+  default:
+    usage(); exit(-1);
+  }
+}
+if(optind+2>=narg) {usage(); exit(-2);}
+char * fitsin          = arg[optind];
+string const fitsphere = arg[optind+1];
+char * fitsout         = arg[optind+2];
+
+cout<<">>>> tstmap2toi:"<<endl
+    <<"Fits Infile(snum,alpha,delta)= "<<fitsin<<endl
+    <<"  ...label_alpha "<<label_alpha<<"  ,  label_delta "<<label_delta<<endl
+    <<"Fits Sphere Healpix"<<fitsphere<<endl
+    <<"Fits Outfile(snum,[alpha,delta],boloMuV)"<<fitsout<<endl
+    <<"  ...label_bolomuv "<<label_bolomuv<<endl;
+
+SophyaInit();
+InitTim();
+
+//--------------------------------------------------------------------
+try {
+//--------------------------------------------------------------------
+
+ // FITS reader et writer
+ FITSTOIReader rfits(fitsin);
+ int ncol = rfits.getNOut();
+ cout<<"Number of columns in fits Infile : "<<ncol<<endl;
+ if(ncol<2) exit(-3);
+
+ FITSTOIWriter wfits(fitsout);
+ wfits.setOutFlags(true);
+ cout << "fits reader and writer created"<<endl;
+
+ // Lecture de la sphere Healpix
+ SphereHEALPix<r_8> sph;        
+ FitsInFile sfits(fitsphere);
+ sfits >> sph;
+ cout<<"SphereHEALPix: Type de map : "<<sph.TypeOfMap()<<endl
+     <<"               Nombre de pixels : "<<sph.NbPixels()<<endl;
+
+ // TOI Processor
+ Map2TOI m2toi(sph);
+ cout<<"Map2TOI created"<<endl;
+
+ // Definition des tuyaux
+ TOISeqBuffered * toialphain = new TOISeqBuffered("toi_alpha_in",width);
+ if(lp) toialphain->setDebugLevel(1);
+ rfits.addOutput(label_alpha,toialphain);
+ m2toi.addInput("AlphaIn",toialphain);
+
+ TOISeqBuffered * toialphaout = new TOISeqBuffered("toi_alpha_out",width);
+ m2toi.addOutput("AlphaOut",toialphaout);
+ wfits.addInput(label_alpha,toialphaout);
+
+ TOISeqBuffered * toideltain = new TOISeqBuffered("toi_delta_in",width);
+ if(lp) toideltain->setDebugLevel(1);
+ rfits.addOutput(label_delta,toideltain);
+ m2toi.addInput("DeltaIn",toideltain);
+
+ TOISeqBuffered * toideltaout = new TOISeqBuffered("toi_delta_out",width);
+ m2toi.addOutput("DeltaOut",toideltaout);
+ wfits.addInput(label_delta,toideltaout);
+
+ TOISeqBuffered * toibolout = new TOISeqBuffered("toi_bolo_out",width);
+ if(lp) toibolout->setDebugLevel(1);
+ m2toi.addOutput("BoloOut",toibolout);
+ wfits.addInput(label_bolomuv,toibolout);
+
+ // Run
+ cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl;
+ rfits.PrintStatus(cout);
+ cout<<"----- FITSWriterTOI::PrintStatus() : -----"<<endl;
+ wfits.PrintStatus(cout);  
+
+ PrtTim("starting threads");
+ rfits.start();
+ m2toi.start();
+ wfits.start();
+
+ if(lp>1)
+   for(int jjjj=0;jjjj<5;jjjj++) {
+     cout<<*toialphain; 
+     cout<<*toibolout; 
+     sleep(2);
+   }
+
+ mgr->joinAll();
+ PrtTim("End threads");
+
+//--------------------------------------------------------------------
+} catch (PThrowable & exc) {
+ cout<<"\ntstmap2toi: Catched Exception \n"<<(string)typeid(exc).name() 
+     <<" - Msg= "<<exc.Msg()<<endl;
+} catch (const std::exception & sex) {
+ cout<<"\ntstmap2toi: Catched std::exception \n" 
+     <<(string)typeid(sex).name()<<endl; 
+} catch (...) {
+ cout<<"\ntstmap2toi: some other exception was caught ! "<<endl;
+}
+//--------------------------------------------------------------------
+
+exit(0);
+}
Index: trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc
===================================================================
--- trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc	(revision 1463)
+++ trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc	(revision 1463)
@@ -0,0 +1,186 @@
+#include <unistd.h>
+#include <stdexcept>
+
+#include "toi.h"
+#include "toiprocessor.h"
+#include "fitstoirdr.h"
+#include "fitstoiwtr.h"
+#include "toimanager.h"
+#include "toiseqbuff.h"
+
+#include "sambainit.h"
+#include "toi2map.h"
+#include "fitsspherehealpix.h" 
+#include "timing.h"
+
+void usage(void);
+void usage(void) {
+ cout<<"tsttoi2map [-h] [-p lp] [-s samplemin,samplemax] [-w data_window_size]"<<endl
+     <<"           [-a label_alpha] [-d label_delta] [-b label_bolomuv]"<<endl
+     <<"           [-n nlat] [-G] fitsin fitsphout fitsphwout"<<endl;
+ return;
+}
+
+////////////////////////////////////////////////////////////////
+int main(int narg, char** arg) {
+
+TOIManager* mgr = TOIManager::getManager();
+
+//-- Decodage arguments
+int lp = 0, width = 8192;
+int nlat = 128;   // npixel = 12 * nlat^2
+char *label_alpha = "alpha", *label_delta = "delta", *label_bolomuv = "boloMuV";
+bool coorgal=false;
+long sdeb,sfin;
+char c;
+while((c = getopt(narg,arg,"hGp:s:w:a:d:b:n:")) != -1) {
+  switch (c) {
+  case 's' :
+    sscanf(optarg,"%ld,%ld",&sdeb,&sfin);
+    cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
+    if(sfin>=sdeb) mgr->setRequestedSample(sdeb,sfin);
+    else {cout<<"Bad sample interval "<<endl; exit(-2);}
+    break;
+  case 'w' :
+    sscanf(optarg,"%d",&width);
+    if(width<=0) width=8192;
+    cout<<"Data window size "<<width<<endl;
+    break;
+  case 'p' :
+    sscanf(optarg,"%d",&lp);
+    if(lp<0) lp=0;
+    break;
+  case 'a' :
+    label_alpha = optarg;
+    break;
+  case 'd' :
+    label_delta = optarg;
+    break;
+  case 'b' :
+    label_bolomuv = optarg;
+    break;
+  case 'n' :
+    sscanf(optarg,"%d",&nlat);
+    if(nlat<0) nlat=128;
+    break;
+  case 'G' :
+    coorgal = true;
+    break;
+  case 'h' :
+    usage(); exit(-1);
+    break;
+  default:
+    usage(); exit(-1);
+  }
+}
+if(optind+1>=narg) {usage(); exit(-2);}
+char * fitsin          = arg[optind];
+string const fitsphout = arg[optind+1];
+string fitsphwout = "";
+if(optind+2<narg) fitsphwout = arg[optind+2];
+
+cout<<">>>> tsttoi2map:"<<endl
+    <<"Fits Infile(snum,alpha,delta,bolomuv)= "<<fitsin<<endl
+    <<"  ...label_alpha "<<label_alpha<<"  ,  label_delta "<<label_delta<<endl
+    <<"  ...label_bolomuv "<<label_bolomuv<<endl
+    <<"Fits Sphere Healpix"<<fitsphout<<endl
+    <<"  ...nlat "<<nlat<<endl
+    <<"Fits Sphere Healpix Error "<<fitsphwout<<endl;
+
+SophyaInit();
+InitTim();
+
+//--------------------------------------------------------------------
+try {
+//--------------------------------------------------------------------
+
+ // FITS reader
+ FITSTOIReader rfits(fitsin);
+ int ncol = rfits.getNOut();
+ cout<<"Number of columns in fits Infile : "<<ncol<<endl;
+ if(ncol<3) exit(-3);
+
+ // Creation de la sphere Healpix
+ SphereHEALPix<r_8>* sph = new SphereHEALPix<r_8>(nlat);
+ cout<<"SphereHEALPix: Type de map : "<<sph->TypeOfMap()<<endl
+     <<"               Nombre de pixels : "<<sph->NbPixels()<<endl;
+
+ // Creation de la sphere de poids Healpix
+ SphereHEALPix<r_8>* wsph = NULL;
+ if(fitsphwout.size()>0) {
+   wsph = new SphereHEALPix<r_8>;
+   cout<<"SphereHEALPix Weight: Type de map : "<<wsph->TypeOfMap()<<endl
+       <<"               Nombre de pixels : "<<wsph->NbPixels()<<endl;
+ }
+
+ // TOI Processor
+ TOI2Map toi2m(sph,wsph);
+ cout<<"TOI2Map created"<<endl;
+ toi2m.SetCoorGal(coorgal,2000.);  // equinoxe de ref. 2000. (pour archtoi)
+
+ // Definition des tuyaux
+ TOISeqBuffered * toialphain = new TOISeqBuffered("toi_alpha_in",width);
+ if(lp) toialphain->setDebugLevel(1);
+ rfits.addOutput(label_alpha,toialphain);
+ toi2m.addInput("AlphaIn",toialphain);
+
+ TOISeqBuffered * toideltain = new TOISeqBuffered("toi_delta_in",width);
+ if(lp) toideltain->setDebugLevel(1);
+ rfits.addOutput(label_delta,toideltain);
+ toi2m.addInput("DeltaIn",toideltain);
+
+ TOISeqBuffered * toibolin = new TOISeqBuffered("toi_bolo_in",width);
+ if(lp) toibolin->setDebugLevel(1);
+ rfits.addOutput(label_bolomuv,toibolin);
+ toi2m.addInput("BoloIn",toibolin);
+
+ // Run
+ cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl;
+ rfits.PrintStatus(cout);
+
+ PrtTim("starting threads");
+ rfits.start();
+ toi2m.start();
+
+ if(lp>1)
+   for(int jjjj=0;jjjj<5;jjjj++) {
+     cout<<*toialphain; 
+     cout<<*toibolin; 
+     sleep(2);
+   }
+
+ mgr->joinAll();
+ PrtTim("End threads");
+
+ // Ecriture de la sphere Healpix sur fits
+ {
+ FitsOutFile sfits(fitsphout);
+ cout<<"tsttoi2map: Creating sphere fits file "<<fitsphout<<endl;
+ sfits << *sph;
+ }
+
+ // Ecriture de la sphere Healpix sur fits
+ if(wsph) {
+   FitsOutFile swfits(fitsphwout);
+   cout<<"tsttoi2map: Creating sphere weight fits file "<<fitsphwout<<endl;
+   swfits << *wsph;
+ }
+
+ // Nettoyage
+ delete sph;
+ if(wsph) delete wsph;
+
+//--------------------------------------------------------------------
+} catch (PThrowable & exc) {
+ cout<<"\ntsttoi2map: Catched Exception \n"<<(string)typeid(exc).name() 
+     <<" - Msg= "<<exc.Msg()<<endl;
+} catch (const std::exception & sex) {
+ cout<<"\ntsttoi2map: Catched std::exception \n" 
+     <<(string)typeid(sex).name()<<endl; 
+} catch (...) {
+ cout<<"\ntsttoi2map: some other exception was caught ! "<<endl;
+}
+//--------------------------------------------------------------------
+
+exit(0);
+}
