Ignore:
Timestamp:
Oct 2, 2011, 8:25:23 PM (14 years ago)
Author:
cmv
Message:

bintable avec elements vecteur, cmv 02/10/2011

File:
1 edited

Legend:

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

    r3772 r4023  
    349349{
    350350 ColLabel = ""; ColTUnit = ""; ColTForm = "";
    351  ColNum = -1; ColTypeCode = 0;
     351 ColNum = -1; ColTypeCode = 0; ColRepeat=0;
    352352 NBcol = 0; NBline = 0;
    353353 SetNulVal(); SetDebug(0);
     
    363363{
    364364 // Initialisation des Parametres Generaux
    365  ColLabel=collabel; ColTUnit=""; ColTForm=""; ColNum=colnum; ColTypeCode=0;
     365 ColLabel=collabel; ColTUnit=""; ColTForm=""; ColNum=colnum; ColTypeCode=0; ColRepeat=0;
    366366 NBcol = 0; NBline = 0;
    367367 SetNulVal(); SetDebug(lp);
     
    469469 ColTUnit = tunit;
    470470 ColTForm = tform;
     471 ColRepeat = repeat;
    471472
    472473 // Set the buffer for reading
     
    475476 if(DbgLevel)
    476477   cout<<"FitsABTColRd::Init Num="<<ColNum<<" Label="<<ColLabel
    477        <<" TypeCode="<<ColTypeCode<<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<endl;
     478       <<" TypeCode="<<ColTypeCode<<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<" Repeat="<<ColRepeat<<endl;
    478479 if(DbgLevel>1)
    479    cout<<"      (repeat="<<repeat<<",tscale="<<tscale<<",tzero="<<tzero
    480        <<",tdisp="<<tdisp<<")"<<endl;
     480   cout<<"      (tscale="<<tscale<<",tzero="<<tzero<<",tdisp="<<tdisp<<")"<<endl;
    481481
    482482}
     
    503503
    504504 // Compute buffer caracteristics
    505  BuffLen = (blen<=0)? 1: blen;
     505 BuffLen = (blen<=0 || ColRepeat!=1)? 1: blen;
    506506 BuffSens = bsens;
    507507 NBuffer = BuffLen;
     
    566566/////////////////////////////////////////////////
    567567/*!
    568   Read row "n" and return the value into a double
     568  Read row "n" element "nfirstel" and return the value into a double
    569569  \warning be carefull for the range: row = [0,NRows[
    570570  \return value in double
     
    576576  \endverbatim
    577577*/
    578 double FitsABTColRd::Read(LONGLONG n,bool usebuffer)
     578double FitsABTColRd::Read(LONGLONG n,long nfirstel,bool usebuffer)
    579579// Attention: n=nline [0,NBline[, cfistio veut [1,NBline]
    580580// Attention: colnum  [0,NBcol[ , cfistio veut [1,NBcol]
     581// Attention: nfirstel  [0,ColRepeat[ , cfistio veut [1,ColRepeat]
    581582{
    582583 int sta=0;
    583584 if(n<0 || n>=NBline)
    584585   throw RangeCheckError("FitsABTColRd::Read try to read outside line range\n");
    585 
    586  // Pas de bufferisation, on lit betement
    587  if(NBuffer==1 || !usebuffer) {
     586 if(nfirstel<0 || nfirstel>=ColRepeat)
     587   throw RangeCheckError("FitsABTColRd::Read try to read outside element range: nfirstel>repeat\n");
     588
     589 // Pas de bufferisation (ou repeat=1), on lit betement
     590 if(NBuffer==1 || !usebuffer || ColRepeat!=1) {
    588591   NFitsRead++;
    589592   double val;
    590    fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n+1,1,1,NULL,&val,NULL,&sta);
     593   fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n+1,nfirstel+1,1,NULL,&val,NULL,&sta);
    591594   if(sta) {
    592595     FitsOpenFile::printerror(sta);
     
    603606 }
    604607
    605  // Gestion avec bufferisation
     608 // Gestion avec bufferisation (uniquement dans le cas repeat=1)
    606609 if(!Buffer)
    607610   throw RangeCheckError("FitsABTColRd::Read: Buffer not allocated\n");
     
    669672LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<double>& data)
    670673{
     674 if(ColRepeat>1)
     675   throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n");
    671676 if(n1<0 || n1>=NBline)
    672677   throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
     
    693698LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<float>& data)
    694699{
     700 if(ColRepeat>1)
     701   throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n");
    695702 if(n1<0 || n1>=NBline)
    696703   throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
     
    717724LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data)
    718725{
     726 if(ColRepeat>1)
     727   throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n");
    719728 if(n1<0 || n1>=NBline)
    720729   throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
     
    740749LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
    741750{
     751 if(ColRepeat>1)
     752   throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n");
    742753 if(n1<0 || n1>=NBline)
    743754   throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
     
    766777{
    767778#ifdef TLONGLONG
     779 if(ColRepeat>1)
     780   throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n");
    768781 if(n1<0 || n1>=NBline)
    769782   throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n");
     
    792805/*!
    793806  Return the number of the first row where "val1"<=val<="val2" starting at row "rowstart"
     807  for element "nfirstel"
    794808  \verbatim
    795809  - The search is performed from "rowstart" to the end
     
    800814  \return <0 means not found
    801815*/
    802 LONGLONG FitsABTColRd::FirstRow(double val1,double val2,LONGLONG rowstart)
    803 {
     816LONGLONG FitsABTColRd::FirstRow(long nfirstel,double val1,double val2,LONGLONG rowstart)
     817{
     818 if(nfirstel<0 || nfirstel>=ColRepeat)
     819   throw RangeCheckError("FitsABTColRd::FirstRow try to read outside element range: nfirstel>repeat\n");
    804820 LONGLONG row = -1;
    805821 if(NBline==0) return row;
     
    810826 if(rowstart>=NBline) rowstart = NBline-1;
    811827 for(LONGLONG i=rowstart;i<NBline;i++) {
    812    double val = Read(i);
     828   double val = Read(i,nfirstel);
    813829   if(val<val1 || val>val2) continue;
    814830   row = i;
     
    820836
    821837/*!
    822   Return the number of the first row where val1<=val<=val2 starting at row rowstart
     838  Return the number of the last row where val1<=val<=val2 starting at row rowstart
     839  for element "nfirstel"
    823840  \return <0 means not found
    824841  \verbatim
     
    829846  \endverbatim
    830847*/
    831 LONGLONG FitsABTColRd::LastRow(double val1,double val2,LONGLONG rowstart)
    832 {
     848LONGLONG FitsABTColRd::LastRow(long nfirstel,double val1,double val2,LONGLONG rowstart)
     849{
     850 if(nfirstel<0 || nfirstel>=ColRepeat)
     851   throw RangeCheckError("FitsABTColRd::FirstRow try to read outside element range: nfirstel>repeat\n");
    833852 LONGLONG row = -1;
    834853 if(NBline==0) return row;
     
    838857 if(rowstart<0 || rowstart>=NBline) rowstart = NBline-1;
    839858 for(LONGLONG i=rowstart;i>=0;i--) {
    840    double val = Read(i);
     859   double val = Read(i,nfirstel);
    841860   if(val<val1 || val>val2) continue;
    842861   row = i;
     
    855874 os<<"\n... "<<FileName()<<"["<<HDU()<<"/"<<NHDU()<<" type="<<HDUType()<<"]"
    856875   <<"\n... Label["<<ColNum<<"]="<<ColLabel<<" TypeCode="<<ColTypeCode
    857    <<" TUnit="<<ColTUnit<<" TForm="<<ColTForm
     876   <<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<" Repeat="<<ColRepeat
    858877   <<endl;
    859878}
     
    9831002{
    9841003 // Initialisation des Parametres Generaux
    985  ColLabel.resize(0); ColTUnit.resize(0); ColTForm.resize(0); ColTypeCode.resize(0);
     1004 ColLabel.resize(0); ColTUnit.resize(0); ColTForm.resize(0); ColTypeCode.resize(0); ColRepeat.resize(0);
    9861005 NBcol = 0; NBline = 0;
    9871006 SetNulVal(); SetDebug(lp);
     
    10771096   ColTUnit.push_back(tunit);
    10781097   ColTForm.push_back(tform);
     1098   ColRepeat.push_back(repeat);
    10791099   // fill the default buffer limits at init
    10801100   LineDeb.push_back(-1);
     
    10831103   if(DbgLevel)
    10841104     cout<<"FitsABTColRd1F::Init Num="<<ColNum<<" Label="<<ColLabel[ColNum]
    1085          <<" TypeCode="<<ColTypeCode[ColNum]<<" TUnit="<<ColTUnit[ColNum]<<" TForm="<<ColTForm[ColNum]<<endl;
     1105         <<" TypeCode="<<ColTypeCode[ColNum]<<" TUnit="<<ColTUnit[ColNum]<<" TForm="<<ColTForm[ColNum]<<" Repeat="<<ColRepeat[ColNum]<<endl;
    10861106   if(DbgLevel>1)
    1087      cout<<"      (repeat="<<repeat<<",tscale="<<tscale<<",tzero="<<tzero
    1088          <<",tdisp="<<tdisp<<")"<<endl;
     1107     cout<<"      (tscale="<<tscale<<",tzero="<<tzero<<",tdisp="<<tdisp<<")"<<endl;
    10891108 }   // ***** ColNum
    10901109
     
    11981217/////////////////////////////////////////////////
    11991218/*!
    1200   Read row "n" of column "ColNum" and return the value into a double
     1219  Read row "n" element "nfirstel" of column "ColNum" and return the value into a double
    12011220  \warning be carefull for the range: row = [0,NRows[
    12021221  \return value in double
     
    12081227  \endverbatim
    12091228*/
    1210 double FitsABTColRd1F::Read(int ColNum,LONGLONG n,bool usebuffer)
     1229double FitsABTColRd1F::Read(int ColNum,LONGLONG n,long nfirstel,bool usebuffer)
    12111230// Attention: n=nline [0,NBline[, cfistio veut [1,NBline]
    12121231// Attention: colnum  [0,NBcol[ , cfistio veut [1,NBcol]
     1232// Attention: nfirstel  [0,ColRepeat[ , cfistio veut [1,ColRepeat]
    12131233{
    12141234 int sta=0;
     
    12171237 if(n<0 || n>=NBline)
    12181238   throw RangeCheckError("FitsABTColRd1F::Read try to read outside line range\n");
    1219 
    1220  // Pas de bufferisation, on lit betement
    1221  if(NBuffer==1 || !usebuffer) {
     1239 if(nfirstel<0 || nfirstel>=ColRepeat[ColNum])
     1240   throw RangeCheckError("FitsABTColRd1F::Read try to read outside element range: nfirstel>repeat\n");
     1241
     1242 // Pas de bufferisation (ou repeat=1), on lit betement
     1243 if(NBuffer==1 || !usebuffer || ColRepeat[ColNum]!=1) {
    12221244   double val;
    1223    fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n+1,1,1,NULL,&val,NULL,&sta);
     1245   fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n+1,nfirstel+1,1,NULL,&val,NULL,&sta);
    12241246   if(sta) {
    12251247     FitsOpenFile::printerror(sta);
     
    12361258 }
    12371259
    1238  // Gestion avec bufferisation
     1260 // Gestion avec bufferisation (uniquement dans le cas repeat=1)
    12391261 if(!Buffer)
    12401262   throw RangeCheckError("FitsABTColRd1F::Read: Buffer not allocated\n");
Note: See TracChangeset for help on using the changeset viewer.