Index: trunk/SophyaProg/PrgMap/cremskfrsph.cc
===================================================================
--- trunk/SophyaProg/PrgMap/cremskfrsph.cc	(revision 1522)
+++ trunk/SophyaProg/PrgMap/cremskfrsph.cc	(revision 1522)
@@ -0,0 +1,114 @@
+// Creation d'une sphere de masque a partir d'une sphere de valeurs
+//         cmv 13/6/01
+#include "machdefs.h"
+#include <unistd.h>
+#include <stdexcept>
+#include <iostream.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "skymapinit.h"
+#include "skymap.h"
+#include "fitsspherehealpix.h" 
+
+void usage();
+void usage()
+{
+cout<<"cremskfrsph [-n -m min -M max -v valmsk,inimsk] sphval.fits sphmask.fits"<<endl
+    <<" -m min : min value"<<endl
+    <<" -M max : max value"<<endl
+    <<"    condition for filling masque is : min<=V<=max"<<endl
+    <<" -n : negate the condition"<<endl
+    <<" -v valmsk,inimsk:"<<endl
+    <<"    valmsk: value to be put into mask if ok (def=1.)"<<endl
+    <<"    inimsk: initialisation value for the mask (def=0.)"<<endl;
+}
+
+
+int main(int narg, char* arg[])
+{
+double vmin=-1.e30,vmax=1.e30,vmask=1.,vmaskini=0.;
+bool tstmin=false,tstmax=false,negate=false;
+int c;
+while((c = getopt(narg,arg,"hnm:M:v:")) != -1) {
+  switch (c) {
+  case 'n' :
+    negate = true;
+    break;
+  case 'm' :
+    sscanf(optarg,"%lf",&vmin);
+    tstmin = true;
+    break;
+  case 'M' :
+    sscanf(optarg,"%lf",&vmax);
+    tstmax = true;
+    break;
+  case 'v' :
+    sscanf(optarg,"%lf,%lf",&vmask,&vmaskini);
+    break;
+  case 'h' :
+  default:
+    usage(); exit(1);
+  }
+}
+
+if(optind+1>=narg) {usage(); exit(1);}
+char * sphval = arg[optind];
+char * sphmsk = arg[optind+1];
+
+{
+cout<<"Sphere values : "<<sphval<<endl
+    <<"Sphere mask   : "<<sphmsk<<endl
+    <<"  ...min "<<vmin<<"  max "<<vmax<<endl
+    <<"  ...negate "<<negate<<endl
+    <<"  ...mask set value "<<vmask<<endl
+    <<"     mask init value "<<vmaskini<<endl;
+cout<<"Condition : ";
+if(negate) cout<<"!";
+cout<<"( "<<vmin<<" <= V <= "<<vmax<<" )"<<endl;
+}
+
+// Lecture de la sphere Healpix des valeurs
+SphereHEALPix<r_8> sph;        
+FitsInFile sfits(sphval);
+sfits >> sph;
+cout<<"Opening Sphere HEALPix for testing values :"<<endl
+    <<"          Type of map : "<<sph.TypeOfMap()<<endl
+    <<"     Number of pixels : "<<sph.NbPixels()<<endl
+    <<"                 Nlat : "<<sph.SizeIndex()<<endl;
+
+// Ouverture de la sphere Healpix pour le masque
+cout<<"Creating Mask Sphere"<<endl;
+SphereHEALPix<r_8> sphm(sph,false);
+
+// Filling Mask Sphere
+cout<<"Filling Mask"<<endl;
+uint_4 nmask = 0;
+for(int_4 i=0;i<sph.NbPixels();i++) {
+  sphm(i) = vmaskini;
+  r_8 v = sph(i);
+  bool intoint = true;
+  if(tstmin && v<vmin) intoint=false;
+  if(tstmax && v>vmax) intoint=false;
+  //                    [vmin , vmax]
+  // intoint :   false  [    true   ]  false  (si tstmin && tstmax)
+  // intoint :   false  [    true             (si tstmin && !tstmax)
+  // intoint :               true   ]  false  (si !tstmin && tstmax)
+  if(negate && intoint) continue;
+  else if(!negate && !intoint) continue;
+  sphm(i) = vmask;
+  nmask++;
+}
+cout<<"    .... Number of values set in mask   : "<<nmask<<endl;
+cout<<"    .... Fraction of values set in mask : "
+    <<(r_8)nmask/sph.NbPixels()*100.<<" %"<<endl;
+
+// Ecriture de la sphere Healpix sur fits
+{
+string dum = "rm -f "; dum += sphmsk; system(dum.c_str());
+FitsOutFile swfits(sphmsk);
+cout<<"Writing Mask Sphere Fits file"<<endl;
+swfits<<sphm;
+}
+
+exit(0);
+}
Index: trunk/SophyaProg/PrgUtil/Makefile
===================================================================
--- trunk/SophyaProg/PrgUtil/Makefile	(revision 1519)
+++ trunk/SophyaProg/PrgUtil/Makefile	(revision 1522)
@@ -15,44 +15,54 @@
 LIBSORA := $(LIBS)
 LDLIBS := $(LIBS) $(LDLIBS)
-PROGS = $(EXE)runcxx $(EXE)scanppf $(EXE)scanfits $(EXE)cl2map $(EXE)map2cl $(EXE)prjsmap
- 
+PROGS = $(EXE)runcxx $(EXE)scanppf $(EXE)scanfits $(EXE)cl2map $(EXE)map2cl $(EXE)prjsmap \
+        $(EXE)cremskfrsph
+
+PROBJS = $(OBJ)runcxx.o $(OBJ)scanppf.o $(OBJ)scanfits.o $(OBJ)cl2map.o $(OBJ)map2cl.o \
+         $(OBJ)prjsmap.o $(OBJ)cremskfrsph.o
+
 all: $(PROGS)
 
 clean:
 	rm -f $(PROGS)
+	rm -f $(PROBJS)
 	if [ -d $(OBJ)cxxrep_PrgUtil ] ; then cd $(OBJ)cxxrep_PrgUtil ; rm -f *.o ; fi
 
 runcxx: $(EXE)runcxx
-	
+	@ echo runcxx done
 $(EXE)runcxx: $(OBJ)runcxx.o
 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
-  
+
 scanppf: $(EXE)scanppf
-	
+	@ echo scanppf done
 $(EXE)scanppf: $(OBJ)scanppf.o
 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
-  
+
 scanfits: $(EXE)scanfits
-	
+	@ echo scanfits done
 $(EXE)scanfits: $(OBJ)scanfits.o
 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
-  
+
 cl2map: $(EXE)cl2map
-	
+	@ echo cl2map done
 $(EXE)cl2map: $(OBJ)cl2map.o
 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
-  
+
 map2cl: $(EXE)map2cl
-	
+	@ echo map2cl done
 $(EXE)map2cl: $(OBJ)map2cl.o
 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
-  
+
 prjsmap: $(EXE)prjsmap
-	
+	@ echo prjsmap done
 $(EXE)prjsmap: $(OBJ)prjsmap.o
 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
-  
+
+cremskfrsph: $(EXE)cremskfrsph
+	@ echo cremskfrsph done
+$(EXE)cremskfrsph: $(OBJ)cremskfrsph.o
+	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
+
 : $(EXE)
-	
+
 $(EXE):
 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
@@ -281,2 +291,3 @@
  $(INC)ntoolsinit.h \
  $(INC)tarrinit.h
+$(OBJ)cremskfrsph.o: cremskfrsph.cc
