Index: trunk/SophyaProg/PrgMap/cl2map.cc
===================================================================
--- trunk/SophyaProg/PrgMap/cl2map.cc	(revision 1427)
+++ trunk/SophyaProg/PrgMap/cl2map.cc	(revision 1427)
@@ -0,0 +1,175 @@
+#include "machdefs.h"    // Definitions specifiques SOPHYA
+
+#include <math.h>
+#include <iostream.h>
+
+#include "nbmath.h"
+#include "timing.h"
+
+#include "array.h"
+#include "skymap.h"
+#include "samba.h"
+#include "sambainit.h"
+#include "fitsspherehealpix.h"
+#include "fitstarray.h"
+
+
+
+/* Nouvelle-Fonction */
+void Usage(bool fgerr)
+{
+  cout << endl;
+  if (fgerr) {
+    cout << " cl2map : Argument Error ! cl2map -h for usage " << endl; 
+    exit(1);
+  }
+  else {
+    cout << " cl2map : Spherical harmonics synthesis - Power spectrum C_l -> HEALPix map \n" 
+	 << " Usage: cl2map [-float/-r4] [-msph pixp] [-beam fwhm] \n" 
+	 << "        [fitsin] [-fitsout] [-autoinirand] InFileName OutFileName \n" 
+	 << "   -float (-r4): single precision C_l and map (default = double) \n"
+	 << "   -msph pix: Spherical map pixelization parameter \n" 
+	 << "              nside=2^n for HEALPix - default=128 \n"
+	 << "                lmax = 2^n  default=128 \n"
+	 << "   -beam fwhm : Beam moothing (in l-space) FWHM in arcmin, default=0 \n"
+	 << "   -fitsout: Select the FITS format for the output map (default PPF format) \n"
+	 << "   -fitsin : Select the FITS format for the input vector (default PPF format) \n"
+	 << "   -autoinirand : Automtatic random number generator initialization \n" 
+	 << "   InFileName : Input file name containing the C_l vector \n" 
+	 << "   OutFileName : Output file name (HEALPix map) \n" << endl;
+    exit(0);
+  }  
+}
+
+/* Nouvelle-Classe */
+template <class T> 
+class _Cl2Map {
+public :
+static void BuildMap(string & infile, string & outfile, int msph, double beam, 
+		     bool fgfitsin, bool fgfitsout)
+{
+  double deg2rad =  M_PI/180.;
+  double minute2rad =  M_PI/(180.*60.);
+
+  TArray<T> cla;
+  SphereHEALPix<T> sph;
+  if (fgfitsin) {
+    cout << "--- Reading Input FITS file " << infile << endl; 
+    FitsInFile fii(infile);
+    fii >> cla;
+  }
+  else {
+    cout << "--- Reading Input PPF file " << infile << endl; 
+    PInPersist ppi(infile);
+    ppi >> cla;
+  }
+  TVector<T> clvec(cla);
+  cout << " Input vector : " ; 
+  clvec.Show(); 
+  T min, max;
+  double mean, sigma;
+  clvec.MinMax(min, max);
+  MeanSigma(clvec, mean, sigma);
+  cout << " C_l.Min= " << min << " C_l.Max= " << max 
+       << " C_l.Mean= " << mean << " C_l.Sigma= " << sigma << endl;
+
+  cout << "--- Calling  GenerateFromCl() (beam= " << beam 
+       << "' msph= " << msph << ") beam=" << beam*minute2rad << " rad" << endl;
+  // on cree la carte 
+  SphericalTransformServer<T> sphtr;
+  sphtr.GenerateFromCl(sph, msph, clvec, beam*minute2rad);
+
+  cout << " Output map : NbPixels= " <<  sph.NbPixels() << " NSide= " 
+       << sph.SizeIndex() << " Resolution= "
+       << sqrt(sph.PixSolAngle(0))/minute2rad << " Arcminutes " << endl;
+
+  if (fgfitsout) {
+    cout << "--- Writing map to Output FITS file " << outfile << endl; 
+    FitsOutFile fio(outfile);
+    fio << sph;
+  }
+  else {
+    cout << "--- Writing map to Output PPF file " << outfile << endl; 
+    POutPersist ppo(outfile);
+    ppo << sph;
+  }
+}
+
+};
+
+/* Main-Program */
+int main(int narg, char *arg[])
+{
+  if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
+  
+  int msph = 128;
+  double beam = 0.;
+  string infile;
+  string outfile;
+  bool fgfitsin = false;
+  bool fgfitsout = false;
+  bool fginirand = false;
+  bool fgr4 = false;
+  cout << " cl2map : Decoding command line options ... " << endl;
+
+  int ko=1;
+  for (int k=1; k<narg; k++)   {
+    if (strcmp(arg[k], "-msph") == 0)  {
+	if (k == narg-1) Usage(true);  // -msph est suivi d'un argument 
+      msph = atoi(arg[k+1]);  k++;       // k++ pour sauter au suivant
+    }
+    else if (strcmp(arg[k], "-beam") == 0)  {
+	if (k == narg-1) Usage(true);  // -beam est suivi d'un argument 
+      beam = atof(arg[k+1]);  k++;       // k++ pour sauter au suivant
+    }
+    else if (strcmp(arg[k], "-fitsin") == 0) {
+      fgfitsin = true;  
+    }
+    else if (strcmp(arg[k], "-fitsout") == 0) {
+      fgfitsout = true;  
+    }
+    else if (strcmp(arg[k], "-autoinirand") == 0) {
+      fginirand = true;  
+    }
+    else if ((strcmp(arg[k], "-float") == 0) || (strcmp(arg[k], "-r4") == 0) ) {
+      fgr4 = true;  
+    }
+   
+    else { ko = k; break; }  // Debut des noms
+  }
+
+  if ((narg-ko) < 1)  Usage(true); 
+  infile = arg[ko];
+  outfile = arg[ko+1];
+  
+  // Bloc try de gestion des exception 
+  try {
+    InitTim();
+    SophyaInit();
+    if (fginirand) {
+      cout << " Setting random number generator seed (using time) " << endl; 
+      Auto_Ini_Ranf(1);
+    }
+    if (fgr4) {
+      cout << " Power spectrum C_l (r_4) --> SphereHEALPix<r_4> (float) " << endl;
+      _Cl2Map<r_4>::BuildMap(infile, outfile, msph, beam, fgfitsin, fgfitsout);
+    }
+    else {
+      cout << " Power spectrum C_l (r_8) --> SphereHEALPix<r_8> (double) " << endl;
+      _Cl2Map<r_8>::BuildMap(infile, outfile, msph, beam, fgfitsin, fgfitsout);
+    }
+  }
+  catch (PThrowable & exc) {   // Exceptions de SOPHYA
+    cerr << " cl2map: Catched Exception " << (string)typeid(exc).name()
+         << " - Msg= " << exc.Msg() << endl;
+  }
+  catch (...) {    // Autres Exceptions
+    cerr << " cl2map: some other exception was caught ! " << endl;
+  }
+  
+  PrtTim("End of cl2map ");
+  return(0);
+}
+
+
+  
Index: trunk/SophyaProg/PrgMap/map2cl.cc
===================================================================
--- trunk/SophyaProg/PrgMap/map2cl.cc	(revision 1427)
+++ trunk/SophyaProg/PrgMap/map2cl.cc	(revision 1427)
@@ -0,0 +1,164 @@
+#include "machdefs.h"    // Definitions specifiques SOPHYA
+
+#include <math.h>
+#include <iostream.h>
+
+#include "nbmath.h"
+#include "timing.h"
+
+#include "array.h"
+#include "skymap.h"
+#include "samba.h"
+#include "sambainit.h"
+#include "fitsspherehealpix.h"
+#include "fitstarray.h"
+
+
+
+/* Nouvelle-Fonction */
+void Usage(bool fgerr)
+{
+  cout << endl;
+  if (fgerr) {
+    cout << " map2cl : Argument Error ! map2cl -h for usage " << endl; 
+    exit(1);
+  }
+  else {
+    cout << " map2cl : Spherical harmonics analysis - HEALPix map -> Power spectrum C_l \n" 
+	 << " Usage: map2cl [-float/-r4] [-lmax lval] [-thetacut dtdeg] \n" 
+	 << "        [fitsin] [-fitsout] InFileName OutFileName \n" 
+	 << "   -float (-r4): single precision C_l and map (default = double) \n"
+	 << "   -lmax lval: Maximum value for l index (default=255)\n" 
+	 << "   -thetacut dtdeg : Symmetric delta-theta cut (in degree) along equator \n" 
+	 << "                    (default=0 -> no cut)\n"
+	 << "   -fitsout: Select the FITS format for the output map (default PPF format) \n"
+	 << "   -fitsin : Select the FITS format for the input vector (default PPF format) \n"
+	 << "   InFileName : Input file name (HEALPix map) \n" 
+	 << "   OutFileName : Output file name (the C_l vector) \n" << endl; 
+    exit(0);
+  }  
+}
+
+/* Nouvelle-Fonction */
+template <class T> 
+class _Map2Cl {
+public :
+static void ComputeCl(string & infile, string & outfile, int lmax, double tcut, 
+		      bool fgfitsin, bool fgfitsout)
+{
+  double deg2rad =  M_PI/180.;
+  double minute2rad =  M_PI/(180.*60.);
+
+  SphereHEALPix<T> sph;
+  if (fgfitsin) {
+    cout << "--- Reading Input FITS file " << infile << endl; 
+    FitsInFile fii(infile);
+    fii >> sph;
+  }
+  else {
+    cout << "--- Reading Input PPF file " << infile << endl; 
+    PInPersist ppi(infile);
+    ppi >> sph;
+  }
+
+  cout << " Input map : NbPixels= " <<  sph.NbPixels() << " NSide= " 
+       << sph.SizeIndex() << " Resolution= "
+       << sqrt(sph.PixSolAngle(0))/minute2rad << " Arcminutes " << endl;
+  
+  double ctcut = (tcut < 1.e-19) ? 0. : cos((90.-tcut)*deg2rad);
+  cout << "--- Calling  DecomposeToCl() (lmax= " << lmax 
+       << " cos_theta_cut= " << ctcut << ") theta_cut=" << tcut << " deg" << endl;
+  // Decomposition de la carte en C_l
+  SphericalTransformServer<T> sphtr;
+  TVector<T> clvec = sphtr.DecomposeToCl(sph, lmax, ctcut);
+ 
+  T min, max;
+  double mean, sigma;
+  clvec.MinMax(min, max);
+  MeanSigma(clvec, mean, sigma);
+  cout << "--- Statistics on the computed C_l vector: Size=" << clvec.Size() << endl; 
+  cout << " C_l.Min= " << min << " C_l.Max= " << max 
+       << " C_l.Mean= " << mean << " C_l.Sigma= " << sigma << endl;
+  
+  if (fgfitsout) {
+    cout << "--- Writing C_l vector to Output FITS file " << outfile << endl; 
+    FitsOutFile fio(outfile);
+    fio << clvec;
+  }
+  else {
+    cout << "--- Writing C_l vector to Output PPF file " << outfile << endl; 
+    POutPersist ppo(outfile);
+    ppo << clvec;
+  }
+}
+
+};
+
+/* Main-Program */
+int main(int narg, char *arg[])
+{
+  if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
+  
+  int lmax = 255;
+  double tcut = 0.;
+  string infile;
+  string outfile;
+  bool fgfitsin = false;
+  bool fgfitsout = false;
+  bool fgr4 = false;
+  cout << " map2cl : Decoding command line options ... " << endl;
+
+  int ko=1;
+  for (int k=1; k<narg; k++)   {
+    if (strcmp(arg[k], "-lmax") == 0)  {
+      if (k == narg-1) Usage(true);  // -lmax est suivi d'un argument 
+      lmax = atoi(arg[k+1]);  k++;       // k++ pour sauter au suivant
+    }
+    else if (strcmp(arg[k], "-thetacut") == 0)  {
+      if (k == narg-1) Usage(true);  // -thetacut est suivi d'un argument 
+      tcut = atof(arg[k+1]);  k++;       // k++ pour sauter au suivant
+    }
+    else if (strcmp(arg[k], "-fitsin") == 0) {
+      fgfitsin = true;  
+    }
+    else if (strcmp(arg[k], "-fitsout") == 0) {
+      fgfitsout = true;  
+    }
+    else if ((strcmp(arg[k], "-float") == 0) || (strcmp(arg[k], "-r4") == 0) ) {
+      fgr4 = true;  
+    }
+   
+    else { ko = k; break; }  // Debut des noms
+  }
+
+  if ((narg-ko) < 1)  Usage(true); 
+  infile = arg[ko];
+  outfile = arg[ko+1];
+  
+  // Bloc try de gestion des exception 
+  try {
+    InitTim();
+    SophyaInit();
+    if (fgr4) {
+      cout << " SphereHEALPix<r_4>  --> Power spectrum C_l<r_4> (float)" << endl;
+      _Map2Cl<r_4>::ComputeCl(infile, outfile, lmax, tcut, fgfitsin, fgfitsout);
+    }
+    else {
+      cout << " SphereHEALPix<r_8>  --> Power spectrum C_l<r_8> (double)" << endl;
+      _Map2Cl<r_8>::ComputeCl(infile, outfile, lmax, tcut, fgfitsin, fgfitsout);
+    }
+  }
+  catch (PThrowable & exc) {   // Exceptions de SOPHYA
+    cerr << " map2cl: Catched Exception " << (string)typeid(exc).name()
+         << " - Msg= " << exc.Msg() << endl;
+  }
+  catch (...) {    // Autres Exceptions
+    cerr << " map2cl: some other exception was caught ! " << endl;
+  }
+  
+  PrtTim("End of map2cl ");
+  return(0);
+}
+
+
+  
Index: trunk/SophyaProg/PrgUtil/Makefile
===================================================================
--- trunk/SophyaProg/PrgUtil/Makefile	(revision 1425)
+++ trunk/SophyaProg/PrgUtil/Makefile	(revision 1427)
@@ -14,9 +14,6 @@
 endif
 LIBSORA := $(LIBS)
