Index: trunk/SophyaExt/FitsIOServer/fitsioserver.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsioserver.cc	(revision 839)
+++ trunk/SophyaExt/FitsIOServer/fitsioserver.cc	(revision 854)
@@ -80,5 +80,5 @@
 	  if(DTYPE == TDOUBLE)
 	    {
-	      SphereHealpix<double> *sph= new SphereHealpix<double>(nside);
+	      SphereHEALPix<double> *sph= new SphereHEALPix<double>(nside);
 	      load(*sph,flnm,hdunum);
 	      return sph;
@@ -87,5 +87,5 @@
 	  else if(DTYPE == TFLOAT)
 	    {
-	      SphereHealpix<float> *sph= new SphereHealpix<float>(nside);
+	      SphereHEALPix<float> *sph= new SphereHEALPix<float>(nside);
 	      load(*sph,flnm,hdunum);
 	      return sph;
@@ -501,5 +501,5 @@
 	{ 
 	  sph.Resize(nside);
-	  cout << "FitsIoServer::load(SphereHealpix<double> ...) ReSizing to NSide= " << nside  << endl;
+	  cout << "FitsIoServer::load(SphereHEALPix<double> ...) ReSizing to NSide= " << nside  << endl;
 	}
       //      else
@@ -513,5 +513,5 @@
 
 
-void FitsIoServer::load(SphereHealpix<float>& sph,char flnm[],int nth) 
+void FitsIoServer::load(SphereHEALPix<float>& sph,char flnm[],int nth) 
 {
   int npixels= 0;
@@ -537,10 +537,10 @@
 	{
 	  cout<<" FITSIOSERVER: no resolution parameter on fits file "<<endl;
-	  throw IOExc("FitsIoServer::load(SphereHealpix<float>& ," + (string)flnm + ", ) Error No resolution parameter !");
+	  throw IOExc("FitsIoServer::load(SphereHEALPix<float>& ," + (string)flnm + ", ) Error No resolution parameter !");
 	}
       if (nside != sph.SizeIndex())
 	{ 
 	  sph.Resize(nside);
-	  cout << " FitsIoServer::load(SphereHealpix<float> ...)";
+	  cout << " FitsIoServer::load(SphereHEALPix<float> ...)";
 	  cout << "  ReSizing to NSide= " << nside << endl;
 	}
@@ -550,5 +550,5 @@
 }
 
-void FitsIoServer::load(SphereHealpix<double>& sph,char flnm[],int nth) 
+void FitsIoServer::load(SphereHEALPix<double>& sph,char flnm[],int nth) 
 {
   int npixels= 0;
@@ -570,10 +570,10 @@
     {
       if(nside <= 0) 
-	throw IOExc("FitsIoServer::load(SphereHealpix<double>& ," + (string)flnm + ", )  No resol parameter !");
+	throw IOExc("FitsIoServer::load(SphereHEALPix<double>& ," + (string)flnm + ", )  No resol parameter !");
 
       if(nside != sph.SizeIndex())
 	{ 
 	  sph.Resize(nside);
-	  cout << " FitsIoServer::load(SphereHealpix<double> ...)";
+	  cout << " FitsIoServer::load(SphereHEALPix<double> ...)";
 	  cout << "  ReSizing to NSide= " << nside << endl;
 	}
@@ -584,5 +584,5 @@
 }
 
-void FitsIoServer::load(SphereHealpix<double>& sph1,SphereHealpix<double>& sph2,SphereHealpix<double>& sph3, char flnm[]) 
+void FitsIoServer::load(SphereHEALPix<double>& sph1,SphereHEALPix<double>& sph2,SphereHEALPix<double>& sph3, char flnm[]) 
 {
   int npixels= 0;
@@ -604,5 +604,5 @@
     {
       if(nside <= 0) 
-	throw IOExc("FitsIoServer::load(SphereHealpix<double>& ," + (string)flnm + ", )  No resol parameter !");
+	throw IOExc("FitsIoServer::load(SphereHEALPix<double>& ," + (string)flnm + ", )  No resol parameter !");
 
       if(nside != sph1.SizeIndex() || nside != sph2.SizeIndex() || nside != sph3.SizeIndex())
@@ -611,5 +611,5 @@
 	  sph2.Resize(nside);
 	  sph3.Resize(nside);
-	  cout << " FitsIoServer::load(SphereHealpix<double> ...)";
+	  cout << " FitsIoServer::load(SphereHEALPix<double> ...)";
 	  cout << "  ReSizing to NSide= " << nside << endl;
 	}
@@ -621,5 +621,5 @@
 }
 
-void FitsIoServer::load(SphereHealpix<float>& sph1,SphereHealpix<float>& sph2,SphereHealpix<float>& sph3, char flnm[]) 
+void FitsIoServer::load(SphereHEALPix<float>& sph1,SphereHEALPix<float>& sph2,SphereHEALPix<float>& sph3, char flnm[]) 
 {
   int npixels= 0;
@@ -645,5 +645,5 @@
 	{
 	  cout<<" FITSIOSERVER: no resolution parameter on fits file "<<endl;
-	  throw IOExc("FitsIoServer::load(SphereHealpix<float>& ," + (string)flnm + ", ) Error No resolution parameter !");
+	  throw IOExc("FitsIoServer::load(SphereHEALPix<float>& ," + (string)flnm + ", ) Error No resolution parameter !");
 	}
       if(nside != sph1.SizeIndex() || nside != sph2.SizeIndex() || nside != sph3.SizeIndex())
@@ -652,5 +652,5 @@
 	  sph2.Resize(nside);
 	  sph3.Resize(nside);
-	  cout << " FitsIoServer::load(SphereHealpix<float> ...)";
+	  cout << " FitsIoServer::load(SphereHEALPix<float> ...)";
 	  cout << "  ReSizing to NSide= " << nside << endl;
 	}
@@ -1064,5 +1064,5 @@
 
 }
-void FitsIoServer::save(SphereHealpix<float>& sph, char filename[], int nth)   
+void FitsIoServer::save(SphereHEALPix<float>& sph, char filename[], int nth)   
 {
   int npixels = sph.NbPixels();
@@ -1086,5 +1086,5 @@
 
 }
-void FitsIoServer::save(SphereHealpix<double>& sph, char filename[], int nth)   
+void FitsIoServer::save(SphereHEALPix<double>& sph, char filename[], int nth)   
 {
   int npixels = sph.NbPixels();
@@ -1108,5 +1108,5 @@
 
 }
-void FitsIoServer::save(SphereHealpix<double>& sph1,SphereHealpix<double>& sph2,SphereHealpix<double>& sph3, char filename[])   
+void FitsIoServer::save(SphereHEALPix<double>& sph1,SphereHEALPix<double>& sph2,SphereHEALPix<double>& sph3, char filename[])   
 {
   int npixels = sph1.NbPixels();
@@ -1140,5 +1140,5 @@
 }
 
-void FitsIoServer::save(SphereHealpix<float>& sph1,SphereHealpix<float>& sph2,SphereHealpix<float>& sph3, char filename[])   
+void FitsIoServer::save(SphereHEALPix<float>& sph1,SphereHEALPix<float>& sph2,SphereHEALPix<float>& sph3, char filename[])   
 {
   int npixels = sph1.NbPixels();
Index: trunk/SophyaExt/FitsIOServer/fitsioserver.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsioserver.h	(revision 839)
+++ trunk/SophyaExt/FitsIOServer/fitsioserver.h	(revision 854)
@@ -3,13 +3,8 @@
 
 #include "machdefs.h" 
-#include "tvector.h"
-#include "sphericalmap.h"
-#include "spherehealpix.h"
-#include "localmap.h"
+#include "array.h"
+#include "skymap.h"
 #include "ntuple.h"
-//#include "outilsinit.h"
 #include "cimage.h"
-#include "dvlist.h"
-#include "anydataobj.h"
 #include "FitsIO/fitsio.h"    
 
@@ -39,8 +34,8 @@
  void load(ImageR4& DpcImg,char flnm[]);
  void load(ImageI4& DpcImg,char flnm[]);
- void load(SphereHealpix<float>& sph, char flnm[], int nth=1); 
- void load(SphereHealpix<double>& sph, char flnm[], int nth=1); 
- void load(SphereHealpix<double>& sph1,SphereHealpix<double>& sph2,SphereHealpix<double>& sph3, char filename[]); 
- void load(SphereHealpix<float>& sph1,SphereHealpix<float>& sph2,SphereHealpix<float>& sph3, char filename[]); 
+ void load(SphereHEALPix<float>& sph, char flnm[], int nth=1); 
+ void load(SphereHEALPix<double>& sph, char flnm[], int nth=1); 
+ void load(SphereHEALPix<double>& sph1,SphereHEALPix<double>& sph2,SphereHEALPix<double>& sph3, char filename[]); 
+ void load(SphereHEALPix<float>& sph1,SphereHEALPix<float>& sph2,SphereHEALPix<float>& sph3, char filename[]); 
  void save(TMatrix<double>& mat, char flnm[]);
  void save(TMatrix<float>& mat, char flnm[]);
@@ -54,9 +49,9 @@
  // so veut sauver par exemple 3 spheres, on appelle 3 fois save
  // avec respectivement nth=1, 2, 3  
- void save(SphereHealpix<float>& sph, char filename[], int nth=1); 
- void save(SphereHealpix<double>& sph, char filename[], int nth=1); 
+ void save(SphereHEALPix<float>& sph, char filename[], int nth=1); 
+ void save(SphereHEALPix<double>& sph, char filename[], int nth=1); 
   
- void save(SphereHealpix<double>& sph1,SphereHealpix<double>& sph2,SphereHealpix<double>& sph3, char filename[]);   
- void save(SphereHealpix<float>& sph1,SphereHealpix<float>& sph2,SphereHealpix<float>& sph3, char filename[]);   
+ void save(SphereHEALPix<double>& sph1,SphereHEALPix<double>& sph2,SphereHEALPix<double>& sph3, char filename[]);   
+ void save(SphereHEALPix<float>& sph1,SphereHEALPix<float>& sph2,SphereHEALPix<float>& sph3, char filename[]);   
  void save(const LocalMap<double>& locm, char flnm[]);
  void save(const ImageR4& DpcImg,char flnm[]);
Index: trunk/SophyaExt/FitsIOServer/fitsspherehealpix.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsspherehealpix.cc	(revision 854)
+++ trunk/SophyaExt/FitsIOServer/fitsspherehealpix.cc	(revision 854)
@@ -0,0 +1,202 @@
+#include "pexceptions.h"
+#include "fitsspherehealpix.h"
+
+
+
+
+///////////////////////////////////////////////////////////////////////
+// ----objets delegues  pour la gestion de persistance I/O format fits--
+// SphereHealpix
+////////////////////////////////////////////////////////////////////
+
+
+template <class T>
+FITS_SphereHEALPix<T>::FITS_SphereHEALPix()
+{
+  dobj_= new SphereHEALPix<T>;
+  ownobj= true;
+}
+  
+template <class T>
+FITS_SphereHEALPix<T>::FITS_SphereHEALPix(char inputfile[],int hdunum)
+{
+  dobj_= new SphereHEALPix<T>;
+  dobj_->SetTemp(true);
+  ownobj= true;
+
+  ReadF(inputfile,hdunum);
+}
+
+template <class T>
+void FITS_SphereHEALPix<T>::Write(char outputfile[],int hdunum)
+{
+  WriteF(outputfile, hdunum);
+}
+
+template <class T>
+FITS_SphereHEALPix<T>::FITS_SphereHEALPix(const SphereHEALPix<T>& obj)
+{
+  dobj_= new SphereHEALPix<T>(obj, true);
+  dobj_->SetTemp(true);
+  ownobj= true;
+}
+
+template <class T>
+FITS_SphereHEALPix<T>::FITS_SphereHEALPix(SphereHEALPix<T>* obj)
+{
+  dobj_= obj;
+  ownobj= false;
+}
+
+template <class T>
+FITS_SphereHEALPix<T>::~FITS_SphereHEALPix()
+{
+  if (ownobj && dobj_) delete dobj_;
+}
+
+template <class T>
+AnyDataObj* FITS_SphereHEALPix<T>::DataObj()
+{
+  return(dobj_);
+}
+
+template <class T>
+void FITS_SphereHEALPix<T>::WriteToFits(const FitsFile& fn)
+{
+  if(dobj_ == NULL) 
+    { 
+      cout << " WriteTo:: dobj_= null " << endl;
+      return;
+    }
+
+  DVList dvl;  
+
+  SphereCoordSys* cs= dobj_->GetCoordSys();
+  string description= cs->description();
+  dvl["COORDSYS"]= description;
+
+  dvl["ORDERING"]= dobj_->TypeOfMap();
+  
+  int nSide= dobj_->SizeIndex();
+  dvl["NSIDE"]= nSide;
+
+  int nPix= dobj_->NbPixels();
+  dvl["FIRSTPIX"]= 0;
+  dvl["LASTPIX"]= nPix-1;
+  dvl["Content"]= "SphereHEALPix";
+  dvl["EXTNAME"]= "SIMULATION";
+  dvl["COMMENT"]= "Sky Map Pixelisation Specific Keywords";
+   
+  // On ecrit les dataBlocks 
+  //  fn.put_fits_bintab(dobj_->pixels_,dvl);
+  char** Noms = new char*[1];   
+  Noms[0]= new char[15];
+  strncpy(Noms[0],dvl.GetS("Content").c_str(),15);
+  char extname[15];
+  strncpy(extname,dvl.GetS("EXTNAME").c_str(),15);
+
+  cout << " nom entre dans sphereHealpix: " << Noms[0] << endl;
+  char Type[2];
+  if (strncmp( typeid(T).name(),"r_8",3)==0 || strncmp( typeid(T).name(),"double",6)==0 ) Type[0]='D';
+  else 
+    if (strncmp( typeid(T).name(),"r_4",3)==0 || strncmp( typeid(T).name(),"float",5)==0 )  Type[0]='E';
+    else
+      {
+	cout <<  " type de la sphere= " <<  typeid(T).name() << endl;
+	throw IOExc("FITS_SphereHEALPix:: unknown type");
+      }
+  Type[1]='\0'; 
+  vector<int> dummy;
+  fn.makeHeaderBntblOnFits(Type, Noms, nPix, 1, dvl, extname, dummy);
+  delete [] Noms[0];
+  delete [] Noms;
+  putColToFits(0,  nPix, dobj_->pixels_.Data()); 
+} 
+
+template <class T> 
+void FITS_SphereHEALPix<T>::ReadFromFits(const FitsFile& fn)
+{
+  if(dobj_ == NULL) 
+    {
+      dobj_= new SphereHEALPix<T>;
+      dobj_->SetTemp(true);
+      ownobj= true;      
+    }
+
+ 
+  int nbcols, nbentries;
+  nbcols = fn.NbColsFromFits();
+  if (nbcols != 1) 
+    {
+      throw IOExc("le fichier fits n'est pas une sphere Healpix");
+    }
+  //   const DVList* dvl = &fn.DVListFromFits();
+  DVList dvl=fn.DVListFromFits();
+  dvl.Print();
+   nbentries = fn.NentriesFromFits(0);
+  int lastpix=dvl.GetI("LASTPIX");
+  if (lastpix>0)
+    {
+      cout << " lastpix trouve= " << lastpix << endl;
+      if (nbentries!=lastpix+1) 
+	{
+	  cout << " nb pixels from LASTPIX = "  << lastpix+1 << endl;
+	  nbentries=lastpix+1;
+      	}
+    }
+  // Let's Read the SphereCoordSys object
+  int id= SphereCoordSys_NEUTRAL;
+  string description= "NEUTRAL SphereCoordSystem";
+  const char* coordsys= dvl.GetS("COORDSYS").c_str();    
+  if(strncmp(coordsys,"ROTATION",8) == 0)
+    {
+      id= SphereCoordSys_ROTATION;
+      description= "ROTATION SphereCoordSystem";
+    } 
+  else if(strncmp(coordsys,"OTHER",5) == 0)
+    {
+      id= SphereCoordSys_OTHER;
+      description= "OTHER SphereCoordSystem";
+    }
+  dobj_->SetCoordSys(new SphereCoordSys(id,description));   
+
+  const char* ordering= dvl.GetS("ORDERING").c_str();
+  if(strncmp(ordering,"RING",4) != 0)
+    { 
+      cout << " ORDERING= " << ordering << endl;
+      throw IOExc(" FITS_SphereHEALPix:: numerotation non RING");
+    }
+
+  int nside= dvl.GetI("NSIDE");
+  if(nside <= 0)
+    throw IOExc("FITS_SphereHEALPix:: No resol parameter nside");
+  int nPix = 12*nside*nside;
+  if (nPix != nbentries)
+    {
+      cout << " le nombre de pixels relu " << nbentries << " est incoherent avec la pixelisation Healpix qui donne nPix= " << nPix << endl; 
+      }
+  double Omega= 4.0*Pi/nPix;
+  dobj_->setParameters(nside,nPix,Omega);
+  cout << " sphere Healpix : las parametres sont introduits" << endl; 
+  // On lit les DataBlocks;
+  cout << "nside= " << nside << "nPix= " << nPix << endl;
+  dobj_->pixels_.ReSize(nPix);
+  cout << " sphere Healpix : resize fait" << endl; 
+  fn.GetSingleColumn(dobj_->pixels_.Data(),nPix);
+
+  // on effectue le decoupage en tranches 
+  dobj_->SetThetaSlices();
+  dobj_->Info()=fn.DVListFromFits();
+
+
+}
+
+
+#ifdef __CXX_PRAGMA_TEMPLATES__
+#pragma define_template FITS_SphereHEALPix<r_8>
+#pragma define_template FITS_SphereHEALPix<r_4>
+#endif
+#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
+template class FITS_SphereHEALPix<r_8>;
+template class FITS_SphereHEALPix<r_4>;
+#endif
Index: trunk/SophyaExt/FitsIOServer/fitsspherehealpix.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsspherehealpix.h	(revision 854)
+++ trunk/SophyaExt/FitsIOServer/fitsspherehealpix.h	(revision 854)
@@ -0,0 +1,48 @@
+#ifndef FITSSPHEREHEALPIX_SEEN
+#define FITSSPHEREHEALPIX_SEEN
+
+
+// Guy Le Meur 03/2000
+
+
+#include "spherehealpix.h"
+#include "anydataobj.h"
+#include "ppersist.h"
+#include "fitsfile.h"
+
+namespace SOPHYA {
+///////////////////////////////////////////////////////////////////////
+// ------------- Classe pour la gestion de persistance I/O format fits--
+// spherehealpix
+//////////////////////////////////////////////////////////////////////
+template <class T>
+class FITS_SphereHEALPix : public FitsFile  
+{
+public:
+
+FITS_SphereHEALPix();
+FITS_SphereHEALPix(char inputfile[],int hdunum=2); 
+FITS_SphereHEALPix(const SphereHEALPix<T>& obj);
+FITS_SphereHEALPix(SphereHEALPix<T>* obj);
+virtual ~FITS_SphereHEALPix();
+virtual AnyDataObj* DataObj();
+
+inline operator SphereHEALPix<T>() { return(*dobj_); }
+void Write(char outputfile[], int hdunum=2);
+
+protected:
+
+virtual void ReadFromFits(const FitsFile& fn);
+virtual void WriteToFits(const FitsFile& fn);
+void WriteTo (FitsFile& fn);            
+SphereHEALPix<T>* dobj_;
+bool ownobj;
+};
+
+
+//////////////////////////////////////////////////////////////////
+
+
+} // Fin du namespace
+
+#endif
