Changeset 3940 in Sophya for trunk/AddOn/TAcq


Ignore:
Timestamp:
Jan 24, 2011, 5:02:54 PM (15 years ago)
Author:
cmv
Message:

acceleration prog + petits ajouts, cmv 24/01/2011

Location:
trunk/AddOn/TAcq
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/chanum_1210.cc

    r3935 r3940  
    3232    <<" -f F0MHz : 1ere frequence pour cette acquisition (def=0.)"<<endl
    3333    <<" -F if0,if1,idf : selection freq de if0 a if1 moyenne par idf (def=\"0,8888,1\")"<<endl
    34     <<" -T it0,it1 : selection fichier temps de it0 a it1 (def=\"0,999999\")"<<endl
     34    <<" -T it0,it1 : selection fichier temps de it0 a it1 (def=\"0,99999\")"<<endl
    3535    <<" -o fichier.csh : nom du fichier de sortie pour les commandes a lancer"<<endl;
    3636}
     
    4040{
    4141  string outname = "chanum_1210.csh";
    42   string selfreq = "0,8888,1", seltime = "0,999999";
     42  string selfreq = "0,8888,1", seltime = "0,99999";
    4343  double freq0 = 0.;
    4444
     
    102102  ofstream ftxt(outname.c_str(), ofstream::out);
    103103  cout<<"writing in "<<outname<<" (is_open="<<ftxt.is_open()<<")"<<endl;
     104  if(!ftxt) {cout<<"!!!!OPENING failed "<<outname<<endl; return -3;}
    104105  ftxt << "#!/bin/csh" <<endl;
    105   if(!ftxt) {cout<<"!!!!OPENING failed "<<outname<<endl; return -3;}
    106106  int dupli = 0, ndupli = 0;
    107107  nvisi = 0;
    108108  for(uint_4 i=0;i<vcode.size();i++) {
    109109    char str[512];
    110     sprintf(str,"${TACQEXE}/svv2mtx2_1210 -f %.7f -T %s -F %s"
     110    sprintf(str,"time ${TACQEXE}/svv2mtx2_1210 -f %.7f -T %s -F %s"
    111111            ,freq0,seltime.c_str(),selfreq.c_str());
    112112    string argu = str;
     
    115115    uint_4 vcode_suiv = (i<vcode.size()-1) ? vcode[IVcode(i+1)]: 99999999;
    116116    uint_4 v1 = vcode[ip]/1000, v2 = vcode[ip]%100;
     117    sprintf(str," -v %d,%d",v1,v2); argu += str;  // numero de canaux acq [1,32]
    117118    sprintf(str," -t %d",vnth[ip]); argu += str;  // numero de threads
    118119    sprintf(str," -r %d",vrow[ip]); argu += str;  // ligne de la matrice acq
  • trunk/AddOn/TAcq/svv2mtx2_1210.cc

    r3937 r3940  
    1111#include <unistd.h>
    1212#include <sys/stat.h>
     13#include <fstream>
    1314#include <iostream>
    1415#include <string>
     
    1718#include "tvector.h"
    1819#include "fioarr.h"
     20#include "timing.h"
    1921
    2022/*
    2123export TACQEXE=~/Reza/TAcq/Objs
    22 ./CasA02Dec.csh > CasA02Dec.log 2>&1
    23 ./Crab03Dec.csh > Crab03Dec.log 2>&1
    24 ./Sun03Dec.csh  > Sun03Dec.log  2>&1
    2524./CasA03Dec.csh > CasA03Dec.log 2>&1
    2625*/
     
    3231cout<<"svv2mtx2_1012 [options] dir : lecture des fichiers acq de Pittsburgh Dec 2010"<<endl
    3332    <<" dir : repertoire ou se trouvent les fichiers d'acq"<<endl
    34     <<" -C : compute and store the complexe conjugated visi"<<endl
    3533    <<" -D : visi is a duplicated one"<<endl
    3634    <<" -o visi.ppf : nom du ficher ppf pour ecrire la visi temps-frequence"<<endl
     35    <<" -v v1,v2 : numero de voie acq pour cette visi [1-32]"<<endl
     36    <<"            on calcule <v1.conj(v2)>"<<endl
     37    <<" -C : compute and store the complexe conjugated visi"<<endl
     38    <<"      dans ce cas on calcule <v2.conj(v1)>, le but est d'avoir toujours <E.conj(W)>"<<endl
    3739    <<" -t thr : numero de la thread ayant traite cette visi [0-N]"<<endl
    3840    <<" -r row : numero de la ligne de la matrice acq pour cette visi [0-Nrow["<<endl
     
    4749{
    4850  // --- Decodage des arguments et traitement
     51  int nmiss_stop = 1000;  // on s'arrete si on a "nmiss_stop" fichiers consecutifs manquants
    4952  string outname = "";
    5053  int numthread = -1, numrow = -1;
    5154  bool dupli = false, doconj = false;
    5255  double freq0 = 0.;
     56  int vacq1=-1, vacq2=-1;
    5357  int ifilmin=0, ifilmax=99999;
    5458  int jfr1=0, jfr2=-1, ngrpfreq=1;
    55   char str[2048];
    5659
    5760  char c;
    58   while((c = getopt(narg,arg,"hDCo:t:r:f:T:F:")) != -1) {
     61  while((c = getopt(narg,arg,"hDCo:t:r:f:T:F:v:")) != -1) {
    5962    switch (c) {
     63    case 'v' :
     64      sscanf(optarg,"%d,%d",&vacq1,&vacq2);
     65      break;
    6066    case 'D' :
    6167      dupli = true;
     
    9298  string indir = arg[optind];
    9399
     100  cout<<"v1="<<vacq1<<" v2="<<vacq2<<" doconj="<<(int)doconj<<endl;
    94101  cout<<"thread="<<numthread<<endl; if(numthread<0) return -2;
    95102  cout<<"numrow="<<numrow<<endl;  if(numrow<0) return -2;
    96103  cout<<"dupli="<<(int)dupli<<endl;
    97   cout<<"doconj="<<(int)doconj<<endl;
    98104  cout<<"outname="<<outname<<endl; if(outname.size()<=0) return -2;
    99105  cout<<"indir="<<indir<<endl;
     
    102108  cout<<"request: freq "<<jfr1<<" to "<<jfr2<<" grouped by "<<ngrpfreq<<endl;
    103109
     110  InitTim();
     111
    104112  // --- recherche et comptage des fichiers de visibilites
    105113  // ATTENTION: il peut manquer des fichiers au debut ou dans la sequence
    106   struct stat buffer;
     114  string flistname = outname; flistname += ".filelist";
    107115  int nfile = 0;
    108116  {
     117  ofstream flistw(flistname.c_str(), ofstream::out);
     118  cout<<"writing in file list in: "<<flistname<<" (is_open="<<flistw.is_open()<<")"<<endl;
     119  if(!flistw) {cout<<"!!!!OPEN failed "<<flistname<<endl; return -4;}
     120
     121  char str[4096];
     122  struct stat buffer;
    109123  int ifmin2 = ifilmin, ifmax2 = ifilmax; ifilmax = -1;
    110124  bool foundfirst = false;
     125  int nmiss = 0;
    111126  for(int ifile=ifmin2; ifile<=ifmax2; ifile++) {
    112127    sprintf(str, "%s/vismtx_%d_%d.ppf",indir.c_str(),numthread,ifile);
     
    119134    if(!foundfirst) continue;
    120135    if(ifile<ifilmin) continue;
    121     if(foundfirst && status!=0) continue;
     136    if(foundfirst && status!=0) {
     137      // On fait ca car "stst()" est extremement long si le fichier n'existe pas!
     138      if(nmiss>nmiss_stop) break;
     139      nmiss++;
     140      continue;
     141    }
    122142    nfile++;
    123143    ifilmax = ifile;
    124   }
     144    nmiss = 0;
     145    flistw << string(str) <<endl;
     146  }
     147 
     148  flistw.close();
    125149  cout<<"Found "<<nfile<<" files from "<<ifilmin<<" to "<<ifilmax<<endl;
    126   if(nfile==0 || ifilmax<ifilmin) return -4;
    127   }
    128 
     150  if(nfile==0 || ifilmax<ifilmin) return -5;
     151  }
     152
     153  PrtTim("--- End of file number search");
    129154
    130155  //--------------------------------------------------------------------
    131156  int rc = 0;
    132157  try {
     158
     159  ifstream flistr(flistname.c_str(), ofstream::in);
     160  if(!flistr) {cout<<"!!!!OPEN failed "<<flistname<<endl; return -6;}
    133161
    134162  // --- read visibility files
     
    140168  double tudeb_day, tufin_day;
    141169  int nfreq = 0;
    142   int lpmod = nfile/10; if(lpmod<=0) lpmod=1;
     170  int lpmod = nfile/25; if(lpmod<=0) lpmod=1;
    143171
    144172  int_4 ntimefill = 0, ntimebad = 0;
    145   for(int ifile=ifilmin; ifile<=ifilmax; ifile++) {
    146 
     173  bool foundfirst = true;
     174  while(!flistr.eof()) {
    147175    // --- Lecture d'une visi elementaire (fichier acq)
    148     sprintf(str, "%s/vismtx_%d_%d.ppf",indir.c_str(),numthread,ifile);
    149     int status = stat(str,&buffer);
    150     if(status) continue; // fichier inexistant
    151     if(ifile==ifilmin || ifile==ifilmax || (ifile-ifilmin)%lpmod==0)
    152         cout<<ntimefill<<" "<<ifile<<" opening: "<<str<<endl;
     176    string fname;
     177    getline(flistr,fname);
     178    if(fname.size()==0) continue;
     179    if(ntimefill%lpmod==0) cout<<ntimefill<<" "<<" : "<<fname<<endl;
    153180    TMatrix< complex<r_4> > vismtx;
    154181    try {
    155       PInPersist pin(str);
     182      PInPersist pin(fname);
    156183      pin >> vismtx;
    157184    } catch(...) {
    158       cout<<"ERROR: bad file "<<str<<endl;
     185      cout<<"ERROR: bad file "<<fname<<endl;
    159186      ntimebad++;
    160187      continue;
     
    167194
    168195    // --- Initialisation purposes for the first read file
    169     if (ifile==ifilmin) {
    170 
     196    if(foundfirst) {
     197      foundfirst = false;
    171198      tudeb = tufin;
    172199      printf("Reference Time: tt = %.5f sec, TU = %s\n",MeanTT(0),tudeb.c_str());
     
    223250  }  // fin boucle sur le fichiers d'acq
    224251  cout<<"ntimefill = "<<ntimefill<<" / "<<nfile<<" , ntimebad="<<ntimebad<<" bad files"<<endl;
     252  flistr.close();
     253  string order = "rm -f "; order += flistname;
     254  system(order.c_str());
    225255
    226256  // --- keeping info with visi
     
    233263  tufin_day = (double)d + ((double)h + mn/60. + s/3600.)/24.;
    234264  }
    235   MVisi.Info()["nth"] = numthread;
    236   MVisi.Info()["row"] = numrow;
    237   MVisi.Info()["dir"] = indir;
    238   MVisi.Info()["dupli"] = (dupli) ? 1: 0;
    239   MVisi.Info()["isconj"] = (doconj) ? 1: 0;
    240   MVisi.Info()["TUobs_0"] = tudeb;
    241   MVisi.Info()["TUobs_N"] = tufin;
    242   MVisi.Info()["TUday_0"] = tudeb_day;
    243   MVisi.Info()["TUday_N"] = tufin_day;
    244   MVisi.Info()["TTag_0"] = MeanTT(0);
    245   if(ntimefill>0) MVisi.Info()["TTag_N"] = MeanTT(ntimefill-1);
    246   MVisi.Info()["freq0"] = freq0;
    247   MVisi.Info()["dfreq0"] = 500./8192.;
    248   MVisi.Info()["jfr1"] = jfr1;
    249   MVisi.Info()["jfr2"] = jfr2;
    250   MVisi.Info()["ngrpfreq"] = ngrpfreq;
    251   MVisi.Info()["ifilmin"] = ifilmin;
    252   MVisi.Info()["ifilmax"] = ifilmax;
    253   MVisi.Info()["ntimefill"] = ntimefill;
    254   MVisi.Info()["ntimebad"] = ntimebad;
     265  DVList dvl;
     266  dvl["vacq1"] = vacq1;
     267  dvl["vacq2"] = vacq2;
     268  dvl["nth"] = numthread;
     269  dvl["row"] = numrow;
     270  dvl["dir"] = indir;
     271  dvl["dupli"] = (dupli) ? 1: 0;
     272  dvl["isconj"] = (doconj) ? 1: 0;
     273  dvl["TUobs_0"] = tudeb;
     274  dvl["TUobs_N"] = tufin;
     275  dvl["TUday_0"] = tudeb_day;
     276  dvl["TUday_N"] = tufin_day;
     277  dvl["TTag_0"] = MeanTT(0);
     278  if(ntimefill>0) dvl["TTag_N"] = MeanTT(ntimefill-1);
     279  dvl["freq0"] = freq0;
     280  dvl["dfreq0"] = 500./8192.;
     281  dvl["jfr1"] = jfr1;
     282  dvl["jfr2"] = jfr2;
     283  dvl["ngrpfreq"] = ngrpfreq;
     284  dvl["ifilmin"] = ifilmin;
     285  dvl["ifilmax"] = ifilmax;
     286  dvl["ntimefill"] = ntimefill;
     287  dvl["ntimebad"] = ntimebad;
    255288
    256289  // --- writing visibility matrix to file
    257   sprintf(str,"%s",outname.c_str());
    258   cout<<"writing visibility matrix to file "<<str<<endl;
    259   POutPersist pos(str);
    260   pos.PutObject(MeanTT,"meantt");
    261   pos.PutObject(Npaqsum,"npaqsum");
     290  cout<<"writing visibility matrix to file "<<outname<<endl;
     291  POutPersist pos(outname);
     292  if(ntimefill>0) {
     293    TVector<r_8> dum1(MeanTT(Range(0,ntimefill-1)));
     294    pos.PutObject(dum1,"meantt");
     295    TVector<int_4> dum2(Npaqsum(Range(0,ntimefill-1)));
     296    pos.PutObject(dum2,"npaqsum");
     297    TMatrix< complex<r_4> > dum3(MVisi(Range(0,ntimefill-1),Range(0,MVisi.NCols()-1)));
     298    dum3.Info() = dvl;
     299    pos.PutObject(dum3,"visi");
     300  }
    262301  pos.PutObject(Freq,"ifreq");
    263   pos.PutObject(MVisi,"visi");
     302
    264303  }
    265304
     
    279318  }
    280319  cout<<">>>> svv2mtx2_1210.cc ------- END ----------- RC="<<rc<<endl;
     320  PrtTim("--- End of job");
    281321  return rc;
    282322}
Note: See TracChangeset for help on using the changeset viewer.