Changeset 3926 in Sophya for trunk/AddOn/TAcq


Ignore:
Timestamp:
Dec 13, 2010, 5:57:43 PM (15 years ago)
Author:
cmv
Message:

add protection against corrupted and mising files, cmv 13/12/2010

Location:
trunk/AddOn/TAcq
Files:
2 edited

Legend:

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

    r3925 r3926  
    9797  for(uint_4 i=0;i<vcode.size();i++) {
    9898    char str[128];
    99     sprintf(str,"svv2mtx2_1210 -T 0,999999 -F 0,9999,1 -f %.7f",freq0);
     99    sprintf(str,"svv2mtx2_1210 -T 0,99999 -F 0,9999,1 -f %.7f",freq0);
    100100    string argu = str;
    101101    uint_4 ip = IVcode(i);
  • trunk/AddOn/TAcq/svv2mtx2_1210.cc

    r3925 r3926  
    4141  bool dupli = false;
    4242  double freq0 = 0.;
    43   int ifilmin=0, ifilmax=999999;
     43  int ifilmin=0, ifilmax=99999;
    4444  int jfr1=0, jfr2=-1, ngrpfreq=1;
    4545  char str[2048];
     
    8989
    9090  // --- recherche et comptage des fichiers de visibilites
     91  // ATTENTION: il peut manquer des fichiers au debut ou dans la sequence
     92  struct stat buffer;
    9193  int nfile = 0;
    9294  {
    93   struct stat buffer;
    94   int i2 = ifilmax; ifilmax = 0;
     95  int ifmin2 = ifilmin, ifmax2 = ifilmax; ifilmax = -1;
    9596  bool foundfirst = false;
    96   for(int ifile=0; ifile<=i2; ifile++) {
     97  for(int ifile=ifmin2; ifile<=ifmax2; ifile++) {
    9798    sprintf(str, "%s/vismtx_%d_%d.ppf",indir.c_str(),numthread,ifile);
    9899    int status = stat(str,&buffer);
     
    104105    if(!foundfirst) continue;
    105106    if(ifile<ifilmin) continue;
    106     if(foundfirst && status) break;
     107    if(foundfirst && status!=0) continue;
    107108    nfile++;
    108109    ifilmax = ifile;
     
    127128  int lpmod = nfile/10; if(lpmod<=0) lpmod=1;
    128129
    129   int ntimefill = 0;
     130  int ntimefill = 0, ntimebad = 0;
    130131  for(int ifile=ifilmin; ifile<=ifilmax; ifile++) {
    131132
    132133    // --- Lecture d'une visi elementaire (fichier acq)
    133134    sprintf(str, "%s/vismtx_%d_%d.ppf",indir.c_str(),numthread,ifile);
     135    int status = stat(str,&buffer);
     136    if(status) continue; // fichier inexistant
    134137    if(ifile==ifilmin || ifile==ifilmax || (ifile-ifilmin)%lpmod==0)
    135       cout<<ifile<<" opening: "<<str<<endl;
    136     PInPersist pin(str);
     138        cout<<ntimefill<<" "<<ifile<<" opening: "<<str<<endl;
    137139    TMatrix< complex<r_4> > vismtx;
    138     pin >> vismtx;
     140    try {
     141      PInPersist pin(str);
     142      pin >> vismtx;
     143    } catch(...) {
     144      cout<<"ERROR: bad file "<<str<<endl;
     145      ntimebad++;
     146      continue;
     147    }
    139148    tufin = (string)vismtx.Info()["DATEOBS"];
    140149
    141150    // --- Time keeping and number of summed elementary visibilities
    142     MeanTT(ifile-ifilmin) = (double)vismtx.Info()["MeanTT"]/125.e6;
     151    MeanTT(ntimefill) = (double)vismtx.Info()["MeanTT"]/125.e6;
    143152    uint_4 npaqsum = vismtx.Info()["NPAQSUM"];
    144153
     
    189198        int f = jfr1 + i*ngrpfreq + j;
    190199        if(f>jfr2) break;
    191         MVisi(ifile-ifilmin,i) += vismtx(numrow,f);
     200        MVisi(ntimefill,i) += vismtx(numrow,f);
    192201        nf++;
    193202      }
    194       Npaqsum(ifile-ifilmin) = nf * npaqsum;
    195       MVisi(ifile-ifilmin,i) /= double(Npaqsum(ifile-ifilmin));
     203      Npaqsum(ntimefill) = nf * npaqsum;
     204      MVisi(ntimefill,i) /= double(Npaqsum(ntimefill));
    196205    }
    197206    ntimefill++;
    198207
    199208  }  // fin boucle sur le fichiers d'acq
    200   cout<<"ntimefill = "<<ntimefill<<" / "<<nfile<<endl;
     209  cout<<"ntimefill = "<<ntimefill<<" / "<<nfile<<" , ntimebad="<<ntimebad<<" bad files"<<endl;
    201210
    202211  // --- keeping info with visi
Note: See TracChangeset for help on using the changeset viewer.