Changeset 4025 in Sophya for trunk/SophyaExt


Ignore:
Timestamp:
Oct 3, 2011, 6:32:44 PM (14 years ago)
Author:
cmv
Message:

read/write string, complex, bufferisation enlevee pour FitsABTColRd1F, cmv 03/10/2011

Location:
trunk/SophyaExt/FitsIOServer
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaExt/FitsIOServer/fabtcolread.cc

    r4023 r4025  
    349349{
    350350 ColLabel = ""; ColTUnit = ""; ColTForm = "";
    351  ColNum = -1; ColTypeCode = 0; ColRepeat=0;
     351 ColNum = -1; ColTypeCode = 0; ColRepeat=0; ColDispWidth=0;
     352 StrBuff = NULL;
    352353 NBcol = 0; NBline = 0;
    353354 SetNulVal(); SetDebug(0);
     
    363364{
    364365 // 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;
    366369 NBcol = 0; NBline = 0;
    367370 SetNulVal(); SetDebug(lp);
     
    445448 }
    446449 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");
    450452
    451453 // Get column name back, tunit, tform
     
    454456 int rc=0;
    455457 if(HDUType()==BINARY_TBL) {
    456    fits_get_bcolparmsll(GetFitsPtr(),ColNum+1,labelcol,tunit,tform
    457                      ,&repeat,&tscale,&tzero,NULL,tdisp,&sta);
     458   rc = fits_get_bcolparmsll(GetFitsPtr(),ColNum+1,labelcol,tunit,tform
     459                            ,&repeat,&tscale,&tzero,NULL,tdisp,&sta);
    458460 } else {
    459461   long repeatlng;
    460    fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeatlng,tunit,tform
    461                      ,&tscale,&tzero,NULL,tdisp,&sta);
     462   rc = fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeatlng,tunit,tform
     463                          ,&tscale,&tzero,NULL,tdisp,&sta);
    462464   repeat = repeatlng;
    463465 }
     
    471473 ColRepeat = repeat;
    472474
     475 fits_get_col_display_width(GetFitsPtr(),ColNum+1,&ColDispWidth,&sta);
     476
    473477 // Set the buffer for reading
    474478 ChangeBuffer(blen,bsens);
     
    476480 if(DbgLevel)
    477481   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;
    479484 if(DbgLevel>1)
    480485   cout<<"      (tscale="<<tscale<<",tzero="<<tzero<<",tdisp="<<tdisp<<")"<<endl;
     
    491496void FitsABTColRd::Delete(void)
    492497{
     498 if(StrBuff!=NULL) {delete [] StrBuff; StrBuff=NULL;}
    493499 if(Buffer!=NULL) {delete [] Buffer; Buffer=NULL;}
    494500 LineDeb = LineFin = -1;
     
    639645
    640646/*!
     647  Read row "n" element "nfirstel" and return a complex value
     648*/
     649complex<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*/
     669char* 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/*!
    641691  Read rows from "n1" to "n2" and return the values into TVector of double
    642692  \return NREAD the number of values read (n2-n1+1).
     
    875925   <<"\n... Label["<<ColNum<<"]="<<ColLabel<<" TypeCode="<<ColTypeCode
    876926   <<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<" Repeat="<<ColRepeat
     927   <<" DispWidth="<<ColDispWidth
    877928   <<endl;
    878929}
     
    9931044///////////////////////////////////////////////////////////////////
    9941045
    995 FitsABTColRd1F::FitsABTColRd1F(FitsOpenFile* fof,int ihdu,long blen,long bsens,int lp)
    996 {
    997   Init(fof,ihdu,blen,bsens,lp);
     1046FitsABTColRd1F::FitsABTColRd1F(FitsOpenFile* fof,int ihdu,int lp)
     1047{
     1048  Init(fof,ihdu,lp);
    9981049}
    9991050
    10001051/*! Init routine called by the constructor */
    1001 void FitsABTColRd1F::Init(FitsOpenFile* fof,int ihdu,long blen,long bsens,int lp)
     1052void FitsABTColRd1F::Init(FitsOpenFile* fof,int ihdu,int lp)
    10021053{
    10031054 // 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);
    10051058 NBcol = 0; NBline = 0;
    10061059 SetNulVal(); SetDebug(lp);
    10071060 FitsOF = NULL;
    1008  LineDeb.resize(0); LineFin.resize(0);
    1009  Buffer = NULL;
    10101061
    10111062 // Caracteristiques du FitsOpenFile
     
    10721123   }
    10731124   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");
    10771127   // Get column name, tunit, tform
    10781128   char labelcol[128];
     
    10811131   int rc=0;
    10821132   if(HDUType()==BINARY_TBL) {
    1083      fits_get_bcolparmsll(GetFitsPtr(),ColNum+1,labelcol,tunit,tform
     1133     rc = fits_get_bcolparmsll(GetFitsPtr(),ColNum+1,labelcol,tunit,tform
    10841134                       ,&repeat,&tscale,&tzero,NULL,tdisp,&sta);
    10851135   } else {
    10861136     long repeatlng;
    1087      fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeatlng,tunit,tform
     1137     rc = fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeatlng,tunit,tform
    10881138                       ,&tscale,&tzero,NULL,tdisp,&sta);
    10891139     repeat = repeatlng;
     
    10971147   ColTForm.push_back(tform);
    10981148   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
    11021155   // some debug print if requested
    11031156   if(DbgLevel)
    11041157     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;
    11061160   if(DbgLevel>1)
    11071161     cout<<"      (tscale="<<tscale<<",tzero="<<tzero<<",tdisp="<<tdisp<<")"<<endl;
    11081162 }   // ***** ColNum
    11091163
    1110  // Set the buffer for reading
    1111  ChangeBuffer(blen,bsens);
    1112 
    11131164}
    11141165
     
    11221173void FitsABTColRd1F::Delete(void)
    11231174{
    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    }
    11301180 //--- 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 caracteristics
    1140  BuffLen = (blen<=0)? 1: blen;
    1141  BuffSens = bsens;
    1142  NBuffer = BuffLen;
    1143  if(bsens==0 && NBuffer%2==0) NBuffer++;
    1144 
    1145  // De-allocate if necessary
    1146  if(Buffer!=NULL) {
    1147    // On des-alloue si pas assez de place
    1148    // 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-allocate
    1156  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 buffer
    1162  for(int ColNum=0; ColNum<NBcol; ColNum++) LineDeb[ColNum] = LineFin[ColNum] = -1;
    11631181}
    11641182
     
    12271245  \endverbatim
    12281246*/
    1229 double FitsABTColRd1F::Read(int ColNum,LONGLONG n,long nfirstel,bool usebuffer)
     1247double FitsABTColRd1F::Read(int ColNum,LONGLONG n,long nfirstel)
    12301248// Attention: n=nline [0,NBline[, cfistio veut [1,NBline]
    12311249// Attention: colnum  [0,NBcol[ , cfistio veut [1,NBcol]
     
    12401258   throw RangeCheckError("FitsABTColRd1F::Read try to read outside element range: nfirstel>repeat\n");
    12411259
    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*/
     1273complex<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*/
     1295char* 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}
    12911316
    12921317/*! Print on stream os */
    12931318void FitsABTColRd1F::Print(ostream& os,int lp) const
    12941319{
    1295  os<<"FitsABTColRd1F:Print ("<<BuffLen<<","<<BuffSens<<","<<NulVal<<")"
     1320 os<<"FitsABTColRd1F:Print ("<<NulVal<<")"
    12961321   <<" ncols="<<NBcol<<" nrows="<<NBline;
    12971322 os<<"\n... "<<FileName()<<"["<<HDU()<<"/"<<NHDU()<<" type="<<HDUType()<<"]"<<endl;
     
    12991324   for(int ColNum=0;ColNum<NBcol;ColNum++) {
    13001325     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]
    13021328       <<endl;
    13031329   }
     
    13161342  \warning col = [0,ncol[
    13171343*/
    1318 FitsABTColRead1F::FitsABTColRead1F(string fname,int ihdu,long blen,long bsens,int lp)
    1319 : FitsABTColRd1F(new FitsOpenFile(fname),ihdu,blen,bsens,lp)
     1344FitsABTColRead1F::FitsABTColRead1F(string fname,int ihdu,int lp)
     1345: FitsABTColRd1F(new FitsOpenFile(fname),ihdu,lp)
    13201346{
    13211347}
    13221348
    13231349/*! 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)
     1350FitsABTColRead1F::FitsABTColRead1F(const char * cfname,int ihdu,int lp)
     1351: FitsABTColRd1F(new FitsOpenFile(cfname),ihdu,lp)
    13261352{
    13271353}
  • trunk/SophyaExt/FitsIOServer/fabtcolread.h

    r4023 r4025  
    8585  double Read(LONGLONG n,long nfirstel,bool usebuffer=true);
    8686  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);
    8789
    8890  LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data);
     
    161163
    162164  string ColLabel,ColTUnit,ColTForm;
    163   int ColNum,ColTypeCode,NBcol;
     165  int ColNum,ColTypeCode,ColDispWidth,NBcol;
    164166  long ColRepeat;
    165167  LONGLONG NBline;
     168  char *StrBuff;
    166169
    167170  double NulVal;
     
    195198
    196199///////////////////////////////////////////////////////////////////
    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)
    198201class FitsABTColRd1F : public AnyDataObj {
    199202public:
    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);
    202204  virtual ~FitsABTColRd1F();
    203 
    204   void ChangeBuffer(long blen=100,long bsens=1);
    205205
    206206  double    ReadKey(const char *keyname);
     
    209209  string    ReadKeyS(const char *keyname);
    210210
    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);
    213215  int GetColNum(const char *colname);
    214216
     
    252254  inline long GetColRepeat(int ColNum) const
    253255         {if(ColNum<0 || ColNum>=NBcol) return -999; else return ColRepeat[ColNum];}
    254   //! Get the read requested buffer length
    255   inline long GetBLen(void) const {return BuffLen;}
    256   //! Get the read buffer direction
    257   inline long GetBSens(void) const {return BuffSens;}
    258256  //! Print to os
    259257  virtual void Print(ostream& os,int lp=1) const;
     
    261259  inline  void Print(int lp=1) const {Print(cout,lp);}
    262260  //! Get the read effective buffer length
    263   inline long GetNBuffer(void) const {return NBuffer;}
    264   //! Get the read bufferpointer
    265   inline double* GetBuffer(int ColNum)
    266          {if(ColNum<0 || ColNum>=NBcol) return NULL; else return Buffer[ColNum];}
    267261
    268262protected:
    269   void Init(FitsOpenFile* fof,int ihdu,long blen,long bsens,int lp);
     263  void Init(FitsOpenFile* fof,int ihdu,int lp);
    270264  void Delete(void);
    271265
    272266  vector<string> ColLabel,ColTUnit,ColTForm;
    273   vector<int> ColTypeCode;
     267  vector<int> ColTypeCode, ColDispWidth;
    274268  vector<long> ColRepeat;
    275269  int NBcol;
    276270  LONGLONG NBline;
     271  vector<char*> StrBuff;
    277272
    278273  double NulVal;
    279274  unsigned short DbgLevel;
    280   long BuffLen, BuffSens;
    281275
    282276  FitsOpenFile* FitsOF;
    283   vector<LONGLONG> LineDeb, LineFin;
    284   double **Buffer;
    285   long NBuffer;
    286277};
    287278
     
    291282class FitsABTColRead1F : public FitsABTColRd1F {
    292283public:
    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);
    297286  virtual ~FitsABTColRead1F();
    298287};
  • trunk/SophyaExt/FitsIOServer/fabtwriter.cc

    r4024 r4025  
    551551
    552552/*! 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))
     553void 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))
    558558    printerrorwrite("char*",col,row,sta);
    559559}
     
    649649  int sta=0;
    650650  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) */
     655void 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) */
     665void 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))
    651671    printerrorwrite("double",col,row,sta);
    652672}
  • trunk/SophyaExt/FitsIOServer/fabtwriter.h

    r4024 r4025  
    104104     {return addcol(label,tform,tunit,datatype);}
    105105
    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());}
    107111  inline void Write(int col,LONGLONG row,string val)
    108               {Write(col,row,val.c_str());}
     112                   {Write(col,row,0,val.c_str());}
    109113
    110114  void Write(int col,LONGLONG row,long nfirstel,int_1 val);
     
    117121  void Write(int col,LONGLONG row,long nfirstel,float val);
    118122  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);
    119125
    120126  inline void Write(int col,LONGLONG row,int_1 val) {Write(col,row,0,val);}
     
    127133  inline void Write(int col,LONGLONG row,float val) {Write(col,row,0,val);}
    128134  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);}
    129137
    130138  LONGLONG Write(int col,LONGLONG row,TVector<uint_2>& val);
Note: See TracChangeset for help on using the changeset viewer.