-ifdef ORACLE_HOME
-LIBSORA := -L$(LIB) -lDb++ $(LIBS) -lErosDb -L$(ORACLE_HOME)/lib -lclntsh
-endif
 LDLIBS := $(LIBS) $(LDLIBS)
-PROGS = $(EXE)runcxx $(EXE)scanppf $(EXE)scanfits
+PROGS = $(EXE)runcxx $(EXE)scanppf $(EXE)scanfits $(EXE)cl2map $(EXE)map2cl
  
 all: $(PROGS)
@@ -41,64 +38,43 @@
 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
   
-$(OBJ)acxxrun.o: acxxrun.cc $(INC)machdefs.h \
- $(INC)systools.h \
- $(INC)sophyainit.h \
- $(INC)ppersist.h \
- $(INC)pexceptions.h \
- $(INC)gnumd5.h \
- $(INC)ndatablock.h \
- $(INC)anydataobj.h \
+cl2map: $(EXE)cl2map
+	
+$(EXE)cl2map: $(OBJ)cl2map.o
+	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
+  
+map2cl: $(EXE)map2cl
+	
+$(EXE)map2cl: $(OBJ)map2cl.o
+	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
+  
+: $(EXE)
+	
+$(EXE):
+	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
+  
+$(OBJ)cl2map.o: cl2map.cc $(INC)machdefs.h \
+ $(INC)nbmath.h \
+ $(INC)smathconst.h \
+ $(INC)timing.h \
+ $(INC)array.h \
+ $(INC)tarray.h \
+ $(INC)basarr.h \
+ $(INC)anydataobj.h \
+ $(INC)mutyv.h \
  $(INC)dvlist.h \
  $(INC)objfio.h \
