Changeset 3979 in Sophya


Ignore:
Timestamp:
May 4, 2011, 9:18:09 AM (14 years ago)
Author:
ansari
Message:

Ajout definition de fenetre en temps de traitement (appel a Process()) ds BRBaseProcessor et BRAnaParam, FileSequenceNumber (numero signalXXX.fits) pour chaque zone memoire dans RAcqMZAuxData / RAcqMemZoneMgr, Reza 04/05/2011

Location:
trunk/AddOn/TAcq
Files:
7 edited

Legend:

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

    r3967 r3979  
    4545
    4646  gainfile_="";
     47
     48  proctimeduration_=9.e9;
     49  fgtimeselect_=false;
    4750}
    4851
     
    137140      ka++;
    138141    }   
     142    //-tmproc hh:mm:ss,nseconds
     143    else if (strcmp(arg[ka],"-tmproc")==0) {
     144      int ah=0,am=0;
     145      double as=0, als=0;
     146      sscanf(arg[ka+1],"%d:%d:%lg,%lg",&ah,&am,&as,&als);
     147      fgtimeselect_=true;  proctimeduration_=als; 
     148      proctimestart_.SetHour(ah,am,as);
     149      ka+=2;
     150    }
    139151    else if (strcmp(arg[ka],"-gain")==0) {
    140152      gainfile_=arg[ka+1];
     
    190202       << "                 [-singlechan] [-twochan] [-fftdata] [-rawdata] \n"
    191203       << "                 [-freqfilter] [-gain filename] [-varcut min,max] [-nband nband,first,last] \n"
    192        << "                 [-filldt] [-tspwin wsz,extsz,nfiles] \n"
     204       << "                 [-tmproc hh:mm:ss,nseconds] [-filldt] [-tspwin wsz,extsz,nfiles] \n"
    193205       << "         -in Imin,Imax,Istep InPath FiberList [InPath2 FiberList2 InPath3 FiberList3 ...] \n" << endl;
    194206  if (fgshort) {
     
    218230       << " -varcut min,max : min-max cut on variance \n"
    219231       << " -nband nband,first,last: numbers of freq. bands and first and last bands used for cuts \n"
     232       << " -tmproc hh:mm:ss,nseconds : processing time window definition \n"
    220233       << " -filldt : force data table filling \n"
    221234       << " -freqfilter : force median filtering on the frequencies \n"
     
    238251  bool fgdatafft_in_fits=false;
    239252  bool fgsinglechan_in_fits=false;
    240   int rc = DecodeMiniFitsHeader(flnm,paqsize_, npaqinfile_,fgdatafft_in_fits, fgsinglechan_in_fits);
     253  SOPHYA::TimeStamp tmstart;
     254  int rc = DecodeMiniFitsHeader(flnm,paqsize_, npaqinfile_,fgdatafft_in_fits, fgsinglechan_in_fits,tmstart);
    241255  if (!fgforcesingleortwochan_) fgsinglechannel_=fgsinglechan_in_fits;
    242256  if (!fgforceraworfft_) fgdatafft_=fgdatafft_in_fits;
     257  if (fgtimeselect_) {
     258    int year,month,day;
     259    tmstart.GetDate(year,month,day);
     260    proctimestart_.SetDate(year,month,day);
     261    proctimeend_.Set(proctimestart_.ToDays()+proctimeduration_/86400.);
     262  }
    243263  return rc;
    244264}
     
    252272  cout << " IMin= " << imin_ << " IMax= " << imax_ << " IStep= " << istep_
    253273       << ((rdsamefc_)?" SameFrameCounter read mode":" AllOKPaquets read mode ") << endl;
     274  if (fgtimeselect_) {
     275     cout << " Processing time window, StartTime=" << proctimestart_ << " duration= " << proctimeduration_
     276              << " EndTime=" << proctimeend_ << endl;
     277  }
    254278  cout << " OutPath= " << outpath_ << (fgfitsout_?" force FITS output":" PPF output") << endl;
    255279  cout << " Action=" << action_ << "  NMean=" << nmean_ << " NBloc=" << nbloc_ << endl;
     
    274298/* --Fonction-- */
    275299int BRAnaParam::DecodeMiniFitsHeader(const char* filename, uint_4& paqsz, uint_4& npaq,
    276                                      bool& fgdatafft, bool& fgsinglechannel)
     300                                     bool& fgdatafft, bool& fgsinglechannel, SOPHYA::TimeStamp& tmstart)
    277301{
    278302  cout << " DecodeMiniFitsHeader - Opening file: " << filename << endl;
     
    285309  if (acqmode.substr(0,3)=="fft") fgdatafft=true;
    286310  if (acqmode.find("1c") < acqmode.length()) fgsinglechannel=true;
     311  string fkvs=mff.GetKeyValue("DATEOBS");
     312  if (fkvs.length()>0)  tmstart.Set(fkvs);
     313  fkvs=mff.GetKeyValue("TMSTART");
     314  if (fkvs.length()>0) tmstart.Set(fkvs);
    287315  return 0;
    288316}
  • trunk/AddOn/TAcq/branap.h

    r3967 r3979  
    1313#include <iostream>
    1414
     15#include "timestamp.h"
     16
    1517class BRAnaParam { 
    1618public:
     
    2628
    2729  static int DecodeMiniFitsHeader(const char* filename, uint_4& paqsz, uint_4& npaq,
    28                                   bool& fgdatafft, bool& fgsinglechannel);
     30                                  bool& fgdatafft, bool& fgsinglechannel, SOPHYA::TimeStamp& tmstart);
    2931
    3032  vector<string> dirlist_;
     
    6163
    6264  string gainfile_;     // nom du fichier de gain (reponse spectrale)
     65
     66  // definition fenetre en temps pour le traitement des paquets
     67  SOPHYA::TimeStamp proctimestart_; //  temps de debut de la fenetre
     68  SOPHYA::TimeStamp proctimeend_; //  temps de debut de la fenetre
     69  double proctimeduration_;  // duree en secondes de la fenetre
     70  bool fgtimeselect_;  // vrai -> selection des paquets dans la fenetre en temps 
    6371};
    6472
  • trunk/AddOn/TAcq/brbaseproc.cc

    r3955 r3979  
    9696    cout << "BRBaseProcessor[" << bpnom_ << "," << bpid_ << "]::run() - Starting " << " NFibers="
    9797         << memgr_.NbFibres() << endl; 
     98    if (fgproctimewin_) cout << " BRBaseProcessor...TimeWindow Start=" << tmstart_ << " End=" << tmend_ << endl;
    9899
    99100    size_t paqsz=memgr_.PaqSize();
    100101    size_t procpaqsz=memgr_.ProcPaqSize();
     102
     103    double tstartdays = tmstart_.ToDays();
     104    double tenddays = tmend_.ToDays();
     105
    101106    bool fgrun=true;
    102107    while (fgrun) {
    103108      if (stop_) break;
    104109      if (memgr_.GetRunState() == MemZR_Stopped) break;
    105       int mid = memgr_.FindMemZoneId(mmact_);  // (MemZA_ProcA);
    106       //      Byte* buffg = memgr_.GetMemZone(mid);
     110      mid_ = memgr_.FindMemZoneId(mmact_);  // (MemZA_ProcA);
     111      //      Byte* buffg = memgr_.GetMemZone(mid_);
    107112      //      if (buffg == NULL) {
    108       if (mid < 0) {
     113      if (mid_ < 0) {
    109114        cout << "BRBaseProcessor[" << bpnom_ << "," << bpid_ << "]::run()/ERROR FindMemZoneId("
    110              << (int)mmact_ << ") ->" << mid << ") -> NULL" << endl;
     115             << (int)mmact_ << ") ->" << mid_ << ") -> NULL" << endl;
    111116        setRC(7);      fgrun=false;             
    112117        break; 
    113118      }
    114       cts_=memgr_.GetAuxData(mid)->FillTime();   // get associated date/time (DATEOBS)
     119      cts_=memgr_.GetAuxData(mid_)->FillTime();   // get associated date/time (DATEOBS)
    115120      for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
    116         fbuff_[fib] = memgr_.GetMemZone(mid,fib);
     121        fbuff_[fib] = memgr_.GetMemZone(mid_,fib);
    117122        if (fbuff_[fib] == NULL) { // cela ne devrait pas arriver
    118123          cout << "BRBaseProcessor[" << bpnom_ << "," << bpid_ << "]::run()/ERROR memgr.GetMemZone("
    119                << mid << "," << fib << ") -> NULL" << endl;
     124               << mid_ << "," << fib << ") -> NULL" << endl;
    120125          setRC(9);       fgrun=false;         
    121126          break;
    122127        }
    123         if ((procpaqsz>0)&&((fprocbuff_[fib]=memgr_.GetProcMemZone(mid,fib))==NULL)) {   // cela ne devrait pas arriver non plus
     128        if ((procpaqsz>0)&&((fprocbuff_[fib]=memgr_.GetProcMemZone(mid_,fib))==NULL)) {   // cela ne devrait pas arriver non plus
    124129          cout << "BRBaseProcessor[" << bpnom_ << "," << bpid_ << "]::run()/ERROR memgr.GetProcMemZone("
    125                << mid << "," << fib << ") -> NULL" << endl;
     130               << mid_ << "," << fib << ") -> NULL" << endl;
    126131          setRC(9);       fgrun=false;         
    127132          break;
    128133        }
    129134      }
    130       for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) {   // boucle sur les paquets d'une zone 
    131         fgokallfibers_=true;
    132         for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
    133           vpaq_[fib].Set(fbuff_[fib]+jp*paqsz);
    134           vfgok_[fib]=vpchk_[fib].Check(vpaq_[fib],curfc_[fib]);
    135           if (!vfgok_[fib])  fgokallfibers_=false;
    136           if (procpaqsz>0)    vprocpaq_[fib] = fprocbuff_[fib]+jp*procpaqsz;
    137         }
    138         //--- Traitement
    139         int rcp=0;
    140         if (fgokallfibers_)  {
    141           if (totprocnpaq_==0) {
    142             for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
    143               fcfirst_[fib]=curfc_[fib];
    144               ttfirst_[fib]=vpaq_[fib].TimeTag();
     135
     136      // On ne traite les paquets que si pas de fenetre en temps ou tmstart_ <= FillTime() <= tmend_
     137      double ftmdays = memgr_.GetAuxData(mid_)->FillTime().ToDays();
     138      if ((!fgproctimewin_) || ( (ftmdays<=tenddays)&&(ftmdays>=tstartdays) ) ) {
     139
     140        for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) {   // boucle sur les paquets d'une zone 
     141          fgokallfibers_=true;
     142          for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
     143            vpaq_[fib].Set(fbuff_[fib]+jp*paqsz);
     144            vfgok_[fib]=vpchk_[fib].Check(vpaq_[fib],curfc_[fib]);
     145            if (!vfgok_[fib])  fgokallfibers_=false;
     146            if (procpaqsz>0)    vprocpaq_[fib] = fprocbuff_[fib]+jp*procpaqsz;
     147          }
     148          //--- Traitement
     149          int rcp=0;
     150          if (fgokallfibers_)  {
     151            if (totprocnpaq_==0) {
     152              for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
     153                fcfirst_[fib]=curfc_[fib];
     154                ttfirst_[fib]=vpaq_[fib].TimeTag();
     155              }
    145156            }
     157            rcp=Process();
     158            totprocnpaq_++;
    146159          }
    147           rcp=Process();
    148           totprocnpaq_++;
    149         }
    150         //      if (rcp != 0)   { fgrun=false; break; }
    151       }  // Fin de boucle sur les paquets
    152       memgr_.FreeMemZone(mid, mmsta_);   // (MemZS_ProcA);
     160          //    if (rcp != 0)   { fgrun=false; break; }
     161        }  // Fin de boucle sur les paquets
     162      }  // Fin de test pour fenetre en temps de traitement des paquets
     163 
     164      memgr_.FreeMemZone(mid_, mmsta_);   // (MemZS_ProcA);
    153165    } // Fin de boucle sur les zones a traiter
    154166    //------------------------------------
     
    198210    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)   
    199211      cout << getCurTimeTagSeconds(fib) << "," ;
     212    if (prtlev_<4) return 0;
     213    cout << " ... FileSequenceNumber[0..." << memgr_.NbFibres()-1 << "]=" ;
     214    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)   
     215      cout << memgr_.GetAuxData(mid_)->FileSequenceNumber(fib) << ",";
    200216    cout << endl;
    201217  }
  • trunk/AddOn/TAcq/brbaseproc.h

    r3955 r3979  
    3939  { bpnom_=nom;   bpid_=id;  }
    4040
     41  // Definition de la fentre en temps des paquets a traiter - par defaut, traitement de tous les paquets
     42  // Process() est alors appele pour les paquets des zones MemZoneMgr
     43  // avec TimeStart <= getObsTime() <= TimeEnd
     44  inline void SetProcTimeWindow(SOPHYA::TimeStamp tmstart, SOPHYA::TimeStamp tmend)
     45  {  tmstart_=tmstart; tmend_=tmend; fgproctimewin_=true; }
     46  // Annulation de la definition de la fenetre de traitement en temps
     47  inline void ClearProcTimeWindow()
     48  {  fgproctimewin_=false; }
     49
    4150  // get Observation Time ( obtained from MemZoneMgr )
    4251  inline SOPHYA::TimeStamp& getObsTime()  { return cts_; }
     
    6574  MemZaction mmact_;    // Definition de l'action sur les paquets (defaut=MemZA_ProcA)
    6675  MemZStatus mmsta_;    // Statut associe a mmact_ (defaut=MemZS_ProcA)
     76  int mid_;  // Identificateur zone memoire  courant
    6777  bool stop_;
    6878  vector<Byte*> fbuff_;      // Vecteur de pointeur de zone memoire pour chaque fibre
     
    8393  int bpid_;        // numero d'identificateur
    8494
     95  SOPHYA::TimeStamp tmstart_, tmend_;  // definition de la fenetre en temps pour appel de Process()
     96  bool fgproctimewin_;   // false -> pas de fenetre en temps, Process() appele pour tous les paquets
     97
    8598  int prtlev_;    // print level
    8699  uint_8 prtmodulo_;   // print periodicity (modulo)
  • trunk/AddOn/TAcq/brfitsrd.cc

    r3978 r3979  
    275275  for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)
    276276    mmbufib_[fib]=memgr_.GetMemZone(mid_,fib);
    277   // Definition temps pour la zone a remplir
     277  // Definition temps pour la zone a remplir et numeros de sequence des fichiers en cours de lecture
    278278  memgr_.GetAuxData(mid_)->FillTime().Set(ctmstart_.ToDays()+cpaqdeltatime_*(double)vfpos_[0]/86400.);
     279  memgr_.GetAuxData(mid_)->FileSequenceNumVec()=vfilenum_;
    279280  return false;
    280281}
  • trunk/AddOn/TAcq/racqumem.cc

    r3958 r3979  
    3939    memzones.push_back(new Byte[mzsz] );
    4040    states.push_back(st);
    41     auxdatap.push_back(new RAcqMZAuxData );
     41    auxdatap.push_back( new RAcqMZAuxData((size_t)NbFibres()) );
    4242    if (procmzsz > 0)  procmemzones.push_back(new Byte[procmzsz] );
    4343  }
  • trunk/AddOn/TAcq/racqumem.h

    r3955 r3979  
    7171class RAcqMZAuxData {
    7272public:
    73   RAcqMZAuxData() { }
     73  RAcqMZAuxData(size_t nbfib)
     74    : fileseqnum_(nbfib) , badseqnum_(-1)   {  }
    7475  inline SOPHYA::TimeStamp& FillTime() { return filltime_; }
    75 
     76  inline std::vector<uint_4>& FileSequenceNumVec() { return fileseqnum_; }
     77  uint_4& FileSequenceNumber(size_t i=0) {
     78    if (i<fileseqnum_.size())  return fileseqnum_[i];
     79    else return badseqnum_;
     80  }
    7681  SOPHYA::TimeStamp filltime_;
     82  std::vector<uint_4> fileseqnum_;
     83  uint_4 badseqnum_;
    7784};
    7885
Note: See TracChangeset for help on using the changeset viewer.