Index: trunk/SophyaExt/FitsIOServer/fitsarrhand.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsarrhand.h	(revision 3167)
+++ trunk/SophyaExt/FitsIOServer/fitsarrhand.h	(revision 3493)
@@ -1,2 +1,7 @@
+/*    
+   --- SOPHYA software - FitsIOServer module ---
+   R. Ansari , 2005-2008 
+   (C) UPS+LAL IN2P3/CNRS     (C) DAPNIA-SPP/CEA 
+*/
 #ifndef FITSARRHAND_H
 #define FITSARRHAND_H
@@ -64,8 +69,10 @@
 
   //----- Ecriture
+  //! Writes the complete array as an IMAGE HDU
   virtual void     Write(FitsInOutFile& os)
     {
-      if ( dobj == NULL) 
-	throw NullPtrError("FitsArrayHandler<T>::Write() dobj=NULL ");
+      if (( dobj == NULL) || (dobj->Size() < 1))  
+  	  throw NullPtrError("FitsArrayHandler<T>::Write() dobj=NULL or dobj->Size()=0");
+    	
       LONGLONG naxes[BASEARRAY_MAXNDIMS] = {0,0,0,0,0};
       for(int_4 id=0; id<dobj->NbDimensions(); id++) 
@@ -81,4 +88,5 @@
 
   //----- Lecture
+  //! Resize the array and reads the complete IMAGE HDU to the array
   virtual void     Read(FitsInOutFile& is)
     {
@@ -97,9 +105,61 @@
       }
       sa_size_t sz[BASEARRAY_MAXNDIMS];
-      if (naxis > BASEARRAY_MAXNDIMS) naxis = BASEARRAY_MAXNDIMS;
+      if (naxis > BASEARRAY_MAXNDIMS) { 
+      	cerr << "FitsArrayHandler<T>::Read()/Warning FITS NAXIS=" << naxis 
+      		 << " > BASEARRAY_MAXNDIMS=" << BASEARRAY_MAXNDIMS << endl;
+      	naxis = BASEARRAY_MAXNDIMS;
+      }
       for(int_4 id=0; id<naxis; id++) sz[id] = naxes[id];
       dobj->SetSize(naxis, sz, 1, false);
       FitsBlockRW<T>::ReadImageData(is, dobj->Data(), dobj->Size());
       is.GetHeaderRecords(dobj->Info());
+    }
+
+  //----- Lecture avec specification d'offset et taille donnee par le tableau
+  /*!  \brief Reads from the fits file into the array, at the specified offset 
+  
+     The array should be allocated and its size is used to define the number of 
+     pixels to be read. 
+     \warning The offset should be specified with SOPHYA/C array index convention 
+     (starting at zero) - and NOT the cfitsio/fortran convention. 
+     The offset should contain as many elements as the fits NAXIS keyword.
+  */
+  virtual void     ReadAtOffset(FitsInOutFile& is, sa_size_t* offset)
+    {
+    if (( dobj == NULL) || (dobj->Size() < 1))  
+  	  throw NullPtrError("FitsArrayHandler<T>::ReadAtOffset() dobj=NULL or dobj->Size()=0");
+	
+    LONGLONG naxes[BASEARRAY_MAXNDIMS];
+    int naxis=BASEARRAY_MAXNDIMS;
+    is.GetImageHDUInfo(naxis, naxes);
+    LONGLONG fpix[15]; 
+    int namx = (naxis < 15) ? naxis : 15;
+    for(int i=0; i<namx; i++) fpix[i] = offset[i]+1;
+    FitsBlockRW<T>::ReadImageData(is, dobj->Data(), dobj->Size(), fpix);
+    is.GetHeaderRecords(dobj->Info());
+    }
+
+  //----- Ecriture avec specification d'offset et taille donnee par le tableau
+  /*!  \brief Writes the array to the fits file, at the specified offset 
+  
+     The array should be allocated and its size is used to define the number of 
+     pixels to be read. 
+     \warning The offset should be specified with SOPHYA/C array index convention 
+     (starting at zero) - and NOT the cfitsio/fortran convention. 
+     The offset should contain as many elements as the fits NAXIS keyword.
+     \warning The IMAGE HDU should be already created using FitsInOutFile::CreateImageHDU().
+  */
+  virtual void     WriteAtOffset(FitsInOutFile& os, sa_size_t* offset)
+    {
+    if (( dobj == NULL) || (dobj->Size() < 1))  
+  	  throw NullPtrError("FitsArrayHandler<T>::ReadAtOffset() dobj=NULL or dobj->Size()=0");
+
+    LONGLONG naxes[BASEARRAY_MAXNDIMS];
+    int naxis=BASEARRAY_MAXNDIMS;
+    os.GetImageHDUInfo(naxis, naxes);
+    LONGLONG fpix[15]; 
+    int namx = (naxis < 15) ? naxis : 15;
+    for(int i=0; i<namx; i++) fpix[i] = offset[i]+1;
+    FitsBlockRW<T>::WriteImageData(os, dobj->Data(), dobj->Size(), fpix);	
     }
 
@@ -110,8 +170,10 @@
 
 
+//! operator << overload to write a TArray<T> to a fits IMAGE HDU
 template <class T>
 inline FitsInOutFile& operator << (FitsInOutFile& os, TArray<T> const & obj)
 { FitsArrayHandler<T> fio(const_cast< TArray<T> &>(obj));  fio.Write(os);  return os; }
 
+//! operator >> overload to read a TArray<T> from a fits IMAGE HDU
 template <class T>
 inline FitsInOutFile& operator >> (FitsInOutFile& is, TArray<T> & obj)