- $(INC)mutyv.h \
- $(INC)pdlmgr.h \
- $(INC)perrors.h \
- $(INC)srandgen.h \
- $(INC)strutil.h \
- $(INC)ctimer.h \
- $(INC)timing.h \
- $(INC)ntools.h \
- $(INC)ntoolsinit.h \
- $(INC)tarrinit.h \
- $(INC)nbconst.h \
- $(INC)fmath.h \
- $(INC)nbrandom.h \
- $(INC)perandom.h \
- $(INC)histos.h \
- $(INC)peida.h \
- $(INC)utils.h \
+ $(INC)ppersist.h \
+ $(INC)pexceptions.h \
+ $(INC)gnumd5.h \
+ $(INC)ndatablock.h \
+ $(INC)utilarr.h \
+ $(INC)tmatrix.h \
  $(INC)tvector.h \
- $(INC)tmatrix.h \
- $(INC)tarray.h \
- $(INC)basarr.h \
- $(INC)utilarr.h \
- $(INC)nbtri.h \
- $(INC)linfit.h \
+ $(INC)matharr.h \
+ $(INC)fioarr.h \
  $(INC)sopemtx.h \
- $(INC)poly.h \
- $(INC)datatypes.h \
- $(INC)cimage.h \
- $(INC)fioarr.h \
- $(INC)dynccd.h \
- $(INC)generaldata.h \
- $(INC)ntupintf.h \
- $(INC)generalfit.h \
- $(INC)fct1dfit.h \
- $(INC)fct2dfit.h \
- $(INC)objfitter.h \
- $(INC)histos2.h \
- $(INC)hisprof.h \
- $(INC)fftpserver.h \
- $(INC)fftservintf.h \
- $(INC)array.h \
- $(INC)matharr.h \
- $(INC)histats.h \
- $(INC)histinit.h \
- $(INC)ntuple.h \
- $(INC)xntuple.h \
  $(INC)skymap.h \
  $(INC)spherethetaphi.h \
  $(INC)sphericalmap.h \
