Index: /trunk/SophyaProg/Tests/tstboloread.cc
===================================================================
--- /trunk/SophyaProg/Tests/tstboloread.cc	(revision 1666)
+++ /trunk/SophyaProg/Tests/tstboloread.cc	(revision 1666)
@@ -0,0 +1,200 @@
+// Test des classes FitsBoloRead
+/*
+set DIR = $PLANCK/Kiruna_2001_01_29/TOI/Full_sampling
+ln -sf $DIR/PointingABv8/gLatLonAB_143k05_104000000_108465000.fits pointing.fits
+ln -sf $DIR/Bolo_etc/b143k05_104000000_108465000.fits bolo.fits
+cmvboloread -L 1000,1 -m 100000 \
+           -a gLonBolo_27 -d gLatBolo_27 -b boloMuV_27  -s sampleNum \
+           -A pointing.fits -1 0 -B bolo.fits -3 0
+*/
+#include "machdefs.h"
+#include <typeinfo>
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream.h>
+#include <values.h>
+#include <string.h>
+#include <string>
+#include <unistd.h>
+#include "sophyainit.h"
+#include "pexceptions.h"
+#include "fboloread.h"
+#include "fabtwriter.h"
+
+//#define NO_VECTOR
+#define USE_EXCEPT
+
+int main(int narg,char *arg[])
+{
+ SophyaInit();
+ char *label_alpha = "", *label_delta = "",
+      *label_bolo  = "", *label_flag  = "",
+      *label_snum  = "";
+ char *fits_alpha  = "", *fits_delta  = "",
+      *fits_bolo   = "", *fits_flag   = "",
+      *fits_snum   = "";
+ int hdu_alpha=0, hdu_delta=0, hdu_bolo=0, hdu_flag=0, hdu_snum=0;
+ long blen = 100, bsens = 1, lpmod=1;
+ char c;
+ while((c = getopt(narg,arg,"ha:d:s:b:f:A:D:S:B:F:1:2:3:4:5:L:m:")) != -1) {
+   switch (c) {
+   case 'a' :
+     label_alpha = optarg;
+     break;
+   case 'd' :
+     label_delta = optarg;
+     break;
+   case 'b' :
+     label_bolo = optarg;
+     break;
+   case 'f' :
+     label_flag = optarg;
+     break;
+   case 's' :
+     label_snum = optarg;
+     break;
+   case 'A' :
+     fits_alpha = optarg;
+     break;
+   case 'D' :
+     fits_delta = optarg;
+     break;
+   case 'B' :
+     fits_bolo = optarg;
+     break;
+   case 'F' :
+     fits_flag = optarg;
+     break;
+   case 'S' :
+     fits_snum = optarg;
+     break;
+   case '1' :
+     sscanf(optarg,"%d",&hdu_alpha);
+     break;
+   case '2' :
+     sscanf(optarg,"%d",&hdu_delta);
+     break;
+   case '3' :
+     sscanf(optarg,"%d",&hdu_bolo);
+     break;
+   case '4' :
+     sscanf(optarg,"%d",&hdu_flag);
+     break;
+   case '5' :
+     sscanf(optarg,"%d",&hdu_snum);
+     break;
+   case 'L' :
+     sscanf(optarg,"%ld,%ld",&blen,&bsens);
+     break;
+   case 'm' :
+     sscanf(optarg,"%ld",&lpmod);
+     if(lpmod<=0) lpmod = 1;
+     break;
+   case 'h' :
+   default :
+     cout<<"cmvcolread -L buflen,sens -m print_modulo"
+         <<"\n           -a label_alpha -d label_delta"
+         <<"\n           -b label_bolo  -f label_flag"
+         <<"\n           -s label_snum"
+         <<"\n           -A fits_alpha  -D fits_delta"
+         <<"\n           -B fits_bolo   -F fits_flag"
+         <<"\n           -S fits_snum"
+         <<"\n           -1 hdu_alpha  -2 hdu_delta"
+         <<"\n           -3 hdu_bolo   -4 hdu_flag"
+         <<"\n           -5 hdu_snum"
+         <<endl;
+     return -1;
+   }
+ }
+
+ cout<<"alpha: "<<label_alpha<<" ("<<fits_alpha<<") hdu="<<hdu_alpha<<endl;
+ cout<<"delta: "<<label_delta<<" ("<<fits_delta<<") hdu="<<hdu_delta<<endl;
+ cout<<"bolo : "<<label_bolo <<" ("<<fits_bolo<<") hdu="<<hdu_bolo<<endl;
+ cout<<"flag : "<<label_flag <<" ("<<fits_flag<<") hdu="<<hdu_flag<<endl;
+ cout<<"snum : "<<label_snum <<" ("<<fits_snum<<") hdu="<<hdu_snum<<endl;
+
+#ifdef USE_EXCEPT
+try {
+#endif
+
+  FitsBoloRead fbr(blen,bsens);
+  fbr.SetDebug(3);
+  fbr.Print(3);
+
+  if(strlen(label_bolo)>0)
+    fbr.SetBolo(label_bolo,fits_bolo,hdu_bolo);
+  if(strlen(label_flag)>0)
+    fbr.SetFlag(label_flag,fits_flag,hdu_flag);
+  if(strlen(label_snum)>0)
+    fbr.SetSNum(label_snum,fits_snum,hdu_snum);
+  if(strlen(label_alpha)>0)
+    fbr.SetAlpha(label_alpha,fits_alpha,hdu_alpha);
+  if(strlen(label_delta)>0)
+    fbr.SetDelta(label_delta,fits_delta,hdu_delta);
+  int col1=-1;
+  if(strlen(label_snum)>0 && strlen(fits_alpha)>0)
+    col1 = fbr.AddCol(label_snum,fits_alpha,hdu_alpha);
+
+  fbr.Print(3);
+  cout<<"NRows= "<<fbr.GetNbLine()<<endl;
+  if(fbr.IsSNum()) fbr.SetNbLine(FitsBoloRead::ColSNum);
+  cout<<"fbr.SetNbLine(ColSNum): NRows= "<<fbr.GetNbLine()<<endl;
+  fbr.SetNbLine(-1);
+  cout<<"fbr.SetNbLine(): NRows= "<<fbr.GetNbLine()<<endl;
+
+#ifdef NO_VECTOR
+  cout<<"Reading element by elements"<<endl;
+  for(long i=0; i<fbr.GetNbLine(); i++) {
+    double a=-1.,d=-1.,b=-1.,f=-1.,s=-1.,c1=-1.;
+    if(fbr.IsAlpha())   a  = fbr.GetAlpha(i);
+    if(fbr.IsDelta())   d  = fbr.GetDelta(i);
+    if(fbr.IsBolo())    b  = fbr.GetBolo(i);
+    if(fbr.IsSNum())    s  = fbr.GetSNum(i);
+    if(fbr.IsFlag())    f  = fbr.GetFlag(i);
+    if(col1>=0) if(fbr.IsCol(col1)) c1 = fbr.GetCol(col1,i);
+    if(i%lpmod==0)
+      cout<<i<<" s="<<(long long)s
+          <<" b="<<b<<" f="<<f
+          <<" a="<<a<<" d="<<d<<" c1="<<(long long)c1<<endl;
+  }
+#else
+  cout<<"Reading with vectors"<<endl;
+  long istep = lpmod;
+  TVector<double> s,a,d,b,f,c1;
+  TVector<int_4> si4,fi4;
+  for(long i=0; i<fbr.GetNbLine(); i+=istep) {
+    long i2=i+istep-1; if(i2>=fbr.GetNbLine()) i2=fbr.GetNbLine()-1;
+    if(fbr.IsSNum())   {fbr.GetSNum(i,i2,s); fbr.GetSNum(i,i2,si4);}
+    if(fbr.IsBolo())    fbr.GetBolo(i,i2,b);
+    if(fbr.IsFlag())   {fbr.GetFlag(i,i2,f); fbr.GetFlag(i,i2,fi4);}
+    if(fbr.IsAlpha())   fbr.GetAlpha(i,i2,a);
+    if(fbr.IsDelta())   fbr.GetDelta(i,i2,d);
+    if(col1>=0) if(fbr.IsCol(col1)) fbr.GetCol(col1,i,i2,c1);
+    for(int j=0; j<2; j++) {
+      int ii = 0; if(j==1) ii=i2-i;
+      cout<<i<<"("<<ii<<") ";
+      if(fbr.IsSNum())    cout<<" s=("<<s(ii)<<","<<si4(ii)<<")";
+      if(fbr.IsBolo())    cout<<" b="<<b(ii);
+      if(fbr.IsFlag())    cout<<" f=("<<f(ii)<<","<<fi4(ii)<<")";
+      if(fbr.IsAlpha())   cout<<" a="<<a(ii);
+      if(fbr.IsDelta())   cout<<" d="<<d(ii);
+      if(col1>=0) if(fbr.IsCol(col1)) cout<<" c1="<<c1(ii);
+      cout<<endl;
+    }
+  }
+#endif
+
+#ifdef USE_EXCEPT
+} catch (PThrowable & exc) {
+  cout<<"Exception : "<<(string)typeid(exc).name()
+      <<" - Msg= "<<exc.Msg()<<endl;
+  return -2;
+
+} catch (...) {
+  cout<<" some other exception was caught !"<<endl;
+  return -2;
+}
+#endif
+
+ return 0;
+}
Index: /trunk/SophyaProg/Tests/tstcolread.cc
===================================================================
--- /trunk/SophyaProg/Tests/tstcolread.cc	(revision 1666)
+++ /trunk/SophyaProg/Tests/tstcolread.cc	(revision 1666)
@@ -0,0 +1,177 @@
+// Test des classes FitsBTColRead
+#include "machdefs.h"
+#include <typeinfo>
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream.h>
+#include <values.h>
+#include <string.h>
+#include <string>
+#include <unistd.h>
+#include "sophyainit.h"
+#include "pexceptions.h"
+#include "fabtcolread.h"
+#include "fabtwriter.h"
+
+#define NO_VECTOR
+#define USE_EXCEPT
+
+int main(int narg,char *arg[])
+{
+ SophyaInit();
+ char *colname = "";
+ int colnum = -1;
+ int ihdu = 0;
+ long blen = 100;
+ long bsens = 1;
+ long lpmod=1;
+ double vs1,vs2; bool vsearch=false;
+ char c;
+ while((c = getopt(narg,arg,"hb:s:H:i:c:m:v:")) != -1) {
+   switch (c) {
+   case 'b' :
+     sscanf(optarg,"%ld",&blen);
+     break;
+   case 's' :
+     sscanf(optarg,"%ld",&bsens);
+     break;
+   case 'H' :
+     sscanf(optarg,"%d",&ihdu);
+     break;
+   case 'i' :
+     sscanf(optarg,"%d",&colnum);
+     break;
+   case 'c' :
+     colname = optarg;
+     break;
+   case 'm' :
+     sscanf(optarg,"%ld",&lpmod);
+     if(lpmod<=0) lpmod = 1;
+     break;
+   case 'v' :
+     sscanf(optarg,"%lf,%lf",&vs1,&vs2);
+     vsearch=true;
+     break;
+   case 'h' :
+   default :
+     cout<<"cmvcolread -b buflen -s sens -H hdu -m print_modulo"
+         <<" -i colnum -c colname -v vsearch1,vsearch2"
+         <<" fitsread fitswrite"<<endl;
+     return -1;
+   }
+ }
+ if(optind>=narg) {
+   cout<<"Donnez un nom de fichier fits"<<endl;
+   return -1;
+ }
+ char * fitsname = arg[optind];
+ char * fitswrit = NULL;
+ if(optind+1<narg) fitswrit = arg[optind+1];
+
+ FitsABTColRead* fbt=NULL;
+ FitsABTWriter*  fbtw=NULL;
+ if(fitswrit)
+   fbtw = new FitsABTWriter(fitswrit,BINARY_TBL,3);
+
+#ifdef USE_EXCEPT
+try {
+#endif
+
+  if(strlen(colname)>0)
+    fbt = new FitsABTColRead(fitsname,colname,ihdu,blen,bsens,3);
+  else
+    fbt = new FitsABTColRead(fitsname,colnum,ihdu,blen,bsens,3);
+  fbt->SetDebug(3);
+  fbt->Print(3);
+  cout<<"ReadFirstRow : "<<fbt->ReadFirstRow()<<endl;
+  cout<<"ReadLastRow  : "<<fbt->ReadLastRow()<<endl;
+
+  if(fbtw) {
+    fbtw->SetExtName("MON_EXTENSION");
+    fbtw->AddCol("xshort",NULL,"unitS",TSHORT);
+    fbtw->AddCol("xlong",NULL,"unitL",TLONG);
+    fbtw->AddCol("xfloat",NULL,"unitF",TFLOAT);
+    fbtw->AddCol("xdouble",NULL,"unitD",TDOUBLE);
+    fbtw->AddCol("xshort2",NULL,"unitS",TSHORT);
+    fbtw->SetDebug(3);
+  }
+
+  if(vsearch) {
+    long mid = fbt->GetNbLine()/2;
+    cout<<"Search vs1="<<vs1<<" vs2="<<vs2<<endl;
+    cout<<"FirstRow: "<<fbt->FirstRow(vs1,vs2,-1)<<endl;
+    cout<<"LastRow : "<<fbt->LastRow(vs1,vs2,-1)<<endl;
+    cout<<"FirstRow from middle: "<<fbt->FirstRow(vs1,vs2,mid)<<endl;
+    cout<<"LastRow  from middle: "<<fbt->LastRow(vs1,vs2,mid)<<endl;
+  }
+
+#ifdef NO_VECTOR
+  cout<<"Writting element by elements"<<endl;
+  for(long i=0;i<fbt->GetNbLine();i++) {
+    double x = fbt->Read(i);
+    if(i%lpmod==0) cout<<i<<": "<<x<<endl;
+    if(fbtw) {
+      fbtw->Write(0,i,x); // Si overflow la conversion est faite par cfitsio
+      fbtw->Write(1,i,x);
+      fbtw->Write(2,i,x);
+      fbtw->Write(3,i,x);
+      fbtw->Write(4,i,(short)x); // Si overflow la conversion est faite par le system
+    }
+  }
+#else
+  cout<<"Writting with vectors"<<endl;
+  TVector<double> data;
+  TVector<float> dataf;
+  TVector<int_4> datal;
+  long istep = fbt->GetNbLine()/10; if(istep>1000) istep=1000;
+  for(long i=0;i<fbt->GetNbLine();i+=istep) {
+    long i2=i+istep-1; if(i2>=fbt->GetNbLine()) i2=fbt->GetNbLine()-1;
+    long n = fbt->Read(i,i2,data);
+    fbt->Read(i,i2,dataf);
+    fbt->Read(i,i2,datal);
+    cout<<i<<" n="<<n<<" ("<<data.Size()<<")"
+        <<" d="<<data(0)<<","<<data(n-1)
+        <<" f="<<dataf(0)<<","<<dataf(n-1)
+        <<" l="<<datal(0)<<","<<datal(n-1)
+        <<endl;
+    if(fbtw) {
+      fbtw->Write(1,i,datal);
+      fbtw->Write(2,i,dataf);
+      fbtw->Write(3,i,data);
+    }
+  }
+#endif
+
+  fbt->Print(3);
+
+  //FitsABTColRead fbt2(*fbt);
+  //fbt2.SetDebug(3);
+  //fbt2.Print(3);
+  //cout<<"Read(0):   "<<fbt2.Read(0)<<endl;
+  //cout<<"Read(n-1): "<<fbt2.Read(fbt2.GetNbLine()-1)<<endl;
+  //fbt2.Print(3);
+
+  if(fbt) delete fbt;
+  if(fbtw) {
+    cout<<"Number of Overflows when writing: "<<fbtw->GetNOverFlow()<<endl;
+    delete fbtw;
+  }
+
+#ifdef USE_EXCEPT
+} catch (PThrowable & exc) {
+  cout<<"Exception : "<<(string)typeid(exc).name()
+      <<" - Msg= "<<exc.Msg()<<endl;
+  if(fbt) delete fbt;
+  if(fbtw) delete fbtw;
+  return -2;
+
+} catch (...) {
+  cout<<" some other exception was caught !"<<endl;
+  if(fbt) delete fbt;
+  if(fbtw) delete fbtw;
+  return -2;
+}
+#endif
+
+ return 0;
+}
