Index: /trunk/AddOn/TAcq/branap.cc
===================================================================
--- /trunk/AddOn/TAcq/branap.cc	(revision 3691)
+++ /trunk/AddOn/TAcq/branap.cc	(revision 3692)
@@ -34,5 +34,4 @@
   int ka=1;
   while (ka<(narg-1)) {
-    cout << " *DBG ka=" << ka << " narg=" << narg << " arg[ka]=" << arg[ka] << endl;
     if (strcmp(arg[ka],"-act")==0) {
       action_=arg[ka+1];
Index: /trunk/AddOn/TAcq/brproc.cc
===================================================================
--- /trunk/AddOn/TAcq/brproc.cc	(revision 3691)
+++ /trunk/AddOn/TAcq/brproc.cc	(revision 3692)
@@ -34,19 +34,54 @@
 					       uint_4 freq1, uint_4 freq2, uint_4 nbfreq)
   : BRBaseProcessor(memgr), outpath_(outpath), nmean_(nmean), numfreq1_(freq1), numfreq2_(freq2), nbinfreq_(nbfreq)
-{
-  for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
-    vframecount_.push_back(0);
-    vtimetag_.push_back(0);
-    vnpaqm_.push_back(0);
-  }
-  
+    // , dtfos_(outpath+"visdt.fits", Fits_Create), visdt_(dtfos_, 1024, true);
+
+{  
   BRPaquet paq(memgr_.PaqSize());
 
-  for(size_t i=0; i<2*memgr_.NbFibres(); i++) 
-    for(size_t j=i; j<2*memgr_.NbFibres(); j++) 
-      vvis_.push_back( TVector< complex<r_4> >(paq.DataSize()/4) );
-
-  cout << " BRVisibilityCalculator/Info NMean= " << nmean_ << endl;
-  totnbpaq_ = 0;
+  vismtx_.SetSize((2*memgr_.NbFibres()+1)*memgr_.NbFibres(), paq.DataSize()/4); 
+  chanum_.SetSize(vismtx_.NRows());
+  sa_size_t k=0;
+  for(size_t i=0; i<2*memgr_.NbFibres(); i++) {
+    for(size_t j=i; j<2*memgr_.NbFibres(); j++) {
+      chanum_(k) = (i+1)*100+(j+1);  k++;
+    }
+  }
+  //  visdt_.AddFloatColumn("mfc");
+  visdt_.AddFloatColumn("mfc");
+  visdt_.AddFloatColumn("mtt");
+  visdt_.AddIntegerColumn("jfreq");
+  visdt_.AddIntegerColumn("numch");
+  visdt_.AddFloatColumn("vre");
+  visdt_.AddFloatColumn("vim");
+
+  /*
+  char colnm[32];
+  for(size_t i=0; i<2*memgr_.NbFibres(); i++) {
+    for(size_t j=i; j<2*memgr_.NbFibres(); j++) {
+      sprintf(colnm,"vr_%d_%d",(int)(i+1),(int)j+1);
+      visdt_.AddFloatColumn(colnm);
+      sprintf(colnm,"vi_%d_%d",(int)(i+1),(int)j+1);
+      visdt_.AddFloatColumn(colnm);
+    }
+  }
+  */
+  if (nmean_ < 1)  nmean_=memgr_.NbPaquets();
+  if (nmean_ < 1)  nmean_=1;
+
+  totnbpaq_=0;
+  numfile_=0;
+  moyfc_=moytt_=0.;
+
+  jf1_=numfreq1_; jf2_=numfreq2_;
+  if ((jf1_<1)||(jf1_>=vismtx_.NCols()))  jf1_=1;
+  if ((jf2_<1)||(jf2_>=vismtx_.NCols())||(jf2_<jf1_))  jf2_=vismtx_.NCols()-1;
+  if (nbinfreq_<1) nbinfreq_=1;
+  djf_=(jf2_-jf1_)/nbinfreq_;
+  if (djf_<1) djf_=0;
+  xnt_ = new double[vismtx_.NRows()];
+  for(int kk=0; kk<vismtx_.NRows(); kk++)  xnt_[kk]=0.;
+
+  cout << " BRVisibilityCalculator/Info NMean= " << nmean_ << " JF1=" << jf1_ 
+       << " JF2=" << jf2_ << " DJF=" << djf_ << endl;
 }
 
@@ -54,4 +89,9 @@
 BRVisibilityCalculator::~BRVisibilityCalculator()
 {
+  cout << " BRVisibilityCalculator - Visibility Datatable : " << endl;
+  cout << visdt_;
+  POutPersist po(outpath_+"visdt.ppf");
+  po << visdt_;
+  delete[] xnt_;
 }
 
@@ -59,19 +99,5 @@
 int BRVisibilityCalculator::Process()
 {
-  /*
-  if (totnbpaq_%nmean_ == 0) {
-    cout << " BRVisibilityCalculator::Process() " << totnbpaq_ << " FrameCnt=" ;
-    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)   
-      cout << curfc_[fib] << "," ;
-    cout << endl;
-    cout << " TimeTag (sec) : " ;
-    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)   
-      cout << vpaq_[fib].TimeTag()/125000000 << "," ;
-    cout << endl;
-  }
-  */
   vector<TwoByteComplex*> vpdata;
-  vector< TVector< complex<r_4> > > vvis;
-
   /*
   for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
@@ -86,14 +112,73 @@
     vpdata.push_back(vpaq_[fib].Data2C());
 
-  if (totnbpaq_%nmean_ == 0) 
-    for(size_t k=0; k<vvis_.size(); k++)   vvis_[k] = complex<r_4>((r_4)0.,(r_4)0.);
-    
-  for(size_t i=0; i<vvis_.size(); i++) {
-    for(sa_size_t f=1; f<vvis_[i].Size(); f++) {
-      vvis_[i](f) += complex<r_4>((r_4)vpdata[0][f].realB(), (r_4)(r_4)vpdata[0][f].imagB());
+  if (totnbpaq_%nmean_ == 0) {
+    if (totnbpaq_ > 0) {
+      // ATTENTION : Matrice visibilites non moyennee 
+      char nfile[32];
+      sprintf(nfile,"vismtx%d.ppf",numfile_);
+      string flnm=outpath_+nfile;
+      POutPersist po(flnm);
+      po << vismtx_;
+      cout << numfile_ << "-BRVisibilityCalculator::Process() NPaqProc="
+	   << totnbpaq_ << "  -> Visibility Matrix in " << flnm << endl;
+      moyfc_/=nmean_;
+      moytt_/=nmean_;
+      FillVisibTable(moyfc_, moytt_);
+      numfile_++;
     }
-  }
-
+    vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
+    moyfc_=moytt_=0.;
+  }
+  
+  sa_size_t k=0;
+  for(size_t i=0; i<vpdata.size(); i++) {
+    for(size_t j=i; j<vpdata.size(); j++) {
+      TVector< complex<r_4> > vis = vismtx_.Row(k);   k++;
+      for(sa_size_t f=1; f<vis.Size(); f++) {
+	vis(f) += complex<r_4>((r_4)vpdata[i][f].realB(), (r_4)vpdata[i][f].imagB()) * 
+	  complex<r_4>((r_4)vpdata[j][f].realB(), -(r_4)vpdata[j][f].imagB());
+      }
+    }
+  }
+
+  moyfc_ += curfc_[0];
+  moytt_ += vpaq_[0].TimeTag();
   totnbpaq_++;
+  return 0;
+}
+
+/* --Methode-- */
+int BRVisibilityCalculator::FillVisibTable(double fcm, double ttm)
+{
+  xnt_[0]=fcm;  xnt_[1]=ttm/1.25e8;
+
+  if (djf_<2) {
+    for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
+      for(sa_size_t jf=jf1_; jf<jf2_; jf++) {
+	xnt_[2]=jf;
+	xnt_[3]=chanum_(rv);
+	xnt_[4]=vismtx_(rv,jf).real()/(r_4)(nmean_);
+	xnt_[5]=vismtx_(rv,jf).imag()/(r_4)(nmean_);
+	visdt_.AddRow(xnt_);
+      }
+    }
+  }
+  else {
+    for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
+      for(sa_size_t jf=jf1_; jf<jf2_; jf+=djf_) {
+	r_4 moyreal=0.;
+	r_4 moyimag=0.;
+	for(sa_size_t jjf=jf; jjf<jf+djf_; jjf++) {
+	  moyreal+=vismtx_(rv,jf).real();
+	  moyimag+=vismtx_(rv,jf).imag();
+	}
+	xnt_[2]=jf+djf_/2;
+	xnt_[3]=chanum_(rv);
+	xnt_[4]=moyreal/(r_4)(nmean_*djf_);
+	xnt_[5]=moyimag/(r_4)(nmean_*djf_);
+	visdt_.AddRow(xnt_);
+      }
+    }
+  }
   return 0;
 }