- $(INC)smathconst.h \
  $(INC)pixelmap.h \
  $(INC)spherepos.h \
@@ -115,5 +91,6 @@
  $(INC)samba.h \
  $(INC)alm.h \
- $(INC)nbmath.h \
+ $(INC)nbrandom.h \
+ $(INC)srandgen.h \
  $(INC)triangmtx.h \
  $(INC)bruit.h \
@@ -126,17 +103,76 @@
  $(INC)scan.h \
  $(INC)sphericaltransformserver.h \
+ $(INC)fftservintf.h \
+ $(INC)fftpserver.h \
  $(INC)tod.h \
- $(INC)skyt.h \
- $(INC)convtools.h \
- $(INC)radspecvector.h \
- $(INC)radspec.h \
- $(INC)specresp.h \
- $(INC)blackbody.h \
- $(INC)derivblackbody.h \
- $(INC)nupower.h \
- $(INC)specrespvector.h \
- $(INC)squarefilt.h \
- $(INC)trianglefilt.h \
- $(INC)gaussfilt.h tst.icc
+ $(INC)sambainit.h \
+ $(INC)skymapinit.h \
+ $(INC)sophyainit.h \
+ $(INC)ntoolsinit.h \
+ $(INC)tarrinit.h \
+ $(INC)fitsspherehealpix.h \
+ $(INC)fitsfile.h \
+ $(INC)fitstarray.h
+$(OBJ)map2cl.o: map2cl.cc $(INC)machdefs.h \
+ $(INC)nbmath.h \
+ $(INC)smathconst.h \
+ $(INC)timing.h \
+ $(INC)array.h \
+ $(INC)tarray.h \
+ $(INC)basarr.h \
+ $(INC)anydataobj.h \
+ $(INC)mutyv.h \
+ $(INC)dvlist.h \
+ $(INC)objfio.h \
+ $(INC)ppersist.h \
+ $(INC)pexceptions.h \
+ $(INC)gnumd5.h \
+ $(INC)ndatablock.h \
+ $(INC)utilarr.h \
+ $(INC)tmatrix.h \
+ $(INC)tvector.h \
+ $(INC)matharr.h \
+ $(INC)fioarr.h \
+ $(INC)sopemtx.h \
+ $(INC)skymap.h \
+ $(INC)spherethetaphi.h \
+ $(INC)sphericalmap.h \
+ $(INC)pixelmap.h \
+ $(INC)spherepos.h \
+ $(INC)unitvector.h \
+ $(INC)vector3d.h \
+ $(INC)longlat.h \
+ $(INC)utilgeom.h \
+ $(INC)spherehealpix.h \
+ $(INC)HEALPixUtils.h \
+ $(INC)localmap.h \
+ $(INC)fiospherethetaphi.h \
+ $(INC)fiospherehealpix.h \
+ $(INC)fiolocalmap.h \
+ $(INC)samba.h \
+ $(INC)alm.h \
+ $(INC)nbrandom.h \
+ $(INC)srandgen.h \
+ $(INC)triangmtx.h \
+ $(INC)bruit.h \
+ $(INC)circle.h \
+ $(INC)geometry.h \
+ $(INC)lambdaBuilder.h \
+ $(INC)misstime.h \
+ $(INC)mlobe.h \
+ $(INC)prefcount.h \
+ $(INC)scan.h \
+ $(INC)sphericaltransformserver.h \
+ $(INC)fftservintf.h \
+ $(INC)fftpserver.h \
+ $(INC)tod.h \
+ $(INC)sambainit.h \
+ $(INC)skymapinit.h \
+ $(INC)sophyainit.h \
+ $(INC)ntoolsinit.h \
+ $(INC)tarrinit.h \
+ $(INC)fitsspherehealpix.h \
+ $(INC)fitsfile.h \
+ $(INC)fitstarray.h
 $(OBJ)runcxx.o: runcxx.cc $(INC)sambainit.h \
  $(INC)skymapinit.h \
Index: trunk/SophyaProg/PrgUtil/programs
===================================================================
--- trunk/SophyaProg/PrgUtil/programs	(revision 1425)
+++ trunk/SophyaProg/PrgUtil/programs	(revision 1427)
@@ -2,2 +2,5 @@
 scanppf scanppf.o
 scanfits scanfits.o
+cl2map cl2map.o
+map2cl map2cl.o
+
