Index: /trunk/SophyaProg/PrgMap/cremskfrsph.cc
===================================================================
--- /trunk/SophyaProg/PrgMap/cremskfrsph.cc	(revision 1527)
+++ /trunk/SophyaProg/PrgMap/cremskfrsph.cc	(revision 1528)
@@ -1,4 +1,6 @@
 // Creation d'une sphere de masque a partir d'une sphere de valeurs
 //         cmv 13/6/01
+// cremskfrsph -m 0.1 -v 1.,0. sph143k05_e.fits sphmskw.fits
+// cremskfrsph -n -m -1.e-30. -M 1.e-30. -v 1.,0. sph143k05.fits sphmsk.fits
 #include "machdefs.h"
 #include <unistd.h>
@@ -17,5 +19,6 @@
     <<" -m min : min value"<<endl
     <<" -M max : max value"<<endl
-    <<"    condition for filling masque is : min<=V<=max"<<endl
+    <<"    condition for filling masque is : min<=sphere value<=max"<<endl
+    <<"                                      (bounds are included)"<<endl
     <<" -n : negate the condition"<<endl
     <<" -v valmsk,inimsk:"<<endl
@@ -56,5 +59,4 @@
 char * sphmsk = arg[optind+1];
 
-{
 cout<<"Sphere values : "<<sphval<<endl
     <<"Sphere mask   : "<<sphmsk<<endl
@@ -65,6 +67,5 @@
 cout<<"Condition : ";
 if(negate) cout<<"!";
-cout<<"( "<<vmin<<" <= V <= "<<vmax<<" )"<<endl;
-}
+cout<<"( "<<vmin<<" <= V <= "<<vmax<<" ) bounds are included"<<endl;
 
 // Lecture de la sphere Healpix des valeurs
Index: /trunk/SophyaProg/PrgMap/extrap2sph.cc
===================================================================
--- /trunk/SophyaProg/PrgMap/extrap2sph.cc	(revision 1527)
+++ /trunk/SophyaProg/PrgMap/extrap2sph.cc	(revision 1528)
@@ -1,4 +1,6 @@
 // Pour boucher les trous d'une sphere HEALPIX utilisant une autre sphere
 //             cmv 13/6/01
+// extrap2sph -w sph143k05_e.fits sph143k05.fits sphred.fits sphout_2.fits
+// extrap2sph -m -1.e-30 -M +1.e-30 sph143k05.fits sphred.fits sphout_22.fits
 #include "machdefs.h"
 #include <unistd.h>
