Changeset 1527 in Sophya for trunk/ArchTOIPipe/Kernel/fitstoiwtr.cc
- Timestamp:
- Jun 14, 2001, 3:39:07 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/Kernel/fitstoiwtr.cc
r1501 r1527 10 10 fname = fn; 11 11 fstatus = 0; 12 outFlags = false;12 nCols = 1; 13 13 14 14 // Open file … … 23 23 } 24 24 25 void FITSTOIWriter::setOutFlags(bool yn) {26 outFlags = yn;27 }28 25 29 void FITSTOIWriter::addInput(string name, TOI* toi ) {26 void FITSTOIWriter::addInput(string name, TOI* toi, bool withFlag) { 30 27 declareInput(name); 28 int iTOI = fwinputs.size(); 31 29 fwinputs.push_back(toi); 30 colsinput[iTOI] = pair<int,bool>(nCols, withFlag); 31 nCols++; 32 if (withFlag) nCols++; 32 33 } 33 34 … … 50 51 51 52 int ndata = inIx.size(); 52 int ncols = inIx.size() * (outFlags ? 2 : 1) + 1;53 //int ncols = inIx.size() * (outFlags ? 2 : 1) + 1; 53 54 54 char** colnames = new (char*[n cols]);55 char** coltypes = new (char*[n cols]);56 char** colunits = new (char*[n cols]);55 char** colnames = new (char*[nCols]); 56 char** coltypes = new (char*[nCols]); 57 char** colunits = new (char*[nCols]); 57 58 58 59 colnames[0] = "sampleNum"; … … 63 64 << fname << endl; 64 65 65 string * coln = new string[n cols];66 string * coln = new string[nCols]; 66 67 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; 70 71 coln[ck] = (*ii).first; 71 72 colnames[ck] = const_cast<char*>(coln[ck].c_str()); … … 73 74 coltypes[ck] = "1D"; 74 75 colunits[ck] = "double"; 75 if ( outFlags) {76 if (p.second) { 76 77 ck++; 77 78 coln[ck] = "fg_" + coln[ck-1]; 78 79 colnames[ck] = const_cast<char*>(coln[ck].c_str()); 79 80 cout << " Column[" << ck << "] -Flag- Name=" << coln[ck] << endl; 80 coltypes[ck] = "1 I";81 coltypes[ck] = "1J"; 81 82 colunits[ck] = "Int_8Flag"; 82 83 } … … 84 85 85 86 fits_lock(); 86 fits_create_tbl(fptr, BINARY_TBL, 0, n cols, colnames, coltypes, colunits, NULL, &fstatus);87 fits_create_tbl(fptr, BINARY_TBL, 0, nCols, colnames, coltypes, colunits, NULL, &fstatus); 87 88 fits_write_date(fptr, &fstatus); 88 89 fits_unlock(); … … 102 103 103 104 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 105 108 bool* tabck = new bool[ndata]; 106 109 int i; … … 121 124 getData(i,sn, out_val, out_flg); 122 125 tabdata[i] = out_val; 123 if (outFlags)tabflag[i] = out_flg;126 tabflag[i] = out_flg; 124 127 } 125 128 } … … 131 134 132 135 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 } 139 141 if (fstatus != 0) { 140 142 cerr << "fitstoiwtr error sn = " << sn << " i = "<< i << endl;
Note:
See TracChangeset
for help on using the changeset viewer.