Changeset 1771 in Sophya for trunk/SophyaExt/FitsIOServer
- Timestamp:
- Nov 16, 2001, 11:26:58 AM (24 years ago)
- Location:
- trunk/SophyaExt/FitsIOServer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fitsfile.cc
r1752 r1771 350 350 else hdunum_++; 351 351 } 352 getHeader ();352 getHeaderWithSophyaObject(); 353 353 if ( hdutype_ == FitsExtensionType_NULL ) 354 354 { … … 356 356 { 357 357 hdunum_++; 358 getHeader ();358 getHeaderWithSophyaObject(); 359 359 } 360 360 else … … 425 425 } 426 426 427 void FitsInFile::GetKeywordsFromHeader (int hdunum, list<FitsKeyword>& mots_cles) const 428 { 429 int status = 0; 430 int hdutype; 431 fits_movabs_hdu(fptr_,hdunum,&hdutype,&status); 432 if( status ) fits_report_error(stderr,status); 433 434 // get number of keywords 435 int nkeys,keypos; 436 fits_get_hdrpos(fptr_, &nkeys, &keypos,&status); 437 if( status ) fits_report_error(stderr,status); 438 // shift with the number of mandatory keywords 439 int num= 0; 440 // if primary header 441 if (hdunum == 1) 442 { 443 // read NAXIS 444 int naxis=0; 445 fits_read_key(fptr_,TINT,"NAXIS",&naxis,NULL,&status); 446 // number of mandatory keywords 447 num = naxis+3; 448 } 449 // extensions 450 else 451 { 452 if (hdutype == IMAGE_HDU) 453 { 454 // read NAXIS 455 int naxis=0; 456 fits_read_key(fptr_,TINT,"NAXIS",&naxis,NULL,&status); 457 // number of mandatory keywords 458 num = naxis+5; 459 } 460 else 461 if(hdutype == ASCII_TBL || hdutype == BINARY_TBL) 462 { 463 // number of mandatory keywords 464 num = 8; 465 } 466 } 467 int j; 468 char keyname[LEN_KEYWORD]; 469 char value[FLEN_VALUE]; 470 char comment[FLEN_COMMENT]; 471 for(j = num+1; j <= nkeys; j++) 472 { 473 char dtype; 474 fits_read_keyn(fptr_,j,keyname,value,comment,&status); 475 if(status) 476 { 477 fits_report_error(stderr,status); 478 status=0; 479 } 480 string kn(keyname); 481 string cm(comment); 482 string val(value); 483 FitsKeyword kw(kn, val, cm); 484 mots_cles.push_back(kw); 485 } 486 if (hdunum_ > 0) fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status); 487 488 } 427 489 void FitsInFile::GetImageParameters (fitsfile* fileptr,FitsDataType& dataType,int& naxis,vector<int>& naxisn) 428 490 { … … 482 544 } 483 545 484 void FitsInFile::getHeader ()546 void FitsInFile::getHeaderWithSophyaObject() 485 547 { 486 548 // si hdunum_ > 1 lit le header correspondant … … 526 588 else 527 589 { 528 cout << "WARNING (FitsInFile::getHeader ) : error during movabs" << endl;590 cout << "WARNING (FitsInFile::getHeaderWithSophyaObject) : error during movabs" << endl; 529 591 hdutype_= FitsExtensionType_ERROR; 530 592 status =0; … … 567 629 int status = 0; 568 630 hdunum_++; 569 getHeader ();631 getHeaderWithSophyaObject(); 570 632 if ( hdutype_ == FitsExtensionType_NULL ) 571 633 { … … 1928 1990 void FitsOutFile::appendInputHeader(FitsInFile& infits, int hdunum) 1929 1991 { 1992 1993 infits.GetKeywordsFromHeader(hdunum, mots_cles_); 1994 /* 1930 1995 int status = 0; 1931 1996 int hdutype; … … 1986 2051 mots_cles_.push_back(kw); 1987 2052 } 2053 */ 1988 2054 } 1989 2055 void FitsOutFile::writeAppendedHeaderOnFits() -
trunk/SophyaExt/FitsIOServer/fitsfile.h
r1703 r1771 105 105 inline void firstImageOnPrimaryHeader(bool choice) {imageOnPrimary_=choice;} 106 106 inline int currentHeaderIndex() {return hdunum_;} 107 inline fitsfile* fitsfilePtr() {return fptr_;}108 107 109 108 110 109 protected: 111 110 112 void ResetStatus(int& status) ; 113 static void printerror(int&) ; 114 static void printerror(int&,char* texte) ; 115 static void printerrorAndContinue(int& status, char* texte); 116 inline void InitNull() {fptr_ = NULL; hdutype_= FitsExtensionType_NULL; hdunum_ = 0; 117 fits_status_ = 0; imageOnPrimary_ = true;} 111 void ResetStatus(int& status) ; 112 static void printerror(int&) ; 113 static void printerror(int&,char* texte) ; 114 static void printerrorAndContinue(int& status, char* texte); 115 inline void InitNull() 116 { 117 fptr_ = NULL; 118 hdutype_= FitsExtensionType_NULL; 119 hdunum_ = 0; 120 fits_status_ = 0; imageOnPrimary_ = true; 121 } 122 inline fitsfile* fitsfilePtr() const {return fptr_;} 123 124 125 118 126 fitsfile *fptr_; /**< pointer to the FITS file, defined in fitsio.h */ 119 127 FitsExtensionType hdutype_; /**< image or bintable ? */ … … 145 153 inline const DVList& DVListFromFits() const { return dvl_;} 146 154 155 void GetKeywordsFromHeader (int hdunum, list<FitsKeyword>& mots_cles) const; 156 157 147 158 DVList DVListFromPrimaryHeader() const; 148 159 void moveToFollowingHeader(); … … 179 190 /*! \return data type of the current IMAGE extension */ 180 191 inline FitsFile::FitsDataType ImageType() const {return imageDataType_;} 192 181 193 182 194 … … 237 249 238 250 void InitNull(); 239 void getHeader ();251 void getHeaderWithSophyaObject(); 240 252 static void KeywordsIntoDVList(fitsfile* fileptr, DVList& dvl, int hdunum); 241 253 static void GetImageParameters (fitsfile* fileptr,FitsDataType& dataType,int& naxis,vector<int>& naxisn);
Note:
See TracChangeset
for help on using the changeset viewer.