Changeset 3992 in Sophya


Ignore:
Timestamp:
May 11, 2011, 4:13:03 PM (13 years ago)
Author:
campagne
Message:

halfmedwith poru le filtrage des freq. TIMWIN pour tagger les fenetres des paquets

Location:
trunk/AddOn/TAcq
Files:
5 edited

Legend:

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

    r3979 r3992  
    4343
    4444  fgfreqfilter_=false; //JEC 1/2/11
     45  medhalfwidth_=50;    //JEC 6/4/11
    4546
    4647  gainfile_="";
     
    137138    }
    138139    else if (strcmp(arg[ka],"-freqfilter")==0) {
    139       fgfreqfilter_=true;
     140      fgfreqfilter_=true;  ka++;
     141      if (strcmp(arg[ka],"-")!=0) medhalfwidth_=atof(arg[ka]);
    140142      ka++;
    141143    }   
     
    201203       << "                 [-prt lev,modulo] [-nvcal n] [-nthr n] [-nosfc]\n"
    202204       << "                 [-singlechan] [-twochan] [-fftdata] [-rawdata] \n"
     205       << "                 [-freqfilter medhw] [-gain filename] [-varcut min,max] [-nband nband,first,last] \n"
    203206       << "                 [-freqfilter] [-gain filename] [-varcut min,max] [-nband nband,first,last] \n"
    204207       << "                 [-tmproc hh:mm:ss,nseconds] [-filldt] [-tspwin wsz,extsz,nfiles] \n"
     
    232235       << " -tmproc hh:mm:ss,nseconds : processing time window definition \n"
    233236       << " -filldt : force data table filling \n"
    234        << " -freqfilter : force median filtering on the frequencies \n"
     237       << " -freqfilter medhw: force median filtering on the frequencies \n"
     238       << "   with half window width medhw (use - for default=" << medhalfwidth_ << ") \n"
    235239       << " -gain filename : spectral response fits file name \n"
    236240       << " -tspwin wsz,extsz,nfiles : spectra time (paquet no) window (ex: -tspwin 120,4,5) \n"
     
    283287       << " Bands: N=" <<  nbands_ << " First=" << bandfirst_ << " Last=" << bandlast_
    284288       << endl;
    285   cout << " force frequence median filtering (action gain)" << endl;
     289  if (fgfreqfilter_) {
     290    cout << " force frequence median filtering (action gain), half width =" << medhalfwidth_
     291         << endl;
     292  } else {
     293    cout<<" NO freq. filtering" << endl;
     294  }
    286295  cout << " Spectra TimeWindow (Nb.Paquets) Size=" << spec_win_sz_ << " ExtensionSize=" << spw_ext_sz_
    287296       << " MaxNbFile=" << nbmax_specwfiles_ << endl;
  • trunk/AddOn/TAcq/branap.h

    r3979 r3992  
    6161
    6262  bool fgfreqfilter_; // if true force median filtering on the frequencies
     63  uint_4 medhalfwidth_; //half freq window for filtering
    6364
    6465  string gainfile_;     // nom du fichier de gain (reponse spectrale)
  • trunk/AddOn/TAcq/brprocGain.cc

    r3953 r3992  
    4141BRGainCalculator::BRGainCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean,
    4242                                           bool fgdatafft, bool fgsinglechan)
    43   : BRMeanSpecCalculator(memgr,outpath,nmean,fgdatafft,fgsinglechan), forceMedianFreqFilter_(false),nbwin4mean_(nmean)
     43  : BRMeanSpecCalculator(memgr,outpath,nmean,fgdatafft,fgsinglechan), forceMedianFreqFilter_(false), medianFilterHalfWidth_(50), nbwin4mean_(nmean)
    4444{
    4545
     
    7070  nummedianfile_ = 0;
    7171  nbtot_specwin_ = 0;
     72  windowTime_ = TimeStamp(); //default
    7273
    7374}
     
    8889{
    8990
    90 //   cout << "(JEC): BRGainCalculator ProcSpecWin: "<<   nbtot_specwin_
    91 //        << " nbwin4mean = " << nbwin4mean_
    92 //        << endl;
    93  
    94   //  cout<< "(Spec_window info) Start" << endl;
    95   //spec_window_.Show();
    96   //cout<< "(Spec_window info) End" << endl;
     91  //   cout << "(JEC): BRGainCalculator ProcSpecWin: "<<   nbtot_specwin_
     92  //        << endl;
     93 
     94
    9795
    9896  //JEC 13/12/10 save the filtered spectra
    9997  if ( (nbtot_specwin_>0)&&(nbtot_specwin_%nbwin4mean_==0) ) SaveMedianSpectra();
    10098
    101 
     99  // Get time of window
     100  windowTime_ = getObsTime();
     101
     102 if (prtlev_>1)  {
     103      cout << " BRGainCalculator::ProcSpecWin() num_win=" << nbtot_specwin_ << " numpaqstart=" << numpaqstart
     104           << " numpaqend=" << numpaqend  << " nbwin4mean = " << nbwin4mean_ << endl;
     105      cout << " (1) ObsTime=" << windowTime_ << " TimeTag=" << getCurTimeTagSeconds() << " s. FrameCounter="
     106           << getCurFrameCounter() << endl;
     107  } 
    102108  //DBG  cout << "BRGainCalculator::ProcSpecWin()/Debug: numpaqstart=" << numpaqstart
    103109  //DBG     << " numpaqend=" << numpaqend << endl;
     
    124130      //perform a median filter on the frequencies
    125131      TVector<r_4> medianFilterFreq = medfiltspecmtx_.Row(i);
    126       sa_size_t hww = 50; //half freq window for filtering
     132      sa_size_t hww = medianFilterHalfWidth_; //half freq window for filtering
    127133      sa_size_t fMin = 0.;
    128134      sa_size_t fMax = spec_window_.SizeX()-1;
     
    164170       << " nbtot_specwin = " <<  nbtot_specwin_
    165171       << endl;
    166  
    167     for(sa_size_t ir=0; ir< medfiltspecmtx_.NRows(); ir++){
    168       char buff[32];
    169       sprintf(buff,"NPAQSUM_%d",(int)ir);
    170       medfiltspecmtx_.Info()["NPAQSUM"] = nbtot_specwin_;
    171       medfiltspecmtx_.Info()[buff] = nbtot_specwin_;
    172       if ( nbtot_specwin_ > 0) {
    173         medfiltspecmtx_.Row(ir)  /= (r_4)nbtot_specwin_;
    174       }
    175     }//eo loop on channels
    176     char nfile[64];
    177     string flnm;
    178     {
    179       sprintf(nfile,"medfiltmtx%d.fits",nummedianfile_);
    180       flnm="!"+outpath_+nfile;
    181       FitsInOutFile fos(flnm,FitsInOutFile::Fits_Create);
    182       fos << medfiltspecmtx_;
     172  if (prtlev_>1)  {
     173    cout << " BRGainCalculator:SaveMedianSpectra() nbwin4mean = " << nbwin4mean_ << endl
     174         << " (2) ObsTime=" << windowTime_ << " Total Intensity " << 0.5*medfiltspecmtx_.Sum() << endl;
     175  } 
     176 
     177  //JEC compute power spectrum
     178 
     179
     180
     181
     182  for(sa_size_t ir=0; ir< medfiltspecmtx_.NRows(); ir++){
     183    char buff[32];
     184    sprintf(buff,"NPAQSUM_%d",(int)ir);
     185    medfiltspecmtx_.Info()["NPAQSUM"] = nbtot_specwin_;
     186    medfiltspecmtx_.Info()[buff] = nbtot_specwin_;
     187    //JEC timeStamp in the day @ millisec: faudra gerer le passage a minuit!
     188    medfiltspecmtx_.Info()["TIMEWIN"] = (windowTime_.SecondsPart())*1000.;
     189
     190
     191    if ( nbtot_specwin_ > 0) {
     192      medfiltspecmtx_.Row(ir)  /= (r_4)nbtot_specwin_;
    183193    }
     194  }//eo loop on channels
     195  char nfile[64];
     196  string flnm;
     197  {
     198    sprintf(nfile,"medfiltmtx%d.fits",nummedianfile_);
     199    flnm="!"+outpath_+nfile;
     200    FitsInOutFile fos(flnm,FitsInOutFile::Fits_Create);
     201    fos << medfiltspecmtx_;
    184202    cout << nummedianfile_ << "-BRGainCalculator::ProcSpecWin() save filtered spectra matrix in "
    185203         << flnm << endl;
    186 
    187     //increment the file index
    188     nummedianfile_++;
     204  }
     205 
     206  //increment the file index
     207  nummedianfile_++;
    189208   
    190     //reset the matirx
    191     medfiltspecmtx_ = (r_4)(0.);
    192 
    193     //reset counter
    194     nbtot_specwin_ = 0;
    195 
    196     return;
     209  //reset the matirx
     210  medfiltspecmtx_ = (r_4)(0.);
     211
     212  //reset counter
     213  nbtot_specwin_ = 0;
     214
     215  return;
    197216}
    198217//JEC 13/12/10 End
  • trunk/AddOn/TAcq/brprocGain.h

    r3943 r3992  
    2828
    2929  void SetOnMedianFreqFilt(){forceMedianFreqFilter_ = true;} 
    30 
     30  void SetMedianFilterHalfWidth(uint_4 val){ medianFilterHalfWidth_ = val; }
    3131
    3232protected:
     
    3939
    4040  bool forceMedianFreqFilter_; // if true force Median frequency filtering
     41  uint_4 medianFilterHalfWidth_; //half freq window for filtering (default=50)
     42
    4143
    4244  TMatrix< r_4 > medfiltspecmtx_;    // Matrice des spectres filtres
     
    4446  uint_4 nummedianfile_; //index of the filtered spectra file
    4547
     48  TimeStamp  windowTime_; //time of the window of paquets
    4649};
    4750#endif
  • trunk/AddOn/TAcq/specmfib.cc

    r3980 r3992  
    9393        new BRGainCalculator(mmgr, par.outpath_, par.nmean_, par.fgdatafft_, par.fgsinglechannel_);
    9494      procgain_p->SetPrintLevel(par.prtlevel_,par.prtmodulo_);
    95       if(par.fgfreqfilter_) procgain_p->SetOnMedianFreqFilt();
     95      if(par.fgfreqfilter_){
     96        procgain_p->SetOnMedianFreqFilt();
     97        //add possibility to set the half width of the Freq. Median Filter
     98        //default is 50 if par.fgfreqfilter_=true
     99        if (par.medhalfwidth_>0) procgain_p->SetMedianFilterHalfWidth(par.medhalfwidth_);
     100      }
    96101      if(par.fgtimeselect_) procgain_p->SetProcTimeWindow(par.proctimestart_,par.proctimeend_);
    97102    }
Note: See TracChangeset for help on using the changeset viewer.