Index: trunk/SophyaExt/FitsIOServer/datacirclefits.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/datacirclefits.cc	(revision 1814)
+++ trunk/SophyaExt/FitsIOServer/datacirclefits.cc	(revision 1815)
@@ -11,43 +11,63 @@
 , _ICircle(0)
 , _mesures(NULL)
-,_stored_data(false)
+, _stored_data(false)
 {;}
 
-DataCircleFits::DataCircleFits(FitsInFile& is,int hdunum,bool sdata) :
+DataCircleFits::DataCircleFits(fitsfile *is,int hdunum,bool sdata) :
   _fptr(NULL)
 , _NMeasurements(0)
 , _ICircle(hdunum)
 , _mesures(NULL)
-,_stored_data(sdata)
+, _stored_data(sdata)
 {
 
   // pointer to the FITS file
-  _fptr= &is;
+  _fptr= is;
+  int status = 0;
 
   // move to the HDU containing a circle
-  _fptr->ReadHeader(hdunum);
-
-  // reference on a DVList containing the keywords
-  DVList dvl= _fptr->DVListFromFits();
+  fits_movabs_hdu(_fptr,hdunum,NULL,&status);
 
   // angles of the circle
-  double theta= dvl.GetD("CIRTHETA");
-  double phi  = dvl.GetD("CIRPHI");
-  double aperture= dvl.GetD("CIRAPER");
+  double theta;
+  fits_read_key(_fptr,TDOUBLE,"CIRTHETA",&theta,NULL,&status);
+
+  double phi;
+  fits_read_key(_fptr,TDOUBLE,"CIRPHI",&phi,NULL,&status);
+
+  double aperture;
+  fits_read_key(_fptr,TDOUBLE,"CIRAPER",&aperture,NULL,&status);
 
   UnitVector temp(theta,phi);
   SetCircle(temp,aperture);
 
- _NMeasurements= dvl.GetI("NSAMPLES");
+  fits_read_key(_fptr,TINT,"NSAMPLES",&_NMeasurements,NULL,&status);
 
- if(_stored_data) {
-   _mesures= new double[_NMeasurements];
+  if(_stored_data) {
+    // vector repeat value for the column (there is only 1 column)
+    long repeat;
+    fits_get_coltype(_fptr,1,NULL,&repeat,NULL,&status);
+
+    double dnull= 0.;
+    int    anull;
+    _mesures= new double[_NMeasurements];
    int i;
    for(i = 0; i < _NMeasurements; i++) {
-     _fptr->GetBinTabLine(i,&_mesures[i],NULL,NULL,NULL);
+     // row index: range 1 to NAXIS2
+     int index= i+1;
+     
+     // starting line index
+     int stline= index/repeat; 
+     int stelem= index-stline*repeat;
+     if(stelem != 0) {
+       stline++;
+     } else {
+       stelem= repeat;
+     }
+     fits_read_col(_fptr,TDOUBLE,1,stline,stelem,1,&dnull,&_mesures[i],&anull,&status);
    }
- }
+  }
 }
-
+  
 DataCircleFits::~DataCircleFits() {
 
@@ -63,11 +83,30 @@
 
   double dtab;
-  int ibin= (int)floor(psi*_NMeasurements/2./M_PI);
+  int ibin= nint(psi*_NMeasurements/(2.*M_PI));
+  //cout << " ibin= " << ibin << ", " << psi << endl;
 
   if(_stored_data) {
     dtab= _mesures[ibin];
   } else {
-    _fptr->ReadHeader(_ICircle);
-    _fptr->GetBinTabLine(ibin,&dtab,NULL,NULL,NULL);
+    int status= 0;
+    fits_movabs_hdu(_fptr,_ICircle,NULL,&status);
+
+    // vector repeat value for the column (there is only 1 column)
+    long repeat;
+    fits_get_coltype(_fptr,1,NULL,&repeat,NULL,&status);
+   
+    double dnull= 0.;
+    int    anull;
+
+    int index= ibin+1;
+    // starting line index
+    int stline= index/repeat; 
+    int stelem= index-stline*repeat;
+    if(stelem != 0) {
+      stline++;
+    } else {
+      stelem= repeat;
+    }
+    fits_read_col(_fptr,TDOUBLE,1,stline,stelem,1,&dnull,&dtab,&anull,&status);
   }
   //cout << "DataCircleFits:: bin= " << ibin << ", " << dtab << endl;
@@ -81,2 +120,22 @@
       << NMeasurements() << endl;
 }
+
+double DataCircleFits::getTMeasure(double psi) const {
+
+  if(_mesures == NULL) {
+    cout << "  DataCircleFits::getTMeasure data must be stored"
+	 << " in an array... verify the option" << endl;
+    exit(0);
+  }
+  int ibin= nint(psi*_NMeasurements/(2.*M_PI));
+  return _mesures[ibin];
+}
+double DataCircleFits::getTOffset() {
+
+  int status= 0;
+  fits_movabs_hdu(_fptr,_ICircle,NULL,&status);
+
+  double omes= 0.0;
+  fits_read_key_dbl(_fptr,"OFFSET",&omes,NULL,&status);
+  return omes;
+}
Index: trunk/SophyaExt/FitsIOServer/datacirclefits.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/datacirclefits.h	(revision 1814)
+++ trunk/SophyaExt/FitsIOServer/datacirclefits.h	(revision 1815)
@@ -3,5 +3,5 @@
 
 #include "datacirclebase.h"
-#include "fitsfile.h"
+#include "FitsIO/fitsio.h" 
 
 class DataCircleFits : public DataCircleBase {
@@ -10,5 +10,5 @@
 
   DataCircleFits();
-  DataCircleFits(FitsInFile&,int,bool);
+  DataCircleFits(fitsfile*,int,bool);
   virtual ~DataCircleFits();
 
@@ -17,7 +17,10 @@
   virtual void print(ostream&) const;
 
+  double getTMeasure(double) const;
+  double getTOffset();
+
  private:
 
-  FitsInFile* _fptr;
+  fitsfile* _fptr;
   int _ICircle;
   int _NMeasurements;
