Changeset 4025 in Sophya
- Timestamp:
- Oct 3, 2011, 6:32:44 PM (14 years ago)
- Location:
- trunk/SophyaExt/FitsIOServer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fabtcolread.cc
r4023 r4025 349 349 { 350 350 ColLabel = ""; ColTUnit = ""; ColTForm = ""; 351 ColNum = -1; ColTypeCode = 0; ColRepeat=0; 351 ColNum = -1; ColTypeCode = 0; ColRepeat=0; ColDispWidth=0; 352 StrBuff = NULL; 352 353 NBcol = 0; NBline = 0; 353 354 SetNulVal(); SetDebug(0); … … 363 364 { 364 365 // Initialisation des Parametres Generaux 365 ColLabel=collabel; ColTUnit=""; ColTForm=""; ColNum=colnum; ColTypeCode=0; ColRepeat=0; 366 ColLabel=collabel; ColTUnit=""; ColTForm=""; 367 ColNum=colnum; ColTypeCode=0; ColRepeat=0; ColDispWidth=0; 368 StrBuff = NULL; 366 369 NBcol = 0; NBline = 0; 367 370 SetNulVal(); SetDebug(lp); … … 445 448 } 446 449 if(DbgLevel>1) cout<<"...Init ColTypeCode="<<ColTypeCode<<endl; 447 if(ColTypeCode==TSTRING || ColTypeCode==TCOMPLEX || ColTypeCode==TDBLCOMPLEX 448 || ColTypeCode<0 ) 449 throw ParmError("FitsABTColRd::Init: Selected column is not Numerical\n"); 450 if(ColTypeCode<0 ) 451 throw ParmError("FitsABTColRd::Init: Selected column type decoding not implemented\n"); 450 452 451 453 // Get column name back, tunit, tform … … 454 456 int rc=0; 455 457 if(HDUType()==BINARY_TBL) { 456 fits_get_bcolparmsll(GetFitsPtr(),ColNum+1,labelcol,tunit,tform457 ,&repeat,&tscale,&tzero,NULL,tdisp,&sta);458 rc = fits_get_bcolparmsll(GetFitsPtr(),ColNum+1,labelcol,tunit,tform 459 ,&repeat,&tscale,&tzero,NULL,tdisp,&sta); 458 460 } else { 459 461 long repeatlng; 460 fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeatlng,tunit,tform461 ,&tscale,&tzero,NULL,tdisp,&sta);462 rc = fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeatlng,tunit,tform 463 ,&tscale,&tzero,NULL,tdisp,&sta); 462 464 repeat = repeatlng; 463 465 } … … 471 473 ColRepeat = repeat; 472 474 475 fits_get_col_display_width(GetFitsPtr(),ColNum+1,&ColDispWidth,&sta); 476 473 477 // Set the buffer for reading 474 478 ChangeBuffer(blen,bsens); … … 476 480 if(DbgLevel) 477 481 cout<<"FitsABTColRd::Init Num="<<ColNum<<" Label="<<ColLabel 478 <<" TypeCode="<<ColTypeCode<<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<" Repeat="<<ColRepeat<<endl; 482 <<" TypeCode="<<ColTypeCode<<" TUnit="<<ColTUnit<<" TForm="<<ColTForm 483 <<" Repeat="<<ColRepeat<<" DispWidth="<<ColDispWidth<<endl; 479 484 if(DbgLevel>1) 480 485 cout<<" (tscale="<<tscale<<",tzero="<<tzero<<",tdisp="<<tdisp<<")"<<endl; … … 491 496 void FitsABTColRd::Delete(void) 492 497 { 498 if(StrBuff!=NULL) {delete [] StrBuff; StrBuff=NULL;} 493 499 if(Buffer!=NULL) {delete [] Buffer; Buffer=NULL;} 494 500 LineDeb = LineFin = -1; … … 639 645 640 646 /*! 647 Read row "n" element "nfirstel" and return a complex value 648 */ 649 complex<r_8> FitsABTColRd::ReadComplex(LONGLONG n,long nfirstel) 650 { 651 int sta=0; 652 if(n<0 || n>=NBline) 653 throw RangeCheckError("FitsABTColRd::ReadComplex try to read outside line range\n"); 654 if(nfirstel<0 || nfirstel>=ColRepeat) 655 throw RangeCheckError("FitsABTColRd::ReadComplex try to read outside element range: nfirstel>repeat\n"); 656 657 r_8 val[2]; 658 fits_read_col(GetFitsPtr(),TDBLCOMPLEX,ColNum+1,n+1,nfirstel+1,1,NULL,val,NULL,&sta); 659 if(sta) { 660 FitsOpenFile::printerror(sta); 661 throw NotAvailableOperation("FitsABTColRd::ReadComplex: Error Reading Fits file\n"); 662 } 663 return complex<r_8>(val[0],val[1]); 664 } 665 666 /*! 667 Read row "n" element "nfirstel" and return in string (internal pointer) 668 */ 669 char* FitsABTColRd::ReadInStr(LONGLONG n,long nfirstel) 670 { 671 int sta=0; 672 if(n<0 || n>=NBline) 673 throw RangeCheckError("FitsABTColRd::ReadInStr try to read outside line range\n"); 674 if(nfirstel<0 || nfirstel>=ColRepeat) 675 throw RangeCheckError("FitsABTColRd::ReadInStr try to read outside element range: nfirstel>repeat\n"); 676 677 if(StrBuff==NULL) StrBuff= new char[ColDispWidth+5]; 678 char nullstr[]=""; 679 680 NFitsRead++; 681 fits_read_col(GetFitsPtr(),TSTRING,ColNum+1,n+1,nfirstel+1,1,nullstr,&StrBuff,NULL,&sta); 682 if(sta) { 683 FitsOpenFile::printerror(sta); 684 throw NotAvailableOperation("FitsABTColRd::ReadInStr: Error Reading Fits file\n"); 685 } 686 687 return StrBuff; 688 } 689 690 /*! 641 691 Read rows from "n1" to "n2" and return the values into TVector of double 642 692 \return NREAD the number of values read (n2-n1+1). … … 875 925 <<"\n... Label["<<ColNum<<"]="<<ColLabel<<" TypeCode="<<ColTypeCode 876 926 <<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<" Repeat="<<ColRepeat 927 <<" DispWidth="<<ColDispWidth 877 928 <<endl; 878 929 } … … 993 1044 /////////////////////////////////////////////////////////////////// 994 1045 995 FitsABTColRd1F::FitsABTColRd1F(FitsOpenFile* fof,int ihdu, long blen,long bsens,int lp)996 { 997 Init(fof,ihdu, blen,bsens,lp);1046 FitsABTColRd1F::FitsABTColRd1F(FitsOpenFile* fof,int ihdu,int lp) 1047 { 1048 Init(fof,ihdu,lp); 998 1049 } 999 1050 1000 1051 /*! Init routine called by the constructor */ 1001 void FitsABTColRd1F::Init(FitsOpenFile* fof,int ihdu, long blen,long bsens,int lp)1052 void FitsABTColRd1F::Init(FitsOpenFile* fof,int ihdu,int lp) 1002 1053 { 1003 1054 // Initialisation des Parametres Generaux 1004 ColLabel.resize(0); ColTUnit.resize(0); ColTForm.resize(0); ColTypeCode.resize(0); ColRepeat.resize(0); 1055 ColLabel.resize(0); ColTUnit.resize(0); ColTForm.resize(0); 1056 ColTypeCode.resize(0); ColRepeat.resize(0); ColDispWidth.resize(0); 1057 StrBuff.resize(0); 1005 1058 NBcol = 0; NBline = 0; 1006 1059 SetNulVal(); SetDebug(lp); 1007 1060 FitsOF = NULL; 1008 LineDeb.resize(0); LineFin.resize(0);1009 Buffer = NULL;1010 1061 1011 1062 // Caracteristiques du FitsOpenFile … … 1072 1123 } 1073 1124 if(DbgLevel>1) cout<<"...Init ColTypeCode="<<ColTypeCode[ColNum]<<endl; 1074 if(ColTypeCode[ColNum]==TSTRING || ColTypeCode[ColNum]==TCOMPLEX 1075 || ColTypeCode[ColNum]==TDBLCOMPLEX || ColTypeCode[ColNum]<0 ) 1076 throw ParmError("FitsABTColRd1F::Init: Selected column is not Numerical\n"); 1125 if(ColTypeCode[ColNum]<0 ) 1126 throw ParmError("FitsABTColRd1F::Init: Selected column type decoding not implemented\n"); 1077 1127 // Get column name, tunit, tform 1078 1128 char labelcol[128]; … … 1081 1131 int rc=0; 1082 1132 if(HDUType()==BINARY_TBL) { 1083 fits_get_bcolparmsll(GetFitsPtr(),ColNum+1,labelcol,tunit,tform1133 rc = fits_get_bcolparmsll(GetFitsPtr(),ColNum+1,labelcol,tunit,tform 1084 1134 ,&repeat,&tscale,&tzero,NULL,tdisp,&sta); 1085 1135 } else { 1086 1136 long repeatlng; 1087 fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeatlng,tunit,tform1137 rc = fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeatlng,tunit,tform 1088 1138 ,&tscale,&tzero,NULL,tdisp,&sta); 1089 1139 repeat = repeatlng; … … 1097 1147 ColTForm.push_back(tform); 1098 1148 ColRepeat.push_back(repeat); 1099 // fill the default buffer limits at init 1100 LineDeb.push_back(-1); 1101 LineFin.push_back(-1); 1149 1150 int cdispw = 0; 1151 fits_get_col_display_width(GetFitsPtr(),ColNum+1,&cdispw,&sta); 1152 ColDispWidth.push_back(cdispw); 1153 StrBuff.push_back(NULL); 1154 1102 1155 // some debug print if requested 1103 1156 if(DbgLevel) 1104 1157 cout<<"FitsABTColRd1F::Init Num="<<ColNum<<" Label="<<ColLabel[ColNum] 1105 <<" TypeCode="<<ColTypeCode[ColNum]<<" TUnit="<<ColTUnit[ColNum]<<" TForm="<<ColTForm[ColNum]<<" Repeat="<<ColRepeat[ColNum]<<endl; 1158 <<" TypeCode="<<ColTypeCode[ColNum]<<" TUnit="<<ColTUnit[ColNum]<<" TForm="<<ColTForm[ColNum] 1159 <<" Repeat="<<ColRepeat[ColNum]<<" ColDispWidth="<<ColDispWidth[ColNum]<<endl; 1106 1160 if(DbgLevel>1) 1107 1161 cout<<" (tscale="<<tscale<<",tzero="<<tzero<<",tdisp="<<tdisp<<")"<<endl; 1108 1162 } // ***** ColNum 1109 1163 1110 // Set the buffer for reading1111 ChangeBuffer(blen,bsens);1112 1113 1164 } 1114 1165 … … 1122 1173 void FitsABTColRd1F::Delete(void) 1123 1174 { 1124 if(NBcol>0 && Buffer!=NULL) { 1125 for(int ColNum=0; ColNum<NBcol; ColNum++) 1126 if(Buffer[ColNum]!=NULL) delete [] Buffer[ColNum]; 1127 delete [] Buffer; Buffer=NULL; 1128 } 1129 LineDeb.resize(0); LineFin.resize(0); 1175 if(NBcol>0) for(int ColNum=0; ColNum<NBcol; ColNum++) { 1176 if(StrBuff[ColNum]==NULL) continue; 1177 delete [] StrBuff[ColNum]; 1178 StrBuff[ColNum] = NULL; 1179 } 1130 1180 //--- Surtout on ne "fits_close_file" pas le fichier FITS !!! 1131 }1132 1133 //////////////////////////////////////////////////////////////1134 /*! Change the buffer caracteristiques (see creator) */1135 void FitsABTColRd1F::ChangeBuffer(long blen,long bsens)1136 {1137 long oldnbuffer = NBuffer;1138 1139 // Compute buffer caracteristics1140 BuffLen = (blen<=0)? 1: blen;1141 BuffSens = bsens;1142 NBuffer = BuffLen;1143 if(bsens==0 && NBuffer%2==0) NBuffer++;1144 1145 // De-allocate if necessary1146 if(Buffer!=NULL) {1147 // On des-alloue si pas assez de place1148 // ou si l'ancienne place est beaucoup trop grande (>25%)1149 if(oldnbuffer<NBuffer || (oldnbuffer>NBuffer+long(0.25*NBuffer)) ) {1150 for(int ColNum=0; ColNum<NBcol; ColNum++) if(Buffer[ColNum]!=NULL) delete [] Buffer[ColNum];1151 if(Buffer!=NULL) {delete [] Buffer; Buffer=NULL;}1152 }1153 }1154 1155 // Re-allocate1156 if(Buffer==NULL) {1157 Buffer = new double*[NBcol];1158 for(int ColNum=0; ColNum<NBcol; ColNum++) Buffer[ColNum] = new double[NBuffer];1159 }1160 1161 // Tell program that nothing is into buffer1162 for(int ColNum=0; ColNum<NBcol; ColNum++) LineDeb[ColNum] = LineFin[ColNum] = -1;1163 1181 } 1164 1182 … … 1227 1245 \endverbatim 1228 1246 */ 1229 double FitsABTColRd1F::Read(int ColNum,LONGLONG n,long nfirstel ,bool usebuffer)1247 double FitsABTColRd1F::Read(int ColNum,LONGLONG n,long nfirstel) 1230 1248 // Attention: n=nline [0,NBline[, cfistio veut [1,NBline] 1231 1249 // Attention: colnum [0,NBcol[ , cfistio veut [1,NBcol] … … 1240 1258 throw RangeCheckError("FitsABTColRd1F::Read try to read outside element range: nfirstel>repeat\n"); 1241 1259 1242 // Pas de bufferisation (ou repeat=1), on lit betement 1243 if(NBuffer==1 || !usebuffer || ColRepeat[ColNum]!=1) { 1244 double val; 1245 fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n+1,nfirstel+1,1,NULL,&val,NULL,&sta); 1246 if(sta) { 1247 FitsOpenFile::printerror(sta); 1248 throw NotAvailableOperation("FitsABTColRd1F::Read: Error Reading Fits file\n"); 1249 } 1250 // On ne remplit Buffer[ColNum][0] que si on a choisit 1251 // un mode de lecture non bufferise (n==1) DES LE DEBUT. 1252 // Si on a initialement choisit un mode bufferise (avec n>1), 1253 // Buffer contient les valeurs chargees auparavent. 1254 // Il ne faut pas faire {Buffer[0]=val; LineDeb=LineFin=n;} 1255 // car on perd l'info de ces valeurs. 1256 if(NBuffer==1) {Buffer[ColNum][0]=val; LineDeb[ColNum]=LineFin[ColNum]=n;} 1257 return val; 1258 } 1259 1260 // Gestion avec bufferisation (uniquement dans le cas repeat=1) 1261 if(!Buffer) 1262 throw RangeCheckError("FitsABTColRd1F::Read: Buffer not allocated\n"); 1263 if(n<LineDeb[ColNum] || n>LineFin[ColNum]) { 1264 LONGLONG row1,row2,nrow; 1265 if(BuffSens>0) { // Cas remplissage forward 1266 row1 = n+1; 1267 row2 = row1+NBuffer-1; if(row2>NBline) row2 = NBline; 1268 } else if(BuffSens<0) { // Cas remplissage backward 1269 row2 = n+1; 1270 row1 = row2-NBuffer+1; if(row1<1) row1 = 1; 1271 } else { // Cas remplissage centre 1272 row1 = n+1 - NBuffer/2; if(row1<1) row1 = 1; 1273 row2 = n+1 + NBuffer/2; if(row2>NBline) row2 = NBline; 1274 } 1275 nrow = row2 - row1 + 1; 1276 LineDeb[ColNum] = row1-1; LineFin[ColNum] = row2-1; 1277 //cout<<"DBG-FitsRead: row1="<<row1<<" row2="<<row2<<" nrow="<<nrow 1278 // <<" LineDeb,Fin="<<LineDeb[ColNum]<<","<<LineFin[ColNum]<<endl; 1279 fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,row1,1,nrow,NULL,Buffer[ColNum],NULL,&sta); 1280 if(sta) { 1281 FitsOpenFile::printerror(sta); 1282 LineDeb[ColNum] = LineFin[ColNum] = -1; 1283 throw NotAvailableOperation("FitsABTColRd1F::Read: Error Reading Fits file\n"); 1284 } 1285 } 1286 1287 long ibuf = n-LineDeb[ColNum]; 1288 return Buffer[ColNum][ibuf]; 1289 } 1290 1260 double val; 1261 fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n+1,nfirstel+1,1,NULL,&val,NULL,&sta); 1262 if(sta) { 1263 FitsOpenFile::printerror(sta); 1264 throw NotAvailableOperation("FitsABTColRd1F::Read: Error Reading Fits file\n"); 1265 } 1266 return val; 1267 } 1268 1269 1270 /*! 1271 Read row "n" element "nfirstel" and return a complex value 1272 */ 1273 complex<r_8> FitsABTColRd1F::ReadComplex(int ColNum,LONGLONG n,long nfirstel) 1274 { 1275 int sta=0; 1276 if(ColNum<0 || ColNum>=NBcol) 1277 throw RangeCheckError("FitsABTColRd1F::ReadComplex try to read outside column range\n"); 1278 if(n<0 || n>=NBline) 1279 throw RangeCheckError("FitsABTColRd1F::ReadComplex try to read outside line range\n"); 1280 if(nfirstel<0 || nfirstel>=ColRepeat[ColNum]) 1281 throw RangeCheckError("FitsABTColRd1F::ReadComplex try to read outside element range: nfirstel>repeat\n"); 1282 1283 r_8 val[2]; 1284 fits_read_col(GetFitsPtr(),TDBLCOMPLEX,ColNum+1,n+1,nfirstel+1,1,NULL,val,NULL,&sta); 1285 if(sta) { 1286 FitsOpenFile::printerror(sta); 1287 throw NotAvailableOperation("FitsABTColRd1F::ReadComplex: Error Reading Fits file\n"); 1288 } 1289 return complex<r_8>(val[0],val[1]); 1290 } 1291 1292 /*! 1293 Read row "n" element "nfirstel" and return in string (internal pointer) 1294 */ 1295 char* FitsABTColRd1F::ReadInStr(int ColNum,LONGLONG n,long nfirstel) 1296 { 1297 int sta=0; 1298 if(ColNum<0 || ColNum>=NBcol) 1299 throw RangeCheckError("FitsABTColRd1F::ReadInStr try to read outside column range\n"); 1300 if(n<0 || n>=NBline) 1301 throw RangeCheckError("FitsABTColRd1F::ReadInStr try to read outside line range\n"); 1302 if(nfirstel<0 || nfirstel>=ColRepeat[ColNum]) 1303 throw RangeCheckError("FitsABTColRd1F::ReadInStr try to read outside element range: nfirstel>repeat\n"); 1304 1305 if(StrBuff[ColNum]==NULL) StrBuff[ColNum] = new char[ColDispWidth[ColNum]+5]; 1306 char nullstr[]=""; 1307 1308 fits_read_col(GetFitsPtr(),TSTRING,ColNum+1,n+1,nfirstel+1,1,nullstr,&(StrBuff[ColNum]),NULL,&sta); 1309 if(sta) { 1310 FitsOpenFile::printerror(sta); 1311 throw NotAvailableOperation("FitsABTColRd::ReadInStr: Error Reading Fits file\n"); 1312 } 1313 1314 return StrBuff[ColNum]; 1315 } 1291 1316 1292 1317 /*! Print on stream os */ 1293 1318 void FitsABTColRd1F::Print(ostream& os,int lp) const 1294 1319 { 1295 os<<"FitsABTColRd1F:Print ("<< BuffLen<<","<<BuffSens<<","<<NulVal<<")"1320 os<<"FitsABTColRd1F:Print ("<<NulVal<<")" 1296 1321 <<" ncols="<<NBcol<<" nrows="<<NBline; 1297 1322 os<<"\n... "<<FileName()<<"["<<HDU()<<"/"<<NHDU()<<" type="<<HDUType()<<"]"<<endl; … … 1299 1324 for(int ColNum=0;ColNum<NBcol;ColNum++) { 1300 1325 os<<"..Col="<<ColNum<<" Label="<<ColLabel[ColNum]<<" TypeCode="<<ColTypeCode[ColNum] 1301 <<" TUnit="<<ColTUnit[ColNum]<<" TForm="<<ColTForm[ColNum] 1326 <<" TUnit="<<ColTUnit[ColNum]<<" TForm="<<ColTForm[ColNum]<<" Repeat="<<ColRepeat[ColNum] 1327 <<" DispWidth="<<ColDispWidth[ColNum] 1302 1328 <<endl; 1303 1329 } … … 1316 1342 \warning col = [0,ncol[ 1317 1343 */ 1318 FitsABTColRead1F::FitsABTColRead1F(string fname,int ihdu, long blen,long bsens,int lp)1319 : FitsABTColRd1F(new FitsOpenFile(fname),ihdu, blen,bsens,lp)1344 FitsABTColRead1F::FitsABTColRead1F(string fname,int ihdu,int lp) 1345 : FitsABTColRd1F(new FitsOpenFile(fname),ihdu,lp) 1320 1346 { 1321 1347 } 1322 1348 1323 1349 /*! Constructor. see below */ 1324 FitsABTColRead1F::FitsABTColRead1F(const char * cfname,int ihdu, long blen,long bsens,int lp)1325 : FitsABTColRd1F(new FitsOpenFile(cfname),ihdu, blen,bsens,lp)1350 FitsABTColRead1F::FitsABTColRead1F(const char * cfname,int ihdu,int lp) 1351 : FitsABTColRd1F(new FitsOpenFile(cfname),ihdu,lp) 1326 1352 { 1327 1353 } -
trunk/SophyaExt/FitsIOServer/fabtcolread.h
r4023 r4025 85 85 double Read(LONGLONG n,long nfirstel,bool usebuffer=true); 86 86 inline double Read(LONGLONG n,bool usebuffer=true) {return Read(n,0,usebuffer);} 87 complex<r_8> ReadComplex(LONGLONG n,long nfirstel=0); 88 char* ReadInStr(LONGLONG n,long nfirstel=0); 87 89 88 90 LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data); … … 161 163 162 164 string ColLabel,ColTUnit,ColTForm; 163 int ColNum,ColTypeCode, NBcol;165 int ColNum,ColTypeCode,ColDispWidth,NBcol; 164 166 long ColRepeat; 165 167 LONGLONG NBline; 168 char *StrBuff; 166 169 167 170 double NulVal; … … 195 198 196 199 /////////////////////////////////////////////////////////////////// 197 //! Class for reading ALL the columns in a FITS ASCII or BINARY table 200 //! Class for reading ALL the columns in a FITS ASCII or BINARY table (no bufferisation) 198 201 class FitsABTColRd1F : public AnyDataObj { 199 202 public: 200 FitsABTColRd1F(FitsOpenFile* fof,int ihdu=0 201 ,long blen=100,long bsens=1,int lp=0); 203 FitsABTColRd1F(FitsOpenFile* fof,int ihdu=0,int lp=0); 202 204 virtual ~FitsABTColRd1F(); 203 204 void ChangeBuffer(long blen=100,long bsens=1);205 205 206 206 double ReadKey(const char *keyname); … … 209 209 string ReadKeyS(const char *keyname); 210 210 211 double Read(int ColNum,LONGLONG n,long nfirstel,bool usebuffer=true); 212 inline double Read(int ColNum,LONGLONG n,bool usebuffer=true) {return Read(ColNum,n,0,usebuffer);} 211 double Read(int ColNum,LONGLONG n,long nfirstel); 212 inline double Read(int ColNum,LONGLONG n) {return Read(ColNum,n,0);} 213 complex<r_8> ReadComplex(int ColNum,LONGLONG n,long nfirstel=0); 214 char* ReadInStr(int ColNum,LONGLONG n,long nfirstel=0); 213 215 int GetColNum(const char *colname); 214 216 … … 252 254 inline long GetColRepeat(int ColNum) const 253 255 {if(ColNum<0 || ColNum>=NBcol) return -999; else return ColRepeat[ColNum];} 254 //! Get the read requested buffer length255 inline long GetBLen(void) const {return BuffLen;}256 //! Get the read buffer direction257 inline long GetBSens(void) const {return BuffSens;}258 256 //! Print to os 259 257 virtual void Print(ostream& os,int lp=1) const; … … 261 259 inline void Print(int lp=1) const {Print(cout,lp);} 262 260 //! Get the read effective buffer length 263 inline long GetNBuffer(void) const {return NBuffer;}264 //! Get the read bufferpointer265 inline double* GetBuffer(int ColNum)266 {if(ColNum<0 || ColNum>=NBcol) return NULL; else return Buffer[ColNum];}267 261 268 262 protected: 269 void Init(FitsOpenFile* fof,int ihdu, long blen,long bsens,int lp);263 void Init(FitsOpenFile* fof,int ihdu,int lp); 270 264 void Delete(void); 271 265 272 266 vector<string> ColLabel,ColTUnit,ColTForm; 273 vector<int> ColTypeCode ;267 vector<int> ColTypeCode, ColDispWidth; 274 268 vector<long> ColRepeat; 275 269 int NBcol; 276 270 LONGLONG NBline; 271 vector<char*> StrBuff; 277 272 278 273 double NulVal; 279 274 unsigned short DbgLevel; 280 long BuffLen, BuffSens;281 275 282 276 FitsOpenFile* FitsOF; 283 vector<LONGLONG> LineDeb, LineFin;284 double **Buffer;285 long NBuffer;286 277 }; 287 278 … … 291 282 class FitsABTColRead1F : public FitsABTColRd1F { 292 283 public: 293 FitsABTColRead1F(string fname,int ihdu=0 294 ,long blen=100,long bsens=1,int lp=0); 295 FitsABTColRead1F(const char *cfname,int ihdu=0 296 ,long blen=100,long bsens=1,int lp=0); 284 FitsABTColRead1F(string fname,int ihdu=0,int lp=0); 285 FitsABTColRead1F(const char *cfname,int ihdu=0,int lp=0); 297 286 virtual ~FitsABTColRead1F(); 298 287 }; -
trunk/SophyaExt/FitsIOServer/fabtwriter.cc
r4024 r4025 551 551 552 552 /*! Write a character string to FITS file */ 553 void FitsABTWriter::Write(int col,LONGLONG row, const char* val)554 { 555 if(FirstTime) createtbl(); 556 int sta=0; 557 if(fits_write_col(FitsPtr,TSTRING,col+1,row+1, 1,1,&val,&sta))553 void FitsABTWriter::Write(int col,LONGLONG row,long nfirstel,const char* val) 554 { 555 if(FirstTime) createtbl(); 556 int sta=0; 557 if(fits_write_col(FitsPtr,TSTRING,col+1,row+1,nfirstel+1,1,&val,&sta)) 558 558 printerrorwrite("char*",col,row,sta); 559 559 } … … 649 649 int sta=0; 650 650 if(fits_write_col(FitsPtr,TDOUBLE,col+1,row+1,nfirstel+1,1,&val,&sta)) 651 printerrorwrite("double",col,row,sta); 652 } 653 654 /*! Write complex float data to FITS file (see below) */ 655 void FitsABTWriter::Write(int col,LONGLONG row,long nfirstel,complex<r_4> val) 656 { 657 if(FirstTime) createtbl(); 658 int sta=0; 659 r_4 tval[2]; tval[0] = val.real(); tval[1] = val.imag(); 660 if(fits_write_col(FitsPtr,TCOMPLEX,col+1,row+1,nfirstel+1,1,&tval,&sta)) 661 printerrorwrite("double",col,row,sta); 662 } 663 664 /*! Write complex double data to FITS file (see below) */ 665 void FitsABTWriter::Write(int col,LONGLONG row,long nfirstel,complex<r_8> val) 666 { 667 if(FirstTime) createtbl(); 668 int sta=0; 669 r_8 tval[2]; tval[0] = val.real(); tval[1] = val.imag(); 670 if(fits_write_col(FitsPtr,TDBLCOMPLEX,col+1,row+1,nfirstel+1,1,&tval,&sta)) 651 671 printerrorwrite("double",col,row,sta); 652 672 } -
trunk/SophyaExt/FitsIOServer/fabtwriter.h
r4024 r4025 104 104 {return addcol(label,tform,tunit,datatype);} 105 105 106 void Write(int col,LONGLONG row,const char* val); 106 void Write(int col,LONGLONG row,long nfirstel,const char* val); 107 inline void Write(int col,LONGLONG row,const char* val) 108 {Write(col,row,0,val);} 109 inline void Write(int col,LONGLONG row,long nfirstel,string val) 110 {Write(col,row,nfirstel,val.c_str());} 107 111 inline void Write(int col,LONGLONG row,string val) 108 {Write(col,row,val.c_str());}112 {Write(col,row,0,val.c_str());} 109 113 110 114 void Write(int col,LONGLONG row,long nfirstel,int_1 val); … … 117 121 void Write(int col,LONGLONG row,long nfirstel,float val); 118 122 void Write(int col,LONGLONG row,long nfirstel,double val); 123 void Write(int col,LONGLONG row,long nfirstel,complex<r_4> val); 124 void Write(int col,LONGLONG row,long nfirstel,complex<r_8> val); 119 125 120 126 inline void Write(int col,LONGLONG row,int_1 val) {Write(col,row,0,val);} … … 127 133 inline void Write(int col,LONGLONG row,float val) {Write(col,row,0,val);} 128 134 inline void Write(int col,LONGLONG row,double val) {Write(col,row,0,val);} 135 inline void Write(int col,LONGLONG row,complex<r_4> val) {Write(col,row,0,val);} 136 inline void Write(int col,LONGLONG row,complex<r_8> val) {Write(col,row,0,val);} 129 137 130 138 LONGLONG Write(int col,LONGLONG row,TVector<uint_2>& val);
Note:
See TracChangeset
for help on using the changeset viewer.