Changeset 1527 in Sophya
- Timestamp:
- Jun 14, 2001, 3:39:07 PM (24 years ago)
- Location:
- trunk/ArchTOIPipe
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/Kernel/fitstoirdr.cc
r1480 r1527 71 71 fits_lock(); 72 72 // Dans cette version, on s'attend a ce que la premiere colonne soit le samplenum 73 int itoi=-1; 73 74 for (int i=1; i<ncols; i++) { 74 75 char templt[10]; … … 78 79 fits_get_colname(fptr, CASESEN, templt, colname, &colnum, &fstatus); 79 80 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 } 81 88 } 82 89 fits_unlock(); … … 130 137 if (sn < mgr->getRequestedBegin()) continue; 131 138 // 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 134 142 fits_lock(); 135 143 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 } 136 148 fits_unlock(); 137 putData( j-1, sn, y);149 putData(k, sn, y, flg); 138 150 } 139 151 } -
trunk/ArchTOIPipe/Kernel/fitstoirdr.h
r1480 r1527 7 7 #include <string> 8 8 #include <vector> 9 #include <map> 9 10 #include "fitsio.h" 10 11 … … 34 35 int firstSn; // current file 35 36 36 int ncols; 37 int ncols; // including flags. getNOut() is # of tois. 37 38 int snBegin; // first file 38 39 int snEnd; // last file 39 40 40 41 vector<string> allfn; 42 map<int,pair<int, bool> > colsinput; // iTOI -> (colonne, hasflag) 43 // le flag est alors en colonne+1 41 44 42 45 }; -
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; -
trunk/ArchTOIPipe/Kernel/fitstoiwtr.h
r1439 r1527 18 18 virtual void afterinit(); 19 19 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); 23 21 24 22 virtual void run(); … … 29 27 int fstatus; 30 28 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 32 32 }; 33 33
Note:
See TracChangeset
for help on using the changeset viewer.