Changeset 4012 in Sophya for trunk/AddOn/TAcq/brviscalc.cc


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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{
Note: See TracChangeset for help on using the changeset viewer.