Changeset 1527 in Sophya


Ignore:
Timestamp:
Jun 14, 2001, 3:39:07 PM (24 years ago)
Author:
aubourg
Message:

gestion des flags

Location:
trunk/ArchTOIPipe
Files:
2 added
4 edited

Legend:

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

    r1480 r1527  
    7171  fits_lock();
    7272  // Dans cette version, on s'attend a ce que la premiere colonne soit le samplenum
     73  int itoi=-1;
    7374  for (int i=1; i<ncols; i++) {
    7475    char templt[10];
     
    7879    fits_get_colname(fptr, CASESEN, templt, colname, &colnum, &fstatus);
    7980    cout << "FITSTOIReader col " << colname << endl;
    80     declareOutput(colname);
     81    if (!strncmp(colname, "fg_", 3)) {
     82      colsinput[itoi].second=true;
     83    } else {
     84      declareOutput(colname);
     85      itoi++;
     86      colsinput[itoi] = pair<int,bool>(i,false);
     87    }
    8188  }
    8289  fits_unlock();
     
    130137    if (sn < mgr->getRequestedBegin()) continue;
    131138    // if (sn < mgr->getRequestedBegin()+10) cout << "rdr out " << sn << endl;
    132     for (int j=1; j<=ncols; j++) {
    133       if ( !checkOutputTOIIndex(j-1) )  continue;  // Reza - Si TOI non connecte
     139    for (int k=0; k<getNOut(); k++) {
     140      int j = colsinput[k].first;
     141      if ( !checkOutputTOIIndex(k) )  continue;  // Reza - Si TOI non connecte
    134142      fits_lock();
    135143      fits_read_col_dbl(fptr,j+1,i+1,1,1,0,&y,&anyNul,&fstatus);
     144      long flg = 0;
     145      if (colsinput[k].second) {
     146        fits_read_col_lng(fptr,j+2,i+1,1,1,0,&flg,&anyNul,&fstatus);
     147      }
    136148      fits_unlock();
    137       putData(j-1, sn, y);
     149      putData(k, sn, y, flg);
    138150    }
    139151  }
  • trunk/ArchTOIPipe/Kernel/fitstoirdr.h

    r1480 r1527  
    77#include <string>
    88#include <vector>
     9#include <map>
    910#include "fitsio.h"
    1011
     
    3435  int       firstSn; // current file
    3536
    36   int       ncols;    
     37  int       ncols;   // including flags. getNOut() is # of tois.
    3738  int       snBegin; // first file
    3839  int       snEnd;   // last file
    3940 
    4041  vector<string> allfn;
     42  map<int,pair<int, bool> > colsinput; // iTOI -> (colonne, hasflag)
     43  // le flag est alors en colonne+1
    4144
    4245};
  • trunk/ArchTOIPipe/Kernel/fitstoiwtr.cc

    r1501 r1527  
    1010  fname = fn;
    1111  fstatus = 0;
    12   outFlags = false;
     12  nCols = 1;
    1313
    1414  // Open file
     
    2323}
    2424
    25 void FITSTOIWriter::setOutFlags(bool yn) {
    26   outFlags = yn;
    27 }
    2825
    29 void FITSTOIWriter::addInput(string name, TOI* toi) {
     26void FITSTOIWriter::addInput(string name, TOI* toi, bool withFlag) {
    3027  declareInput(name);
     28  int iTOI = fwinputs.size();
    3129  fwinputs.push_back(toi);
     30  colsinput[iTOI] = pair<int,bool>(nCols, withFlag);
     31  nCols++;
     32  if (withFlag) nCols++;
    3233}
    3334
     
    5051
    5152  int ndata = inIx.size();
    52   int ncols = inIx.size() * (outFlags ? 2 : 1) + 1;
     53  //int ncols = inIx.size() * (outFlags ? 2 : 1) + 1;
    5354
    54   char** colnames = new (char*[ncols]);
    55   char** coltypes = new (char*[ncols]);
    56   char** colunits = new (char*[ncols]);
     55  char** colnames = new (char*[nCols]);
     56  char** coltypes = new (char*[nCols]);
     57  char** colunits = new (char*[nCols]);
    5758
    5859  colnames[0] = "sampleNum";
     
    6364       << fname << endl;
    6465
    65   string * coln = new string[ncols];
     66  string * coln = new string[nCols];
    6667  for (map<string, int>::iterator ii = inIx.begin(); ii != inIx.end(); ii++) {
    67     int j = (*ii).second;
    68     if (outFlags) j += j;
    69     int ck = j+1;
     68    int jTOI = (*ii).second;
     69    pair<int,bool> p = colsinput[jTOI];
     70    int ck = p.first;
    7071    coln[ck] = (*ii).first;
    7172    colnames[ck] = const_cast<char*>(coln[ck].c_str()); 
     
    7374    coltypes[ck] = "1D";
    7475    colunits[ck] = "double";
    75     if (outFlags) {
     76    if (p.second) {
    7677      ck++;
    7778      coln[ck] = "fg_" + coln[ck-1];
    7879      colnames[ck] = const_cast<char*>(coln[ck].c_str()); 
    7980      cout << " Column[" << ck << "] -Flag- Name=" << coln[ck] << endl;
    80       coltypes[ck] = "1I";
     81      coltypes[ck] = "1J";
    8182      colunits[ck] = "Int_8Flag";
    8283    }
     
    8485
    8586  fits_lock();
    86   fits_create_tbl(fptr, BINARY_TBL, 0, ncols, colnames, coltypes, colunits, NULL, &fstatus);
     87  fits_create_tbl(fptr, BINARY_TBL, 0, nCols, colnames, coltypes, colunits, NULL, &fstatus);
    8788  fits_write_date(fptr, &fstatus);
    8889  fits_unlock();
     
    102103
    103104  double* tabdata = new double[ndata];
    104   int* tabflag = new int[ndata]; // ? pas int_8 ?? $CHECK$ - Reza
     105  int_8* tabflag = new int_8[ndata];
     106  long* tabflagl = (long*) tabflag; // il faut int_8 == long,
     107                                    // c'est long long dans sophya
    105108  bool* tabck = new bool[ndata];
    106109  int i;
     
    121124          getData(i,sn, out_val, out_flg);
    122125          tabdata[i] = out_val;
    123           if (outFlags) tabflag[i] = out_flg;
     126          tabflag[i] = out_flg;
    124127        }
    125128      }
     
    131134     
    132135      for (i=0; i<ndata; i++) {
    133         if (outFlags) {
    134           fits_write_col_dbl(fptr, 2*i+2, fitsLine, 1, 1, tabdata+i, &fstatus);
    135           fits_write_col_int(fptr, 2*i+3, fitsLine, 1, 1, tabflag+i, &fstatus);
    136         } else {
    137           fits_write_col_dbl(fptr, i+2, fitsLine, 1, 1, tabdata+i, &fstatus);
    138         }
     136        pair<int,bool> p = colsinput[i];
     137        fits_write_col_dbl(fptr, p.first+1, fitsLine, 1, 1, tabdata+i, &fstatus);
     138        if (p.second) {
     139          fits_write_col_lng(fptr, p.first+2, fitsLine, 1, 1, tabflagl+i, &fstatus);
     140        }
    139141        if (fstatus != 0) {
    140142          cerr << "fitstoiwtr error sn = " << sn << " i = "<< i << endl;
  • trunk/ArchTOIPipe/Kernel/fitstoiwtr.h

    r1439 r1527  
    1818  virtual void afterinit();
    1919
    20   virtual void  addInput(string name, TOI* toi);
    21 
    22   virtual void  setOutFlags(bool yn = true);
     20  virtual void  addInput(string name, TOI* toi, bool withFlag=false);
    2321
    2422  virtual void  run(); 
     
    2927  int fstatus;
    3028  vector<TOI*> fwinputs;
    31   bool outFlags;
     29  int nCols;
     30  map<int,pair<int, bool> > colsinput; // iTOI -> (colonne, hasflag)
     31  // le flag est alors en colonne+1
    3232};
    3333
Note: See TracChangeset for help on using the changeset viewer.