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

gestion des flags

File:
1 edited

Legend:

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