Changeset 4012 in Sophya for trunk/AddOn


Ignore:
Timestamp:
Aug 2, 2011, 7:25:02 PM (14 years ago)
Author:
ansari
Message:

Codage du mode de calcul de visibilites par intervalle de temps (BRVisibiliyCalculator) et propagation des modifs (ajouts de parametres) ds mfacq.cc et vismfib.cc, Reza 02/08/2011

Location:
trunk/AddOn/TAcq
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/acqparam_exemple.d

    r4010 r4012  
    113113#  Defaut : visicalc 1024  1 1
    114114visicalc 5000  2 1
     115#### Passage en mode Time Interval
     116# @visitimeint  deltatime_in_seconds
     117visitimeint 0.5
    115118## Activation de remplissage du DataTable des visibilites
    116119## @visidtable
  • trunk/AddOn/TAcq/branap.cc

    r4004 r4012  
    1717  outpath_="./";
    1818  fgfitsout_=false;
    19   nmean_=nmean;
    20   nbloc_=1;
    2119  imin_=imax_=0;
    2220  istep_=1;
     
    3129  prtlevel_=0;
    3230  prtmodulo_=50000;
     31
     32  nmean_=nmean;
     33  fgtimeinterval_=false;
     34  timeinterval_=1.;
     35  nbloc_=1;
     36
    3337  nbcalgrp_=1;
    3438  nthreads_=1;
     
    7781      nmean_=atoi(arg[ka+1]);
    7882      ka+=2;
     83    }
     84    else if (strcmp(arg[ka],"-tmint")==0) {
     85      timeinterval_=atoi(arg[ka+1]);
     86      fgtimeinterval_=true;  ka+=2;
    7987    }
    8088    else if (strcmp(arg[ka],"-nbloc")==0) {
     
    224232       << " -fitsout : Force FITS format for output files  \n"
    225233       << " -nmean NMean: Number of packet used for spectra/visibility computation \n"
     234       << " -tmint dtime: Time interval definition (instead of nmean) for spectra/visibility computation \n"
    226235       << " -nbloc NBloc: Number of MemMgr blocs in output file\n"
    227236       << " -zones NZones,NbPaqinZone : Number of Zones and number of paquets in one zone (RAcqMemZoneMgr) \n"
     
    287296  cout << " OutPath= " << outpath_ << (fgfitsout_?" force FITS output":" PPF output") << endl;
    288297  cout << " Action=" << action_ << "  NMean=" << nmean_ << " NBloc=" << nbloc_ << endl;
     298  cout << ((fgtimeinterval_)?" Time Interval mode for visi/spectra ":" NPaq Interval mode")
     299       << " TimeInterval=" << timeinterval_ << " seconds " << endl;
    289300  cout << " FreqMin= " << freqmin_ << " FreqMax= " << freqmax_ << " NBinFreq= " << nbinfreq_ << endl;
    290301  if (fgdtpaq_) cout<<  " Fill Per Paquet DadaTable ";
  • trunk/AddOn/TAcq/branap.h

    r3993 r4012  
    3434  string outpath_;
    3535  bool fgfitsout_;   // true -> force fichier sortie format FITS (defaut PPF)
    36   uint_4 nmean_;
    37   uint_4 nbloc_;
    38   uint_4 imin_, imax_, istep_;
     36 uint_4 imin_, imax_, istep_;
    3937  bool rdsamefc_;    // read paquets with same frame counter
    4038  uint_4 freqmin_, freqmax_, nbinfreq_;
     
    4947  long int prtmodulo_;
    5048
     49  uint_4 nmean_;
     50  // definition intervalle de temps (au lieu du nombre de paquet pour spectres moyennes/visibilites
     51  bool fgtimeinterval_;  // true : calcul visibilites/spectres moyens par intervalle de temps (au lieu de nmean)
     52  double timeinterval_;  // definition de l'intervalle de temps en secondes pour spectres moyens/visibilites
     53  uint_4 nbloc_;
     54 
    5155  uint_4 nbcalgrp_;    // Nb d'objets/threads dans BRVisCalcGroup
    5256  uint_4 nthreads_;  // Nb de threads pour l'execution parallele ds BRVisibilityCalculator
  • trunk/AddOn/TAcq/brparam.cc

    r4010 r4012  
    204204  fgdoVisiC=false;
    205205  nmeanVisiC=1024;
     206  fgtimeintervalVisiC=false;
     207  timeintervalVisiC=1.;
    206208  nbcalgrpVisiC=1;
    207209  nthrVisiC=1;
     
    290292
    291293  fgdoVisiC=p.fgdoVisiC;           
    292   nmeanVisiC=p.nmeanVisiC;         
     294  nmeanVisiC=p.nmeanVisiC; 
     295  fgtimeintervalVisiC=p.fgtimeintervalVisiC;       
     296  timeintervalVisiC=p.timeintervalVisiC;
    293297  nbcalgrpVisiC=p.nbcalgrpVisiC;     
    294298  nthrVisiC=p.nthrVisiC;     
     
    384388    nbcalgrpVisiC=conf.IParam("visicalc",1,1);
    385389    nthrVisiC=conf.IParam("visicalc",2,1);
     390  }
     391  if (conf.HasKey("visitimeint")) {
     392    fgtimeintervalVisiC=true;
     393    timeintervalVisiC=conf.DParam("visitimeint",0,1.);
    386394  }
    387395  if (conf.HasKey("visidtable"))  fgfdtVisiC=true;
     
    551559    os << " Visibility calculation, nbCalGrp=" << nbcalgrpVisiC << " NThr/VisCal=" << nthrVisiC
    552560       << ((fgfdtVisiC)?" Fill_VisiDTable":" ") << endl;
     561    if (fgtimeintervalVisiC) os << " ... VisiCalc TimeIntervalMode : " << timeintervalVisiC << " seconds " << endl;
     562    else  os << " ... VisiCalc  NPaq=" << nmeanVisiC  << " IntervalMode " << endl;
    553563    os << " ... VisiCalc FirstPair= " << firstpairVisiC << " NbPairs= " << nbpairsVisiC
    554564       << ((fgpimpVisiC)?" (Odd-Even visibilities+AutoCorrel only) ":"") << endl;
  • trunk/AddOn/TAcq/brparam.h

    r4010 r4012  
    206206  bool fgdoVisiC;           // true -> calcul des visibilites
    207207  uint_4 nmeanVisiC;        // nombre de paquets moyennes pour les calculs de visibilites
     208  bool fgtimeintervalVisiC;  // true : sauvegarde matrice de visibilites par intervalle de temps
     209  double timeintervalVisiC;  // definition de l'intervalle de temps en secondes pour suvegarde de la matrice de visibilites
    208210  uint_4 nbcalgrpVisiC;     // Nb d'objets/threads dans BRVisCalcGroup
    209211  uint_4 nthrVisiC;         // Nb de threads pour l'execution parallele ds BRVisibilityCalculator
  • trunk/AddOn/TAcq/brviscalc.cc

    r3993 r4012  
    2828BRVisibilityCalculator::BRVisibilityCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean, size_t nthr)
    2929  : BRBaseProcessor(memgr), paralex_(*this, nthr), nparthr_(nthr),
    30     outpath_(outpath), nmean_(nmean), nbcalc_(1), calcid_(0),
     30    outpath_(outpath), nbcalc_(1), calcid_(0),
    3131    vpdata_(2*memgr.NbFibres()), vpdatar_(2*memgr.NbFibres())
    3232    // , dtfos_(outpath+"visdt.fits", Fits_Create), visdt_(dtfos_, 1024, true);
    3333
    3434  SetFFTData();
     35  SetNPaqIntervalMode(nmean);
    3536  DefineRank(1,0);
    3637  SetPPFOutput();
     38
     39  npaqcumul_=0;
     40  moyfc_=moytt_=0.;
     41  first_fc_=first_tt_=0;
    3742
    3843  uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
     
    5762  if (nmean_ < 1)  nmean_=1;
    5863
    59   cout << " BRVisibilityCalculator::/Info  nmean=" << nmean_ << endl;
    60 
    6164  totnbpaq_=0;
    6265  numfile_=0;
    6366  nb_flop_=0.;
    64   moyfc_=moytt_=0.;
    6567
    6668  fgallfibok=NULL;
     
    272274       << "]::run() - Starting " << " NFibers=" << memgr_.NbFibres()
    273275       << " NChan=" << 2*memgr_.NbFibres() << " NPairs=" << nbpairs_ << " First:" << pairst_ << endl;   
    274  
     276
     277  if (fgnpaq_time)
     278    cout << " BRVisibilityCalculator::run()/Info  NPaq=" << nmean_ << " Interval mode for visibility mtrix save" << endl;
     279  else
     280    cout << " BRVisibilityCalculator::run()/Info  Time Tnterval (dt=" << dtimemean_ << ") for visibility mtrix save" << endl;
     281
    275282  if (nparthr_ < 2)  return BRBaseProcessor::run();
    276283  // Execution multithread parallele
     
    324331      }
    325332
    326       if (totnbpaq_%nmean_ == 0) {
    327         if (totnbpaq_ > 0) {
    328           moyfc_/=nmean_;
    329           moytt_/=nmean_;
    330           UpdateVisMtxInfo();    // add/update keywords in the Info DVList
    331           // ATTENTION : Matrice visibilites non moyennee
    332           char nfile[48];
    333           if (nbcalc_==1)
    334             sprintf(nfile,"vismtx%d.%s",numfile_,OutFileExtension());
    335           else
    336             sprintf(nfile,"vismtx_%d_%d.%s",(int)calcid_,numfile_,OutFileExtension());
    337           string flnm=outpath_+nfile;
    338           if (fgfitsout_) {  // Ecriture au format FITS
    339             FitsInOutFile fo(flnm, FitsInOutFile::Fits_Create);
    340             TArray<r_4> arvismtx = ArrCastC2R(vismtx_);
    341             arvismtx.Info()=vismtx_.Info();
    342             fo << arvismtx;
    343           }
    344           else {  // Format PPF
    345             POutPersist po(flnm);
    346             po << vismtx_;
    347           }
    348           if ((prtlev_>0)&&(numfile_%prtmodulo_==0)) {
    349             cout << numfile_ << "-BRVisCalc[" << calcid_ << "/" << nbcalc_ << "]::run() NPaqProc="
    350                  << totnbpaq_ << " TotMegaFLOP=" << (uint_8)TotNbMegaFLOP() << " -> VisibMtx in " << flnm << endl;
    351           }
    352           if (fgvisdt_) FillVisibTable(moyfc_, moytt_);
    353           numfile_++;
    354         }
    355         vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
    356         moyfc_=moytt_=0.;
    357         //      first_tmstamp_.SetNow();  // Current date and time
    358         first_tmstamp_=cts_;  // Current date and time
     333      if ( CheckInterval4VisMtxSave() ) {
     334        if ((prtlev_>0)&&(numfile_%prtmodulo_==0)) {
     335          cout << numfile_ << "-BRVisCalc[" << calcid_ << "/" << nbcalc_ << "]::run() NPaqProc="
     336               << totnbpaq_ << " TotMegaFLOP=" << (uint_8)TotNbMegaFLOP() << " -> VisibMtx FileNum=" << numfile_ << endl;
     337        }
     338        SaveVisibilityMatrix();
    359339      }
    360340
     
    378358          moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
    379359          if ((fgcktt_)&&(calcid_==0))  CheckTimeTag();
    380           if (totnbpaq_%nmean_ == 0) {
     360          if (npaqcumul_==0) {
    381361            first_fc_=curfc_[0];
    382             first_tt_= (vpaq_[0].TimeTag()-ttfirst_[0]);
     362            first_tt_= vpaq_[0].TimeTag();
    383363          }
     364          npaqcumul_++;
    384365          totnbpaq_++;
    385366        }
     
    431412  }
    432413 
    433   if (totnbpaq_%nmean_ == 0) {
    434     if (totnbpaq_ > 0) {
    435       moyfc_/=nmean_;
    436       moytt_/=nmean_;
    437       UpdateVisMtxInfo();    // add/update keywords in the Info DVList
    438       // ATTENTION : Matrice visibilites non moyennee
    439       char nfile[48];
    440       if (nbcalc_==1)
    441         sprintf(nfile,"vismtx%d.%s",numfile_,OutFileExtension());
    442       else
    443         sprintf(nfile,"vismtx_%d_%d.%s",(int)calcid_,numfile_,OutFileExtension());
    444       string flnm=outpath_+nfile;
    445       if (fgfitsout_) {  // Ecriture au format FITS
    446         FitsInOutFile fo(flnm, FitsInOutFile::Fits_Create);
    447         TArray<r_4> arvismtx = ArrCastC2R(vismtx_);
    448         arvismtx.Info()=vismtx_.Info();
    449         fo << arvismtx;
    450       }
    451       else {  // Format PPF
    452         POutPersist po(flnm);
    453         po << vismtx_;
    454       }
    455       if ((prtlev_>0)&&(numfile_%prtmodulo_==0)) {
    456         cout << numfile_ << "-BRVisCalc[" << calcid_ << "/" << nbcalc_ << "]::Process() NPaqProc="
    457              << totnbpaq_ << " TotMegaFLOP=" << (uint_8)TotNbMegaFLOP() << " -> VisibMtx in " << flnm << endl;
    458       }
    459       if (fgvisdt_) FillVisibTable(moyfc_, moytt_);
    460       numfile_++;
    461     }
    462     vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
    463     moyfc_=moytt_=0.;
    464     first_fc_=curfc_[0];
    465     first_tt_= (vpaq_[0].TimeTag()-ttfirst_[0]);
    466     // first_tmstamp_.SetNow();  // Current date and time
    467     first_tmstamp_=cts_;  // Current date and time
     414  if ( CheckInterval4VisMtxSave() ) {
     415    if ((prtlev_>0)&&(numfile_%prtmodulo_==0)) {
     416      cout << numfile_ << "-BRVisCalc[" << calcid_ << "/" << nbcalc_ << "]::Process() NPaqProc="
     417           << totnbpaq_ << " TotMegaFLOP=" << (uint_8)TotNbMegaFLOP() << " -> VisibMtx FileNum= " << numfile_ << endl;
     418    }
     419    SaveVisibilityMatrix();
    468420  }
    469421
     
    494446  }
    495447
     448  npaqcumul_++;
    496449  moyfc_ += curfc_[0];
    497450  moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
     
    499452  totnbpaq_++;
    500453  return 0;
     454}
     455/* --Methode-- */
     456void BRVisibilityCalculator::SaveVisibilityMatrix()
     457{
     458  if (totnbpaq_ > 0) {
     459    moyfc_/=npaqcumul_;
     460    moytt_/=npaqcumul_;
     461    UpdateVisMtxInfo();    // add/update keywords in the Info DVList
     462    // ATTENTION : Matrice visibilites non moyennee
     463    char nfile[48];
     464    if (nbcalc_==1)
     465      sprintf(nfile,"vismtx%d.%s",numfile_,OutFileExtension());
     466    else
     467      sprintf(nfile,"vismtx_%d_%d.%s",(int)calcid_,numfile_,OutFileExtension());
     468    string flnm=outpath_+nfile;
     469    if (fgfitsout_) {  // Ecriture au format FITS
     470      FitsInOutFile fo(flnm, FitsInOutFile::Fits_Create);
     471      TArray<r_4> arvismtx = ArrCastC2R(vismtx_);
     472      arvismtx.Info()=vismtx_.Info();
     473      fo << arvismtx;
     474    }
     475    else {  // Format PPF
     476      POutPersist po(flnm);
     477      po << vismtx_;
     478    }
     479    if (fgvisdt_) FillVisibTable(moyfc_, moytt_);
     480    numfile_++;
     481  }
     482  vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
     483  npaqcumul_=0;
     484  moyfc_=moytt_=0.;
     485  first_fc_=curfc_[0];
     486  first_tt_=vpaq_[0].TimeTag();
     487  // first_tmstamp_.SetNow();  // Current date and time
     488  first_tmstamp_=cts_;  // Current date and time
     489 
     490  return;
    501491}
    502492
     
    512502  vismtx_.Info().SetComment(ikey,ikdesc);
    513503  ikey="FirstTT";  ikdesc="First TimeTag";
    514   vismtx_.Info().SetI(ikey,first_tt_);
     504  vismtx_.Info().SetI(ikey,(first_tt_-ttfirst_[0]));
    515505  vismtx_.Info().SetComment(ikey,ikdesc);
    516506  ikey="LastFC";  ikdesc="Last FrameCounter";
     
    527517  vismtx_.Info().SetComment(ikey,ikdesc);
    528518  ikey="NPAQSUM";  ikdesc="Number of paquets summed";
    529   vismtx_.Info().SetI(ikey,nmean_);
     519  vismtx_.Info().SetI(ikey,npaqcumul_);
    530520}
    531521
     
    752742
    753743/* --Methode-- */
     744void BRVisCalcGroup::SetNPaqIntervalMode(uint_4 nmean)
     745{
     746  for(size_t i=0; i<viscalcp_.size(); i++)
     747    viscalcp_[i]->SetNPaqIntervalMode(nmean);
     748}
     749/* --Methode-- */
     750void BRVisCalcGroup::SetTimeIntervalMode(double dtime)
     751{
     752  for(size_t i=0; i<viscalcp_.size(); i++)
     753    viscalcp_[i]->SetTimeIntervalMode(dtime);
     754
     755/* --Methode-- */
    754756void BRVisCalcGroup::SetPrintLevel(int lev, uint_8 prtmodulo)
    755757{
  • trunk/AddOn/TAcq/brviscalc.h

    r3967 r4012  
    6767  // Pour ecrire les fichiers de sortie au format PPF (defaut)
    6868  inline void SetPPFOutput() { fgfitsout_=false; }
     69  // Pour passer en mode nombre de paquet pour sauvegarde matrices visibilites (defaut)
     70  inline void SetNPaqIntervalMode(uint_4 nmean=1000) 
     71    { fgnpaq_time=true; nmean_=(nmean>0)?nmean:1000; }
     72  // Pour passer en mode intervalle en temps pour sauvegarde matrices visibilites - intervalle de temps en secondes
     73  inline void SetTimeIntervalMode(double dtime=1.)
     74    { fgnpaq_time=false; dtimemean_=(dtime>1e-6)?dtime:1.; }
    6975
    7076  // Methode d'execution standard du thread (on redefinit la methode de BRBaseProcessor)
     
    8490  virtual void UpdateChanIds();
    8591  virtual int Process();
     92  virtual void SaveVisibilityMatrix();
    8693  virtual void UpdateVisMtxInfo();
    8794  virtual int FillVisibTable(double fcm, double ttm);
     95  inline  bool CheckInterval4Save(); 
    8896  virtual int CheckTimeTag();
    8997  inline const char* OutFileExtension() { return ((fgfitsout_)?"fits":"ppf"); }
     98 // return true if npaq or time interval elasped to save visibility matrix
     99  inline  bool CheckInterval4VisMtxSave() 
     100  {
     101    if (npaqcumul_<1) return false;
     102    if (fgnpaq_time)
     103      return ((npaqcumul_>=nmean_)?true:false);
     104    else {
     105      return (((vpaq_[0].TimeTag()-first_tt_)/1.25e8>=dtimemean_)?true:false);
     106    }
     107  }
    90108
    91109  ParallelExecutor paralex_;  // Pour l'execution en parallele 
     
    93111
    94112  bool fgdataraw_;  // true -> donnees provenant du firmware RAW
    95   uint_4 nmean_;  // Nombre de spectres pour le calcul des moyennes
    96113  string outpath_;  // directory pour fichiers de sortie
    97114  uint_4 nbcalc_, calcid_;  // Nombre total de threads/objets BRVisibilityCalculator parallèles, l'identificateur de l'objet 
    98115
     116  //  Definition du mode (type d'intervalle) pour calcul des moyennes
     117  uint_4 nmean_;  // Nombre de spectres pour le calcul des moyennes
     118  double dtimemean_;  // Intervalle en temps pour le calcul des moyennes - exprimes en secondes
     119  bool fgnpaq_time;  // true -> utilisation nmean_ comme nb de paquet/spectre, false -> dtimemean_
     120
    99121  uint_4 pairst_, nbpairs_;   // Numero de la premiere paire, nombre de paires ( 1 paire= 1 visibilites)
    100122  bool fgpimp_;    //  true -> calculer uniquement visibilities avec no voie pair-impair 
     
    107129  bool* fgallfibok; 
    108130
     131  uint_8 npaqcumul_;     // Nb de paquets cumules/moyennes ds la matrice de visibilite
    109132  double moyfc_, moytt_;  // moyenne des FrameCounter / TimeTag pour chaque matrice de visibilite
    110133  uint_8 first_fc_,first_tt_;  // Valeurs premier FrameCounter / TimeTag pour chaque matrice de visibilite
     
    167190  // configuration avec donnees firmware RAW 
    168191  void SetRawData(); 
     192  // Pour passer en mode nombre de paquet pour sauvegarde matrices visibilites (defaut)
     193  void SetNPaqIntervalMode(uint_4 nmean=1000);
     194  // Pour passer en mode intervalle en temps pour sauvegarde matrices visibilites
     195  void SetTimeIntervalMode(double dtime=1.);
    169196
    170197  void SetPrintLevel(int lev=0, uint_8 prtmodulo=10);
  • trunk/AddOn/TAcq/mfacq.cc

    r4010 r4012  
    432432  VCGThr.SetPrintLevel(acpar.prtlevel_, acpar.prtmodulo2_);
    433433  if (acpar.fgfitsVisiC) VCGThr.SetFitsOutput();
     434  if (acpar.fgtimeintervalVisiC)  VCGThr.SetTimeIntervalMode(acpar.timeintervalVisiC);
    434435
    435436  cout << "mfacq[3] Creating   EthernetReader thread object     " << endl;
  • trunk/AddOn/TAcq/vismfib.cc

    r3967 r4012  
    7676    if (par.action_ == "viscktt")  procg.ActivateTimeTagCheck(par.TotalNPaquets());
    7777    if (par.fgfitsout_) procg.SetFitsOutput();
    78 
     78    if (par.fgtimeinterval_)  procg.SetTimeIntervalMode(par.timeinterval_);
    7979    BRFFTCalculator procfft(mmgr, par.fgsinglechannel_);
    8080
Note: See TracChangeset for help on using the changeset viewer.