Changeset 1484 in Sophya for trunk/ArchTOIPipe/ProcWSophya


Ignore:
Timestamp:
Apr 30, 2001, 5:20:03 PM (24 years ago)
Author:
ansari
Message:

Ameliorations diverses - Reza 30/4/2001

Location:
trunk/ArchTOIPipe/ProcWSophya
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ArchTOIPipe/ProcWSophya/simtoipr.cc

    r1483 r1484  
    162162    uint_8 fgcur;
    163163    bool fgokcur=false;
     164
     165    int sx_refresh_count = 0;
     166    int sx_refresh_count_max = 16*wsize;
     167
    164168    // Boucle sur les sampleNum
    165 
    166169    int knext;
    167170    int kfin = sne-snb;
     
    199202        }
    200203        else {
    201           s += (valadd-valsub);
    202           s2 += (valadd*valadd-valsub*valsub);
     204          if (sx_refresh_count >= sx_refresh_count_max) {
     205            //  On recalcule la somme
     206            s = vas.Sum();
     207            s2 = vas.SumX2();
     208            sx_refresh_count = 0;
     209          }
     210          else {
     211            s += (valadd-valsub);
     212            s2 += (valadd*valadd-valsub*valsub);
     213            sx_refresh_count++;
     214          }
    203215          mean = s/wsize;
    204216          sigma = sqrt(s2/wsize-mean*mean);
     
    616628    throw ParmError("SimpleFourierFilter::SimpleFourierFilter() WSize<16 !");
    617629  KeepSpectra("spectra.ppf", 0);
     630  ComputeMeanSpectra(false);
     631  totnscount = 0;
     632  totnbblock = 0;
    618633}
    619634
     
    629644     << WSize() << endl;
    630645  TOIProcessor::PrintStatus(os);
    631   os << " Coeff= " << ffcoef << endl;
    632   os << " ProcessedSampleCount=" << ProcessedSampleCount() << endl;
     646  os << " Coeff (Size= " << ffcoef.Size() << "): " << endl; 
     647  for(int i=0; i<16; i++) {
     648    os << ffcoef(i) << "  " ;
     649    if (i == 7) os << endl;
     650  }
     651  os << "  .... " << endl;
     652  os << " ProcessedSampleCount=" << ProcessedSampleCount()
     653     << " NbFFTBlocks= " << totnbblock << endl;
    633654  os << " ------------------------------------------------------ " << endl;
    634655}
     
    657678    throw ParmError("SimpleFourierFilter::run() Input TOI (in) not connected!");
    658679  }
    659   if (!fgout) {
    660     cerr << " SimpleFourierFilter::run() - No Output TOI connected! "
    661          << endl;
    662     throw ParmError("SimpleFourierFilter::run() No output TOI connected!");
    663   }
     680
     681  // ---- On peut utiliser cette classe pour calculer un spectre de Fourier ----
     682  //  if (!fgout) {
     683  //    cerr << " SimpleFourierFilter::run() - No Output TOI connected! "
     684  //     << endl;
     685  //    throw ParmError("SimpleFourierFilter::run() No output TOI connected!");
     686  //  }
    664687
    665688  cout << " SimpleFourierFilter::run() SNRange=" << snb << " - " << sne << endl;
     
    673696    TVector<int_8> vfg(wsize);
    674697    TVector< complex<r_8> > vfft, vfftmean;
     698    Vector meanpowerspectra;
    675699    TVector< complex<r_8> > zcoef(ffcoef.Size());
    676700    zcoef = ffcoef;
     
    684708    int k,i,klast;
    685709    int nks = 0;
    686     int nblk = 0;
    687710    klast = snb-1;
     711    totnbblock = 0;
    688712    // Boucle sur les sampleNum
    689713    // 1er partie, on traite par paquets de wsize
     
    692716        getData(0, k+i, vin(i), vfg(i));
    693717      ffts.FFTForward(vin, vfft);
    694       if (nblk == 0)  vfftmean = vfft;
    695       else vfftmean += vfft;
    696       nblk++;
     718      if (c_meanspectra) { // Compute mean-spectra
     719        if (totnbblock == 0)  {
     720          vfftmean = vfft;
     721          meanpowerspectra.ReSize(vfft.Size());
     722          for(i=0; i<meanpowerspectra.Size(); i++)
     723            meanpowerspectra(i) = sqrt(vfft(i).real()*vfft(i).real() +
     724                                    vfft(i).imag()*vfft(i).imag() );
     725        }
     726        else {
     727          vfftmean += vfft;
     728          for(i=0; i<meanpowerspectra.Size(); i++)
     729            meanpowerspectra(i) += sqrt(vfft(i).real()*vfft(i).real() +
     730                                        vfft(i).imag()*vfft(i).imag() );
     731        }
     732      }
     733      totnbblock++;
    697734      if (nks < nb_keep) {
    698735        TVector< complex<r_8> > vfftcopie;
    699736        vfftcopie = vfft;
    700         string nomvfft = "spectra" + MuTyV(nks);
     737        string nomvfft = "spectra" + (string)MuTyV(nks);
    701738        pout.PutObject(vfftcopie, nomvfft);
    702739        nks++;
    703740      }
    704       vfft.MulElt(zcoef);
    705       ffts.FFTBackward(vfft, vout);
    706       for(i=0; i<wsize; i++)
    707         putData(0,k+i,vout(i),vfg(i));
    708       if (fgincopie)
    709         for(i=0; i<wsize; i++)
     741      if (fgout) {
     742        vfft.MulElt(zcoef);
     743        ffts.FFTBackward(vfft, vout);
     744      }
     745      for(i=0; i<wsize; i++) {
     746        if (fgout)
     747          putData(0,k+i,vout(i),vfg(i));
     748        if (fgincopie) 
    710749          putData(1, k+i, vin(i), vfg(i));
     750      }
    711751      klast+=wsize;
    712752      totnscount+=wsize;
     
    720760      for(k=klast+1; k<=sne; k++) {
    721761        getData(0, k, inval, inflg);
    722         putData(0, k, inval, inflg);
     762        if (fgout) putData(0, k, inval, inflg);
    723763        if (fgincopie)
    724764          putData(1, k, inval, inflg);
     
    726766      }
    727767
    728    
    729     vfftmean /= complex<r_8>((r_8)nblk, 0.);   
    730     pout.PutObject(vfftmean, "meanspectra");
    731 
    732     cout << " SimpleFourierFilter::run() - End of processing " << endl;
     768    if (c_meanspectra) {
     769      vfftmean /= complex<r_8>((r_8)totnbblock, 0.);   
     770      pout.PutObject(vfftmean, "meanspectra");
     771      meanpowerspectra /= (r_8)totnbblock;
     772      pout.PutObject(vfftmean, "meanpowerspectra");
     773    }
     774    pout.PutObject(ffcoef, "fourierfilter");
     775
     776    cout << " SimpleFourierFilter::run() - End of processing "
     777         << " NbFFTBlocks= " << totnbblock << endl;
    733778  }  // Bloc try
    734779
  • trunk/ArchTOIPipe/ProcWSophya/simtoipr.h

    r1483 r1484  
    160160  inline  void  KeepSpectra(string outname, int nb)
    161161                { outppfname = outname; nb_keep = nb; }
     162  inline  void  ComputeMeanSpectra(bool fg)
     163                {  c_meanspectra = fg; }
    162164protected:
    163165  int_8 totnscount;   // Nombre total d'echantillon processe
     166  int_8 totnbblock;   // Nombre total de blocs pour FFT
    164167  int wsize;         // Taille de fenetre de travail
    165168  Vector ffcoef;     // Coefficients du filtre
     169  bool c_meanspectra;
    166170  int nb_keep;
    167171  string outppfname;
Note: See TracChangeset for help on using the changeset viewer.