Changeset 1484 in Sophya for trunk/ArchTOIPipe/ProcWSophya
- Timestamp:
- Apr 30, 2001, 5:20:03 PM (24 years ago)
- Location:
- trunk/ArchTOIPipe/ProcWSophya
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/ProcWSophya/simtoipr.cc
r1483 r1484 162 162 uint_8 fgcur; 163 163 bool fgokcur=false; 164 165 int sx_refresh_count = 0; 166 int sx_refresh_count_max = 16*wsize; 167 164 168 // Boucle sur les sampleNum 165 166 169 int knext; 167 170 int kfin = sne-snb; … … 199 202 } 200 203 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 } 203 215 mean = s/wsize; 204 216 sigma = sqrt(s2/wsize-mean*mean); … … 616 628 throw ParmError("SimpleFourierFilter::SimpleFourierFilter() WSize<16 !"); 617 629 KeepSpectra("spectra.ppf", 0); 630 ComputeMeanSpectra(false); 631 totnscount = 0; 632 totnbblock = 0; 618 633 } 619 634 … … 629 644 << WSize() << endl; 630 645 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; 633 654 os << " ------------------------------------------------------ " << endl; 634 655 } … … 657 678 throw ParmError("SimpleFourierFilter::run() Input TOI (in) not connected!"); 658 679 } 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 // } 664 687 665 688 cout << " SimpleFourierFilter::run() SNRange=" << snb << " - " << sne << endl; … … 673 696 TVector<int_8> vfg(wsize); 674 697 TVector< complex<r_8> > vfft, vfftmean; 698 Vector meanpowerspectra; 675 699 TVector< complex<r_8> > zcoef(ffcoef.Size()); 676 700 zcoef = ffcoef; … … 684 708 int k,i,klast; 685 709 int nks = 0; 686 int nblk = 0;687 710 klast = snb-1; 711 totnbblock = 0; 688 712 // Boucle sur les sampleNum 689 713 // 1er partie, on traite par paquets de wsize … … 692 716 getData(0, k+i, vin(i), vfg(i)); 693 717 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++; 697 734 if (nks < nb_keep) { 698 735 TVector< complex<r_8> > vfftcopie; 699 736 vfftcopie = vfft; 700 string nomvfft = "spectra" + MuTyV(nks);737 string nomvfft = "spectra" + (string)MuTyV(nks); 701 738 pout.PutObject(vfftcopie, nomvfft); 702 739 nks++; 703 740 } 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) 710 749 putData(1, k+i, vin(i), vfg(i)); 750 } 711 751 klast+=wsize; 712 752 totnscount+=wsize; … … 720 760 for(k=klast+1; k<=sne; k++) { 721 761 getData(0, k, inval, inflg); 722 putData(0, k, inval, inflg);762 if (fgout) putData(0, k, inval, inflg); 723 763 if (fgincopie) 724 764 putData(1, k, inval, inflg); … … 726 766 } 727 767 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; 733 778 } // Bloc try 734 779 -
trunk/ArchTOIPipe/ProcWSophya/simtoipr.h
r1483 r1484 160 160 inline void KeepSpectra(string outname, int nb) 161 161 { outppfname = outname; nb_keep = nb; } 162 inline void ComputeMeanSpectra(bool fg) 163 { c_meanspectra = fg; } 162 164 protected: 163 165 int_8 totnscount; // Nombre total d'echantillon processe 166 int_8 totnbblock; // Nombre total de blocs pour FFT 164 167 int wsize; // Taille de fenetre de travail 165 168 Vector ffcoef; // Coefficients du filtre 169 bool c_meanspectra; 166 170 int nb_keep; 167 171 string outppfname;
Note:
See TracChangeset
for help on using the changeset viewer.