Changeset 1136 in Sophya for trunk/SophyaExt
- Timestamp:
- Aug 24, 2000, 12:18:02 PM (25 years ago)
- Location:
- trunk/SophyaExt/FitsIOServer
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fitsbntbllinereader.cc
r1048 r1136 20 20 21 21 // FitsFile* fn=ReadFInit(inputfile,hdunum); 22 ReadFInit(inputfile,hdunum); 23 22 // ReadFInit(inputfile,hdunum); 23 inFits_ = new FitsInFile (inputfile); 24 inFits_->ReadFInit(hdunum); 24 25 25 26 // if (!fn->IsFitsTable()) 26 if (! IsFitsTable())27 if (!inFits_->IsFitsTable()) 27 28 { 28 29 throw PException("FITS_BntblLineReader: the fits file seems not to be a bintable nor ASCII table"); … … 32 33 int nbcols, nbentries; 33 34 // nbcols = fn->NbColsFromFits(); 34 nbcols = NbColsFromFits();35 nbcols = inFits_->NbColsFromFits(); 35 36 nbentries = 0; 36 37 int k; 37 38 // for (k=0; k<nbcols; k++) nbentries=max( nbentries, fn->NentriesFromFits(k) ); 38 for (k=0; k<nbcols; k++) nbentries=max( nbentries, NentriesFromFits(k) );39 for (k=0; k<nbcols; k++) nbentries=max( nbentries, inFits_->NentriesFromFits(k) ); 39 40 40 41 // … … 53 54 { 54 55 // char ss= fn->ColTypeFromFits(k); 55 char ss= ColTypeFromFits(k);56 char ss= inFits_->ColTypeFromFits(k); 56 57 if (ss == 'D') DfitsCol.push_back(k); 57 58 else if (ss == 'E') FfitsCol.push_back(k); … … 69 70 ColName_[compt] = new char[LONNOM+1]; 70 71 // strncpy(ColName_[compt], fn->ColNameFromFits(DfitsCol[k]).c_str(), LONNOM); 71 strncpy(ColName_[compt], ColNameFromFits(DfitsCol[k]).c_str(), LONNOM);72 strncpy(ColName_[compt], inFits_->ColNameFromFits(DfitsCol[k]).c_str(), LONNOM); 72 73 ColName_[compt++][ LONNOM] = '\0'; 73 74 } … … 76 77 ColName_[compt] = new char[LONNOM+1]; 77 78 // strncpy(ColName_[compt], fn->ColNameFromFits(FfitsCol[k]).c_str(), LONNOM); 78 strncpy(ColName_[compt], ColNameFromFits(FfitsCol[k]).c_str(), LONNOM);79 strncpy(ColName_[compt], inFits_->ColNameFromFits(FfitsCol[k]).c_str(), LONNOM); 79 80 ColName_[compt++][ LONNOM] = '\0'; 80 81 } … … 83 84 ColName_[compt] = new char[LONNOM+1]; 84 85 // strncpy(ColName_[compt], fn->ColNameFromFits(IfitsCol[k]).c_str(), LONNOM); 85 strncpy(ColName_[compt], ColNameFromFits(IfitsCol[k]).c_str(), LONNOM);86 strncpy(ColName_[compt], inFits_->ColNameFromFits(IfitsCol[k]).c_str(), LONNOM); 86 87 ColName_[compt++][ LONNOM] = '\0'; 87 88 } … … 90 91 ColName_[compt] = new char[LONNOM+1]; 91 92 // strncpy(ColName_[compt], fn->ColNameFromFits(SfitsCol[k]).c_str(), LONNOM); 92 strncpy(ColName_[compt], ColNameFromFits(SfitsCol[k]).c_str(), LONNOM);93 strncpy(ColName_[compt], inFits_->ColNameFromFits(SfitsCol[k]).c_str(), LONNOM); 93 94 ColName_[compt++][LONNOM] = '\0'; 94 95 } … … 115 116 taille_des_chaines_ = 0; 116 117 // for (k=0; k< ccount_; k++) taille_des_chaines_ = max( taille_des_chaines_, fn->ColStringLengthFromFits(SfitsCol[k]) ); 117 for (k=0; k< ccount_; k++) taille_des_chaines_ = max( taille_des_chaines_, ColStringLengthFromFits(SfitsCol[k]) );118 for (k=0; k< ccount_; k++) taille_des_chaines_ = max( taille_des_chaines_, inFits_->ColStringLengthFromFits(SfitsCol[k]) ); 118 119 for (k=0; k<ccount_; k++) cdata_[k]=new char[taille_des_chaines_+1]; 119 120 } … … 123 124 FITS_BntblLineReader::~FITS_BntblLineReader() 124 125 { 126 if (inFits_ != NULL) delete inFits_; 125 127 if (ddata_ != NULL) delete [] ddata_; 126 128 if (fdata_ != NULL) delete [] fdata_; … … 147 149 XNTuple FITS_BntblLineReader::ReadNextLine() 148 150 { 149 GetBinTabLine(nextLineToBeRead_++, ddata_, fdata_, idata_, cdata_ );151 inFits_->GetBinTabLine(nextLineToBeRead_++, ddata_, fdata_, idata_, cdata_ ); 150 152 XNTuple xnt(dcount_, fcount_, icount_,ccount_, ColName_); 151 153 xnt.Fill(ddata_, fdata_, idata_, cdata_); … … 153 155 } 154 156 155 void FITS_BntblLineReader::ReadFromFits( )157 void FITS_BntblLineReader::ReadFromFits(FitsInFile&) 156 158 { 157 159 } 158 160 159 void FITS_BntblLineReader::WriteToFits( )161 void FITS_BntblLineReader::WriteToFits(FitsOutFile&) 160 162 { 161 163 } -
trunk/SophyaExt/FitsIOServer/fitsbntbllinereader.h
r1048 r1136 13 13 /////////////////////////////////////////////////////////// 14 14 15 class FITS_BntblLineReader : public Fits File15 class FITS_BntblLineReader : public FitsIOHandler 16 16 { 17 17 … … 25 25 inline void SetStartingLineIndex(long n) { nextLineToBeRead_ = n;} 26 26 27 inline int status() const {return statusF();};28 inline string getStatus(int status) const {return getErrStatus(status);};27 inline int status() const {return inFits_->statusF();}; 28 inline string getStatus(int status) const {return inFits_->getErrStatus(status);}; 29 29 30 30 … … 34 34 // implementation de FitsFile 35 35 // virtual void ReadFromFits(FitsFile& fn); 36 virtual void ReadFromFits( );37 virtual void WriteToFits( );36 virtual void ReadFromFits(FitsInFile& is); 37 virtual void WriteToFits(FitsOutFile& os); 38 38 39 39 private : … … 41 41 inline void InitNull() 42 42 { 43 inFits_ = NULL; 43 44 nextLineToBeRead_= 0; 44 45 dcount_ = 0; … … 54 55 } 55 56 // attributs de classe 57 58 FitsInFile* inFits_; 56 59 long nextLineToBeRead_; 57 60 int dcount_; -
trunk/SophyaExt/FitsIOServer/fitsfile.cc
r1082 r1136 6 6 #include "anydataobj.h" 7 7 #include "fitsspherehealpix.h" 8 FitsFile::FitsFile() 9 { 10 InitNull(); 11 } 8 9 10 void FitsIOHandler::Read(char flnm[],int hdunum) 11 { 12 // FitsInFile ifts(flnm, hdunum); 13 FitsInFile ifts(flnm); 14 Read(ifts, hdunum); 15 } 16 void FitsIOHandler::Read(FitsInFile& is, int hdunum) 17 { 18 if (hdunum == 0) is.moveToFollowingHeader(); 19 else is.ReadFInit(hdunum); 20 ReadFromFits(is); 21 } 22 23 24 void FitsIOHandler::Write(char flnm[], bool OldFile) 25 26 { 27 28 FitsOutFile of(flnm, OldFile); 29 Write(of); 30 } 31 32 void FitsIOHandler::Write(FitsOutFile& os) 33 { 34 WriteToFits(os); 35 } 36 37 38 12 39 13 40 FitsFile::~FitsFile() 14 41 { 42 cout << " destructeur FitsFile " << endl; 15 43 int status = 0; 16 44 if( fptr_ != NULL) … … 22 50 } 23 51 24 void FitsFile::InitNull() 25 { 26 fptr_= NULL; 27 hdutype_= 0; 28 hdunum_ = 0; 29 52 53 void FitsFile::printerror(int &status) 54 //*****************************************************/ 55 //* Print out cfitsio error messages and exit program */ 56 //*****************************************************/ 57 { 58 if( status ) 59 { 60 fits_report_error(stderr,status); 61 throw IOExc("FitsFile:: error FITSIO status"); 62 } 63 return; 64 } 65 66 void FitsFile::printerror(int& status, char* texte) 67 //*****************************************************/ 68 //* Print out cfitsio error messages and exit program */ 69 //*****************************************************/ 70 { 71 // print out cfitsio error messages and exit program 72 // print error report 73 fits_report_error(stderr, status); 74 cout << " erreur:: " << texte << endl; 75 throw IOExc("FitsFile:: error FITSIO status"); 76 } 77 78 void FitsFile::ResetStatus(int& status) 79 { 80 fits_status_ = status; 81 status = 0; 82 } 83 84 string FitsFile::getErrStatus(int status) 85 { 86 char text[31]; 87 fits_get_errstatus(status, text); 88 return string(text); 89 } 90 91 FitsInFile::FitsInFile() 92 { 93 InitNull(); 94 } 95 //FitsInFile::FitsInFile(char flnm[], int hdunum) 96 FitsInFile::FitsInFile(char flnm[]) 97 { 98 InitNull(); 99 int status = 0; 100 fits_open_file(&fptr_,flnm,READONLY,&status); 101 if( status ) printerror( status ); 102 // ReadFInit(flnm, hdunum); 103 } 104 105 106 void FitsInFile::InitNull() 107 { 108 cout << " init FitsInFile " << endl; 30 109 bitpix_ = 0; 31 110 naxis_ = 0; … … 33 112 nrows_ = 0; 34 113 nbcols_ = 0; 35 fits_status_ = 0;36 114 naxisn_.clear(); 37 115 repeat_.clear(); … … 42 120 43 121 44 int Fits File::NbBlocks(char flnm[])122 int FitsInFile::NbBlocks(char flnm[]) 45 123 { 46 124 int status = 0; … … 54 132 } 55 133 56 void Fits File::getBlockType(char flnm[], int hdunum, string& typeOfExtension, int& naxis, vector<int>& naxisn, string& dataType, DVList& dvl )134 void FitsInFile::getBlockType(char flnm[], int hdunum, string& typeOfExtension, int& naxis, vector<int>& naxisn, string& dataType, DVList& dvl ) 57 135 { 58 136 int status = 0; … … 123 201 } 124 202 125 void FitsFile::ReadF(char flnm[],int hdunum) 126 { 127 ReadFInit(flnm, hdunum); 128 // ReadFromFits(*this); 129 ReadFromFits(); 130 } 131 132 133 //FitsFile* FitsFile::ReadFInit(char flnm[],int hdunum) 134 void FitsFile::ReadFInit(char flnm[],int hdunum) 135 { 136 InitNull(); 137 int status = 0; 138 // hdutype_= 0; 203 void FitsInFile::GetImageParameters (fitsfile* fileptr,int& bitpix,int& naxis,vector<int>& naxisn) 204 { 205 int hdunum=0; 206 cout << " Reading a FITS image in HDU : " << fits_get_hdu_num(fileptr,&hdunum) << endl; 207 int status= 0; 208 209 // bits per pixels 210 fits_read_key(fileptr,TINT,"BITPIX",&bitpix,NULL,&status); 211 if( status ) printerror( status ); 212 213 // number of dimensions in the FITS array 214 naxis= 0; 215 fits_read_key(fileptr,TINT,"NAXIS",&naxis,NULL,&status); 216 if( status ) printerror( status ); 217 // cout << " dimension lue " << naxis << endl; 218 // read the NAXISn keywords to get image size 219 long* naxes = new long[naxis] ; 220 int nfound; 221 fits_read_keys_lng(fileptr,"NAXIS",1,naxis,naxes,&nfound,&status); 222 if( status ) printerror( status ); 223 if (nfound != naxis ) 224 cout << " WARNING : " << nfound << " axes found, expected naxis= " << naxis << endl; 225 int k; 226 for (k=0; k<naxis; k++) 227 { 228 naxisn.push_back( (int)naxes[k] ); 229 } 230 delete [] naxes; 231 } 232 233 234 //void FitsInFile::ReadFInit(char flnm[],int hdunum) 235 void FitsInFile::ReadFInit(int hdunum) 236 { 237 // InitNull(); 238 // int status = 0; 139 239 140 fits_open_file(&fptr_,flnm,READONLY,&status); 141 if( status ) printerror( status ); 142 // 240 // fits_open_file(&fptr_,flnm,READONLY,&status); 241 // if( status ) printerror( status ); 242 243 int status = 0; 244 143 245 if (hdunum <= 1) 144 246 { … … 171 273 moveToFollowingHeader(); 172 274 } 173 // return this; 174 } 175 176 void FitsFile::moveToFollowingHeader() 275 } 276 277 278 279 void FitsInFile::moveToFollowingHeader() 177 280 { 178 281 int status = 0; … … 197 300 } 198 301 199 200 void FitsFile::WriteF(char flnm[], bool OldFile) 201 { 202 int status = 0; 203 hdutype_= 0; 204 hdunum_ = 0; 205 206 207 // create new FITS file 208 if (!OldFile) 209 { 210 fits_create_file(&fptr_,flnm,&status); 211 if( status ) printerror(status,"file already exists"); 212 } 302 303 int FitsInFile::NbColsFromFits() const 304 { 305 if(hdutype_ == BINARY_TBL) return nbcols_; 213 306 else 214 { 215 fits_open_file(&fptr_,flnm,READWRITE,&status); 216 if( status ) printerror(status,"file does not exist"); 217 fits_get_num_hdus(fptr_, &hdunum_, &status); 218 int hdutype; 219 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status); 220 if( status ) printerror( status,":FitsFile::WriteF : erreur movabs"); 221 222 } 223 // WriteToFits(*this); 224 WriteToFits(); 225 } 226 void FitsFile::GetSingleColumn(double* map, int nentries) const 307 if(hdutype_ == ASCII_TBL || hdutype_ == IMAGE_HDU) return 1; 308 else 309 { 310 cout << " hdutype= " << hdutype_ << endl; 311 throw PException("FitsFile::NbColsFromFits, this HDU is unknown"); 312 } 313 } 314 315 int FitsInFile::NentriesFromFits(int nocol) const 316 { 317 if(hdutype_ == BINARY_TBL ) return nrows_*repeat_[nocol]; 318 else 319 if(hdutype_ == ASCII_TBL) return nrows_; 320 else 321 if(hdutype_ == IMAGE_HDU) return nbData_; 322 else 323 { 324 cout << "hdutype= " << hdutype_ << endl; 325 throw PException("FitsFile::NentriesFromFits, this HDU is unknown"); 326 } 327 } 328 329 char FitsInFile::ColTypeFromFits(int nocol) const 330 { 331 if(hdutype_ != ASCII_TBL && hdutype_ != BINARY_TBL) 332 { 333 throw IOExc("FitsFile::TypeFromFits, this HDU is not an ASCII table nor a binary table"); 334 } 335 return types_[nocol]; 336 } 337 string FitsInFile::ColNameFromFits(int nocol) const 338 { 339 if(hdutype_ != ASCII_TBL && hdutype_ != BINARY_TBL) 340 { 341 throw IOExc("FitsFile::TypeFromFits, this HDU is not an ASCII table nor a binary table"); 342 } 343 return noms_[nocol]; 344 } 345 346 int FitsInFile::ColStringLengthFromFits(int nocol) const 347 { 348 if(hdutype_ != ASCII_TBL && hdutype_ != BINARY_TBL) 349 { 350 throw IOExc("FitsFile::TypeFromFits, this HDU is not an ASCII table nor a binary table"); 351 } 352 int index=-1; 353 int k; 354 for (k=0; k<=nocol; k++) 355 { 356 if (types_[k] == 'S') index++; 357 } 358 return taille_des_chaines_[index]; 359 } 360 void FitsInFile::GetBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char ** cdata) 361 { 362 int status= 0; 363 int anull; 364 double dnull= 0.; 365 float fnull= 0.; 366 int inull= 0; 367 char* cnull= ""; 368 int dcount = 0.; 369 int fcount = 0.; 370 int icount = 0; 371 int ccount =0; 372 int ncol; 373 long nels=1; 374 for (ncol=0; ncol<nbcols_; ncol++) 375 { 376 switch (types_[ncol]) 377 { 378 case 'D' : 379 fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull,&ddata[dcount++],&anull,&status); 380 break; 381 case 'E' : 382 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&fdata[fcount++],&anull,&status); 383 break; 384 case 'I' : 385 fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&idata[icount++], 386 &anull,&status); 387 break; 388 case 'S' : 389 fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&cdata[ccount++],&anull,&status); 390 break; 391 } 392 if (status) 393 { 394 ResetStatus(status); 395 break; 396 } 397 } 398 } 399 400 void FitsInFile::GetBinTabLine(int NoLine, float* fdata) 401 { 402 int status= 0; 403 int anull; 404 float fnull= 0.; 405 long nels=1; 406 int ncol; 407 for (ncol=0; ncol<nbcols_; ncol++) 408 { 409 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&fdata[ncol],&anull,&status); 410 if (status) 411 { 412 ResetStatus(status); 413 break; 414 } 415 } 416 } 417 418 419 void FitsInFile::GetBinTabFCol(double* valeurs,int nentries, int NoCol) const 420 { 421 int status= 0; 422 int DTYPE; 423 long repeat,width; 424 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status); 425 if( DTYPE != TDOUBLE) 426 { 427 if (DTYPE == TFLOAT) cout << " WARNING: reading double from float : conversion will be made by fitsio library" << endl; 428 else 429 throw IOExc("FitsFile::GetBinTabFCol, tentative de lecture non double"); 430 } 431 long nels=nentries; 432 int anull; 433 // no checking for undefined pixels 434 double dnull= 0.; 435 // fits_read_key(fptr_,TDOUBLE,"BAD_DATA",&dnull,NULL,&status); 436 // if (status != 0) 437 // { 438 // dnull = -1.6375e30; // default value 439 // status = 0; 440 // } 441 if (nentries != nrows_*repeat) 442 { 443 cout << " found " << nentries << " pixels, expected: " << nrows_*repeat << endl; 444 throw PException(" FitsFile:::GetBinTabFCol "); 445 } 446 fits_read_col(fptr_,TDOUBLE,NoCol+1,1,1,nels,&dnull,valeurs, 447 &anull,&status); 448 if( status ) printerror( status,"erreur lecture de colonne" ); 449 450 } 451 452 void FitsInFile::GetBinTabFCol(float* valeurs,int nentries, int NoCol) const 453 { 454 int status= 0; 455 int DTYPE; 456 long repeat,width; 457 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status); 458 if( DTYPE != TFLOAT) 459 { 460 if (DTYPE == TDOUBLE) cout << " WARNING: reading float from double : conversion will be made by fitsio library" << endl; 461 else 462 throw IOExc("FitsFile::GetBinTabFCol, tentative de lecture non float"); 463 } 464 long nels=nentries; 465 int anull; 466 // no checking for undefined pixels 467 float fnull= 0.; 468 // fits_read_key(fptr_,TFLOAT,"BAD_DATA",&fnull,NULL,&status); 469 // if (status != 0) 470 // { 471 // fnull = -1.6375e30; // default value 472 // status = 0; 473 // } 474 if (nentries != nrows_*repeat) 475 { 476 cout << " found " << nentries << " pixels, expected: " << nrows_*repeat << endl; 477 throw PException(" FitsFile:::GetBinTabFCol "); 478 } 479 fits_read_col(fptr_,TFLOAT,NoCol+1,1,1,nels,&fnull,valeurs, 480 &anull,&status); 481 if( status ) printerror( status,"erreur lecture de colonne" ); 482 } 483 484 void FitsInFile::GetBinTabFCol(int* valeurs,int nentries, int NoCol) const 485 { 486 cout <<" entree GetBinTabFCol " << endl; 487 int status= 0; 488 int DTYPE; 489 long repeat,width; 490 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status); 491 if( DTYPE != TLONG && DTYPE != TINT && DTYPE != TSHORT ) 492 { 493 throw IOExc("FitsFile::GetBinTabFCol, tentative de lecture non entier"); 494 } 495 long nels=nentries; 496 // no checking for undefined pixels 497 int anull; 498 int inull= 0; 499 // fits_read_key(fptr_,TINT,"BAD_DATA",&inull,NULL,&status); 500 // if (status != 0) 501 // { 502 // inull = -999999; // default value 503 // status = 0; 504 // } 505 if (nentries != nrows_*repeat) 506 { 507 cout << " found " << nentries << " pixels, expected: " << nrows_*repeat << endl; 508 throw PException(" FitsFile:::GetBinTabFCol "); 509 } 510 fits_read_col(fptr_,TINT,NoCol+1,1,1,nels,&inull,valeurs, 511 &anull,&status); 512 if( status ) printerror( status,"erreur lecture de colonne" ); 513 } 514 515 void FitsInFile::GetBinTabFCol(char** valeurs, int nentries, int NoCol) const 516 { 517 int status= 0; 518 int DTYPE; 519 long repeat,width; 520 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status); 521 if( DTYPE != TSTRING ) 522 { 523 throw IOExc("FitsFile::GetBinTabFCol, tentative de lecture non float"); 524 } 525 long nels=nentries; 526 // no checking for undefined pixels 527 int anull; 528 char* cnull= ""; 529 if (nentries != nrows_*repeat/width) 530 { 531 cout << " found " << nentries << " pixels, expected: " << nrows_*repeat/width << endl; 532 throw PException(" FitsFile:::GetBinTabFCol "); 533 } 534 long frow=1; 535 long felem=1; 536 fits_read_col(fptr_,TSTRING,NoCol+1,frow,felem,nels,cnull,valeurs, 537 &anull,&status); 538 if( status ) printerror( status,"erreur lecture de colonne" ); 539 } 540 541 void FitsInFile::GetSingleColumn(double* map, int nentries) const 227 542 { 228 543 int status = 0; … … 256 571 } 257 572 258 void Fits File::GetSingleColumn(float* map, int nentries) const573 void FitsInFile::GetSingleColumn(float* map, int nentries) const 259 574 { 260 575 int status = 0; … … 286 601 } 287 602 288 void Fits File::GetSingleColumn( int* map, int nentries) const603 void FitsInFile::GetSingleColumn( int* map, int nentries) const 289 604 { 290 605 int status = 0; … … 315 630 } 316 631 } 317 void FitsFile::makeHeaderImageOnFits(char type, int nbdim, int* naxisn) 318 { 319 int status = 0; 320 long naxis = nbdim; 321 long* naxes = new long[nbdim]; 322 if (hdunum_ == 0) 323 { 324 fits_create_img(fptr_,FLOAT_IMG,0,naxes,&status); 325 hdunum_ = 1; 326 } 327 int k; 328 for (k=0; k< nbdim; k++) naxes[k] = (long)naxisn[k]; 329 if (type == 'D') 330 fits_create_img(fptr_,DOUBLE_IMG,naxis,naxes,&status); 331 else 332 if (type == 'E') 333 fits_create_img(fptr_,FLOAT_IMG,naxis,naxes,&status); 334 else 335 if (type == 'I') 336 fits_create_img(fptr_,LONG_IMG,naxis,naxes,&status); 337 else 338 { 339 cout << " type of data: " << type << endl; 340 throw PException("FitsFile:::makeHeaderImageOnFits:unprogrammed type of data "); 341 } 342 343 hdunum_++; 344 delete [] naxes; 345 if( status ) printerror( status, "erreur creation HDU IMAGE" ); 346 347 } 348 void FitsFile::putImageToFits(int nbData, double* map) const 349 { 350 int status = 0; 351 long npix= nbData; 352 fits_write_img(fptr_,TDOUBLE,1,npix,map,&status); 353 if( status ) printerror( status, "erreur ecriture putImageToFits" ); 354 writeSignatureOnFits(); 355 } 356 357 void FitsFile::putImageToFits(int nbData, float* map) const 358 { 359 int status = 0; 360 long npix= nbData; 361 fits_write_img(fptr_,TFLOAT,1,npix, map,&status); 362 if( status ) printerror( status, "erreur ecriture putImageToFits" ); 363 writeSignatureOnFits(); 364 365 } 366 void FitsFile::putImageToFits( int nbData, int* map) const 367 { 368 int status = 0; 369 370 long npix= nbData; 371 fits_write_img(fptr_,TINT,1,npix,map,&status); 372 if( status ) printerror( status, "erreur ecriture putImageToFits" ); 373 writeSignatureOnFits(); 374 } 375 376 377 378 void FitsFile::GetImageParameters (fitsfile* fileptr,int& bitpix,int& naxis,vector<int>& naxisn) 379 { 632 633 void FitsInFile::GetBinTabParameters(fitsfile* fileptr, int& nbcols, int& nrows, 634 vector<int>& repeat, 635 vector<string>& noms, 636 vector<char>& types, 637 vector<int>& taille_des_chaines) 638 { 639 int status= 0; 380 640 int hdunum=0; 381 cout << " Reading a FITS image in HDU : " << fits_get_hdu_num(fileptr,&hdunum) << endl; 382 int status= 0; 383 384 // bits per pixels 385 fits_read_key(fileptr,TINT,"BITPIX",&bitpix,NULL,&status); 386 if( status ) printerror( status ); 387 388 // number of dimensions in the FITS array 389 naxis= 0; 390 fits_read_key(fileptr,TINT,"NAXIS",&naxis,NULL,&status); 641 int hdutype=0; 642 fits_get_hdu_num(fileptr,&hdunum); 643 fits_get_hdu_type(fileptr, &hdutype, &status); 644 645 if(hdutype != ASCII_TBL && hdutype != BINARY_TBL) 646 { 647 throw IOExc("FitsFile::GetBinTabParameters this HDU is not an ASCII table nor a binary table"); 648 } 649 if(hdutype == ASCII_TBL) 650 cout << " Reading a FITS ascii table in HDU : " << hdunum << endl; 651 if(hdutype == BINARY_TBL) 652 cout << " Reading a FITS binary table in HDU : " << hdunum << endl; 653 654 // get the number of columns 655 fits_get_num_cols(fileptr, &nbcols,&status); 391 656 if( status ) printerror( status ); 392 657 393 // read the NAXISn keywords to get image size 394 long* naxes = new long[naxis] ; 658 // get the number of rows 659 long naxis2= 0; 660 fits_get_num_rows(fileptr,&naxis2,&status); 661 if( status ) printerror( status ); 662 nrows = (int)naxis2; 663 664 // get the datatype, names and the repeat count 665 noms.clear(); 666 noms.reserve(nbcols); 667 types.clear(); 668 types.reserve(nbcols); 669 repeat.clear(); 670 repeat.reserve(nbcols); 671 taille_des_chaines.clear(); 672 char **ttype = new char*[nbcols]; 673 int ii; 674 for (ii=0; ii < nbcols; ii++) ttype[ii]=new char[FLEN_VALUE]; 395 675 int nfound; 396 fits_read_keys_lng(fileptr,"NAXIS",1,naxis,naxes,&nfound,&status); 397 if( status ) printerror( status ); 398 if (nfound != naxis ) 399 cout << " WARNING : " << nfound << " axes found, expected naxis= " << naxis << endl; 400 int k; 401 for (k=0; k<naxis; k++) 402 { 403 naxisn.push_back( (int)naxes[k] ); 404 } 405 delete [] naxes; 406 } 407 408 void FitsFile::KeywordsIntoDVList(fitsfile* fileptr, DVList& dvl, int hdunum) 676 fits_read_keys_str(fileptr, "TTYPE",1,nbcols,ttype,&nfound, &status); 677 if( status ) printerror( status,"erreur lecture des noms de colonne"); 678 int rept=0; 679 for(ii = 0; ii < nbcols; ii++) 680 { 681 int DTYPE; 682 long width; 683 long repete = 0; 684 fits_get_coltype(fileptr,ii+1,&DTYPE,&repete,&width,&status); 685 if( status ) printerror( status,"erreur lecture type de colonne"); 686 rept = repete; 687 noms.push_back(string(ttype[ii])); 688 switch (DTYPE) 689 { 690 case TDOUBLE : 691 types.push_back('D'); 692 break; 693 case TFLOAT : 694 types.push_back('E'); 695 break; 696 case TLONG : 697 types.push_back('I'); 698 break; 699 case TINT : 700 types.push_back('I'); 701 break; 702 case TSHORT : 703 types.push_back('I'); 704 break; 705 case TSTRING : 706 types.push_back('S'); 707 taille_des_chaines.push_back(width); 708 rept/=width; 709 break; 710 default : 711 cout << " field " << ii+1 << " DTYPE= " << DTYPE << endl; 712 throw IOExc("FitsFile:: unknown type of field"); 713 } 714 repeat.push_back(rept); 715 } 716 for (ii=0; ii < nbcols; ii++) delete [] ttype[ii]; 717 delete [] ttype; 718 } 719 720 void FitsInFile::KeywordsIntoDVList(fitsfile* fileptr, DVList& dvl, int hdunum) 409 721 { 410 722 int status = 0; … … 473 785 } 474 786 475 476 477 void FitsFile::GetBinTabFCol(double* valeurs,int nentries, int NoCol) const 478 { 479 int status= 0; 480 int DTYPE; 481 long repeat,width; 482 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status); 483 if( DTYPE != TDOUBLE) 484 { 485 if (DTYPE == TFLOAT) cout << " WARNING: reading double from float : conversion will be made by fitsio library" << endl; 486 else 487 throw IOExc("FitsFile::GetBinTabFCol, tentative de lecture non double"); 488 } 489 long nels=nentries; 490 int anull; 491 // no checking for undefined pixels 492 double dnull= 0.; 493 // fits_read_key(fptr_,TDOUBLE,"BAD_DATA",&dnull,NULL,&status); 494 // if (status != 0) 495 // { 496 // dnull = -1.6375e30; // default value 497 // status = 0; 498 // } 499 if (nentries != nrows_*repeat) 500 { 501 cout << " found " << nentries << " pixels, expected: " << nrows_*repeat << endl; 502 throw PException(" FitsFile:::GetBinTabFCol "); 503 } 504 fits_read_col(fptr_,TDOUBLE,NoCol+1,1,1,nels,&dnull,valeurs, 505 &anull,&status); 506 if( status ) printerror( status,"erreur lecture de colonne" ); 507 508 } 509 510 void FitsFile::GetBinTabFCol(float* valeurs,int nentries, int NoCol) const 511 { 512 int status= 0; 513 int DTYPE; 514 long repeat,width; 515 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status); 516 if( DTYPE != TFLOAT) 517 { 518 if (DTYPE == TDOUBLE) cout << " WARNING: reading float from double : conversion will be made by fitsio library" << endl; 519 else 520 throw IOExc("FitsFile::GetBinTabFCol, tentative de lecture non float"); 521 } 522 long nels=nentries; 523 int anull; 524 // no checking for undefined pixels 525 float fnull= 0.; 526 // fits_read_key(fptr_,TFLOAT,"BAD_DATA",&fnull,NULL,&status); 527 // if (status != 0) 528 // { 529 // fnull = -1.6375e30; // default value 530 // status = 0; 531 // } 532 if (nentries != nrows_*repeat) 533 { 534 cout << " found " << nentries << " pixels, expected: " << nrows_*repeat << endl; 535 throw PException(" FitsFile:::GetBinTabFCol "); 536 } 537 fits_read_col(fptr_,TFLOAT,NoCol+1,1,1,nels,&fnull,valeurs, 538 &anull,&status); 539 if( status ) printerror( status,"erreur lecture de colonne" ); 540 } 541 void FitsFile::GetBinTabFCol(int* valeurs,int nentries, int NoCol) const 542 { 543 cout <<" entree GetBinTabFCol " << endl; 544 int status= 0; 545 int DTYPE; 546 long repeat,width; 547 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status); 548 if( DTYPE != TLONG && DTYPE != TINT && DTYPE != TSHORT ) 549 { 550 throw IOExc("FitsFile::GetBinTabFCol, tentative de lecture non entier"); 551 } 552 long nels=nentries; 553 // no checking for undefined pixels 554 int anull; 555 int inull= 0; 556 // fits_read_key(fptr_,TINT,"BAD_DATA",&inull,NULL,&status); 557 // if (status != 0) 558 // { 559 // inull = -999999; // default value 560 // status = 0; 561 // } 562 if (nentries != nrows_*repeat) 563 { 564 cout << " found " << nentries << " pixels, expected: " << nrows_*repeat << endl; 565 throw PException(" FitsFile:::GetBinTabFCol "); 566 } 567 fits_read_col(fptr_,TINT,NoCol+1,1,1,nels,&inull,valeurs, 568 &anull,&status); 569 if( status ) printerror( status,"erreur lecture de colonne" ); 570 } 571 void FitsFile::GetBinTabFCol(char** valeurs, int nentries, int NoCol) const 572 { 573 int status= 0; 574 int DTYPE; 575 long repeat,width; 576 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status); 577 if( DTYPE != TSTRING ) 578 { 579 throw IOExc("FitsFile::GetBinTabFCol, tentative de lecture non float"); 580 } 581 long nels=nentries; 582 // no checking for undefined pixels 583 int anull; 584 char* cnull= ""; 585 if (nentries != nrows_*repeat/width) 586 { 587 cout << " found " << nentries << " pixels, expected: " << nrows_*repeat/width << endl; 588 throw PException(" FitsFile:::GetBinTabFCol "); 589 } 590 long frow=1; 591 long felem=1; 592 fits_read_col(fptr_,TSTRING,NoCol+1,frow,felem,nels,cnull,valeurs, 593 &anull,&status); 594 if( status ) printerror( status,"erreur lecture de colonne" ); 595 } 596 597 598 599 void FitsFile::GetBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char ** cdata) 600 { 601 int status= 0; 602 int anull; 603 double dnull= 0.; 604 float fnull= 0.; 605 int inull= 0; 606 char* cnull= ""; 607 int dcount = 0.; 608 int fcount = 0.; 609 int icount = 0; 610 int ccount =0; 611 int ncol; 612 long nels=1; 613 for (ncol=0; ncol<nbcols_; ncol++) 614 { 615 switch (types_[ncol]) 616 { 617 case 'D' : 618 fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull,&ddata[dcount++],&anull,&status); 619 break; 620 case 'E' : 621 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&fdata[fcount++],&anull,&status); 622 break; 623 case 'I' : 624 fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&idata[icount++], 625 &anull,&status); 626 break; 627 case 'S' : 628 fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&cdata[ccount++],&anull,&status); 629 break; 630 } 631 if (status) 632 { 633 ResetStatus(status); 634 break; 635 } 636 // if( status ) printerror( status,"GetBinTabLine : erreur lecture de colonne char" ); 637 } 638 } 639 640 void FitsFile::GetBinTabLine(int NoLine, float* fdata) 641 { 642 int status= 0; 643 int anull; 644 float fnull= 0.; 645 long nels=1; 646 int ncol; 647 for (ncol=0; ncol<nbcols_; ncol++) 648 { 649 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&fdata[ncol],&anull,&status); 650 if (status) 651 { 652 ResetStatus(status); 653 break; 654 } 655 // if( status ) printerror( status,"GetBinTabLine : erreur lecture de colonne float" ); 656 } 657 } 658 659 660 661 662 663 664 665 666 int FitsFile::NbColsFromFits() const 667 { 668 if(hdutype_ == BINARY_TBL) return nbcols_; 787 FitsOutFile::FitsOutFile() 788 { 789 InitNull(); 790 } 791 792 FitsOutFile::FitsOutFile(char flnm[], bool OldFile) 793 { 794 795 InitNull(); 796 int status = 0; 797 798 // create new FITS file 799 if (!OldFile) 800 { 801 fits_create_file(&fptr_,flnm,&status); 802 if( status ) printerror(status,"file already exists"); 803 } 669 804 else 670 if(hdutype_ == ASCII_TBL || hdutype_ == IMAGE_HDU) return 1; 805 { 806 fits_open_file(&fptr_,flnm,READWRITE,&status); 807 if( status ) printerror(status,"file does not exist"); 808 fits_get_num_hdus(fptr_, &hdunum_, &status); 809 int hdutype; 810 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status); 811 if( status ) printerror( status,":FitsFile::WriteF : erreur movabs"); 812 813 } 814 815 } 816 817 818 819 void FitsOutFile::makeHeaderImageOnFits(char type, int nbdim, int* naxisn) 820 { 821 int status = 0; 822 long naxis = nbdim; 823 long* naxes = new long[nbdim]; 824 if (hdunum_ == 1) 825 { 826 if (imageOnPrimary_ == false) fits_create_img(fptr_,FLOAT_IMG,0,naxes,&status); 827 else hdunum_--; 828 } 829 int k; 830 for (k=0; k< nbdim; k++) naxes[k] = (long)naxisn[k]; 831 if (type == 'D') 832 fits_create_img(fptr_,DOUBLE_IMG,naxis,naxes,&status); 833 else 834 if (type == 'E') 835 fits_create_img(fptr_,FLOAT_IMG,naxis,naxes,&status); 671 836 else 672 { 673 cout << " hdutype= " << hdutype_ << endl; 674 throw PException("FitsFile::NbColsFromFits, this HDU is unknown"); 675 } 676 } 677 678 char FitsFile::ColTypeFromFits(int nocol) const 679 { 680 if(hdutype_ != ASCII_TBL && hdutype_ != BINARY_TBL) 681 { 682 throw IOExc("FitsFile::TypeFromFits, this HDU is not an ASCII table nor a binary table"); 683 } 684 return types_[nocol]; 685 } 686 int FitsFile::NentriesFromFits(int nocol) const 687 { 688 if(hdutype_ == BINARY_TBL ) return nrows_*repeat_[nocol]; 689 else 690 if(hdutype_ == ASCII_TBL) return nrows_; 691 else 692 if(hdutype_ == IMAGE_HDU) return nbData_; 837 if (type == 'I') 838 fits_create_img(fptr_,LONG_IMG,naxis,naxes,&status); 693 839 else 694 840 { 695 cout << "hdutype= " << hdutype_ << endl; 696 throw PException("FitsFile::NentriesFromFits, this HDU is unknown"); 697 } 698 } 699 700 string FitsFile::ColNameFromFits(int nocol) const 701 { 702 if(hdutype_ != ASCII_TBL && hdutype_ != BINARY_TBL) 703 { 704 throw IOExc("FitsFile::TypeFromFits, this HDU is not an ASCII table nor a binary table"); 705 } 706 return noms_[nocol]; 707 } 708 int FitsFile::ColStringLengthFromFits(int nocol) const 709 { 710 if(hdutype_ != ASCII_TBL && hdutype_ != BINARY_TBL) 711 { 712 throw IOExc("FitsFile::TypeFromFits, this HDU is not an ASCII table nor a binary table"); 713 } 714 int index=-1; 715 int k; 716 for (k=0; k<=nocol; k++) 717 { 718 if (types_[k] == 'S') index++; 719 } 720 return taille_des_chaines_[index]; 721 } 722 723 724 725 void FitsFile::GetBinTabParameters(fitsfile* fileptr, int& nbcols, int& nrows, 726 vector<int>& repeat, 727 vector<string>& noms, 728 vector<char>& types, 729 vector<int>& taille_des_chaines) 730 { 731 int status= 0; 732 int hdunum=0; 733 int hdutype=0; 734 fits_get_hdu_num(fileptr,&hdunum); 735 fits_get_hdu_type(fileptr, &hdutype, &status); 736 737 if(hdutype != ASCII_TBL && hdutype != BINARY_TBL) 738 { 739 throw IOExc("FitsFile::GetBinTabParameters this HDU is not an ASCII table nor a binary table"); 740 } 741 if(hdutype == ASCII_TBL) 742 cout << " Reading a FITS ascii table in HDU : " << hdunum << endl; 743 if(hdutype == BINARY_TBL) 744 cout << " Reading a FITS binary table in HDU : " << hdunum << endl; 745 746 // get the number of columns 747 fits_get_num_cols(fileptr, &nbcols,&status); 748 if( status ) printerror( status ); 749 750 // get the number of rows 751 long naxis2= 0; 752 fits_get_num_rows(fileptr,&naxis2,&status); 753 if( status ) printerror( status ); 754 nrows = (int)naxis2; 755 756 // get the datatype, names and the repeat count 757 noms.clear(); 758 noms.reserve(nbcols); 759 types.clear(); 760 types.reserve(nbcols); 761 repeat.clear(); 762 repeat.reserve(nbcols); 763 taille_des_chaines.clear(); 764 char **ttype = new char*[nbcols]; 765 int ii; 766 for (ii=0; ii < nbcols; ii++) ttype[ii]=new char[FLEN_VALUE]; 767 int nfound; 768 fits_read_keys_str(fileptr, "TTYPE",1,nbcols,ttype,&nfound, &status); 769 if( status ) printerror( status,"erreur lecture des noms de colonne"); 770 int rept=0; 771 for(ii = 0; ii < nbcols; ii++) 772 { 773 int DTYPE; 774 long width; 775 long repete = 0; 776 fits_get_coltype(fileptr,ii+1,&DTYPE,&repete,&width,&status); 777 if( status ) printerror( status,"erreur lecture type de colonne"); 778 rept = repete; 779 noms.push_back(string(ttype[ii])); 780 switch (DTYPE) 781 { 782 case TDOUBLE : 783 types.push_back('D'); 784 break; 785 case TFLOAT : 786 types.push_back('E'); 787 break; 788 case TLONG : 789 types.push_back('I'); 790 break; 791 case TINT : 792 types.push_back('I'); 793 break; 794 case TSHORT : 795 types.push_back('I'); 796 break; 797 case TSTRING : 798 types.push_back('S'); 799 taille_des_chaines.push_back(width); 800 rept/=width; 801 break; 802 default : 803 cout << " field " << ii+1 << " DTYPE= " << DTYPE << endl; 804 throw IOExc("FitsFile:: unknown type of field"); 805 } 806 repeat.push_back(rept); 807 } 808 } 809 810 811 812 void FitsFile::makeHeaderBntblOnFits( char* fieldType, char** Noms, int nentries, int tfields, DVList &dvl, char* extname, vector<int> taille_des_chaines) 841 cout << " type of data: " << type << endl; 842 throw PException("FitsFile:::makeHeaderImageOnFits:unprogrammed type of data "); 843 } 844 845 hdunum_++; 846 delete [] naxes; 847 if( status ) printerror( status, "erreur creation HDU IMAGE" ); 848 849 } 850 void FitsOutFile::putImageToFits(int nbData, double* map) const 851 { 852 int status = 0; 853 long npix= nbData; 854 fits_write_img(fptr_,TDOUBLE,1,npix,map,&status); 855 if( status ) printerror( status, "erreur ecriture putImageToFits" ); 856 writeSignatureOnFits(); 857 } 858 859 void FitsOutFile::putImageToFits(int nbData, float* map) const 860 { 861 int status = 0; 862 long npix= nbData; 863 fits_write_img(fptr_,TFLOAT,1,npix, map,&status); 864 if( status ) printerror( status, "erreur ecriture putImageToFits" ); 865 writeSignatureOnFits(); 866 867 } 868 void FitsOutFile::putImageToFits( int nbData, int* map) const 869 { 870 int status = 0; 871 872 long npix= nbData; 873 fits_write_img(fptr_,TINT,1,npix,map,&status); 874 if( status ) printerror( status, "erreur ecriture putImageToFits" ); 875 writeSignatureOnFits(); 876 } 877 878 879 880 void FitsOutFile::makeHeaderBntblOnFits( char* fieldType, char** Noms, int nentries, int tfields, DVList &dvl, char* extname, vector<int> taille_des_chaines) 813 881 { 814 882 int status = 0; … … 817 885 { 818 886 cout << " nombre de champs :" << tfields << "nombre de types: " << strlen(fieldType) << endl; 819 887 throw ParmError("FitsFile:: fields and types don't match"); 820 888 821 889 } … … 824 892 char largeur[FLEN_VALUE]; 825 893 int noColString=0; 826 827 828 894 int k; 829 895 for (k=0; k<tfields;k++) … … 847 913 if (fieldType[k] == 'A') 848 914 { 849 char largaux[FLEN_VALUE];850 sprintf(largeur,"%d",taille_des_chaines[noColString]);851 sprintf(largaux,"%d",1024*taille_des_chaines[noColString]);852 noColString++;853 strcpy(format, largaux);915 char largaux[FLEN_VALUE]; 916 sprintf(largeur,"%d",taille_des_chaines[noColString]); 917 sprintf(largaux,"%d",1024*taille_des_chaines[noColString]); 918 noColString++; 919 strcpy(format, largaux); 854 920 } 855 921 else strcpy(format,"1024"); … … 930 996 } 931 997 932 void Fits File::putColToFits(int nocol, int nentries, double* donnees) const998 void FitsOutFile::putColToFits(int nocol, int nentries, double* donnees) const 933 999 { 934 1000 int status = 0; … … 952 1018 if( status ) printerror( status,"erreur ecriture du fichier fits" ); 953 1019 } 954 void Fits File::putColToFits(int nocol, int nentries, float* donnees) const1020 void FitsOutFile::putColToFits(int nocol, int nentries, float* donnees) const 955 1021 { 956 1022 int status = 0; … … 978 1044 if( status ) printerror( status,"erreur ecriture du fichier fits" ); 979 1045 } 980 void Fits File::putColToFits(int nocol, int nentries, int* donnees) const1046 void FitsOutFile::putColToFits(int nocol, int nentries, int* donnees) const 981 1047 { 982 1048 int status = 0; … … 1004 1070 if( status ) printerror( status," ecriture du fichier fits" ); 1005 1071 } 1006 void Fits File::putColToFits(int nocol, int nentries, char** donnees) const1072 void FitsOutFile::putColToFits(int nocol, int nentries, char** donnees) const 1007 1073 { 1008 1074 int status = 0; … … 1032 1098 1033 1099 1034 1035 1036 1037 1038 void FitsFile::writeSignatureOnFits() const 1100 void FitsOutFile::writeSignatureOnFits() const 1039 1101 { 1040 1102 int status = 0; … … 1060 1122 1061 1123 1062 void FitsFile::printerror(int &status) 1063 //*****************************************************/ 1064 //* Print out cfitsio error messages and exit program */ 1065 //*****************************************************/ 1066 { 1067 if( status ) 1068 { 1069 fits_report_error(stderr,status); 1070 throw IOExc("FitsFile:: error FITSIO status"); 1071 } 1072 return; 1073 } 1074 1075 void FitsFile::printerror(int& status, char* texte) 1076 //*****************************************************/ 1077 //* Print out cfitsio error messages and exit program */ 1078 //*****************************************************/ 1079 { 1080 // print out cfitsio error messages and exit program 1081 // print error report 1082 fits_report_error(stderr, status); 1083 cout << " erreur:: " << texte << endl; 1084 throw IOExc("FitsFile:: error FITSIO status"); 1085 } 1086 1087 int FitsFile::statusF() const 1088 { 1089 return fits_status_; 1090 } 1091 void FitsFile::ResetStatus(int& status) 1092 { 1093 fits_status_ = status; 1094 status = 0; 1095 } 1096 1097 string FitsFile::getErrStatus(int status) 1098 { 1099 char text[31]; 1100 fits_get_errstatus(status, text); 1101 return string(text); 1102 } 1124 -
trunk/SophyaExt/FitsIOServer/fitsfile.h
r1047 r1136 12 12 namespace SOPHYA { 13 13 14 class FitsFile; 15 class FitsInFile; 16 class FitsOutFile; 17 18 19 14 20 // 15 //! VirtualClass for managing Interface for SOPHYA objects to FITS Format Files (uses cfitsio lib)21 //! Class for managing Interface for SOPHYA objects to FITS Format Files (uses cfitsio lib) 16 22 17 23 /*! 18 24 The class structure is analogous to Sophya-PPersist system : 19 25 Each SOPHYA object XXX is associated with a object of class FITS_XXX 20 (inheriting from FitsFile), to which input/output operations with FITS 21 files are delegated. A typical example of use is the following : 26 (inheriting from FitsFileHandler), to which input/output operations with FITS 27 files are delegated (through a class Hierarchy : FitsFile (virtual), 28 FitsInFile, FitsOutFile) . A typical example of use is the following : 22 29 23 30 \verbatim … … 39 46 40 47 */ 48 49 class FitsIOHandler { 50 51 52 public: 53 54 virtual ~FitsIOHandler() {} 55 /*! 56 this method is called from inherited objects : 57 58 opens a file 'flnm' 59 60 gets parameters in header (hdunum) 61 62 calls the method 'ReadFromFits' from the inherited object 63 64 65 */ 66 void Read(char flnm[],int hdunum= 2); 67 /*! 68 this method is called from inherited objects : 69 70 for writing a new object in a new fits-extension, at the end of 71 72 the existing file (flnm), if OldFile=true. 73 74 If OldFile=false, an exception occurs 75 76 By convention, primary header does not contain fits-image data : i.e. 77 all data are fits-extensions. The first relevant header will have hdunum=2. 78 For switching off this convention use the method : 79 80 firstImageOnPrimaryHeader() (see below) 81 82 In that case do not forget to precise hdunum=1 when reading data on primary header. 83 84 calls the method 'WriteToFits' from the inherited object 85 86 */ 87 void Write(char flnm[], bool OldFile=false) ; 88 89 /*! 90 Read the data on extension hdunum (or primary header, if hdunum=1) from FitsInFIle. With default value for hdunum, one reads the next extension, with respect to the current position. 91 */ 92 void Read(FitsInFile& ifts, int hdunum=0); 93 void Write(FitsOutFile& ofts) ; 94 95 96 protected: 97 virtual void ReadFromFits(FitsInFile& is)=0; 98 virtual void WriteToFits(FitsOutFile& os) =0; 99 friend class FitsInFile; 100 friend class FitsOutFile; 101 102 }; 103 104 105 41 106 class FitsFile 42 107 { … … 44 109 public: 45 110 46 FitsFile() ;111 FitsFile() { InitNull();}; 47 112 virtual ~FitsFile(); 113 114 static string getErrStatus(int status); 115 116 117 118 119 inline int statusF() const { return fits_status_;} 120 121 122 protected: 123 124 void ResetStatus(int& status) ; 125 static void printerror(int&) ; 126 static void printerror(int&,char* texte) ; 127 inline void InitNull() { cout << " init fitsfile " << endl; fptr_= NULL; hdutype_= 0; hdunum_ = 1; 128 fits_status_ = 0;} 129 130 //! pointer to the FITS file, defined in fitsio.h 131 fitsfile *fptr_; 132 133 //! image or bintable ? 134 int hdutype_; 135 136 //! index of header to be read/written 137 int hdunum_; 138 139 //! last status returned by fitsio library. updated only by several methods 140 int fits_status_; 141 142 143 }; 144 145 146 class FitsInFile : public FitsFile { 147 148 public: 149 FitsInFile(); 150 // FitsInFile(char flnm[], int hdunum=0); 151 FitsInFile(char flnm[]); 152 ~FitsInFile() { cout << " destructeur FitsInFile " << endl; }; 153 154 155 ////////////////////////////////////////////////////////// 156 // methods with general purpose 157 /////////////////////////////////////// 158 159 160 48 161 static int NbBlocks(char flnm[]); 49 162 static void getBlockType(char flnm[], int hdunum, string& typeOfExtension, int& naxis, vector<int>& naxisn, string& dataType, DVList& dvl ); 50 163 51 protected: 164 165 166 // void ReadFInit(char flnm[],int hdunum=0); 167 void ReadFInit(int hdunum); 52 168 53 /*!54 this method is called from inherited objects :55 56 moves to header 'hdunum' on file 'flnm'57 58 gets parameters in header59 60 calls the method 'ReadFromFits' from the inherited object61 62 */63 void ReadF(char flnm[],int hdunum= 0);64 // FitsFile* ReadFInit(char flnm[],int hdunum=0);65 void ReadFInit(char flnm[],int hdunum=0);66 67 /*!68 this method is called from inherited objects :69 70 opens a file 'flnm'71 72 gets parameters in header73 74 calls the method 'ReadFromFits' from the inherited object75 76 */77 void WriteF(char flnm[], bool OldFile=false);78 // virtual void ReadFromFits(FitsFile& ff)=0;79 80 81 82 virtual void ReadFromFits()=0;83 virtual void WriteToFits()=0;84 85 static string getErrStatus(int status);86 87 88 //////////////////////////////////////////////////////////89 /////// methods for managing extensions ////////////////90 //////////////////////////////////////////////////////////91 92 //////////////////////////////////////////////////////////93 // methods with general purpose94 ///////////////////////////////////////95 96 169 /*! return a reference on a DVList containing the keywords from FITS file 97 170 */ 98 inline const DVList& DVListFromFits() const { return dvl_;} 99 100 void moveToFollowingHeader(); 101 int statusF() const; 171 inline const DVList& DVListFromFits() const { return dvl_;} 172 173 void moveToFollowingHeader(); 174 175 176 ////////////////////////////////////////////////////////// 177 /////// methods for managing extensions //////////////// 178 ////////////////////////////////////////////////////////// 179 102 180 103 181 104 182 ///////////////////////////////////////////////////////////// 105 // methods for managing FITS IMAGE extension 106 /////////////////////////////////////////////////// 107 108 109 //read 110 //---- 183 // methods for managing FITS IMAGE extension 184 /////////////////////////////////////////////////// 185 111 186 112 187 /*! return true if the current header corresponds to a FITS image extension */ 113 188 inline bool IsFitsImage() const { return (hdutype_ == IMAGE_HDU);} 189 190 114 191 115 192 /*! number of dimensions of an image extension : NAXIS parameter (in FITS notations) … … 125 202 126 203 127 //write128 //-----129 130 131 /*! create an IMAGE header on FITS file.132 \param <type> type of data (see method ColTypeFromFits)133 \param <nbdim> number of dimensions : 1D, 2D, 3D etc. = NAXIS134 \param <naxisn> array containind sizes of the different dimensions135 */136 void makeHeaderImageOnFits(char type, int nbdim, int* naxisn) ;137 138 /*! write double data from array 'map'on an IMAGE extension139 \param <nbData> number of data to be written140 141 */142 void putImageToFits( int nbData, double* map) const;143 144 /*! same as previous method with float data */145 void putImageToFits(int nbData, float* map ) const;146 147 /*! same as previous method with int data */148 void putImageToFits(int nbData, int* map) const;149 150 151 204 152 205 ////////////////////////////////////////////////////////////////////////// 153 // methods for managing FITS BINARY TABLE or ASCII TABLE extension 154 //////////////////////////////////////////////////////////////////////// 155 156 157 158 // read 159 //----- 206 // methods for managing FITS BINARY TABLE or ASCII TABLE extension 207 //////////////////////////////////////////////////////////////////////// 208 209 210 160 211 161 212 /*! return true if the current header corresponds to a FITS ASCII or BINTABLE extension */ 162 213 inline bool IsFitsTable() const {return (hdutype_ == ASCII_TBL || hdutype_ == BINARY_TBL);} 163 /*! return number of columns (return 1 if IMAGE) */ 164 int NbColsFromFits() const; 165 /*! number of data in the current IMAGE extension on FITS file, or number 166 of data of column number 'nocol' of the current BINTABLE extension 167 */ 168 int NentriesFromFits(int nocol) const; 214 215 216 static void GetBinTabParameters(fitsfile* fileptr, int& nbcols, int& nrows, 217 vector<int>& repeat, 218 vector<string>& noms, 219 vector<char>& types, 220 vector<int>& taille_des_chaines); 221 222 223 169 224 /*! return a character denoting data type of column number 'nocol' in a BINTABLE : 170 225 … … 200 255 void GetBinTabLine(int NoLine, float* fdata) ; 201 256 202 203 204 205 206 /*! 257 /*! 207 258 fill the array 'valeurs' with double data from the current BINTABLE extension on FITS file, from column number 'NoCol' 208 259 … … 219 270 // Write elements into the FITS data array 220 271 221 222 223 //write 224 //----- 272 ///////////////////////////////////////////////////////////// 273 // methods for managing any type of FITS extension 274 //////////////////////////////////////////////////////// 275 276 /*! return number of columns (return 1 if IMAGE) */ 277 int NbColsFromFits() const; 278 /*! number of data in the current IMAGE extension on FITS file, or number 279 of data of column number 'nocol' of the current BINTABLE extension 280 */ 281 int NentriesFromFits(int nocol) const; 282 283 284 /*! 285 fill the array 'map' with double data from the current extension on FITS file. 286 If the extension is BINTABLE, the first column is provided. 287 288 \param <nentries> number of data to be read 289 */ 290 void GetSingleColumn(double* map, int nentries) const; 291 292 /*! same as above with float data */ 293 void GetSingleColumn(float* map, int nentries) const; 294 295 /*! same as above with int data */ 296 void GetSingleColumn(int* map, int nentries) const; 297 298 private : 299 300 void InitNull(); 301 static void KeywordsIntoDVList(fitsfile* fileptr, DVList& dvl, int hdunum); 302 static void GetImageParameters (fitsfile* fileptr,int& bitpix,int& naxis,vector<int>& naxisn); 303 304 305 306 307 //! fits-Image parameter 308 int bitpix_; 309 310 //! fits-Image parameter 311 int naxis_; 312 313 //! fits-Image parameters : sizes of dimensions 314 vector<int> naxisn_; 315 316 //! fits-Image parameter: number of data 317 int nbData_; 318 319 //! Bintable parameter 320 int nrows_; 321 322 //! Bintable parameter 323 vector<int> repeat_; 324 325 //! Bintable parameter 326 int nbcols_; 327 328 //! Bintable parameter: column names 329 vector<string> noms_; 330 331 //! Bintable parameters: types of columns (D: double, E: float, I: integers, A: char*) 332 vector<char> types_; 333 334 //! Bintable parameters: length of the char* variables 335 vector<int> taille_des_chaines_; 336 337 //! DVList for transferring keywords 338 DVList dvl_; 339 340 341 }; 342 343 344 class FitsOutFile : public FitsFile { 345 346 public: 347 FitsOutFile(); 348 FitsOutFile(char flnm[], bool OldFile=false); 349 ~FitsOutFile() { cout << " destructeur FitsOutFile " << endl;}; 350 inline void InitNull() {imageOnPrimary_=false;} 351 352 ////////////////////////////////////////////////////////// 353 /////// methods for managing extensions //////////////// 354 ////////////////////////////////////////////////////////// 355 356 357 358 ///////////////////////////////////////////////////////////// 359 // methods for managing FITS IMAGE extension 360 /////////////////////////////////////////////////// 361 362 363 inline void firstImageOnPrimaryHeader() {imageOnPrimary_=true;} 364 365 /*! create an IMAGE header on FITS file. 366 \param <type> type of data (see method ColTypeFromFits) 367 \param <nbdim> number of dimensions : 1D, 2D, 3D etc. = NAXIS 368 \param <naxisn> array containind sizes of the different dimensions 369 */ 370 void makeHeaderImageOnFits(char type, int nbdim, int* naxisn) ; 371 372 /*! write double data from array 'map'on an IMAGE extension 373 \param <nbData> number of data to be written 374 375 */ 376 void putImageToFits( int nbData, double* map) const; 377 378 /*! same as previous method with float data */ 379 void putImageToFits(int nbData, float* map ) const; 380 381 /*! same as previous method with int data */ 382 void putImageToFits(int nbData, int* map) const; 383 384 385 386 ////////////////////////////////////////////////////////////////////////// 387 // methods for managing FITS BINARY TABLE or ASCII TABLE extension 388 //////////////////////////////////////////////////////////////////////// 389 390 225 391 226 392 /*! create an BINTABLE header on FITS file. … … 250 416 void putColToFits(int nocol, int nentries, char** donnees) const; 251 417 252 253 ///////////////////////////////////////////////////////////// 254 // methods for managing any type of FITS extension 255 //////////////////////////////////////////////////////// 256 257 258 /*! 259 fill the array 'map' with double data from the current extension on FITS file. 260 If the extension is BINTABLE, the first column is provided. 261 262 \param <nentries> number of data to be read 263 */ 264 void GetSingleColumn(double* map, int nentries) const; 265 266 /*! same as above with float data */ 267 void GetSingleColumn(float* map, int nentries) const; 268 269 /*! same as above with int data */ 270 void GetSingleColumn(int* map, int nentries) const; 271 272 273 274 private: 275 276 void InitNull(); 277 void ResetStatus(int& status) ; 278 static void printerror(int&) ; 279 static void printerror(int&,char* texte) ; 280 281 static void GetImageParameters (fitsfile* fileptr,int& bitpix,int& naxis,vector<int>& naxisn); 282 static void GetBinTabParameters(fitsfile* fileptr, int& nbcols, int& nrows, 283 vector<int>& repeat, 284 vector<string>& noms, 285 vector<char>& types, 286 vector<int>& taille_des_chaines); 287 static void KeywordsIntoDVList(fitsfile* fileptr, DVList& dvl, int hdunum); 418 private : 419 288 420 void writeSignatureOnFits() const; 289 421 290 //! pointer to the FITS file, defined in fitsio.h 291 fitsfile *fptr_; 292 293 //! image or bintable ? 294 int hdutype_; 295 296 //! index of header to be read/written 297 int hdunum_; 298 299 300 //! fits-Image parameter 301 int bitpix_; 302 303 //! fits-Image parameter 304 int naxis_; 305 306 //! fits-Image parameters : sizes of dimensions 307 vector<int> naxisn_; 308 309 //! fits-Image parameter: number of data 310 int nbData_; 311 312 //! Bintable parameter 313 int nrows_; 314 315 //! Bintable parameter 316 vector<int> repeat_; 317 318 //! Bintable parameter 319 int nbcols_; 320 321 //! Bintable parameter: column names 322 vector<string> noms_; 323 324 //! Bintable parameters: types of columns (D: double, E: float, I: integers, A: char*) 325 vector<char> types_; 326 327 //! Bintable parameters: length of the char* variables 328 vector<int> taille_des_chaines_; 329 330 //! DVList for transferring keywords 331 DVList dvl_; 332 333 334 335 //! last status returned by fitsio library. updated only by several methods 336 int fits_status_; 337 }; 422 423 bool imageOnPrimary_; 424 425 }; 426 338 427 339 428 -
trunk/SophyaExt/FitsIOServer/fitsntuple.cc
r1047 r1136 25 25 ownobj_ = true; 26 26 27 Read F(inputfile,hdunum);27 Read(inputfile,hdunum); 28 28 } 29 29 … … 46 46 { 47 47 if (ownobj_ && dobj_ != NULL) delete dobj_; 48 if (column_ != NULL) delete [] column_;48 // if (column_ != NULL) delete [] column_; 49 49 } 50 50 51 void FITS_NTuple::Read(char inputfile[],int hdunum)52 {53 ReadF(inputfile,hdunum);54 }51 //void FITS_NTuple::Read(char inputfile[],int hdunum) 52 //{ 53 // ReadF(inputfile,hdunum); 54 //} 55 55 void FITS_NTuple::ReadLines(char inputfile[],int firstLine, int numberOfLines,int hdunum) 56 56 { 57 57 fistLineToBeRead_ = firstLine; 58 58 numberOfLinesToBeRead_ = numberOfLines; 59 Read F(inputfile,hdunum);59 Read(inputfile,hdunum); 60 60 } 61 61 62 62 63 63 64 void FITS_NTuple::Write(char outputfile[], bool OldFile) 64 //void FITS_NTuple::Write(char outputfile[], bool OldFile) 65 //{ 66 // WriteF(outputfile, OldFile); 67 //} 68 69 void FITS_NTuple::ReadFromFits(FitsInFile& is) 65 70 { 66 WriteF(outputfile, OldFile); 67 } 68 69 void FITS_NTuple::ReadFromFits() 70 { 71 // if (!fn.IsFitsTable()) 72 if (!IsFitsTable()) 71 if (!is.IsFitsTable()) 73 72 { 74 73 throw PException("ReadFromFits: the fits file seems not to be a bintable nor ASCII table"); 75 74 } 76 75 int nbcols, nbentries; 77 // nbcols = fn.NbColsFromFits(); 78 nbcols = NbColsFromFits(); 76 nbcols = is.NbColsFromFits(); 79 77 nbentries = 0; 80 78 int k; 81 // for (k=0; k<nbcols; k++) nbentries=max( nbentries, fn.NentriesFromFits(k) ); 82 for (k=0; k<nbcols; k++) nbentries=max( nbentries, NentriesFromFits(k) ); 79 for (k=0; k<nbcols; k++) nbentries=max( nbentries, is.NentriesFromFits(k) ); 83 80 84 81 char ** ColName = new char*[nbcols]; … … 87 84 { 88 85 ColName[k] = new char[LONNOM1]; 89 // strncpy(ColName[k], fn.ColNameFromFits(k).c_str(),LONNOM); 90 strncpy(ColName[k], ColNameFromFits(k).c_str(),LONNOM); 86 strncpy(ColName[k], is.ColNameFromFits(k).c_str(),LONNOM); 91 87 ColName[k][LONNOM] = '\0'; 92 88 } 93 89 for (k=0; k<nbcols;k++) 94 90 { 95 // char ss= fn.ColTypeFromFits(k); 96 char ss= ColTypeFromFits(k); 91 char ss= is.ColTypeFromFits(k); 97 92 string type; 98 93 if (ss != 'E') … … 123 118 } 124 119 delete [] ColName; 125 // if (column_ != NULL) delete [] column_;126 // column_ = new float[nbentries];127 120 128 // j'initialise le NTuple a zero, pour le dimensionner129 // (SetVal suppose que le ntuple est deja dimensionne)130 121 r_4* ligne = new r_4[nbcols]; 131 // for (k=0; k<nbcols; k++) ligne[k]=0.;132 // for (k=0; k<nbentries;k++) dobj_->Fill(ligne);133 // delete [] ligne;134 122 135 //%%%%%% 136 int firstln, lastln; 137 if (numberOfLinesToBeRead_ > 0) 138 { 139 firstln = fistLineToBeRead_; 140 lastln = firstln + numberOfLinesToBeRead_; 141 } 142 else 143 { 144 firstln = 0; 145 lastln = nbentries; 146 } 147 int numLigne; 148 for (numLigne=firstln; numLigne < lastln; numLigne++) 149 { 150 // fn.GetBinTabLine(numLigne, ligne); 151 GetBinTabLine(numLigne, ligne); 152 dobj_->Fill(ligne); 153 } 154 delete [] ligne; 123 int firstln, lastln; 124 if (numberOfLinesToBeRead_ > 0) 125 { 126 firstln = fistLineToBeRead_; 127 lastln = firstln + numberOfLinesToBeRead_; 128 } 129 else 130 { 131 firstln = 0; 132 lastln = nbentries; 133 } 134 int numLigne; 135 for (numLigne=firstln; numLigne < lastln; numLigne++) 136 { 137 is.GetBinTabLine(numLigne, ligne); 138 dobj_->Fill(ligne); 139 } 140 delete [] ligne; 155 141 156 //%%%%%%% 142 dobj_->Info()=is.DVListFromFits(); 143 } 157 144 158 159 // for (k=0; k<nbcols;k++) 160 // { 161 // fn.GetBinTabFCol(column_, nbentries, k); 162 // for (int nent=0; nent<nbentries; nent++) dobj_->SetVal(nent,k, column_[nent]); 163 // } 164 // dobj_->Info()=fn.DVListFromFits(); 165 dobj_->Info()=DVListFromFits(); 166 } 167 void FITS_NTuple::WriteToFits() 145 void FITS_NTuple::WriteToFits(FitsOutFile& os) 168 146 { 169 147 if(dobj_ == NULL) … … 192 170 strncpy(Noms[k],dobj_->NomIndex(k),LONNOM1); 193 171 } 194 // la librairie fitsio ecrit colonne par colonne 172 195 173 char* type= new char[ncols+1]; 196 174 for (k=0;k<ncols+1;k++) type[k]='E'; 197 175 type[ncols]='\0'; 198 176 vector<int> dummy; 199 // fn.makeHeaderBntblOnFits(type,Noms, nentries, ncols, dvl, extname, dummy); 200 makeHeaderBntblOnFits(type,Noms, nentries, ncols, dvl, extname, dummy);177 178 os.makeHeaderBntblOnFits(type,Noms, nentries, ncols, dvl, extname, dummy); 201 179 for (k=0; k< ncols; k++) 202 180 { … … 205 183 delete [] Noms; 206 184 delete [] type; 207 for (k=0; k<ncols;k++) putColToFits(k, nentries, getColFromObj(k)); 185 float* column = new float[nentries]; 186 for (k=0; k<ncols;k++) 187 { 188 for(int j = 0; j < nentries; j++) column[j]= dobj_->GetVal(j,k); 189 os.putColToFits(k, nentries, column); 190 } 191 delete [] column; 208 192 209 193 } 210 194 211 float* FITS_NTuple::getColFromObj(int colNr)212 {213 if (column_ != NULL)214 {215 delete [] column_;216 column_ = NULL;217 }218 column_ = new float[dobj_->NEntry()];219 for(int j = 0; j < dobj_->NEntry(); j++) column_[j]= dobj_->GetVal(j,colNr);220 return column_;221 } -
trunk/SophyaExt/FitsIOServer/fitsntuple.h
r1049 r1136 4 4 #ifndef FITSNTuple_SEEN 5 5 #define FITSNTuple_SEEN 6 #include "machdefs.h" 6 7 #include "ntuple.h" 7 8 #include "anydataobj.h" … … 14 15 // pout NTuple 15 16 //////////////////////////////////////////////////////////////// 16 class FITS_NTuple : public Fits File17 class FITS_NTuple : public FitsIOHandler 17 18 { 18 19 … … 24 25 FITS_NTuple(NTuple* obj); 25 26 virtual ~FITS_NTuple(); 26 void Read(char inputfile[],int hdunum=2); 27 28 virtual AnyDataObj* DataObj() { return(dobj_); } 29 virtual void SetDataObj(AnyDataObj & o) 30 { 31 NTuple* po = dynamic_cast< NTuple* >(& o); 32 if (po == NULL) return; 33 if (ownobj_ && dobj_) delete dobj_; 34 dobj_ = po; 35 ownobj_ = false; 36 } 37 38 27 39 /*! 28 40 fill the XNTuple only with lines from firstLine-th to (firstLine+numberOfLines-1)-th of the FITS-file inputfile. … … 31 43 */ 32 44 void ReadLines(char inputfile[],int firstLine, int numberOfLines,int hdunum=2); 33 void Write(char outputfile[], bool OldFile=false); 45 34 46 inline operator NTuple() { return(*dobj_); } 35 47 inline NTuple * getObj() { return(dobj_); } … … 38 50 39 51 // implementation de FitsFile 40 //virtual void ReadFromFits(FitsFile& fn); 41 virtual void ReadFromFits(); 42 virtual void WriteToFits(); 43 44 float* getColFromObj(int colNr); 52 virtual void ReadFromFits(FitsInFile& is); 53 virtual void WriteToFits(FitsOutFile& os) ; 45 54 46 55 private : 47 56 48 inline void InitNull() 49 { 50 fistLineToBeRead_= -1; 51 numberOfLinesToBeRead_= -1; 52 column_ = NULL; 53 } 57 inline void InitNull() { fistLineToBeRead_= -1; numberOfLinesToBeRead_= -1;} 54 58 55 59 … … 59 63 int fistLineToBeRead_; 60 64 int numberOfLinesToBeRead_; 61 float* column_;62 65 }; 63 66 ////////////////////////////////////////////////////////////////// -
trunk/SophyaExt/FitsIOServer/fitsspherehealpix.cc
r1047 r1136 15 15 { 16 16 dobj_= new SphereHEALPix<T>; 17 ownobj = true;17 ownobj_= true; 18 18 } 19 19 … … 22 22 { 23 23 dobj_= new SphereHEALPix<T>; 24 ownobj = true;25 26 Read F(inputfile,hdunum);27 dobj_->SetTemp(true);24 ownobj_= true; 25 26 Read(inputfile,hdunum); 27 // dobj_->SetTemp(true); 28 28 } 29 29 … … 33 33 { 34 34 dobj_= new SphereHEALPix<T>(obj, true); 35 dobj_->SetTemp(true);36 ownobj = true;35 // dobj_->SetTemp(true); 36 ownobj_= true; 37 37 } 38 38 … … 41 41 { 42 42 dobj_= obj; 43 ownobj = false;43 ownobj_= false; 44 44 } 45 45 … … 47 47 FITS_SphereHEALPix<T>::~FITS_SphereHEALPix() 48 48 { 49 if (ownobj && dobj_) delete dobj_;49 if (ownobj_ && dobj_) delete dobj_; 50 50 } 51 51 … … 61 61 SphereHEALPix<T> * po = dynamic_cast< SphereHEALPix<T> * >(&o); 62 62 if (po == NULL) return; 63 if (ownobj && dobj_) delete dobj_;63 if (ownobj_ && dobj_) delete dobj_; 64 64 dobj_ = po; 65 ownobj = false;65 ownobj_ = false; 66 66 } 67 67 68 68 69 69 70 template <class T> 71 void FITS_SphereHEALPix<T>::Write(char outputfile[], bool OldFile) 72 { 73 WriteF(outputfile, OldFile); 74 } 75 template <class T> 76 void FITS_SphereHEALPix<T>::Read(char inputfile[],int hdunum) 77 { 78 ReadF(inputfile,hdunum); 79 } 80 81 template <class T> 82 void FITS_SphereHEALPix<T>::WriteToFits() 70 71 template <class T> 72 void FITS_SphereHEALPix<T>::WriteToFits(FitsOutFile& os) 83 73 { 84 74 if(dobj_ == NULL) … … 130 120 Type[1]='\0'; 131 121 vector<int> dummy; 132 // fn.makeHeaderBntblOnFits(Type, Noms, nPix, 1, dvl, extname, dummy); 133 makeHeaderBntblOnFits(Type, Noms, nPix, 1, dvl, extname, dummy); 122 os.makeHeaderBntblOnFits(Type, Noms, nPix, 1, dvl, extname, dummy); 134 123 delete [] Noms[0]; 135 124 delete [] Noms; 136 putColToFits(0, nPix, dobj_->pixels_.Data());125 os.putColToFits(0, nPix, dobj_->pixels_.Data()); 137 126 } 138 127 139 128 template <class T> 140 void FITS_SphereHEALPix<T>::ReadFromFits( )129 void FITS_SphereHEALPix<T>::ReadFromFits(FitsInFile& is) 141 130 { 142 131 if(dobj_ == NULL) 143 132 { 144 133 dobj_= new SphereHEALPix<T>; 145 dobj_->SetTemp(true); 146 ownobj= true; 134 ownobj_= true; 147 135 } 148 136 149 137 150 138 int nbcols, nbentries; 151 // nbcols = fn.NbColsFromFits(); 152 nbcols = NbColsFromFits(); 139 nbcols = is.NbColsFromFits(); 153 140 if (nbcols != 1) 154 141 { 155 142 throw IOExc("le fichier fits n'est pas une sphere Healpix"); 156 143 } 157 // const DVList* dvl = &fn.DVListFromFits(); 158 // DVList dvl=fn.DVListFromFits(); 159 DVList dvl=DVListFromFits(); 160 // dvl.Print(); 161 // nbentries = fn.NentriesFromFits(0); 162 nbentries = NentriesFromFits(0); 144 DVList dvl=is.DVListFromFits(); 145 nbentries = is.NentriesFromFits(0); 163 146 int lastpix=dvl.GetI("LASTPIX"); 164 147 if (lastpix>0) … … 211 194 // On lit les DataBlocks; 212 195 dobj_->pixels_.ReSize(nPix); 213 // fn.GetSingleColumn(dobj_->pixels_.Data(),nPix); 214 GetSingleColumn(dobj_->pixels_.Data(),nPix); 196 is.GetSingleColumn(dobj_->pixels_.Data(),nPix); 215 197 216 198 // on effectue le decoupage en tranches 217 199 dobj_->SetThetaSlices(); 218 // dobj_->Info()=fn.DVListFromFits(); 219 dobj_->Info()=DVListFromFits(); 200 dobj_->Info()=is.DVListFromFits(); 220 201 221 202 -
trunk/SophyaExt/FitsIOServer/fitsspherehealpix.h
r1047 r1136 17 17 ////////////////////////////////////////////////////////////////////// 18 18 template <class T> 19 class FITS_SphereHEALPix : public Fits File19 class FITS_SphereHEALPix : public FitsIOHandler 20 20 { 21 21 public: … … 30 30 31 31 inline operator SphereHEALPix<T>() { return(*dobj_); } 32 void Read(char inputfile[],int hdunum=2);33 void Write(char outputfile[], bool Oldfile=false);34 32 35 33 protected: 36 34 37 35 //virtual void ReadFromFits(FitsFile& fn); 38 virtual void ReadFromFits( );39 virtual void WriteToFits( );36 virtual void ReadFromFits(FitsInFile& is); 37 virtual void WriteToFits(FitsOutFile& os) ; 40 38 SphereHEALPix<T>* dobj_; 41 bool ownobj ;39 bool ownobj_; 42 40 }; 43 41 -
trunk/SophyaExt/FitsIOServer/fitstarray.cc
r1047 r1136 12 12 FITS_TArray<T>::FITS_TArray() 13 13 { 14 dobj_= new TArray<T>;15 ownobj =true;14 dobj_= NULL; 15 ownobj_=false; 16 16 } 17 17 … … 19 19 FITS_TArray<T>::FITS_TArray(char inputfile[],int hdunum) 20 20 { 21 dobj_= new TArray<T>;22 ownobj =true;23 Read F(inputfile,hdunum);21 dobj_=NULL; 22 ownobj_=false; 23 Read(inputfile,hdunum); 24 24 } 25 25 … … 27 27 FITS_TArray<T>::FITS_TArray(const TArray<T> & obj) 28 28 { 29 dobj_ = new TArray<T>(obj);30 ownobj =true;29 dobj_ = new TArray<T>(obj); 30 ownobj_=true; 31 31 } 32 32 … … 35 35 { 36 36 dobj_ = obj; 37 ownobj =false;37 ownobj_=false; 38 38 } 39 39 … … 42 42 FITS_TArray<T>::~FITS_TArray() 43 43 { 44 if (ownobj && dobj_) delete dobj_;44 if (ownobj_ && dobj_) delete dobj_; 45 45 } 46 47 template <class T>48 void FITS_TArray<T>::Write(char outputfile[], bool OldFile)49 {50 WriteF(outputfile, OldFile);51 }52 53 46 54 47 … … 59 52 } 60 53 54 61 55 template <class T> 62 void FITS_TArray<T>::ReadFromFits() 56 void FITS_TArray<T>::SetDataObj(AnyDataObj & o) 57 { 58 TArray<T>* po = dynamic_cast< TArray<T>* >(& o); 59 if (po == NULL) return; 60 if (ownobj_ && dobj_) delete dobj_; 61 dobj_ = po; 62 ownobj_ = false; 63 } 64 65 66 67 template <class T> 68 void FITS_TArray<T>::ReadFromFits(FitsInFile& is) 63 69 { 64 65 // if (!fn.IsFitsImage()) 66 if (!IsFitsImage()) 70 if (!is.IsFitsImage()) 67 71 { 68 72 throw PException("ReadFromFits: the fits file seems not to be an image"); 69 73 } 70 // int dimension = fn.nbDimOfImage(); 71 int dimension = nbDimOfImage(); 74 int dimension = is.nbDimOfImage(); 72 75 cout << " dimension de l'image a lire: " << dimension << endl; 73 76 74 77 uint_4* siz = new uint_4[dimension]; 75 // for (int k=0; k< dimension; k++) siz[k] = fn.dimOfImageAxes()[k]; 76 for (int k=0; k< dimension; k++) siz[k] = dimOfImageAxes()[k]; 78 for (int k=0; k< dimension; k++) siz[k] = is.dimOfImageAxes()[k]; 77 79 if(dobj_ == NULL) 78 dobj_ = new TArray<T>(dimension,siz); 80 { 81 dobj_ = new TArray<T>(dimension,siz); 82 ownobj_ = true; 83 } 79 84 else 80 85 dobj_->ReSize(dimension,siz); 81 86 82 87 delete [] siz; 83 // if (dobj_->Size() != fn.nbOfImageData() ) 84 if (dobj_->Size() != nbOfImageData() ) 88 if (dobj_->Size() != is.nbOfImageData() ) 85 89 { 86 90 cout << " total size of TArray: " << dobj_->Size() << endl; 87 cout << " total size from fits file: " << nbOfImageData() << endl;91 cout << " total size from fits file: " << is.nbOfImageData() << endl; 88 92 throw PException("ReadFromFits: size conflict"); 89 93 } 90 94 // On lit le tableau 91 // fn.GetSingleColumn( dobj_->Data(),dobj_->Size()); 92 GetSingleColumn( dobj_->Data(),dobj_->Size()); 95 is.GetSingleColumn( dobj_->Data(),dobj_->Size()); 93 96 94 97 } 95 98 96 99 97 98 void FITS_TArray<T>::WriteToFits( )100 template <class T> 101 void FITS_TArray<T>::WriteToFits(FitsOutFile& os) 99 102 { 100 103 if(dobj_ == NULL) return; … … 130 133 } 131 134 cout << " nombre total d'elements a copier " << nbels << endl; 132 // fn.makeHeaderImageOnFits(type, nbdim, naxisn); 133 makeHeaderImageOnFits(type, nbdim, naxisn); 135 os.makeHeaderImageOnFits(type, nbdim, naxisn); 134 136 if (!dobj_->IsPacked()) 135 137 { … … 144 146 145 147 } 146 // fn.putImageToFits(nbels, dobj_->Data()); 147 putImageToFits(nbels, dobj_->Data()); 148 os.putImageToFits(nbels, dobj_->Data()); 148 149 149 150 delete [] naxisn; -
trunk/SophyaExt/FitsIOServer/fitstarray.h
r1047 r1136 20 20 21 21 template <class T> 22 class FITS_TArray : public Fits File{22 class FITS_TArray : public FitsIOHandler { 23 23 24 24 public: … … 30 30 virtual ~FITS_TArray(); 31 31 virtual AnyDataObj* DataObj(); 32 virtual void SetDataObj(AnyDataObj & o); 32 33 inline operator TArray<T>() { return(*dobj_); } 33 void Write(char outputfile[], bool OldFile=false);34 34 35 35 protected : 36 36 37 //void ReadFromFits(FitsFile& fn); 38 void ReadFromFits(); 39 void WriteToFits(); 37 void ReadFromFits(FitsInFile& is); 38 void WriteToFits(FitsOutFile& os) ; 40 39 41 40 TArray<T> * dobj_; 42 bool ownobj ;41 bool ownobj_; 43 42 }; 44 43 ////////////////////////////////////////////////////////////////// -
trunk/SophyaExt/FitsIOServer/fitsxntuple.cc
r1047 r1136 23 23 ownobj_ = true; 24 24 25 Read F(inputfile,hdunum);25 Read(inputfile,hdunum); 26 26 } 27 27 … … 41 41 FITS_XNTuple::~FITS_XNTuple() 42 42 { 43 Clean();44 }45 46 void FITS_XNTuple::Clean()47 {48 if (dcolumn_ != NULL) delete [] dcolumn_;49 if (fcolumn_ != NULL) delete [] fcolumn_;50 if (icolumn_ != NULL) delete [] icolumn_;51 if (ccolumn_ != NULL)52 {53 if (dobj_ != NULL)54 {55 for (int k=0; k<dobj_->NEntry(); k++) delete [] ccolumn_[k];56 delete [] ccolumn_;57 }58 else59 {60 cout << "FITS_XNTuple, destructeur: bizarre, ccolumn non vide, sans objet?" << endl;; }61 }62 43 if (ownobj_ && dobj_ != NULL) delete dobj_; 63 44 } 64 45 65 void FITS_XNTuple::Read(char inputfile[],int hdunum)66 {67 ReadF(inputfile,hdunum);68 }69 46 70 47 void FITS_XNTuple::ReadLines(char inputfile[],int firstLine, int numberOfLines,int hdunum) … … 72 49 fistLineToBeRead_ = firstLine; 73 50 numberOfLinesToBeRead_ = numberOfLines; 74 ReadF(inputfile,hdunum); 75 // return dobj_; 76 } 77 78 79 void FITS_XNTuple::Write(char outputfile[], bool OldFile) 80 { 81 WriteF(outputfile, OldFile); 82 } 51 Read(inputfile,hdunum); 52 } 53 54 83 55 84 void FITS_XNTuple::ReadFromFits( )56 void FITS_XNTuple::ReadFromFits(FitsInFile& is) 85 57 { 86 // if (!fn.IsFitsTable()) 87 if (!IsFitsTable()) 58 if (!is.IsFitsTable()) 88 59 { 89 60 throw PException("ReadFromFits: the fits file seems not to be a bintable nor ASCII table"); 90 61 } 91 62 int nbcols, nbentries; 92 // nbcols = fn.NbColsFromFits(); 93 nbcols = NbColsFromFits(); 63 nbcols = is.NbColsFromFits(); 94 64 nbentries = 0; 95 65 int k; 96 // for (k=0; k<nbcols; k++) nbentries=max( nbentries, fn.NentriesFromFits(k) ); 97 for (k=0; k<nbcols; k++) nbentries=max( nbentries, NentriesFromFits(k) ); 66 for (k=0; k<nbcols; k++) nbentries=max( nbentries, is.NentriesFromFits(k) ); 98 67 99 68 // … … 111 80 for (k=0; k<nbcols;k++) 112 81 { 113 // char ss= fn.ColTypeFromFits(k); 114 char ss= ColTypeFromFits(k); 82 char ss= is.ColTypeFromFits(k); 115 83 if (ss == 'D') DfitsCol.push_back(k); 116 84 else if (ss == 'E') FfitsCol.push_back(k); … … 127 95 { 128 96 ColName[compt] = new char[LONNOM+1]; 129 // strncpy(ColName[compt], fn.ColNameFromFits(DfitsCol[k]).c_str(), LONNOM); 130 strncpy(ColName[compt], ColNameFromFits(DfitsCol[k]).c_str(), LONNOM); 97 strncpy(ColName[compt], is.ColNameFromFits(DfitsCol[k]).c_str(), LONNOM); 131 98 ColName[compt++][ LONNOM] = '\0'; 132 99 } … … 134 101 { 135 102 ColName[compt] = new char[LONNOM+1]; 136 // strncpy(ColName[compt], fn.ColNameFromFits(FfitsCol[k]).c_str(), LONNOM); 137 strncpy(ColName[compt], ColNameFromFits(FfitsCol[k]).c_str(), LONNOM); 103 strncpy(ColName[compt], is.ColNameFromFits(FfitsCol[k]).c_str(), LONNOM); 138 104 ColName[compt++][ LONNOM] = '\0'; 139 105 } … … 141 107 { 142 108 ColName[compt] = new char[LONNOM+1]; 143 // strncpy(ColName[compt], fn.ColNameFromFits(IfitsCol[k]).c_str(), LONNOM); 144 strncpy(ColName[compt], ColNameFromFits(IfitsCol[k]).c_str(), LONNOM); 109 strncpy(ColName[compt], is.ColNameFromFits(IfitsCol[k]).c_str(), LONNOM); 145 110 ColName[compt++][ LONNOM] = '\0'; 146 111 } … … 148 113 { 149 114 ColName[compt] = new char[LONNOM+1]; 150 // strncpy(ColName[compt], fn.ColNameFromFits(SfitsCol[k]).c_str(), LONNOM); 151 strncpy(ColName[compt], ColNameFromFits(SfitsCol[k]).c_str(), LONNOM); 115 strncpy(ColName[compt], is.ColNameFromFits(SfitsCol[k]).c_str(), LONNOM); 152 116 ColName[compt++][LONNOM] = '\0'; 153 117 } … … 193 157 cligne = new char*[SfitsCol.size()]; 194 158 int taille_des_chaines=0; 195 // for (k=0; k< SfitsCol.size(); k++) taille_des_chaines = max( taille_des_chaines, fn.ColStringLengthFromFits(SfitsCol[k]) ); 196 for (k=0; k< SfitsCol.size(); k++) taille_des_chaines = max( taille_des_chaines, ColStringLengthFromFits(SfitsCol[k]) ); 159 for (k=0; k< SfitsCol.size(); k++) taille_des_chaines = max( taille_des_chaines, is.ColStringLengthFromFits(SfitsCol[k]) ); 197 160 for (k=0; k<SfitsCol.size(); k++) cligne[k]=new char[taille_des_chaines+1]; 198 161 } … … 212 175 for (numLigne=firstln; numLigne < lastln; numLigne++) 213 176 { 214 // fn.GetBinTabLine(numLigne, dligne, fligne, iligne, cligne ); 215 GetBinTabLine(numLigne, dligne, fligne, iligne, cligne ); 177 is.GetBinTabLine(numLigne, dligne, fligne, iligne, cligne ); 216 178 dobj_->Fill(dligne, fligne, iligne, cligne); 217 179 } … … 221 183 for (k=0; k< SfitsCol.size(); k++) delete [] cligne[k]; 222 184 delete [] cligne; 223 // dobj_->Info()=fn.DVListFromFits(); 224 dobj_->Info()=DVListFromFits(); 225 226 } 227 void FITS_XNTuple::WriteToFits() 185 dobj_->Info()=is.DVListFromFits(); 186 187 } 188 void FITS_XNTuple::WriteToFits(FitsOutFile& os) 228 189 { 229 190 if(dobj_ == NULL) … … 270 231 vector<int> StringSizes(dobj_->NSVar()); 271 232 for (k=0; k< StringSizes.size(); k++) StringSizes[k]=dobj_->mStrSz; 272 // la librairie fitsio ecrit colonne par colonne 273 // fn.makeHeaderBntblOnFits(types, Noms, nrows, ncols, dvl, extname,StringSizes); 274 makeHeaderBntblOnFits(types, Noms, nrows, ncols, dvl, extname,StringSizes); 233 os.makeHeaderBntblOnFits(types, Noms, nrows, ncols, dvl, extname,StringSizes); 275 234 for (k=0; k< ncols; k++) 276 235 { … … 279 238 delete [] Noms; 280 239 delete [] types; 240 241 281 242 compt=0; 282 for (k=0; k<dobj_->NDVar();k++) 283 { 284 putColToFits(compt, dobj_->NEntry(), getColDFromObj(compt)); 285 compt++; 286 } 287 for (k=0; k<dobj_->NFVar();k++) 288 { 289 putColToFits(compt, dobj_->NEntry(), getColFFromObj(compt)); 290 compt++; 291 } 292 for (k=0; k<dobj_->NIVar();k++) 293 { 294 putColToFits(compt, dobj_->NEntry(), getColIFromObj(compt)); 295 compt++; 296 } 297 for (k=0; k<dobj_->NSVar();k++) 298 { 299 putColToFits(compt, dobj_->NEntry(), getColSFromObj(compt)); 300 compt++; 301 } 302 } 303 double* FITS_XNTuple::getColDFromObj(int colNr) 304 { 305 if (dcolumn_ != NULL) 306 { 307 delete [] dcolumn_; 308 dcolumn_ = NULL; 309 } 310 dcolumn_ = new double[dobj_->NEntry()]; 311 for(int j = 0; j < dobj_->NEntry(); j++) dcolumn_[j]= dobj_->GetDVal(j,colNr); 312 return dcolumn_; 313 } 314 315 float* FITS_XNTuple::getColFFromObj(int colNr) 316 { 317 if (fcolumn_ != NULL) 318 { 319 delete [] fcolumn_; 320 fcolumn_ = NULL; 321 } 322 fcolumn_ = new float[dobj_->NEntry()]; 323 for(int j = 0; j < dobj_->NEntry(); j++) fcolumn_[j]= dobj_->GetFVal(j,colNr); 324 return fcolumn_; 325 } 326 327 int* FITS_XNTuple::getColIFromObj(int colNr) 328 { 329 if (icolumn_ != NULL) 330 { 331 delete [] icolumn_; 332 icolumn_ = NULL; 333 } 334 icolumn_ = new int[dobj_->NEntry()]; 335 for(int j = 0; j < dobj_->NEntry(); j++) icolumn_[j]= dobj_->GetIVal(j,colNr); 336 return icolumn_; 337 } 338 char** FITS_XNTuple::getColSFromObj(int colNr) 339 { 340 if (ccolumn_ != NULL) 341 { 342 for (int k=0; k<dobj_->NEntry(); k++) delete [] ccolumn_[k]; 343 delete [] ccolumn_; 344 ccolumn_ = NULL; 345 } 346 ccolumn_ = new char*[dobj_->NEntry()]; 347 for(int j = 0; j < dobj_->NEntry(); j++) 348 { 349 string s= dobj_->GetSVal(j,colNr); 350 ccolumn_[j] = new char[dobj_->mStrSz+1]; 351 strcpy(ccolumn_[j],s.c_str()); 352 } 353 return ccolumn_; 354 } 243 if (dobj_->NDVar() > 0) 244 { 245 double* dcolumn = new double[nrows]; 246 for (k=0; k<dobj_->NDVar();k++) 247 { 248 for(int j = 0; j < nrows; j++) dcolumn[j]= dobj_->GetDVal(j,compt); 249 os.putColToFits(compt, nrows, dcolumn); 250 compt++; 251 } 252 delete [] dcolumn; 253 } 254 255 if (dobj_->NFVar() > 0) 256 { 257 float* fcolumn = new float[nrows]; 258 for (k=0; k<dobj_->NFVar();k++) 259 { 260 for(int j = 0; j < nrows; j++) fcolumn[j]= dobj_->GetFVal(j,compt); 261 os.putColToFits(compt, nrows, fcolumn); 262 compt++; 263 } 264 delete [] fcolumn; 265 } 266 267 if (dobj_->NIVar() > 0) 268 { 269 int* icolumn = new int[nrows]; 270 for (k=0; k<dobj_->NIVar();k++) 271 { 272 for(int j = 0; j < nrows; j++) icolumn[j]= dobj_->GetIVal(j,compt); 273 os.putColToFits(compt, nrows, icolumn); 274 compt++; 275 } 276 delete [] icolumn; 277 } 278 279 if (dobj_->NSVar() > 0) 280 { 281 char** ccolumn = new char*[nrows]; 282 for (k=0; k<dobj_->NSVar();k++) 283 { 284 int j; 285 for(j = 0; j < nrows; j++) 286 { 287 string s= dobj_->GetSVal(j,compt); 288 ccolumn[j] = new char[dobj_->mStrSz+1]; 289 strcpy(ccolumn[j],s.c_str()); 290 } 291 os.putColToFits(compt, nrows, ccolumn); 292 compt++; 293 for(j = 0; j < nrows; j++) 294 { 295 delete [] ccolumn[j]; 296 ccolumn[j] = NULL; 297 } 298 } 299 delete [] ccolumn; 300 } 301 } -
trunk/SophyaExt/FitsIOServer/fitsxntuple.h
r1049 r1136 4 4 #ifndef FITSXNTuple_SEEN 5 5 #define FITSXNTuple_SEEN 6 #include "machdefs.h" 6 7 #include "xntuple.h" 7 8 #include "anydataobj.h" … … 15 16 /////////////////////////////////////////////////////////// 16 17 17 class FITS_XNTuple : public Fits File18 class FITS_XNTuple : public FitsIOHandler 18 19 { 19 20 … … 24 25 FITS_XNTuple(XNTuple* obj); 25 26 ~FITS_XNTuple(); 26 void Read(char inputfile[],int hdunum=2); 27 28 virtual AnyDataObj* DataObj() { return(dobj_); } 29 virtual void SetDataObj(AnyDataObj & o) 30 { 31 XNTuple* po = dynamic_cast< XNTuple* >(& o); 32 if (po == NULL) return; 33 if (ownobj_ && dobj_) delete dobj_; 34 dobj_ = po; 35 ownobj_ = false; 36 } 37 27 38 28 39 /*! … … 32 43 */ 33 44 void ReadLines(char inputfile[],int firstLine, int numberOfLines,int hdunum=2); 34 void Write(char outputfile[], bool OldFile=false);35 45 inline operator XNTuple() { return(*dobj_); } 36 46 inline XNTuple * getObj() { return(dobj_); } … … 39 49 40 50 // implementation de FitsFile 41 // virtual void ReadFromFits(FitsFile& fn); 42 virtual void ReadFromFits(); 43 virtual void WriteToFits(); 44 void* getColFromObj(int colNr); 45 double* getColDFromObj(int colNr); 46 float* getColFFromObj(int colNr); 47 int* getColIFromObj(int colNr); 48 char** getColSFromObj(int colNr); 51 virtual void ReadFromFits(FitsInFile& is); 52 virtual void WriteToFits(FitsOutFile& os) ; 49 53 50 54 private : 51 55 52 void Clean();53 56 54 57 inline void InitNull() … … 56 59 fistLineToBeRead_= -1; 57 60 numberOfLinesToBeRead_= -1; 58 dcolumn_ = NULL;59 fcolumn_ = NULL;60 icolumn_ = NULL;61 ccolumn_ = NULL;62 61 } 63 62 … … 67 66 int fistLineToBeRead_; 68 67 int numberOfLinesToBeRead_; 69 double* dcolumn_;70 float* fcolumn_;71 int* icolumn_;72 char** ccolumn_;73 68 }; 74 69 //////////////////////////////////////////////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.