Changeset 2456 in Sophya for trunk/SophyaExt/FitsIOServer
- Timestamp:
- Nov 18, 2003, 1:06:24 AM (22 years ago)
- Location:
- trunk/SophyaExt/FitsIOServer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fabtcolread.cc
r2453 r2456 43 43 { 44 44 FitsFN = ""; 45 NHdu = -1; 45 NHdu = IHdu = HduType = 0; 46 HasBeenPos = false; 46 47 FitsPtr = NULL; 47 48 } … … 52 53 FitsOpenFile::FitsOpenFile(FitsOpenFile& fof) 53 54 { 54 Init(fof. GetFileName().c_str());55 Init(fof.FileName().c_str()); 55 56 } 56 57 … … 62 63 Delete(); 63 64 FitsFN = ""; 64 NHdu = 0; 65 NHdu = IHdu = HduType = 0; 66 HasBeenPos = false; 65 67 } 66 68 … … 80 82 void FitsOpenFile::Init(const char* fname) 81 83 { 82 // Parametres Generaux 83 FitsFN = fname; 84 NHdu = 0; 85 FitsPtr = NULL; 86 87 // Ouverture du fichier 88 if(FitsFN.size() <= 0 ) 89 throw ParmError("FitsOpenFile::Init: Fits file name error\n"); 90 91 int sta = 0; 92 if(fits_open_file(&FitsPtr,FitsFN.c_str(),READONLY,&sta)) { 93 printerror(sta); 94 FitsPtr = NULL; 95 throw NullPtrError("FitsOpenFile::Init: Error opening Fits file\n"); 96 } 97 98 // Get number of hdu 99 if(fits_get_num_hdus(FitsPtr,&NHdu,&sta)) { 100 printerror(sta); 101 NHdu = 0; 102 Delete(); 103 throw NotAvailableOperation("FitsOpenFile::Init: Error getting NHdu\n"); 104 } 105 if(NHdu<=0) { 106 Delete(); 107 throw SzMismatchError("FitsOpenFile::Init: Bad NHdu\n"); 108 } 109 110 } 84 // Parametres Generaux 85 FitsFN = fname; 86 NHdu = IHdu = HduType = 0; 87 HasBeenPos = false; 88 FitsPtr = NULL; 89 90 // Ouverture du fichier 91 if(FitsFN.size() <= 0 ) 92 throw ParmError("FitsOpenFile::Init: Fits file name error\n"); 93 94 int sta = 0; 95 if(fits_open_file(&FitsPtr,FitsFN.c_str(),READONLY,&sta)) { 96 printerror(sta); 97 FitsPtr = NULL; 98 throw NullPtrError("FitsOpenFile::Init: Error opening Fits file\n"); 99 } 100 101 // Get number of hdu 102 if(fits_get_num_hdus(FitsPtr,&NHdu,&sta)) { 103 printerror(sta); 104 NHdu = 0; 105 Delete(); 106 throw NotAvailableOperation("FitsOpenFile::Init: Error getting NHdu\n"); 107 } 108 if(NHdu<=0) { 109 Delete(); 110 throw SzMismatchError("FitsOpenFile::Init: Bad NHdu\n"); 111 } 112 113 MoveToHDU(1); 114 } 115 116 /*! Move to an HDU 117 \param ihdu: hdu number to move 118 \warning ihdu = [1,nhdu] 119 \return 0 if positionning failed, ihdu if success 120 */ 121 int FitsOpenFile::MoveToHDU(int ihdu) 122 { 123 if(FitsPtr==NULL) 124 throw NullPtrError("FitsOpenFile::MoveToHDU: no fits file open FitsPtr==NULL\n"); 125 int ihdusave = IHdu; 126 if(ihdu<=0) ihdu=1; if(ihdu>NHdu) ihdu=NHdu; 127 int sta=0; 128 if(fits_movabs_hdu(FitsPtr,ihdu,&HduType,&sta)) { 129 printerror(sta); 130 // On se repositionne ou on etait 131 fits_movabs_hdu(FitsPtr,ihdusave,&HduType,&sta); 132 IHdu = ihdusave; 133 } else IHdu = ihdu; 134 return IHdu; 135 } 136 137 /*! Move to the first HDU of a certain type 138 \param hdutype: type of the hdu 139 \param hdudeb: start at that hdu 140 \return the type of HDU the file is positionned 141 */ 142 int FitsOpenFile::MoveToFirst(int hdutype,int ihdudeb) 143 { 144 if(ihdudeb<=0) ihdudeb=1; if(ihdudeb>NHdu) ihdudeb=NHdu; 145 int ihdusave = IHdu; 146 for(int ihdu=ihdudeb;ihdu<=NHdu;ihdu++) { 147 MoveToHDU(ihdu); 148 if(HduType==hdutype) break; 149 } 150 // Si echec, on se repositionne ou on etait 151 if(HduType!=hdutype) MoveToHDU(ihdusave); 152 return HduType; 153 } 154 155 /*! Move to the last HDU of a certain type 156 \param hdutype: type of the hdu 157 \param hdudeb: stop at that hdu 158 \return the type of HDU the file is positionned 159 */ 160 int FitsOpenFile::MoveToLast(int hdutype,int ihdudeb) 161 { 162 if(ihdudeb<=0) ihdudeb=1; if(ihdudeb>NHdu) ihdudeb=NHdu; 163 int ihdusave = IHdu; 164 for(int ihdu=NHdu;ihdu>=ihdudeb;ihdu--) { 165 MoveToHDU(ihdu); 166 if(HduType==hdutype) break; 167 } 168 // Si echec, on se repositionne ou on etait 169 if(HduType!=hdutype) MoveToHDU(ihdusave); 170 return HduType; 171 } 172 173 /*! Print */ 174 void FitsOpenFile::Print(void) 175 { 176 cout<<"FitsOpenFile::Print: "<<FitsFN 177 <<" hdu="<<IHdu<<"/"<<NHdu<<" type="<<HduType 178 <<" hasbeenpos="<<HasBeenPos<<endl; 179 } 111 180 112 181 ////////////////////////////////////////////////////////////// … … 121 190 double FitsOpenFile::ReadKey(fitsfile *fitsptr,char *keyname) 122 191 { 123 if(keyname==NULL ) return 0.;192 if(keyname==NULL || fitsptr==NULL) return 0.; 124 193 int sta=0; double val=0.; 125 194 if(fits_read_key(fitsptr,TDOUBLE,keyname,&val,NULL,&sta)) … … 136 205 long FitsOpenFile::ReadKeyL(fitsfile *fitsptr,char *keyname) 137 206 { 138 if(keyname==NULL ) return 0;207 if(keyname==NULL || fitsptr==NULL) return 0; 139 208 int sta=0; long val=0; 140 209 if(fits_read_key(fitsptr,TLONG,keyname,&val,NULL,&sta)) … … 151 220 string FitsOpenFile::ReadKeyS(fitsfile *fitsptr,char *keyname) 152 221 { 153 if(keyname==NULL ) return (string)"";222 if(keyname==NULL || fitsptr==NULL) return (string)""; 154 223 int sta=0; char val[FLEN_VALUE]; 155 224 if(fits_read_key(fitsptr,TSTRING,keyname,val,NULL,&sta)) … … 189 258 // Select the column to be read 190 259 FitsABTColRd fbt(fof,"BoloMuv_28",0,1000,1,3); 260 FitsABTColRd fbt2(fof,"BoloMuv_29",0,1000,1,3); 191 261 fbt.SetDebug(3); 192 262 fbt.Print(3); … … 194 264 for(long i=0;i<fbt.GetNbLine();i++) { 195 265 double x = fbt.Read(i); 196 if(i%lpmod==0) cout<<i<<": "<<x<<endl; 266 double y = fbt2.Read(i); 267 if(i%lpmod==0) cout<<i<<": "<<x<<", "<<y<<endl; 197 268 } 198 269 // Read into a vector … … 203 274 n = fbt.Read(10,-1,data); 204 275 cout<<"Number of values read: "<<n<<endl; 276 TVector<double> data2; 277 fbt2.Read(32,50,data); 205 278 // Close the fits file 206 279 delete fof; … … 218 291 \param lp : debug level 219 292 \verbatim 220 - if ihdu=0 or ihdu>nhdu first binary or ASCII table is taken 293 - if ihdu<=0 first BINARY or ASCII table is taken 294 - if ihdu>nhdu ihdu is set to nhdu 221 295 - bsens>0 read forward 222 296 bsens<0 read backward … … 247 321 { 248 322 Init(fbt.GetFitsOpenFile(),fbt.GetColLabel().c_str() 249 ,fbt.GetColNum(),fbt. GetHDU()323 ,fbt.GetColNum(),fbt.HDU() 250 324 ,fbt.GetBLen(),fbt.GetBSens(),fbt.DbgLevel); 251 325 } … … 254 328 FitsABTColRd::FitsABTColRd() 255 329 { 256 FitsFN = "";257 330 ColLabel = ""; ColTUnit = ""; ColTForm = ""; 258 331 ColNum = -1; ColTypeCode = 0; 259 IHdu = 0; NHdu = 0; HduType = 0;260 332 NBcol = 0; NBline = 0; 261 333 SetNulVal(); SetDebug(0); … … 271 343 { 272 344 // Initialisation des Parametres Generaux 273 FitsFN = ""; 274 ColLabel = collabel; 275 ColTUnit = ""; 276 ColTForm = ""; 277 ColNum = colnum; 278 ColTypeCode = 0; 279 IHdu = ihdu; 280 NHdu = 0; 281 HduType = 0; 282 NBcol = 0; 283 NBline = 0; 284 SetNulVal(); 285 SetDebug(lp); 345 ColLabel=collabel; ColTUnit=""; ColTForm=""; ColNum=colnum; ColTypeCode=0; 346 NBcol = 0; NBline = 0; 347 SetNulVal(); SetDebug(lp); 286 348 NFitsRead = 0; 287 FitsOF = NULL; 288 FitsPtr = NULL; 349 FitsOF = NULL; FitsPtr = NULL; 289 350 LineDeb = LineFin = -1; 290 351 Buffer = NULL; 291 ChangeBuffer(blen,bsens);292 352 293 353 // Caracteristiques du FitsOpenFile 294 354 FitsOF = fof; 295 if(FitsOF==NULL) { 296 Delete(); 355 if(FitsOF==NULL) 297 356 throw NullPtrError("FitsABTColRd::Init: FitsOpenFile pointer is NULL\n"); 298 } 357 299 358 FitsPtr = FitsOF->GetFitsPtr(); 300 if(FitsPtr==NULL) { 301 Delete(); 359 if(FitsPtr==NULL) 302 360 throw NullPtrError("FitsABTColRd::Init: FitsPtr pointer is NULL\n"); 303 }304 NHdu = FitsOF->GetNHdu();305 if(DbgLevel>1) cout<<"FitsABTColRd::Init NHdu="<<NHdu<<endl;306 if(NHdu<=0) {307 Delete();308 throw SzMismatchError("FitsABTColRd::Init: Bad NHdu\n");309 }310 FitsFN = FitsOF->GetFileName();311 if(FitsFN.size() <= 0 ) {312 Delete();313 throw ParmError("FitsABTColRd::Init: Fits file name error\n");314 }315 361 316 362 int sta = 0; 363 if(ihdu<0) ihdu=0; if(ihdu>NHDU()) ihdu=NHDU(); 317 364 318 365 // Get HDU for bin/ascii table 319 // si IHdu <=0 || >NHdu on cherche la 1ere bin/ascii table 320 // sinon on se positionne sur IHdu 321 if(IHdu<=0 || IHdu>NHdu) 322 for(int ihdu=1;ihdu<=NHdu;ihdu++) { 323 if(fits_movabs_hdu(FitsPtr,ihdu,&HduType,&sta)) FitsOpenFile::printerror(sta); 324 if(DbgLevel>1) cout<<"...Init ihdu=" 325 <<ihdu<<" HduType="<<HduType<<endl; 326 if(HduType==BINARY_TBL || HduType==ASCII_TBL) {IHdu = ihdu; break;} 366 // ATTENTION: le fichier est ouvert mais non positionne sur un HDU, 367 // une classe utilisant ce fichier doit le positionner sur un HDU. 368 // Par contre, si une autre classe utilise ce meme FitsOpenFile, 369 // elle ne peut le positionner que sur ce meme HDU ! 370 if(FitsOF->GetPosStatus()==false) { 371 if(ihdu==0) { // find the first BINARY then the first ASCII 372 int rc = FitsOF->MoveToFirst(BINARY_TBL); 373 if(rc!=BINARY_TBL) FitsOF->MoveToFirst(ASCII_TBL); 374 } else { 375 int rc = FitsOF->MoveToHDU(ihdu); 376 if(rc!=ihdu) 377 throw RangeCheckError("FitsABTColRd::Init: Error moving to requested HDU\n"); 327 378 } 328 if(IHdu<=0 || IHdu>NHdu) { 329 cout<<"NO BINARY or ASCII hdu found"<<endl; 330 IHdu = 0; Delete(); 331 throw TypeMismatchExc("FitsABTColRd::Init: NO BINARY or ASCII hdu found\n"); 332 } 333 if(fits_movabs_hdu(FitsPtr,IHdu,&HduType,&sta)) { 334 FitsOpenFile::printerror(sta); Delete(); 335 throw RangeCheckError("FitsABTColRd::Init: Error moving to requested HDU\n"); 336 } 337 if(HduType!=BINARY_TBL && HduType!=ASCII_TBL) { 338 Delete(); 379 } else { // Fits file has already been positionned 380 if(ihdu>0 && ihdu!=HDU()) 381 throw RangeCheckError("FitsABTColRd::Init: file already posit. at another HDU\n"); 382 } 383 384 // Check HDUType and set position status to TRUE 385 if(HDUType()!=BINARY_TBL && HDUType()!=ASCII_TBL) 339 386 throw TypeMismatchExc("FitsABTColRd::Init: HDU not ASCII/BINARY table\n"); 340 } 387 if(DbgLevel>1) cout<<"...Init ihdu="<<ihdu<<" HduType="<<HDUType()<<endl; 388 FitsOF->SetPosStatus(true); 341 389 342 390 // Get number of columns 343 391 if(fits_get_num_cols(FitsPtr,&NBcol,&sta)) { 344 FitsOpenFile::printerror(sta); Delete();392 FitsOpenFile::printerror(sta); 345 393 throw NotAvailableOperation("FitsABTColRd::Init: Error getting number of columns\n"); 346 394 } 347 395 if(DbgLevel>1) cout<<"...Init NBcol="<<NBcol<<endl; 348 if(NBcol<1) { 349 Delete(); 396 if(NBcol<1) 350 397 throw RangeCheckError("FitsABTColRd::Init: Bad number of colums\n"); 351 }352 398 353 399 // Get number of rows 354 400 if(fits_get_num_rows(FitsPtr,&NBline,&sta)) { 355 FitsOpenFile::printerror(sta); Delete();401 FitsOpenFile::printerror(sta); 356 402 throw NotAvailableOperation("FitsABTColRd::Init: Error getting number of rows\n"); 357 403 } 358 404 if(DbgLevel>1) cout<<"...Init NBline="<<NBline<<endl; 359 if(NBline<1) { 360 Delete(); 405 if(NBline<1) 361 406 throw RangeCheckError("FitsABTColRd::Init: Bad number of rows\n"); 362 }363 407 364 408 // Get column number … … 367 411 strcpy(labelcol,ColLabel.c_str()); 368 412 if(fits_get_colnum(FitsPtr,CASESEN,labelcol,&ColNum,&sta)) { 369 FitsOpenFile::printerror(sta); Delete();413 FitsOpenFile::printerror(sta); 370 414 throw NotAvailableOperation("FitsABTColRd::Init: Error getting column name\n"); 371 415 } … … 373 417 } 374 418 if(DbgLevel>1) cout<<"...Init ColNum="<<ColNum<<endl; 375 if(ColNum<0 || ColNum>=NBcol) { 376 Delete(); 419 if(ColNum<0 || ColNum>=NBcol) 377 420 throw RangeCheckError("FitsABTColRd::Init: Bad column number\n"); 378 }379 421 380 422 // Get column type 381 423 if(fits_get_coltype(FitsPtr,ColNum+1,&ColTypeCode,NULL,NULL,&sta)) { 382 FitsOpenFile::printerror(sta); Delete();424 FitsOpenFile::printerror(sta); 383 425 throw ParmError("FitsABTColRd::Init: Error getting column type\n"); 384 426 } 385 427 if(DbgLevel>1) cout<<"...Init ColTypeCode="<<ColTypeCode<<endl; 386 428 if(ColTypeCode==TSTRING || ColTypeCode==TCOMPLEX || ColTypeCode==TDBLCOMPLEX 387 || ColTypeCode<0 ) { 388 Delete(); 429 || ColTypeCode<0 ) 389 430 throw ParmError("FitsABTColRd::Init: Selected column is not Numerical\n"); 390 }391 431 392 432 // Get column name back, tunit, tform … … 394 434 long repeat=0; double tscale=1., tzero=0.; 395 435 int rc=0; 396 if(H duType==BINARY_TBL) {436 if(HDUType()==BINARY_TBL) { 397 437 fits_get_bcolparms(FitsPtr,ColNum+1,labelcol,tunit,tform 398 438 ,&repeat,&tscale,&tzero,NULL,tdisp,&sta); … … 402 442 } 403 443 if(rc) { 404 FitsOpenFile::printerror(sta); Delete();444 FitsOpenFile::printerror(sta); 405 445 throw RangeCheckError("FitsABTColRd::Init: Error getting the column caracteristics\n"); 406 446 } … … 408 448 ColTUnit = tunit; 409 449 ColTForm = tform; 450 451 // Set the buffer for reading 452 ChangeBuffer(blen,bsens); 410 453 411 454 if(DbgLevel) … … 779 822 <<" ncols="<<NBcol<<" nrows="<<NBline; 780 823 if(lp>0) os<<" NRead="<<NFitsRead; 781 os<<"\n... "<<FitsFN<<"["<<IHdu<<"/"<<NHdu<<"]" 782 <<"\n... Label["<<ColNum<<"]="<<ColLabel 783 <<" TypeCode="<<ColTypeCode 824 os<<"\n... "<<FileName()<<"["<<HDU()<<"/"<<NHDU()<<" type="<<HDUType()<<"]" 825 <<"\n... Label["<<ColNum<<"]="<<ColLabel<<" TypeCode="<<ColTypeCode 784 826 <<" TUnit="<<ColTUnit<<" TForm="<<ColTForm 785 827 <<endl; … … 828 870 \param lp : debug level 829 871 \verbatim 830 - if ihdu=0 or ihdu>nhdu first binary or ASCII table is taken 872 - if ihdu<=0 first BINARY or ASCII table is taken 873 - if ihdu>nhdu ihdu is set to nhdu 831 874 - bsens>0 read forward 832 875 bsens<0 read backward … … 878 921 FitsOpenFile* fof = new FitsOpenFile(*fbt.GetFitsOpenFile()); 879 922 Init(fof,fbt.GetColLabel().c_str() 880 ,fbt.GetColNum(),fbt. GetHDU()923 ,fbt.GetColNum(),fbt.HDU() 881 924 ,fbt.GetBLen(),fbt.GetBSens(),fbt.DbgLevel); 882 925 } … … 902 945 Constructor. 903 946 \param fof : Pointer to the Class for opening the FITS file 904 \param ihdu : number of the HDU where the columnis.947 \param ihdu : number of the HDU where the image is. 905 948 \param lp : debug level 906 949 \verbatim 907 - if ihdu=0 or ihdu>nhdu first binary or ASCII table is taken 950 - if ihdu<=0 first IMAGE hdu is taken 951 - if ihdu>nhdu ihdu is set to nhdu 908 952 \endverbatim 909 953 \warning ihdu = [1,nhdu] … … 917 961 FitsImg2DRd::FitsImg2DRd(FitsImg2DRd& fbt) 918 962 { 919 Init(fbt.GetFitsOpenFile(),fbt. GetHDU(),fbt.DbgLevel);963 Init(fbt.GetFitsOpenFile(),fbt.HDU(),fbt.DbgLevel); 920 964 } 921 965 … … 923 967 FitsImg2DRd::FitsImg2DRd() 924 968 { 925 FitsFN = "";926 IHdu = 0; NHdu = 0; HduType = 0;927 969 Naxis[0] = Naxis[1] = 0; 928 970 SetNulVal(); SetDebug(0); … … 934 976 { 935 977 // Initialisation des Parametres Generaux 936 FitsFN = "";937 IHdu = ihdu; NHdu = 0; HduType = 0;938 978 Naxis[0] = Naxis[1] = 0; 939 979 SetNulVal(); SetDebug(lp); … … 944 984 if(FitsOF==NULL) 945 985 throw NullPtrError("FitsImg2DRd::Init: FitsOpenFile pointer is NULL\n"); 986 946 987 FitsPtr = FitsOF->GetFitsPtr(); 947 988 if(FitsPtr==NULL) 948 989 throw NullPtrError("FitsImg2DRd::Init: FitsPtr pointer is NULL\n"); 949 NHdu = FitsOF->GetNHdu();950 if(DbgLevel>1) cout<<"FitsImg2DRd::Init NHdu="<<NHdu<<endl;951 if(NHdu<=0)952 throw SzMismatchError("FitsImg2DRd::Init: Bad NHdu\n");953 FitsFN = FitsOF->GetFileName();954 if(FitsFN.size() <= 0 )955 throw ParmError("FitsImg2DRd::Init: Fits file name error\n");956 990 957 991 int sta = 0; 992 if(ihdu<0) ihdu=0; if(ihdu>NHDU()) ihdu=NHDU(); 958 993 959 994 // Get HDU 2D image 960 // si IHdu <=0 || >NHdu on cherche la 1ere image961 // sinon on se positionne sur IHdu962 if(IHdu<=0 || IHdu>NHdu)963 for(int ihdu=1;ihdu<=NHdu;ihdu++) {964 if(fits_movabs_hdu(FitsPtr,ihdu,&HduType,&sta)) FitsOpenFile::printerror(sta);965 i f(DbgLevel>1)966 cout<<"...Init ihdu="<<ihdu<<" HduType="<<HduType<<endl;967 if(HduType==IMAGE_HDU) {IHdu = ihdu; break;}995 // ATTENTION: ... cf blabla equivalent dans FitsABTColRd::Init() 996 if(FitsOF->GetPosStatus()==false) { 997 if(ihdu==0) { // find the first IMAGE_HDU 998 FitsOF->MoveToFirst(IMAGE_HDU); 999 } else { 1000 int rc = FitsOF->MoveToHDU(ihdu); 1001 if(rc!=ihdu) 1002 throw RangeCheckError("FitsABTColRd::Init: Error moving to requested HDU\n"); 968 1003 } 969 if(IHdu<=0 || IHdu>NHdu) { 970 cout<<"NO IMAGE_HDU hdu found"<<endl; 971 IHdu = 0; 972 throw TypeMismatchExc("FitsImg2DRd::Init: NO IMAGE_HDU hdu found\n"); 973 } 974 if(fits_movabs_hdu(FitsPtr,IHdu,&HduType,&sta)) { 975 FitsOpenFile::printerror(sta); 976 throw RangeCheckError("FitsImg2DRd::Init: Error moving to requested HDU\n"); 977 } 978 if(HduType!=IMAGE_HDU) 1004 } else { // Fits file has already been positionned 1005 if(ihdu>0 && ihdu!=HDU()) 1006 throw RangeCheckError("FitsABTColRd::Init: file already posit. at another HDU\n"); 1007 } 1008 1009 // Check HDUType and set position status to TRUE 1010 if(HDUType()!=IMAGE_HDU) 979 1011 throw TypeMismatchExc("FitsImg2DRd::Init: HDU not IMAGE_HDU\n"); 1012 FitsOF->SetPosStatus(true); 980 1013 981 1014 // Get NAXIS 1 et 2 … … 986 1019 } 987 1020 if(DbgLevel>1) 988 cout<<"...Init(hdu="<<IHdu<<") NAXIS1="<<Naxis[0]<<" NAXIS2="<<Naxis[1]<<" (nfound="<<nfound<<")"<<endl; 1021 cout<<"...Init(hdu="<<HDU()<<") NAXIS1="<<Naxis[0]<<" NAXIS2=" 1022 <<Naxis[1]<<" (nfound="<<nfound<<")"<<endl; 989 1023 if(nfound!=2 || Naxis[0]<=0 || Naxis[1]<=0) 990 1024 throw NotAvailableOperation("FitsImg2DRd::Init: bad Naxis[0-1] value\n"); -
trunk/SophyaExt/FitsIOServer/fabtcolread.h
r2453 r2456 24 24 virtual ~FitsOpenFile(); 25 25 26 inline string GetFileName() {return FitsFN;} 27 inline int GetNHdu() {return NHdu;} 28 inline fitsfile* GetFitsPtr() {return FitsPtr;} 26 inline string FileName() const {return FitsFN;} 27 //! Get the number of the HDU read 28 inline int HDU(void) const {return IHdu;} 29 //! Get the number of the HDU type 30 inline int HDUType(void) const {return HduType;} 31 //! Get the number of HDU in file 32 inline int NHDU() const {return NHdu;} 33 //! Get the CFISTIO fits file pointer 34 inline fitsfile* GetFitsPtr() const {return FitsPtr;} 35 //! Set the positionning status of the file 36 inline void SetPosStatus(bool sta=true) {HasBeenPos = sta;} 37 //! Get the positionning status of the file 38 inline bool GetPosStatus(void) const {return HasBeenPos;} 39 40 int MoveToHDU(int ihdu); 41 int MoveToFirst(int hdutype,int ihdudeb=1); 42 int MoveToLast(int hdutype,int ihdudeb=1); 43 void Print(void); 29 44 30 45 static double ReadKey(fitsfile *fitsptr,char *keyname); … … 38 53 39 54 string FitsFN; 40 int NHdu ;55 int NHdu, IHdu, HduType; 41 56 fitsfile *FitsPtr; 57 bool HasBeenPos; 42 58 }; 43 59 … … 62 78 double Read(long n,bool usebuffer=true); 63 79 64 long 65 long 66 long 67 long 68 long 80 long Read(long n1,long n2,TVector<uint_2>& data); 81 long Read(long n1,long n2,TVector<int_4>& data); 82 long Read(long n1,long n2,TVector<int_8>& data); 83 long Read(long n1,long n2,TVector<float>& data); 84 long Read(long n1,long n2,TVector<double>& data); 69 85 70 86 //! return the value of the first row … … 79 95 80 96 //! Set debug level 81 inline void 97 inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;} 82 98 //! Set null value to be return when reading null data (0=return the data) 83 inline void 99 inline void SetNulVal(double nulval=0.) {NulVal = nulval;} 84 100 //! Get the FITS file name 85 inline string GetFileName(void) {return FitsFN;} 101 inline string FileName(void) const 102 {if(FitsOF) return FitsOF->FileName(); else return (string)"";} 86 103 //! Get the pointer to FitsOpenFile 87 inline FitsOpenFile* GetFitsOpenFile(void) {return FitsOF;}104 inline FitsOpenFile* GetFitsOpenFile(void) const {return FitsOF;} 88 105 //! Get the FITS file pointer (cfistio pointer) 89 inline fitsfile* GetFitsP ointer(void){return FitsPtr;}106 inline fitsfile* GetFitsPtr(void) const {return FitsPtr;} 90 107 //! Get the number of HDU in the FITS file 91 inline int GetNHDU(void) {return NHdu;} 108 inline int NHDU(void) const 109 {if(FitsOF) return FitsOF->NHDU(); else return 0;} 92 110 //! Get the number of the HDU read 93 inline int GetHDU(void) {return IHdu;} 111 inline int HDU(void) const 112 {if(FitsOF) return FitsOF->HDU(); else return 0;} 94 113 //! Get the HDU type 95 inline int GetHDUType(void) {return HduType;} 114 inline int HDUType(void) const 115 {if(FitsOF) return FitsOF->HDUType(); else return 0;} 96 116 //! Get the number of rows in the FITS HDU to be read 97 inline long GetNbLine(void){return NBline;}117 inline long GetNbLine(void) const {return NBline;} 98 118 //! Get the number of columns in the FITS HDU to be read 99 inline int GetNbCol(void){return NBcol;}119 inline int GetNbCol(void) const {return NBcol;} 100 120 //! Get the columns number that is read 101 inline int GetColNum(void){return ColNum;}121 inline int GetColNum(void) const {return ColNum;} 102 122 //! Get the columns label that is read 103 inline string GetColLabel(void){return ColLabel;}123 inline string GetColLabel(void) const {return ColLabel;} 104 124 //! Get the columns type code that is read 105 inline int GetColTypeCode(void){return ColTypeCode;}125 inline int GetColTypeCode(void) const {return ColTypeCode;} 106 126 //! Get the columns fits tunit that is read 107 inline string GetColTUnit(void){return ColTUnit;}127 inline string GetColTUnit(void) const {return ColTUnit;} 108 128 //! Get the columns fits tform that is read 109 inline string GetColTForm(void){return ColTForm;}129 inline string GetColTForm(void) const {return ColTForm;} 110 130 //! Get the read requested buffer length 111 inline long GetBLen(void){return BuffLen;}131 inline long GetBLen(void) const {return BuffLen;} 112 132 //! Get the read buffer direction 113 inline long GetBSens(void){return BuffSens;}133 inline long GetBSens(void) const {return BuffSens;} 114 134 //! Print to os 115 virtual void 135 virtual void Print(ostream& os,int lp=1) const; 116 136 //! Print to stdout 117 inline void 137 inline void Print(int lp=1) const {Print(cout,lp);} 118 138 //! Get the read effective buffer length 119 inline long GetNBuffer(void){return NBuffer;}139 inline long GetNBuffer(void) const {return NBuffer;} 120 140 //! Get the read bufferpointer 121 141 inline double* GetBuffer(void) {return Buffer;} … … 126 146 void Delete(void); 127 147 128 string FitsFN,ColLabel,ColTUnit,ColTForm;129 int ColNum,ColTypeCode, IHdu,NHdu,HduType,NBcol;148 string ColLabel,ColTUnit,ColTForm; 149 int ColNum,ColTypeCode,NBcol; 130 150 long NBline; 131 151 … … 136 156 unsigned long NFitsRead; 137 157 FitsOpenFile* FitsOF; 138 fitsfile* FitsPtr; 158 fitsfile* FitsPtr; // Redite avec FitsOF->FitsPtr, mais utilise partout! 139 159 long LineDeb, LineFin; 140 160 double *Buffer; … … 175 195 string ReadKeyS(char *keyname); 176 196 177 long 178 long 179 long 180 long 181 long 197 long Read(TMatrix<uint_2>& data); 198 long Read(TMatrix<int_4>& data); 199 long Read(TMatrix<int_8>& data); 200 long Read(TMatrix<float>& data); 201 long Read(TMatrix<double>& data); 182 202 183 203 //! Set debug level … … 186 206 inline void SetNulVal(double nulval=0.) {NulVal = nulval;} 187 207 //! Get the pointer to FitsOpenFile 188 inline FitsOpenFile* GetFitsOpenFile(void) {return FitsOF;} 208 inline FitsOpenFile* GetFitsOpenFile(void) const {return FitsOF;} 209 //! Get the FITS file pointer (cfistio pointer) 210 inline fitsfile* GetFitsPtr(void) const {return FitsPtr;} 211 //! Get the number of HDU in the FITS file 212 inline int NHDU(void) const 213 {if(FitsOF) return FitsOF->NHDU(); else return 0;} 189 214 //! Get the number of the HDU read 190 inline int GetHDU(void) {return IHdu;} 215 inline int HDU(void) const 216 {if(FitsOF) return FitsOF->HDU(); else return 0;} 191 217 //! Get the HDU type 192 inline int GetHDUType(void) {return HduType;} 218 inline int HDUType(void) const 219 {if(FitsOF) return FitsOF->HDUType(); else return 0;} 193 220 //! Get NAXIS1 194 inline long GetNaxis1(void){return Naxis[0];}221 inline long Naxis1(void) const {return Naxis[0];} 195 222 //! Get NAXIS2 196 inline long GetNaxis2(void){return Naxis[1];}223 inline long Naxis2(void) const {return Naxis[1];} 197 224 198 225 protected: 199 226 void Init(FitsOpenFile* fof,int ihdu,int lp); 200 227 201 string FitsFN;202 int IHdu,NHdu,HduType;203 228 long Naxis[2]; 204 205 229 double NulVal; 206 230 unsigned short DbgLevel; 207 231 208 232 FitsOpenFile* FitsOF; 209 fitsfile* FitsPtr; 210 }; 233 fitsfile* FitsPtr; // Redite avec FitsOF->FitsPtr, mais utilise partout! 234 };
Note:
See TracChangeset
for help on using the changeset viewer.