Changeset 1047 in Sophya for trunk/SophyaExt/FitsIOServer/fitsfile.cc
- Timestamp:
- Jun 15, 2000, 12:22:23 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fitsfile.cc
r1045 r1047 33 33 nrows_ = 0; 34 34 nbcols_ = 0; 35 fits_status_ = 0; 35 36 naxisn_.clear(); 36 37 repeat_.clear(); … … 125 126 { 126 127 ReadFInit(flnm, hdunum); 127 /* 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 { 128 136 InitNull(); 129 137 int status = 0; … … 163 171 moveToFollowingHeader(); 164 172 } 165 */ 166 ReadFromFits(*this); 167 } 168 169 170 FitsFile* FitsFile::ReadFInit(char flnm[],int hdunum) 171 { 172 InitNull(); 173 int status = 0; 174 // hdutype_= 0; 175 176 fits_open_file(&fptr_,flnm,READONLY,&status); 177 if( status ) printerror( status ); 178 // 179 if (hdunum <= 1) 180 { 181 hdunum_ = 1; 182 // presence of image ? 183 int naxis= 0; 184 fits_read_key(fptr_,TINT,"NAXIS",&naxis,NULL,&status); 185 if( status ) printerror( status ); 186 if (naxis > 0 ) // there is an image 187 { 188 hdutype_ = IMAGE_HDU; 189 GetImageParameters (fptr_, bitpix_, naxis_, naxisn_); 190 nbData_ = 1; 191 int k; 192 for (k=0; k<naxis_; k++) if (naxisn_[k] > 0) nbData_ *= naxisn_[k]; 193 KeywordsIntoDVList(fptr_, dvl_,hdunum_); 194 } 195 else 196 { 197 throw PException(" first header : no image, probably error in hdunum"); 198 } 199 // 200 } 201 else 202 { 203 hdunum_ = hdunum-1; 204 int hdutype; 205 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status); 206 if( status ) printerror( status,":FitsFile::ReadF : erreur movabs"); 207 moveToFollowingHeader(); 208 } 209 return this; 210 } 211 212 void FitsFile::ReadFFromFits() 213 { 214 ReadFromFits(*this); 215 } 173 // return this; 174 } 175 216 176 void FitsFile::moveToFollowingHeader() 217 177 { … … 261 221 262 222 } 263 WriteToFits(*this); 223 // WriteToFits(*this); 224 WriteToFits(); 264 225 } 265 226 void FitsFile::GetSingleColumn(double* map, int nentries) const … … 636 597 637 598 638 void FitsFile::GetBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char ** cdata) const599 void FitsFile::GetBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char ** cdata) 639 600 { 640 601 int status= 0; … … 656 617 case 'D' : 657 618 fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull,&ddata[dcount++],&anull,&status); 658 if( status ) printerror( status,"GetBinTabLine : erreur lecture de colonne double" );659 619 break; 660 620 case 'E' : 661 621 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&fdata[fcount++],&anull,&status); 662 if( status ) printerror( status,"GetBinTabLine : erreur lecture de colonne float" );663 622 break; 664 623 case 'I' : 665 624 fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&idata[icount++], 666 625 &anull,&status); 667 if( status ) printerror( status,"GetBinTabLine : erreur lecture de colonne tint" );668 626 break; 669 627 case 'S' : 670 628 fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&cdata[ccount++],&anull,&status); 671 if( status ) printerror( status,"GetBinTabLine : erreur lecture de colonne char" );672 629 break; 673 630 } 674 } 675 } 676 677 void FitsFile::GetBinTabLine(int NoLine, float* fdata) const 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) 678 641 { 679 642 int status= 0; … … 685 648 { 686 649 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&fdata[ncol],&anull,&status); 687 if( status ) printerror( status,"GetBinTabLine : erreur lecture de colonne float" ); 650 if (status) 651 { 652 ResetStatus(status); 653 break; 654 } 655 // if( status ) printerror( status,"GetBinTabLine : erreur lecture de colonne float" ); 688 656 } 689 657 } … … 1066 1034 1067 1035 1068 void FitsFile::readheader()1069 //*************************************/1070 //* Print out all the header keywords */1071 //*************************************/1072 {1073 // standard string lengths defined in fitsioc.h1074 char card[FLEN_CARD];1075 1076 int status = 0;1077 1078 // get the number of keywords1079 int nkeys, keypos;1080 if( fits_get_hdrpos(fptr_,&nkeys,&keypos,&status) )1081 printerror( status );1082 1083 cout << " Header listing for HDU : " << hdunum_ << endl;1084 int jj;1085 for(jj = 1; jj <= nkeys; jj++)1086 {1087 if( fits_read_record(fptr_,jj,card,&status) )1088 printerror( status );1089 1090 // print the keyword card1091 cout << card << endl;1092 }1093 cout << "END" << endl;1094 }1095 1036 1096 1037 … … 1143 1084 throw IOExc("FitsFile:: error FITSIO status"); 1144 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 }
Note:
See TracChangeset
for help on using the changeset viewer.