Index: /trunk/AddOn/TAcq/chanum_1210.cc
===================================================================
--- /trunk/AddOn/TAcq/chanum_1210.cc	(revision 3939)
+++ /trunk/AddOn/TAcq/chanum_1210.cc	(revision 3940)
@@ -32,5 +32,5 @@
     <<" -f F0MHz : 1ere frequence pour cette acquisition (def=0.)"<<endl
     <<" -F if0,if1,idf : selection freq de if0 a if1 moyenne par idf (def=\"0,8888,1\")"<<endl
-    <<" -T it0,it1 : selection fichier temps de it0 a it1 (def=\"0,999999\")"<<endl
+    <<" -T it0,it1 : selection fichier temps de it0 a it1 (def=\"0,99999\")"<<endl
     <<" -o fichier.csh : nom du fichier de sortie pour les commandes a lancer"<<endl;
 }
@@ -40,5 +40,5 @@
 {
   string outname = "chanum_1210.csh";
-  string selfreq = "0,8888,1", seltime = "0,999999";
+  string selfreq = "0,8888,1", seltime = "0,99999";
   double freq0 = 0.;
 
@@ -102,11 +102,11 @@
   ofstream ftxt(outname.c_str(), ofstream::out);
   cout<<"writing in "<<outname<<" (is_open="<<ftxt.is_open()<<")"<<endl;
+  if(!ftxt) {cout<<"!!!!OPENING failed "<<outname<<endl; return -3;}
   ftxt << "#!/bin/csh" <<endl;
-  if(!ftxt) {cout<<"!!!!OPENING failed "<<outname<<endl; return -3;}
   int dupli = 0, ndupli = 0;
   nvisi = 0;
   for(uint_4 i=0;i<vcode.size();i++) {
     char str[512];
-    sprintf(str,"${TACQEXE}/svv2mtx2_1210 -f %.7f -T %s -F %s"
+    sprintf(str,"time ${TACQEXE}/svv2mtx2_1210 -f %.7f -T %s -F %s"
 	    ,freq0,seltime.c_str(),selfreq.c_str());
     string argu = str;
@@ -115,4 +115,5 @@
     uint_4 vcode_suiv = (i<vcode.size()-1) ? vcode[IVcode(i+1)]: 99999999;
     uint_4 v1 = vcode[ip]/1000, v2 = vcode[ip]%100;
+    sprintf(str," -v %d,%d",v1,v2); argu += str;  // numero de canaux acq [1,32]
     sprintf(str," -t %d",vnth[ip]); argu += str;  // numero de threads
     sprintf(str," -r %d",vrow[ip]); argu += str;  // ligne de la matrice acq
Index: /trunk/AddOn/TAcq/svv2mtx2_1210.cc
===================================================================
--- /trunk/AddOn/TAcq/svv2mtx2_1210.cc	(revision 3939)
+++ /trunk/AddOn/TAcq/svv2mtx2_1210.cc	(revision 3940)
@@ -11,4 +11,5 @@
 #include <unistd.h>
 #include <sys/stat.h>
+#include <fstream>
 #include <iostream>
 #include <string>
@@ -17,10 +18,8 @@
 #include "tvector.h"
 #include "fioarr.h"
+#include "timing.h"
 
 /*
 export TACQEXE=~/Reza/TAcq/Objs
-./CasA02Dec.csh > CasA02Dec.log 2>&1
-./Crab03Dec.csh > Crab03Dec.log 2>&1
-./Sun03Dec.csh  > Sun03Dec.log  2>&1
 ./CasA03Dec.csh > CasA03Dec.log 2>&1
 */
@@ -32,7 +31,10 @@
 cout<<"svv2mtx2_1012 [options] dir : lecture des fichiers acq de Pittsburgh Dec 2010"<<endl
     <<" dir : repertoire ou se trouvent les fichiers d'acq"<<endl
-    <<" -C : compute and store the complexe conjugated visi"<<endl
     <<" -D : visi is a duplicated one"<<endl
     <<" -o visi.ppf : nom du ficher ppf pour ecrire la visi temps-frequence"<<endl
+    <<" -v v1,v2 : numero de voie acq pour cette visi [1-32]"<<endl
+    <<"            on calcule <v1.conj(v2)>"<<endl
+    <<" -C : compute and store the complexe conjugated visi"<<endl
+    <<"      dans ce cas on calcule <v2.conj(v1)>, le but est d'avoir toujours <E.conj(W)>"<<endl
     <<" -t thr : numero de la thread ayant traite cette visi [0-N]"<<endl
     <<" -r row : numero de la ligne de la matrice acq pour cette visi [0-Nrow["<<endl
@@ -47,15 +49,19 @@
 {
   // --- Decodage des arguments et traitement 
+  int nmiss_stop = 1000;  // on s'arrete si on a "nmiss_stop" fichiers consecutifs manquants
   string outname = "";
   int numthread = -1, numrow = -1;
   bool dupli = false, doconj = false;
   double freq0 = 0.;
+  int vacq1=-1, vacq2=-1;
   int ifilmin=0, ifilmax=99999;
   int jfr1=0, jfr2=-1, ngrpfreq=1;
-  char str[2048];
 
   char c;
-  while((c = getopt(narg,arg,"hDCo:t:r:f:T:F:")) != -1) {
+  while((c = getopt(narg,arg,"hDCo:t:r:f:T:F:v:")) != -1) {
     switch (c) {
+    case 'v' :
+      sscanf(optarg,"%d,%d",&vacq1,&vacq2);
+      break;
     case 'D' :
       dupli = true;
@@ -92,8 +98,8 @@
   string indir = arg[optind];
 
+  cout<<"v1="<<vacq1<<" v2="<<vacq2<<" doconj="<<(int)doconj<<endl;
   cout<<"thread="<<numthread<<endl; if(numthread<0) return -2;
   cout<<"numrow="<<numrow<<endl;  if(numrow<0) return -2;
   cout<<"dupli="<<(int)dupli<<endl;
-  cout<<"doconj="<<(int)doconj<<endl;
   cout<<"outname="<<outname<<endl; if(outname.size()<=0) return -2;
   cout<<"indir="<<indir<<endl;
@@ -102,11 +108,20 @@
   cout<<"request: freq "<<jfr1<<" to "<<jfr2<<" grouped by "<<ngrpfreq<<endl;
 
+  InitTim();
+
   // --- recherche et comptage des fichiers de visibilites
   // ATTENTION: il peut manquer des fichiers au debut ou dans la sequence
-  struct stat buffer;
+  string flistname = outname; flistname += ".filelist";
   int nfile = 0;
   {
+  ofstream flistw(flistname.c_str(), ofstream::out);
+  cout<<"writing in file list in: "<<flistname<<" (is_open="<<flistw.is_open()<<")"<<endl;
+  if(!flistw) {cout<<"!!!!OPEN failed "<<flistname<<endl; return -4;}
+
+  char str[4096];
+  struct stat buffer;
   int ifmin2 = ifilmin, ifmax2 = ifilmax; ifilmax = -1;
   bool foundfirst = false;
+  int nmiss = 0;
   for(int ifile=ifmin2; ifile<=ifmax2; ifile++) {
     sprintf(str, "%s/vismtx_%d_%d.ppf",indir.c_str(),numthread,ifile);
@@ -119,16 +134,29 @@
     if(!foundfirst) continue;
     if(ifile<ifilmin) continue;
-    if(foundfirst && status!=0) continue;
+    if(foundfirst && status!=0) {
+      // On fait ca car "stst()" est extremement long si le fichier n'existe pas!
+      if(nmiss>nmiss_stop) break;
+      nmiss++;
+      continue;
+    }
     nfile++;
     ifilmax = ifile;
-  }
+    nmiss = 0;
+    flistw << string(str) <<endl;
+  }
+  
+  flistw.close();
   cout<<"Found "<<nfile<<" files from "<<ifilmin<<" to "<<ifilmax<<endl;
-  if(nfile==0 || ifilmax<ifilmin) return -4;
-  }
-
+  if(nfile==0 || ifilmax<ifilmin) return -5;
+  }
+
+  PrtTim("--- End of file number search");
 
   //--------------------------------------------------------------------
   int rc = 0;
   try {
+
+  ifstream flistr(flistname.c_str(), ofstream::in);
+  if(!flistr) {cout<<"!!!!OPEN failed "<<flistname<<endl; return -6;}
 
   // --- read visibility files
@@ -140,21 +168,20 @@
   double tudeb_day, tufin_day;
   int nfreq = 0;
-  int lpmod = nfile/10; if(lpmod<=0) lpmod=1;
+  int lpmod = nfile/25; if(lpmod<=0) lpmod=1;
 
   int_4 ntimefill = 0, ntimebad = 0;
-  for(int ifile=ifilmin; ifile<=ifilmax; ifile++) {
-
+  bool foundfirst = true;
+  while(!flistr.eof()) {
     // --- Lecture d'une visi elementaire (fichier acq)
-    sprintf(str, "%s/vismtx_%d_%d.ppf",indir.c_str(),numthread,ifile);
-    int status = stat(str,&buffer);
-    if(status) continue; // fichier inexistant
-    if(ifile==ifilmin || ifile==ifilmax || (ifile-ifilmin)%lpmod==0)
-        cout<<ntimefill<<" "<<ifile<<" opening: "<<str<<endl;
+    string fname;
+    getline(flistr,fname);
+    if(fname.size()==0) continue;
+    if(ntimefill%lpmod==0) cout<<ntimefill<<" "<<" : "<<fname<<endl;
     TMatrix< complex<r_4> > vismtx;
     try {
-      PInPersist pin(str);
+      PInPersist pin(fname);
       pin >> vismtx;
     } catch(...) {
-      cout<<"ERROR: bad file "<<str<<endl;
+      cout<<"ERROR: bad file "<<fname<<endl;
       ntimebad++;
       continue;
@@ -167,6 +194,6 @@
 
     // --- Initialisation purposes for the first read file
-    if (ifile==ifilmin) {
-
+    if(foundfirst) {
+      foundfirst = false;
       tudeb = tufin;
       printf("Reference Time: tt = %.5f sec, TU = %s\n",MeanTT(0),tudeb.c_str());
@@ -223,4 +250,7 @@
   }  // fin boucle sur le fichiers d'acq
   cout<<"ntimefill = "<<ntimefill<<" / "<<nfile<<" , ntimebad="<<ntimebad<<" bad files"<<endl;
+  flistr.close();
+  string order = "rm -f "; order += flistname;
+  system(order.c_str());
 
   // --- keeping info with visi
@@ -233,33 +263,42 @@
   tufin_day = (double)d + ((double)h + mn/60. + s/3600.)/24.;
   }
-  MVisi.Info()["nth"] = numthread;
-  MVisi.Info()["row"] = numrow;
-  MVisi.Info()["dir"] = indir;
-  MVisi.Info()["dupli"] = (dupli) ? 1: 0;
-  MVisi.Info()["isconj"] = (doconj) ? 1: 0;
-  MVisi.Info()["TUobs_0"] = tudeb;
-  MVisi.Info()["TUobs_N"] = tufin;
-  MVisi.Info()["TUday_0"] = tudeb_day;
-  MVisi.Info()["TUday_N"] = tufin_day;
-  MVisi.Info()["TTag_0"] = MeanTT(0);
-  if(ntimefill>0) MVisi.Info()["TTag_N"] = MeanTT(ntimefill-1);
-  MVisi.Info()["freq0"] = freq0;
-  MVisi.Info()["dfreq0"] = 500./8192.;
-  MVisi.Info()["jfr1"] = jfr1;
-  MVisi.Info()["jfr2"] = jfr2;
-  MVisi.Info()["ngrpfreq"] = ngrpfreq;
-  MVisi.Info()["ifilmin"] = ifilmin;
-  MVisi.Info()["ifilmax"] = ifilmax;
-  MVisi.Info()["ntimefill"] = ntimefill;
-  MVisi.Info()["ntimebad"] = ntimebad;
+  DVList dvl;
+  dvl["vacq1"] = vacq1;
+  dvl["vacq2"] = vacq2;
+  dvl["nth"] = numthread;
+  dvl["row"] = numrow;
+  dvl["dir"] = indir;
+  dvl["dupli"] = (dupli) ? 1: 0;
+  dvl["isconj"] = (doconj) ? 1: 0;
+  dvl["TUobs_0"] = tudeb;
+  dvl["TUobs_N"] = tufin;
+  dvl["TUday_0"] = tudeb_day;
+  dvl["TUday_N"] = tufin_day;
+  dvl["TTag_0"] = MeanTT(0);
+  if(ntimefill>0) dvl["TTag_N"] = MeanTT(ntimefill-1);
+  dvl["freq0"] = freq0;
+  dvl["dfreq0"] = 500./8192.;
+  dvl["jfr1"] = jfr1;
+  dvl["jfr2"] = jfr2;
+  dvl["ngrpfreq"] = ngrpfreq;
+  dvl["ifilmin"] = ifilmin;
+  dvl["ifilmax"] = ifilmax;
+  dvl["ntimefill"] = ntimefill;
+  dvl["ntimebad"] = ntimebad;
 
   // --- writing visibility matrix to file
-  sprintf(str,"%s",outname.c_str());
-  cout<<"writing visibility matrix to file "<<str<<endl;
-  POutPersist pos(str);
-  pos.PutObject(MeanTT,"meantt");
-  pos.PutObject(Npaqsum,"npaqsum");
+  cout<<"writing visibility matrix to file "<<outname<<endl;
+  POutPersist pos(outname);
+  if(ntimefill>0) {
+    TVector<r_8> dum1(MeanTT(Range(0,ntimefill-1)));
+    pos.PutObject(dum1,"meantt");
+    TVector<int_4> dum2(Npaqsum(Range(0,ntimefill-1)));
+    pos.PutObject(dum2,"npaqsum");
+    TMatrix< complex<r_4> > dum3(MVisi(Range(0,ntimefill-1),Range(0,MVisi.NCols()-1)));
+    dum3.Info() = dvl;
+    pos.PutObject(dum3,"visi");
+  }
   pos.PutObject(Freq,"ifreq");
-  pos.PutObject(MVisi,"visi");
+
   }
 
@@ -279,4 +318,5 @@
   }
   cout<<">>>> svv2mtx2_1210.cc ------- END ----------- RC="<<rc<<endl;
+  PrtTim("--- End of job");
   return rc;
 }
