Changeset 1439 in Sophya


Ignore:
Timestamp:
Mar 13, 2001, 7:23:14 PM (25 years ago)
Author:
ansari
Message:

Correction bugs, protections, ameliorations - Reza 13/3/2001

Location:
trunk/ArchTOIPipe
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ArchTOIPipe/Kernel/fitstoiwtr.cc

    r1437 r1439  
    3232}
    3333
    34 
    35 void FITSTOIWriter::run() {
    36   cout << "fitstoiwriter running" << endl;
    37   // init done here
    38   delete[] inTOIs;
     34void FITSTOIWriter::afterinit()
     35{
     36  if (inTOIs) delete[] inTOIs;
    3937  inTOIs = new (TOI*[fwinputs.size()]);
    4038
     
    4240    inTOIs[i] = fwinputs[i];
    4341  }
     42 
     43}
     44
     45void FITSTOIWriter::run() {
     46  cout << "fitstoiwriter running" << endl;
     47  // init done here
     48  afterinit();
     49  inited=true;
    4450
    4551  int ndata = inIx.size();
     
    5460  colunits[0] = "integer";
    5561
     62  cout << " FITSTOIWriter::run() - Creating output FITS file: "
     63       << name << endl;
     64
     65  vector<string> coln;
     66  int ck=0;
    5667  for (map<string, int>::iterator ii = inIx.begin(); ii != inIx.end(); ii++) {
    5768    int j = (*ii).second;
    58     string n = (*ii).first;
     69    coln.push_back((*ii).first);
    5970    if (outFlags) j += j;
    60     colnames[j+1] = const_cast<char*>(n.c_str());
     71    colnames[j+1] = const_cast<char*>(coln[ck].c_str()); 
     72    cout << " Column[" << j+1 << "] Name=" << coln[ck] << endl;
     73    ck++;
    6174    coltypes[j+1] = "1D";
    62     colunits[j+1] = "?";
     75    colunits[j+1] = "double";
    6376    if (outFlags) {
    64       colnames[j+2] = const_cast<char*>((n+"_flg").c_str());
     77      coln.push_back("fg_" + coln[ck-1]);
     78      colnames[j+2] = const_cast<char*>(coln[ck].c_str()); 
     79      cout << " Column[" << j+1 << "] -Flag- Name=" << coln[ck] << endl;
     80      ck++;
    6581      coltypes[j+2] = "1D";
    66       colunits[j+2] = "?";
     82      colunits[j+2] = "IntFlag";
    6783    }
    6884  }
  • trunk/ArchTOIPipe/Kernel/fitstoiwtr.h

    r1370 r1439  
    1616  ~FITSTOIWriter();
    1717 
     18  virtual void afterinit();
     19
    1820  virtual void  addInput(string name, TOI* toi);
    1921
  • trunk/ArchTOIPipe/Kernel/toiprocessor.cc

    r1437 r1439  
    4747  inTOIs = new (TOI*[inIx.size()]);
    4848  for(i=0; i<inIx.size(); i++)
    49     inTOIs[i] = NULL;
     49    inTOIs[i] = NULL;     // Protection-Initialisation - Reza  11/3/2001
    5050  outTOIs = new (TOI*[outIx.size()]);
    5151  for(i=0; i<outIx.size(); i++)
    52     outTOIs[i] = NULL;
     52    outTOIs[i] = NULL;    // Protection-Initialisation - Reza  11/3/2001
    5353}
    5454
     
    8080  for (int i=0; i<nIn; i++) {
    8181    TOI* toi = inTOIs[i];
     82    if (toi == NULL) continue;  // Protection - Reza  13/3/2001
    8283    int x = toi->getMinSn();
    8384    if (x > minIn) minIn = x;
     
    9192  for (int i=0; i<nIn; i++) {
    9293    TOI* toi = inTOIs[i];
     94    if (toi == NULL) continue;  // Protection - Reza  13/3/2001
    9395    int x = toi->getMaxSn();
    9496    if (x < maxIn) maxIn = x;
     
    163165void TOIProcessor::PrintStatus(ostream & os)
    164166{
     167  chkinit();
    165168  os << " TOIProcessor::PrintStatus() - Name= " << name
    166169     << " MinIn=" << getMinIn() << " MaxIn=" << getMaxIn() << endl;
     
    191194  if (i == inIx.end()) throw NotFoundExc("TOIProcessor::addInput "+
    192195                                         name+" not declared");
    193   inTOIs[(*i).second] = toi;
     196  inTOIs[(*i).second] = toi;
     197  toi->addConsumer(this);   // $CHECK$  Reza 13/3/2001
    194198}
    195199
  • trunk/ArchTOIPipe/ProcWSophya/rztoi.cc

    r1438 r1439  
    4545    if (outppf.length() > 0)    fgppf = true;
    4646   
    47     Vector vin, vout;
     47    Vector vin, vout, vsave(_width2);
    4848    TVector< complex<r_8> > vfft;
     49    double vlast = 0.;
    4950
    5051    for (int k=0; k<_nmax; k++) {
    51       istart = snb + k*_width1;
    52       //      if (k>0)  istart -= _width2;
     52      //      istart = snb + k*_width1;
     53      istart = snb + k*_width1 - k*_width2;
    5354      iend = istart +_width1;
    54       cout << " RzTOIProc::run() - Processing bloc k= " << k
     55      cout << "---RzTOIProc::run() - Processing bloc k= " << k
    5556           << " istart= " << istart << " iend= " << iend << endl;
    5657      if (iend > sne) {
     
    6061      //      Vector vin = getData(0, istart, iend);
    6162      vin.ReSize(_width1);
    62       jj = 0;
    63       for(ii=istart; ii<iend; ii++) 
    64         vin(jj++) = getData(0, ii);
    65      
    66       cout << " End of getData() for bloc " << k << endl;
     63      if (k == 0) {
     64        jj = 0;
     65        for(ii=istart; ii<iend; ii++) 
     66          vin(jj++) = getData(0, ii);
     67      }
     68      else {
     69        vin(Range(0,-1,_width2)) = vsave;
     70        jj = _width2;
     71        for(ii=istart+_width2; ii<iend; ii++) 
     72          vin(jj++) = getData(0, ii);
     73      }
     74
     75      vsave = vin(Range(_width1-_width2, -1,_width2));
     76      cout << "> End of getData() for bloc " << k << endl;
    6777
    6878      vout.ReSize(vin.Size());
    69       double vlast = 0.;
     79      //      cout << " DBG : Bloc[" << k << "] FirstSN=" << istart
     80      //           << " LastSN= " << istart+vout.Size()-_width2-1 << endl;
    7081      for(int i=0; i<vout.Size()-_width2; i++) {
    7182        vout(i) = vin(Range(i,-1,_width2)).Sum()/(r_8)_width2;
     
    7687      for(int i=vout.Size()-_width2; i<vout.Size(); i++) {
    7788        vout(i) = vlast;
    78         putData(0, i+istart, vout(i));
     89        //      putData(0, i+istart, vout(i));
    7990      }
    8091
    81       cout << " End of putData() for bloc " << k << " Mean vout= "
    82            << vout.Sum()/vout.Size() << endl;
     92      cout << ">> End of putData() for bloc[" << k << "] FirstSN="
     93           << istart << " LastSN= " << istart+vout.Size()-_width2-1
     94           << " Mean vout= " << vout.Sum()/vout.Size() << endl;
    8395
    8496      vin -= vout;
     
    121133    }
    122134
    123     cout << " Filling -9999 : putData(0, ii, -9999.) ii: "
     135    cout << " Filling with flag!=0  : putData(0, ii, flag) ii: "
    124136         << iend << " .. " << sne << endl;
     137    for(ii=iend-_width2; ii<iend; ii++) {
     138      putData(0, ii, vlast, 1);
     139    }
     140
    125141    double xxx;
    126142    for(ii=iend; ii<sne; ii++) {
     
    129145             << endl;
    130146      xxx=getData(0,ii);
    131       putData(0,ii,xxx-9999.);
     147      putData(0,ii,xxx,2);
    132148    }
    133149
  • trunk/ArchTOIPipe/TestPipes/tstrztoi.cc

    r1437 r1439  
    11#include <unistd.h>
     2#include <stdexcept>
    23#include "toi.h"
    34#include "toiprocessor.h"
     
    105106    //    FITSTOIWriter w("/data/Archeops/rz.fits");
    106107    FITSTOIWriter w(outfile);
    107     w.setOutFlags(true);
    108108    cout << "fits writer created" << endl;
    109109
    110110
    111111    char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"};
     112    char * toiname[5] = {"MJD", "UTC","bolo11","magneto","pivot"};
    112113    TOI* toitab[5];
    113114    TOI* toi2;
     
    116117      cout << " Using TOIRegularWindow TOI's ... " << endl;
    117118      for(kk=0; kk<5; kk++) {
    118         toitab[kk] = new TOIRegularWindow((string)"t_"+colname[kk]);
     119        toitab[kk] = new TOIRegularWindow(toiname[kk]);
    119120      }
    120121      toi2 = new TOIRegularWindow("t2");
     
    123124      cout << " Using TOISeqBuffered TOI's ... " << endl;
    124125      for(kk=0; kk<5; kk++) {
    125         TOISeqBuffered * toisb = new TOISeqBuffered((string)"t_"+colname[kk], w1);
     126        TOISeqBuffered * toisb = new TOISeqBuffered(toiname[kk], w1);
    126127        toitab[kk] = toisb;
    127128        if (fgdbg) toisb->setDebugLevel(1);
     
    163164
    164165
    165     w.addInput("bolo_filtered", toi2);
     166    w.setOutFlags(true);
     167    w.addInput("bolodrift", toi2);
     168
     169    cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
     170    r.PrintStatus(cout); 
     171    cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
     172    w.PrintStatus(cout); 
    166173
    167174    PrtTim("starting threads");
     
    170177    else rzp.start();
    171178    w.start();
    172 
    173     r.PrintStatus(cout); 
    174179   
    175     for(int jj=0; jj<3; jj++) {
    176       sleep(2);
    177       cout << *toi;
    178     }
     180    //    for(int jj=0; jj<3; jj++) {
     181    //      sleep(2);
     182    //      cout << *toi;
     183    //    }
    179184
    180185    mgr->joinAll();
    181186    PrtTim("End threads");
     187
     188    //    cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
     189    //    r.PrintStatus(cout); 
     190    //    cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
     191    //    w.PrintStatus(cout); 
     192
    182193    cout << " ------ toi and toi2 Status information ------- " << endl;
    183194    cout << *toi;
     
    185196  }
    186197  catch (PThrowable & exc) {
    187     cerr << "rztsttoi: Catched Exception \n" << (string)typeid(exc).name()
     198    cerr << "\nrztsttoi: Catched Exception \n" << (string)typeid(exc).name()
    188199         << " - Msg= " << exc.Msg() << endl;
    189200  }
     201  catch (const std::exception & sex) {
     202    cerr << "\nrztsttoi: Catched std::exception \n"
     203         << (string)typeid(sex).name() << endl;
     204  }
    190205  catch (...) {
    191     cerr << "rztsttoi: some other exception was caught ! " << endl;
     206    cerr << "\nrztsttoi: some other exception was caught ! " << endl;
    192207  }
    193208
Note: See TracChangeset for help on using the changeset viewer.