- Timestamp:
- Oct 22, 2001, 11:59:31 AM (24 years ago)
- Location:
- trunk/ArchTOIPipe/Kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/Kernel/fitstoirdr.cc
r1716 r1717 4 4 5 5 6 FITSTOIReader::FITSTOIReader(string fn ) {6 FITSTOIReader::FITSTOIReader(string fn,int buff_sz) { 7 7 fname = fn; 8 8 allfn.push_back(fn); 9 cout << "FITSTOIReader::FITSTOIReader" << endl; 10 cout << "FITSTOIReader::inited " << inited << endl; 9 Buff_Sz = (buff_sz>0) ? buff_sz: 1000; 10 cout<<"FITSTOIReader::FITSTOIReader"<<endl; 11 cout<<"FITSTOIReader::inited "<<inited<<" bsz="<<Buff_Sz<<endl; 11 12 name = "rdr"; 12 13 fptr = NULL; … … 42 43 fits_report_error(stderr, fstatus); 43 44 fits_unlock(); 44 exit (-1); 45 exit (-1); // $CHECK EA: normallement ca devrait etre un "throw" 45 46 } 46 47 … … 116 117 for (vector<string>::iterator i=allfn.begin(); i!=allfn.end(); i++) { 117 118 openFile(*i); 118 run1(); 119 //run1(); 120 run2(); 119 121 } 120 122 } … … 128 130 << firstSn << endl; 129 131 130 double* tabdata = new double[getNOut()]; 131 uint_8* tabflag = new uint_8[getNOut()]; 132 133 for (int i=0; i<nrows; i++) { 132 double* tabdata = new double[getNOut()]; // $CHECK EA: pas terrible le new never deleted 133 uint_8* tabflag = new uint_8[getNOut()]; // $CHECK EA: pas terrible le new never deleted 134 135 for (int i=0; i<nrows; i++) { // $CHECK EA: vaut mieux mettre long que int 134 136 int anyNul; 135 137 double y; … … 137 139 fits_read_col_dbl(fptr,1,i+1,1,1,0,&y,&anyNul,&fstatus); 138 140 //fits_unlock(); 139 int sn = (int) (y+.1); 141 int sn = (int) (y+.1); // $CHECK EA: vaut mieux mettre long que int SURTOUT POUR SNUM 140 142 TOIManager* mgr = TOIManager::getManager(); 141 143 if (sn > mgr->getRequestedEnd()) {fits_unlock(); break;} … … 171 173 cout << "reader done reading... " << pthread_self() << endl; 172 174 } 175 176 void FITSTOIReader::run2() 177 // ---- Version bufferisee (Christophe 20/10/2001) 178 { 179 int ncols = outIx.size(); 180 cout<<"reader reading... NRows="<<nrows<<" firstSn= " <<firstSn<<endl; 181 182 //////// Prepare buffer, allocate memory 183 double *samplenum = new double[Buff_Sz]; 184 vector<double*> colval; 185 vector<long*> colflg; 186 for(int k=0; k<getNOut(); k++) { 187 colval.push_back(NULL); 188 colflg.push_back(NULL); 189 if(!checkOutputTOIIndex(k)) continue; 190 colval[k] = new double[Buff_Sz]; 191 if(colsinput[k].second) colflg[k] = new long[Buff_Sz]; 192 } 193 194 //////// Read data and put into pipe 195 long ideb=-1,ifin=-1; 196 for(long i=0; i<nrows; i++) { 197 198 // faut-il lire dans le fichier fits ? 199 if(i<ideb || i>ifin) { 200 ideb = i; 201 ifin = ideb+Buff_Sz-1; 202 if(ifin>=nrows) ifin=nrows-1; 203 long n = ifin-ideb+1; 204 int anyNul; 205 fits_lock(); 206 fits_read_col_dbl(fptr,1,ideb+1,1,n,0,samplenum,&anyNul,&fstatus); 207 for(int k=0; k<getNOut(); k++) { 208 if(colval[k]==NULL) continue; 209 int j = colsinput[k].first; 210 fits_read_col_dbl(fptr,j+1,ideb+1,1,n,0,colval[k],&anyNul,&fstatus); 211 if(colflg[k]==NULL) continue; 212 fits_read_col_lng(fptr,j+2,ideb+1,1,n,0,colflg[k],&anyNul,&fstatus); 213 } 214 if(fstatus!=0) { 215 fits_report_error(stderr,fstatus); 216 // $CHECK EA: attention j'ai mis un throw OK avec ca ? 217 throw RangeCheckError("FITSTOIReader::run2: Error Reading Fits file\n"); 218 } 219 fits_unlock(); 220 } 221 222 long ip = i-ideb; // pointeurs dans les buffers 223 long sn = (long) (samplenum[ip]+.1); 224 TOIManager* mgr = TOIManager::getManager(); 225 if(sn > mgr->getRequestedEnd()) break; 226 if(sn < mgr->getRequestedBegin()) continue; 227 for(int k=0; k<getNOut(); k++) { 228 if(colval[k]==NULL) continue; 229 uint_8 flg = (colflg[k]==NULL)? 0: colflg[k][ip]; 230 putData(k,sn,colval[k][ip],flg); 231 } 232 totnscount++; 233 } 234 235 //////// des-allocate buffers 236 delete [] samplenum; 237 for(int k=0; k<getNOut(); k++) { 238 if(colval[k]!=NULL) delete [] colval[k]; 239 if(colflg[k]!=NULL) delete [] colflg[k]; 240 } 241 colval.resize(0); colflg.resize(0); 242 243 cout << "reader done reading... " << pthread_self() << endl; 244 } -
trunk/ArchTOIPipe/Kernel/fitstoirdr.h
r1629 r1717 13 13 class FITSTOIReader : public TOIProcessor { 14 14 public: 15 FITSTOIReader(string fn );15 FITSTOIReader(string fn,int buff_sz=1000); 16 16 ~FITSTOIReader(); 17 17 … … 28 28 29 29 virtual void run1(); 30 virtual void run2(); 30 31 virtual void openFile(string fn); 31 32 … … 36 37 long nrows; // current file 37 38 int firstSn; // current file 39 int Buff_Sz; // buffer size 38 40 39 41 int ncols; // including flags. getNOut() is # of tois. … … 49 51 }; 50 52 51 52 53 #endif
Note:
See TracChangeset
for help on using the changeset viewer.