Index: /trunk/AddOn/TAcq/brproc.h
===================================================================
--- /trunk/AddOn/TAcq/brproc.h	(revision 3691)
+++ /trunk/AddOn/TAcq/brproc.h	(revision 3692)
@@ -32,15 +32,21 @@
 
   virtual int Process(); 
+  virtual int FillVisibTable(double fcm, double ttm); 
+
 protected:
   uint_4 nmean_;  // Nombre de spectres pour le calcul des moyennes 
   string outpath_;  // directory pour fichiers de sortie
   uint_4 numfreq1_,numfreq2_,nbinfreq_;
-  vector<uint_8> vframecount_;
-  vector<uint_8> vtimetag_;
-  vector<uint_8> vnpaqm_;
-  
-  vector< TVector< complex<r_4> > > vvis_;
+  uint_4 jf1_,jf2_,djf_;
+  uint_4 numfile_;
+
+  double moyfc_, moytt_;
+  TMatrix< complex<r_4> > vismtx_; 
+  TVector< uint_4 > chanum_;
+  //  FitsInOutFile dtfos_;
+  DataTable visdt_;
 
   uint_4 totnbpaq_;
+  double* xnt_;
 };
 
Index: /trunk/AddOn/TAcq/tstminifits.cc
===================================================================
--- /trunk/AddOn/TAcq/tstminifits.cc	(revision 3691)
+++ /trunk/AddOn/TAcq/tstminifits.cc	(revision 3692)
@@ -93,4 +93,6 @@
     }
     mff.setDTypeNaxis(MF_Byte, sx, sy);
+    mff.AddKeyI("CleI_A", 12);
+    mff.AddKeyD("CleD_B", 3.1415, " Valeur de Pi");
     delete [] data;
     cout << "5/ FIN ecriture tableau ds tmfb.fits " << endl;   
@@ -106,4 +108,6 @@
     uint_1* data = new uint_1[sx*sy];
     mff.ReadB(data, sx*sy);
+    cout << " ---- mff.GetKey(CleD_B) : "  << mff.GetKey("CleD_B") << endl;
+    cout << " ---- mff.GetKey(Non-Existing) : "  << mff.GetKey("NonExisting") << endl;
     cout << "7/ FIN lecture depuis tmfb.fits " << endl;   
     TArray<int_2> ta(sx, sy);
