Changeset 4023 in Sophya for trunk/SophyaExt/FitsIOServer/fabtcolread.cc
- Timestamp:
- Oct 2, 2011, 8:25:23 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fabtcolread.cc
r3772 r4023 349 349 { 350 350 ColLabel = ""; ColTUnit = ""; ColTForm = ""; 351 ColNum = -1; ColTypeCode = 0; 351 ColNum = -1; ColTypeCode = 0; ColRepeat=0; 352 352 NBcol = 0; NBline = 0; 353 353 SetNulVal(); SetDebug(0); … … 363 363 { 364 364 // Initialisation des Parametres Generaux 365 ColLabel=collabel; ColTUnit=""; ColTForm=""; ColNum=colnum; ColTypeCode=0; 365 ColLabel=collabel; ColTUnit=""; ColTForm=""; ColNum=colnum; ColTypeCode=0; ColRepeat=0; 366 366 NBcol = 0; NBline = 0; 367 367 SetNulVal(); SetDebug(lp); … … 469 469 ColTUnit = tunit; 470 470 ColTForm = tform; 471 ColRepeat = repeat; 471 472 472 473 // Set the buffer for reading … … 475 476 if(DbgLevel) 476 477 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; 478 479 if(DbgLevel>1) 479 cout<<" (repeat="<<repeat<<",tscale="<<tscale<<",tzero="<<tzero 480 <<",tdisp="<<tdisp<<")"<<endl; 480 cout<<" (tscale="<<tscale<<",tzero="<<tzero<<",tdisp="<<tdisp<<")"<<endl; 481 481 482 482 } … … 503 503 504 504 // Compute buffer caracteristics 505 BuffLen = (blen<=0 )? 1: blen;505 BuffLen = (blen<=0 || ColRepeat!=1)? 1: blen; 506 506 BuffSens = bsens; 507 507 NBuffer = BuffLen; … … 566 566 ///////////////////////////////////////////////// 567 567 /*! 568 Read row "n" and return the value into a double568 Read row "n" element "nfirstel" and return the value into a double 569 569 \warning be carefull for the range: row = [0,NRows[ 570 570 \return value in double … … 576 576 \endverbatim 577 577 */ 578 double FitsABTColRd::Read(LONGLONG n, bool usebuffer)578 double FitsABTColRd::Read(LONGLONG n,long nfirstel,bool usebuffer) 579 579 // Attention: n=nline [0,NBline[, cfistio veut [1,NBline] 580 580 // Attention: colnum [0,NBcol[ , cfistio veut [1,NBcol] 581 // Attention: nfirstel [0,ColRepeat[ , cfistio veut [1,ColRepeat] 581 582 { 582 583 int sta=0; 583 584 if(n<0 || n>=NBline) 584 585 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) { 588 591 NFitsRead++; 589 592 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); 591 594 if(sta) { 592 595 FitsOpenFile::printerror(sta); … … 603 606 } 604 607 605 // Gestion avec bufferisation 608 // Gestion avec bufferisation (uniquement dans le cas repeat=1) 606 609 if(!Buffer) 607 610 throw RangeCheckError("FitsABTColRd::Read: Buffer not allocated\n"); … … 669 672 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<double>& data) 670 673 { 674 if(ColRepeat>1) 675 throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n"); 671 676 if(n1<0 || n1>=NBline) 672 677 throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n"); … … 693 698 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<float>& data) 694 699 { 700 if(ColRepeat>1) 701 throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n"); 695 702 if(n1<0 || n1>=NBline) 696 703 throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n"); … … 717 724 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data) 718 725 { 726 if(ColRepeat>1) 727 throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n"); 719 728 if(n1<0 || n1>=NBline) 720 729 throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n"); … … 740 749 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<int_4>& data) 741 750 { 751 if(ColRepeat>1) 752 throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n"); 742 753 if(n1<0 || n1>=NBline) 743 754 throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n"); … … 766 777 { 767 778 #ifdef TLONGLONG 779 if(ColRepeat>1) 780 throw RangeCheckError("FitsABTColRd::Read TVector not-implemented for repeat>1 \n"); 768 781 if(n1<0 || n1>=NBline) 769 782 throw RangeCheckError("FitsABTColRd::Read TVector bad requested 1srt line \n"); … … 792 805 /*! 793 806 Return the number of the first row where "val1"<=val<="val2" starting at row "rowstart" 807 for element "nfirstel" 794 808 \verbatim 795 809 - The search is performed from "rowstart" to the end … … 800 814 \return <0 means not found 801 815 */ 802 LONGLONG FitsABTColRd::FirstRow(double val1,double val2,LONGLONG rowstart) 803 { 816 LONGLONG 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"); 804 820 LONGLONG row = -1; 805 821 if(NBline==0) return row; … … 810 826 if(rowstart>=NBline) rowstart = NBline-1; 811 827 for(LONGLONG i=rowstart;i<NBline;i++) { 812 double val = Read(i );828 double val = Read(i,nfirstel); 813 829 if(val<val1 || val>val2) continue; 814 830 row = i; … … 820 836 821 837 /*! 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" 823 840 \return <0 means not found 824 841 \verbatim … … 829 846 \endverbatim 830 847 */ 831 LONGLONG FitsABTColRd::LastRow(double val1,double val2,LONGLONG rowstart) 832 { 848 LONGLONG 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"); 833 852 LONGLONG row = -1; 834 853 if(NBline==0) return row; … … 838 857 if(rowstart<0 || rowstart>=NBline) rowstart = NBline-1; 839 858 for(LONGLONG i=rowstart;i>=0;i--) { 840 double val = Read(i );859 double val = Read(i,nfirstel); 841 860 if(val<val1 || val>val2) continue; 842 861 row = i; … … 855 874 os<<"\n... "<<FileName()<<"["<<HDU()<<"/"<<NHDU()<<" type="<<HDUType()<<"]" 856 875 <<"\n... Label["<<ColNum<<"]="<<ColLabel<<" TypeCode="<<ColTypeCode 857 <<" TUnit="<<ColTUnit<<" TForm="<<ColTForm 876 <<" TUnit="<<ColTUnit<<" TForm="<<ColTForm<<" Repeat="<<ColRepeat 858 877 <<endl; 859 878 } … … 983 1002 { 984 1003 // 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); 986 1005 NBcol = 0; NBline = 0; 987 1006 SetNulVal(); SetDebug(lp); … … 1077 1096 ColTUnit.push_back(tunit); 1078 1097 ColTForm.push_back(tform); 1098 ColRepeat.push_back(repeat); 1079 1099 // fill the default buffer limits at init 1080 1100 LineDeb.push_back(-1); … … 1083 1103 if(DbgLevel) 1084 1104 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; 1086 1106 if(DbgLevel>1) 1087 cout<<" (repeat="<<repeat<<",tscale="<<tscale<<",tzero="<<tzero 1088 <<",tdisp="<<tdisp<<")"<<endl; 1107 cout<<" (tscale="<<tscale<<",tzero="<<tzero<<",tdisp="<<tdisp<<")"<<endl; 1089 1108 } // ***** ColNum 1090 1109 … … 1198 1217 ///////////////////////////////////////////////// 1199 1218 /*! 1200 Read row "n" of column "ColNum" and return the value into a double1219 Read row "n" element "nfirstel" of column "ColNum" and return the value into a double 1201 1220 \warning be carefull for the range: row = [0,NRows[ 1202 1221 \return value in double … … 1208 1227 \endverbatim 1209 1228 */ 1210 double FitsABTColRd1F::Read(int ColNum,LONGLONG n, bool usebuffer)1229 double FitsABTColRd1F::Read(int ColNum,LONGLONG n,long nfirstel,bool usebuffer) 1211 1230 // Attention: n=nline [0,NBline[, cfistio veut [1,NBline] 1212 1231 // Attention: colnum [0,NBcol[ , cfistio veut [1,NBcol] 1232 // Attention: nfirstel [0,ColRepeat[ , cfistio veut [1,ColRepeat] 1213 1233 { 1214 1234 int sta=0; … … 1217 1237 if(n<0 || n>=NBline) 1218 1238 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) { 1222 1244 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); 1224 1246 if(sta) { 1225 1247 FitsOpenFile::printerror(sta); … … 1236 1258 } 1237 1259 1238 // Gestion avec bufferisation 1260 // Gestion avec bufferisation (uniquement dans le cas repeat=1) 1239 1261 if(!Buffer) 1240 1262 throw RangeCheckError("FitsABTColRd1F::Read: Buffer not allocated\n");
Note:
See TracChangeset
for help on using the changeset viewer.