@@ -14,10 +16,12 @@
 void usage()
 {
-cout<<"extrap2sph [-w sphinw.fits -0 nulval]"<<endl
+cout<<"extrap2sph [-w sphinw.fits -m valmin -M valmax]"<<endl
     <<"           sphin.fits sphred.fits sphout.fits"<<endl
     <<" -w sphinw.fits : input sphere  weight (def=NULL)"<<endl
-    <<" -0 nulval : value to identify empty pixel in sphin (def=0.)"<<endl
-    <<"             (used if sphinw.fits==NULL)"<<endl
-    <<" sphin.fits : input sphere"<<endl
+    <<" -m minval : value to identify EMPTY pixel (def=-1.e30.)"<<endl
+    <<" -M maxval : value to identify EMPTY pixel (def=+1.e30)"<<endl
+    <<"    condition for EMPTY pixel is (minval<val<maxval)"<<endl
+    <<"    (bounds are excluded, used only if sphinw.fits==NULL)"<<endl
+    <<" sphin.fits   : input sphere"<<endl
     <<" sphred.fits  : input reducted sphere"<<endl
     <<" sphout.fits  : output sphere"<<endl;
@@ -26,11 +30,17 @@
 int main(int narg, char* arg[])
 {
-double nulval=0.;
+bool tstmin=false, tstmax=false;
+double valmin=-1.e30, valmax=+1.e30;
 char * fsphinw = NULL;
 int c;
-while((c = getopt(narg,arg,"h0:w:")) != -1) {
+while((c = getopt(narg,arg,"hm:M:w:")) != -1) {
   switch (c) {
-  case '0' :
-    sscanf(optarg,"%lf",&nulval);
+  case 'm' :
+    sscanf(optarg,"%lf",&valmin);
+    tstmin=true;
+    break;
+  case 'M' :
+    sscanf(optarg,"%lf",&valmax);
+    tstmax=true;
     break;
   case 'w' :
@@ -48,9 +58,13 @@
 char * fsphout  = arg[optind+2];
 
-cout<<"Sphere Input : "<<fsphin<<endl
-    <<"Weight Sphere Input : "<<fsphinw<<endl
-    <<"Reducted Sphere Input : "<<fsphred<<endl
-    <<"Sphere Output : "<<fsphout<<endl
-    <<"nulval : "<<nulval<<endl;
+cout<<"Input Sphere          : "<<fsphin<<endl
+    <<"Input Weight Sphere   : "<<fsphinw<<endl
+    <<"Input Reducted Sphere : "<<fsphred<<endl
+    <<"Output Sphere         : "<<fsphout<<endl;
+if(!fsphinw)
+  cout<<"- test min("<<tstmin<<") : "<<valmin<<endl
+      <<"  test max("<<tstmax<<") : "<<valmax<<endl
+      <<"Condition for EMPTY pixel is :\n    ("<<valmin
+      <<" < sphere value < "<<valmax<<") bounds are excluded!"<<endl;
 
 // Lecture des spheres
@@ -58,5 +72,5 @@
 {FitsInFile sfits(fsphin); sfits >> sphin;}
 int nlat = sphin.SizeIndex();
-cout<<"Opening Sphere Input :"<<endl
+cout<<"Opening Input Sphere :"<<endl
     <<"          Type of map : "<<sphin.TypeOfMap()<<endl
     <<"     Number of pixels : "<<sphin.NbPixels()<<endl
@@ -67,5 +81,5 @@
   FitsInFile sfits(fsphinw);
   sfits >> sphinw;
-  cout<<"Opening Weight Sphere Input :"<<endl
+  cout<<"Opening Input Weight Sphere :"<<endl
       <<"          Type of map : "<<sphinw.TypeOfMap()<<endl
       <<"     Number of pixels : "<<sphinw.NbPixels()<<endl
@@ -79,26 +93,29 @@
 SphereHEALPix<r_8> sphred;
 {FitsInFile sfits(fsphred); sfits >> sphred;}
-cout<<"Opening Reducted Sphere Input :"<<endl
+cout<<"Opening Input Reducted Sphere :"<<endl
     <<"          Type of map : "<<sphred.TypeOfMap()<<endl
     <<"     Number of pixels : "<<sphred.NbPixels()<<endl
     <<"                 Nlat : "<<sphred.SizeIndex()<<endl;
 
-// Creation de la sphere output
-cout<<"Creating Sphere for output"<<endl;
-SphereHEALPix<r_8> sphout(sphin,false);
-
 // Filling hole for Output Sphere
 cout<<"...Filling hole for Output Sphere"<<endl;
-uint_4 n=0;
-for(int_4 i=0;i<sphout.NbPixels();i++) {
-  if(fsphinw) {if(sphinw(i)>0.) continue;}
-     else     {if(sphout(i)!=nulval) continue;}
+uint_4 n=0, n0=0;
+for(int_4 i=0;i<sphin.NbPixels();i++) {
+  if(fsphinw) {
+    if(sphinw(i)>0.) continue;
+  } else {
+    // Not Filled pixels ]valmin,valmax[
+    // Filled pixels ]-Infinity,valmin] or [valmax,+Infinity[
+    if(tstmin && sphin(i)<=valmin) continue;
+    if(tstmax && sphin(i)>=valmax) continue;
+  }
   double theta,phi;
-  sphout.PixThetaPhi(i,theta,phi);
+  sphin.PixThetaPhi(i,theta,phi);
   int_4 ir = sphred.PixIndexSph(theta,phi);
-  sphout(i) = sphred(ir);
-  n++;
+  sphin(i) = sphred(ir);
+  n++; if(sphred(ir)!=0.) n0++;
 }
-cout<<"      Number of filled pixels "<<n<<endl;
+cout<<"      Number of pixels filled "
+    <<n<<" (not null values "<<n0<<")"<<endl;
 
 // Ecriture de la sphere
@@ -107,5 +124,5 @@
 FitsOutFile sfits(fsphout);
 cout<<"Writing Output Sphere Fits file"<<endl;
-sfits<<sphout;
+sfits<<sphin;
 }
 
Index: /trunk/SophyaProg/PrgMap/extrapsph.cc
===================================================================
--- /trunk/SophyaProg/PrgMap/extrapsph.cc	(revision 1527)
+++ /trunk/SophyaProg/PrgMap/extrapsph.cc	(revision 1528)
@@ -1,4 +1,6 @@
 // Pour boucher les trous d'une sphere HEALPIX en clusterisant dans une sphere
 // plus petite             cmv 13/6/01
+// extrapsph -r 2 sph143k05.fits sph143k05_e.fits
+//                sphout.fits sphoutw.fits sphred.fits sphredw.fits
 #include "machdefs.h"
 #include <unistd.h>
@@ -17,11 +19,11 @@
     <<"                     sphout.fits [sphout_w.fits"
     <<" sphred.fits sphred_w.fits]"<<endl
-    <<" -r reduc : reduction factor for nlat in clustering must be 2^n (def=2)"<<endl
-    <<" sphin.fits : input sphere"<<endl
-    <<" sphin_w.fits : input sphere filling weight"<<endl
-    <<" sphout.fits  : output sphere"<<endl
-    <<" sphout_w.fits  : output sphere filling weight"<<endl
-    <<" sphred.fits  : output reducted sphere"<<endl
-    <<" sphred_w.fits  : output reducted sphere filling weight"<<endl;
+    <<" -r reduc : reduction factor for clustering (must be 2^n, def=2)"<<endl
+    <<" sphin.fits    : input sphere"<<endl
+    <<" sphin_w.fits  : input sphere filling weight"<<endl
+    <<" sphout.fits   : output sphere"<<endl
+    <<" sphout_w.fits : output sphere filling weight"<<endl
+    <<" sphred.fits   : output reducted sphere"<<endl
+    <<" sphred_w.fits : output reducted sphere filling weight"<<endl;
 }
 
@@ -52,10 +54,10 @@
 if(optind+5<narg) fsphredw = arg[optind+5];
 
-cout<<"Sphere Input : "<<fsphin<<endl
-    <<"Weight Sphere Input : "<<fsphinw<<endl
-    <<"Sphere Output : "<<fsphout<<endl
-    <<"Weight Sphere Output : "<<fsphoutw<<endl
-    <<"Reducted Sphere Output : "<<fsphred<<endl
-    <<"Reducted Weight Sphere Output : "<<fsphredw<<endl
+cout<<"Input Sphere : "<<fsphin<<endl
+    <<"Input Weight Sphere : "<<fsphinw<<endl
+    <<"Output Sphere : "<<fsphout<<endl
+    <<"Output Weight Sphere : "<<fsphoutw<<endl
+    <<"Output Reducted Sphere : "<<fsphred<<endl
+    <<"Output Reducted Weight Sphere : "<<fsphredw<<endl
     <<"Reduction : "<<red<<endl;
 
@@ -65,5 +67,5 @@
 int nlat = sphin.SizeIndex();
 int nlatr = nlat/red;
-cout<<"Opening Sphere Input :"<<endl
+cout<<"Opening Input Sphere :"<<endl
     <<"          Type of map : "<<sphin.TypeOfMap()<<endl
     <<"     Number of pixels : "<<sphin.NbPixels()<<endl
@@ -72,5 +74,5 @@
 SphereHEALPix<r_8> sphinw;
 {FitsInFile sfits(fsphinw); sfits >> sphinw;}
-cout<<"Opening Weight Sphere Input :"<<endl
+cout<<"Opening Input Weight Sphere :"<<endl
     <<"          Type of map : "<<sphinw.TypeOfMap()<<endl
     <<"     Number of pixels : "<<sphinw.NbPixels()<<endl
@@ -81,9 +83,4 @@
 }
 
-// Creation des spheres output
-cout<<"Creating Spheres for output"<<endl;
-SphereHEALPix<r_8> sphout(sphin,false);
-SphereHEALPix<r_8> sphoutw(sphinw,false);
-
 // Creation des spheres reduites
 cout<<"Creating Reducted Spheres : nlatr = "<<nlatr<<endl;
@@ -92,10 +89,10 @@
 SphereHEALPix<r_8> sphredw(nlatr);
   sphredw.SetPixels(0.);
-cout<<"Creating Reducted Sphere :"<<endl
-    <<"     Number of pixels : "<<sphred.NbPixels()<<endl
+cout<<"     Number of pixels : "<<sphred.NbPixels()<<endl
     <<"                 Nlat : "<<sphred.SizeIndex()<<endl;
 
 // Filling reducted spheres
 cout<<"...Filling Reducted Spheres"<<endl;
+uint_4 n=0;
 for(int_4 i=0;i<sphin.NbPixels();i++) {
   if(sphinw(i)<=0.) continue;
@@ -105,25 +102,27 @@
   sphred(ir)  += sphin(i)*sphinw(i);
   sphredw(ir) += sphinw(i);
+  n++;
 }
+cout<<"      Input Sphere: Number of filled pixels "<<n<<endl;
 cout<<"...Computing Reducted Spheres"<<endl;
-uint_4 n=0;
+n=0;
 for(int_4 ir=0;ir<sphred.NbPixels();ir++)
   if(sphredw(ir) > 0.) {sphred(ir) /= sphredw(ir); n++;}
-cout<<"      Number of filled pixels "<<n<<endl;
+cout<<"      Reducted Sphere: Number of pixels filled "<<n<<endl;
 
 // Filling hole for Output Spheres
 cout<<"...Filling hole for Output Spheres"<<endl;
 n=0;
-for(int_4 i=0;i<sphout.NbPixels();i++) {
-  if(sphoutw(i)>0.) continue;
+for(int_4 i=0;i<sphin.NbPixels();i++) {
+  if(sphinw(i)>0.) continue;
   double theta,phi;
-  sphout.PixThetaPhi(i,theta,phi);
+  sphin.PixThetaPhi(i,theta,phi);
   int_4 ir = sphred.PixIndexSph(theta,phi);
   if(sphredw(ir)<=0.) continue;
-  sphout(i)  = sphred(ir);
-  sphoutw(i) = -sphredw(ir);
+  sphin(i)  = sphred(ir);
+  sphinw(i) = -sphredw(ir);
   n++;
 }
-cout<<"      Number of filled pixels "<<n<<endl;
+cout<<"      Output Sphere: Number of pixels filled "<<n<<endl;
 
 // Ecriture des spheres
@@ -132,5 +131,5 @@
 FitsOutFile sfits(fsphout);
 cout<<"Writing Output Sphere Fits file"<<endl;
-sfits<<sphout;
+sfits<<sphin;
 }
 if(fsphoutw) {
@@ -138,5 +137,5 @@
 FitsOutFile sfits(fsphoutw);
 cout<<"Writing Output Sphere Weight Fits file"<<endl;
-sfits<<sphoutw;
+sfits<<sphinw;
 }
 if(fsphred) {
Index: /trunk/SophyaProg/PrgUtil/Makefile
===================================================================
--- /trunk/SophyaProg/PrgUtil/Makefile	(revision 1527)
+++ /trunk/SophyaProg/PrgUtil/Makefile	(revision 1528)
@@ -301,5 +301,107 @@
  $(INC)ntoolsinit.h \
  $(INC)tarrinit.h
-$(OBJ)cremskfrsph.o: cremskfrsph.cc
-$(OBJ)extrapsph.o: extrapsph.cc
-$(OBJ)extrap2sph.o: extrap2sph.cc
+$(OBJ)cremskfrsph.o: cremskfrsph.cc \
+ $(INC)machdefs.h \
+ $(INC)skymapinit.h \
+ $(INC)sophyainit.h \
+ $(INC)skymap.h \
+ $(INC)spherethetaphi.h \
+ $(INC)sphericalmap.h \
+ $(INC)smathconst.h \
+ $(INC)pixelmap.h \
+ $(INC)ppersist.h \
+ $(INC)pexceptions.h \
+ $(INC)gnumd5.h \
+ $(INC)dvlist.h \
+ $(INC)objfio.h \
+ $(INC)anydataobj.h \
+ $(INC)mutyv.h \
+ $(INC)spherepos.h \
+ $(INC)unitvector.h \
+ $(INC)vector3d.h \
+ $(INC)longlat.h \
+ $(INC)utilgeom.h \
+ $(INC)tvector.h \
+ $(INC)tmatrix.h \
+ $(INC)tarray.h \
+ $(INC)basarr.h \
+ $(INC)ndatablock.h \
+ $(INC)utilarr.h \
+ $(INC)spherehealpix.h \
+ $(INC)HEALPixUtils.h \
+ $(INC)localmap.h \
+ $(INC)fiospherethetaphi.h \
+ $(INC)fiospherehealpix.h \
+ $(INC)fiolocalmap.h \
+ $(INC)fitsspherehealpix.h \
+ $(INC)fitsfile.h
+$(OBJ)extrapsph.o: extrapsph.cc \
+ $(INC)machdefs.h \
+ $(INC)skymapinit.h \
+ $(INC)sophyainit.h \
+ $(INC)skymap.h \
+ $(INC)spherethetaphi.h \
+ $(INC)sphericalmap.h \
+ $(INC)smathconst.h \
+ $(INC)pixelmap.h \
+ $(INC)ppersist.h \
+ $(INC)pexceptions.h \
+ $(INC)gnumd5.h \
+ $(INC)dvlist.h \
+ $(INC)objfio.h \
+ $(INC)anydataobj.h \
+ $(INC)mutyv.h \
+ $(INC)spherepos.h \
+ $(INC)unitvector.h \
+ $(INC)vector3d.h \
+ $(INC)longlat.h \
+ $(INC)utilgeom.h \
+ $(INC)tvector.h \
+ $(INC)tmatrix.h \
+ $(INC)tarray.h \
+ $(INC)basarr.h \
+ $(INC)ndatablock.h \
+ $(INC)utilarr.h \
+ $(INC)spherehealpix.h \
+ $(INC)HEALPixUtils.h \
+ $(INC)localmap.h \
+ $(INC)fiospherethetaphi.h \
+ $(INC)fiospherehealpix.h \
+ $(INC)fiolocalmap.h \
+ $(INC)fitsspherehealpix.h \
+ $(INC)fitsfile.h
+$(OBJ)extrap2sph.o: extrap2sph.cc \
+ $(INC)machdefs.h \
+ $(INC)skymapinit.h \
+ $(INC)sophyainit.h \
+ $(INC)skymap.h \
+ $(INC)spherethetaphi.h \
+ $(INC)sphericalmap.h \
+ $(INC)smathconst.h \
+ $(INC)pixelmap.h \
+ $(INC)ppersist.h \
+ $(INC)pexceptions.h \
+ $(INC)gnumd5.h \
+ $(INC)dvlist.h \
+ $(INC)objfio.h \
+ $(INC)anydataobj.h \
+ $(INC)mutyv.h \
+ $(INC)spherepos.h \
+ $(INC)unitvector.h \
+ $(INC)vector3d.h \
+ $(INC)longlat.h \
+ $(INC)utilgeom.h \
+ $(INC)tvector.h \
+ $(INC)tmatrix.h \
+ $(INC)tarray.h \
+ $(INC)basarr.h \
+ $(INC)ndatablock.h \
+ $(INC)utilarr.h \
+ $(INC)spherehealpix.h \
+ $(INC)HEALPixUtils.h \
+ $(INC)localmap.h \
+ $(INC)fiospherethetaphi.h \
+ $(INC)fiospherehealpix.h \
+ $(INC)fiolocalmap.h \
+ $(INC)fitsspherehealpix.h \
+ $(INC)fitsfile.h
