Index: /trunk/SophyaLib/SkyT/blackbody.cc
===================================================================
--- /trunk/SophyaLib/SkyT/blackbody.cc	(revision 606)
+++ /trunk/SophyaLib/SkyT/blackbody.cc	(revision 607)
@@ -1,5 +1,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: blackbody.cc,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: blackbody.cc,v 1.2 1999-11-20 21:00:47 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/blackbody.h
===================================================================
--- /trunk/SophyaLib/SkyT/blackbody.h	(revision 606)
+++ /trunk/SophyaLib/SkyT/blackbody.h	(revision 607)
@@ -2,5 +2,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: blackbody.h,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: blackbody.h,v 1.2 1999-11-20 21:00:47 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/convtools.cc
===================================================================
--- /trunk/SophyaLib/SkyT/convtools.cc	(revision 606)
+++ /trunk/SophyaLib/SkyT/convtools.cc	(revision 607)
@@ -1,5 +1,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: convtools.cc,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: convtools.cc,v 1.2 1999-11-20 21:00:48 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/convtools.h
===================================================================
--- /trunk/SophyaLib/SkyT/convtools.h	(revision 606)
+++ /trunk/SophyaLib/SkyT/convtools.h	(revision 607)
@@ -2,5 +2,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: convtools.h,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: convtools.h,v 1.2 1999-11-20 21:00:48 ansari Exp $
 //
 // Description:
Index: unk/SophyaLib/SkyT/detection.cc
===================================================================
--- /trunk/SophyaLib/SkyT/detection.cc	(revision 606)
+++ 	(revision )
@@ -1,334 +1,0 @@
-//==============================================================================
-/* Nouvelle-Fonction */
-
-// code By Reza Ansari
-
-
-NTuple *  MkAssocNTuple (StarList* stl1, StarList* stl2)
-{
-    // Association des listes d'objets (sources)
-    stl1->Complete();
-    stl2->Complete();
-    StarList::SetPrtLevel(2);
-    stl1->AlGTransfo().SetIdentite(1);
-    int rc = stl1->AlignGeom(stl2, 3, 50, AlG_Transl);
-    cout << " stl1->AlignGeom() -> " << rc << endl;
-    if (rc) { stl1->resTr1_2 = 1;  stl1->AlGTransfo().SetIdentite(1); }
-    int nassoc = stl1->AssocStars(stl2, 3);
-    cout << " stl->AssocStars() NAssoc= " << nassoc << endl;
-    
-    char* nomnt[6] = { "x", "y", "ysz", "yszdet", "dismin", "dism2" } ;
-    NTuple* nt = new NTuple(6, nomnt);
-    float xnt[10];
-    BStar *s1, *s2;
-    int i,j;
-    for(i=0; i<stl1->NbStars(); i++) 
-    {
-	for(j=0; j<10; j++) xnt[j] = -0.;
-	s1 = stl1->Star(i);
-	if (!s1->Nice())  continue;
-	xnt[0] = s1->PosX();
-	xnt[1] = s1->PosY();
-	xnt[2] = s1->Flux();
-	j = stl1->XRef(i);        // probleme ici a cause de aligngeom ou assocstar 
-	if (j >= 0) 
-	{
-	    
-	    s2 = stl2->Star(j);
-	    if (s2->Nice()) 
-	    {
-
-		xnt[3] = s2->Flux();
-		xnt[4] = stl1->DAss(i);
-		xnt[5] = stl1->DAss2(i);
-	    }
-        }
-	nt->Fill(xnt); 
-    }
-    return(nt);
-}
-
-//==============================================================================
-/* Nouvelle-Fonction */ 
-// la fonction repond a la question : le point de coordonnees (x,y) est-
-// il un maximum local ( sur un pave 9*9 centre sur (x,y) )
-// ceci quelques soient x et y
-
-void MaxImg(ImageR4* im,double x,double y,bool& max)
-{
-  
-   	
-    if ( ( x>0 ) && ( x<im->XSize()-1 ) && ( y>0 ) && ( y<im->YSize()-1 ) )
-    // pour le centre de l'image (8 points a verifier)
-    {
-		
-	if (( (*im)(x,y) > (*im)(x-1,y-1) )&& ( (*im)(x,y) > (*im)(x,y-1) ))
-	{
-	    if (( (*im)(x,y) > (*im)(x+1,y-1) ) && ( (*im)(x,y) > (*im)(x-1,y+1) ))
-	    {
-		if (( (*im)(x,y) > (*im)(x,y+1) ) && ( (*im)(x,y) > (*im)(x+1,y+1) ))
-		{
-		    if (( (*im)(x,y) > (*im)(x-1,y) ) && ( (*im)(x,y) > (*im)(x+1,y) ))
-		    {
-			max= true;
-		    }
-		}
-	    }
-	}
-    }
-    if ( (x==0) &&  ( y>0 ) && ( y<im->YSize()-1 ) )
-    // bord en x a "gauche" (5 points a verifier)
-    {
-	if (( (*im)(x,y) > (*im)(x+1,y-1) ) && ( (*im)(x,y) > (*im)(x,y-1) ))
-	{
-	    if (( (*im)(x,y) > (*im)(x,y+1) ) && ( (*im)(x,y) > (*im)(x+1,y+1) ))
-	    {	
-		if ( (*im)(x,y) > (*im)(x+1,y) )
-		{
-		    max= true;
-		}
-	    }
-	}
-    }
-    if ( (y==0) &&  ( x>0 ) && ( x<im->XSize()-1 ) )
-    // bord en y en haut (5 points )
-    {
-	if (( (*im)(x,y) > (*im)(x,y+1) ) && ( (*im)(x,y) > (*im)(x+1,y+1) ))
-	{
-	    if (( (*im)(x,y) > (*im)(x-1,y) ) && ( (*im)(x,y) > (*im)(x+1,y) ))
-	    {
-		if ( (*im)(x,y) > (*im)(x-1,y+1) )
-		{
-		    max= true;
-		}
-	    }
-	}
-    }
-    if ( (x==im->XSize()-1 ) &&  ( y>0 ) && ( y<im->YSize()-1 ) )
-    // bord en x a "droite" (5 points a verifier)
-    {
-	if (( (*im)(x,y) > (*im)(x-1,y-1) ) && ( (*im)(x,y) > (*im)(x,y-1) ))
-	{
-	    if (( (*im)(x,y) > (*im)(x,y+1) ) && ( (*im)(x,y) > (*im)(x-1,y+1) ))
-	    {	
-		if ( (*im)(x,y) > (*im)(x-1,y) )
-	       	{
-		    max= true;
-		}
-	    }
-	}
-    }
-    if ( (y==im->YSize()-1 ) &&  ( x>0 ) && ( x<im->XSize()-1 ) )
-    // bord en y en bas (5 points )
-    {
-	if (( (*im)(x,y) > (*im)(x,y-1) ) && ( (*im)(x,y) > (*im)(x+1,y-1) ))
-	{
-	    if (( (*im)(x,y) > (*im)(x-1,y) ) && ( (*im)(x,y) > (*im)(x+1,y) ))
-	    {
-		if ( (*im)(x,y) > (*im)(x-1,y-1) )
-		{
-		    max= true;
-		}
-	    }
-	}
-    }
-    
-    if ( (x==0) &&  ( y==0 ) )
-    // coin en haut a "gauche" (3 points a verifier)
-    {
-	if (( (*im)(x,y) > (*im)(x,y+1) ) && ( (*im)(x,y) > (*im)(x+1,y+1) ))
-	{	
-	    if ( (*im)(x,y) > (*im)(x+1,y) )
-	    {
-		max= true;
-	    }
-	}
-    }
-    
-
-    if ( (x==im->XSize()-1 ) &&  ( y==0 ) )
-    // coin en haut a "droite" (3 points a verifier)
-    {
-	if (( (*im)(x,y) > (*im)(x,y+1) ) && ( (*im)(x,y) > (*im)(x-1,y+1) ))
-	{	
-	    if ( (*im)(x,y) > (*im)(x-1,y) )
-	    {
-		max= true;
-	    }
-	}
-    }
-		
-    if ( (x==im->XSize()-1 ) &&  ( y==im->YSize()-1 ) )
-    // coin en bas a "droite" (3 points a verifier)
-    {
-	if (( (*im)(x,y) > (*im)(x,y-1) ) && ( (*im)(x,y) > (*im)(x-1,y-1) ))
-	{	
-	    if ( (*im)(x,y) > (*im)(x-1,y) )
-	    {
-		max= true;
-	    }
-	}
-    }
-    if ( (x==0) &&  ( y==im->YSize()-1 ) )
-    // coin en bas a "gauche" (3 points a verifier)
-    {
-	if (( (*im)(x,y) > (*im)(x,y-1) ) && ( (*im)(x,y) > (*im)(x+1,y-1) ))
-	{	
-	    if ( (*im)(x,y) > (*im)(x+1,y) )
-	    {
-		max= true;
-	    }
-	}
-    }
-}
-
-
-//==============================================================================
-/* Nouvelle-Fonction */ 
-// calcule la somme des pixels dans un carre 9*9 centre sur (x,y)
-// dans l'image im, ceci quelques soient x et y
-
-void SomPix(ImageR4& im,double x,double y,float& som)
-{
-  
-   	
-    if ( ( x>0 ) && ( x<im.XSize()-1 ) && ( y>0 ) && ( y<im.YSize()-1 ))
-    // pour le centre de l'image (9 points)
-    {
-		
-	som=  im(x,y) +  im(x,y+1) + 
-		im(x,y-1) + im(x+1,y) +
-		im(x-1,y) + im(x-1,y-1) +
-		im(x-1,y+1) + im(x+1,y+1) +
-		im(x+1,y-1);
-    }
-    if ( (x==0) &&  ( y>0 ) && ( y<im.YSize()-1 ) )
-    // bord en x a "gauche" (6 points )
-    {
-	som= im(x,y) +  im(x,y+1) + im(x,y-1) + im(x+1,y) + im(x+1,y+1) +
-		im(x+1,y-1);
-    }
-
-    if ( (y==0) &&  ( x>0 ) && ( x<im.XSize()-1 ) )
-    // bord en y en haut (6 points )
-    {
-	som=  im(x,y) +  im(x,y+1) + im(x+1,y) +
-		im(x-1,y) +	im(x-1,y+1) + im(x+1,y+1) ;
-    }
-
-    if ( (x==im.XSize()-1 ) &&  ( y>0 ) && ( y<im.YSize()-1 ) )
-    // bord en x a "droite" (6 points)
-    {
-	som= im(x,y) +  im(x,y+1) + 
-	       im(x,y-1) +	im(x-1,y) + im(x-1,y-1) +
-	       im(x-1,y+1) ;
-
-    }
-    if ( (y==im.YSize()-1 ) &&  ( x>0 ) && ( x<im.XSize()-1 ) )
-    // bord en y en bas (6 points )
-    {
-	som=  im(x,y) +	im(x,y-1) + im(x+1,y) +
-		im(x-1,y) + im(x-1,y-1) +	im(x+1,y-1);
-    }
-    
-    if ( (x==0) &&  ( y==0 ) )
-    // coin en haut a "gauche" (4 points )
-    {
-	som= im(x,y) +im(x+1,y) + im(x,y+1) + im(x+1,y+1) ;
-    }
-    
-
-    if ( (x==im.XSize()-1 ) &&  ( y==0 ) )
-    // coin en haut a "droite" (4 points )
-    {
-	som= im(x,y) + im(x-1,y) + im(x-1,y+1) + im(x,y+1) ;
-    }
-		
-    if ( (x==im.XSize()-1 ) &&  ( y==im.YSize()-1 ) )
-    // coin en bas a "droite" (4 points )
-    {
-	som= im(x,y) + im(x-1,y) + im(x-1,y-1) + im(x,y-1) ;
-    }
-    if ( (x==0) &&  ( y==im.YSize()-1 ) )
-    // coin en bas a "gauche" (4 points)
-    {
-	som= im(x,y) + im(x+1,y) + im(x+1,y-1) + im(x,y-1) ;
-    }
-    
-
-}
-
-/* ------Nouvelle fonction -----------*/
-// detection de l'effet SZ
-// la carte des sources detectees est mise dans nb_det (d'ou la tramsmission par reference)
-// le nombre de sources detectees est mis dans nb (d'ou la tramsmission par reference)
-// la fonction retourne une StarList
-
-StarList * detec_SZ(ImageR4 & corin, ImageR4& nb_det,double& nb,int taille_f)
-{
-    ImageR4 * cor=NULL; 
-    // On cree une liste d'etoiles pour stocker les sources detectees
-    StarList* stl = new StarList(NULL, 1000, 250); 
-    BStar* star;
-    
-    if (taille_f <= 1 ) cor = &corin;             // si l'on ne veut pas de filtrage il suffit d'appeler
-                                                  // la fonction detec_SZ(..,.,.,1)
-    else 
-    { 
-	ImageR4 filt_c(taille_f,taille_f);        // declaration et ...
-	filt_c=1.;                                // initialisation du filtre 
-	cor = FilterImage(&corin,cor,&filt_c);    // filtrage
-    }
-
-    nb=0;
-    nb_det=0;
-    
-    
-    double seuil=9/taille_f;                        // on garde 3 sigma pour chaque dimension x et y
-    //    cout << "in seuil!!!" << seuil << endl;
-    double taille=cor->XSize()*cor->YSize();
-
-    bool tmp=false;
-    bool& fgdet=tmp;
-    float posx, posy, flux, fond, sompix, pixmax;   // parametre d'un etoile (source SZ)
-    
-
-
-    for (int i=0;i<cor->XSize();i++)    
-    {
-	for (int j=0;j<cor->YSize();j++)
-	{
-            fgdet = false;
-	    
-	    if ( (*cor)(i,j)>seuil )        // image filtree ou non filtree  
-	    { 
-		MaxImg(cor,i,j,fgdet);
-		if ( fgdet )
-		{
-		    
-		    nb=nb+1;          // calcul du nombre de sources
-		    nb_det(i,j)=10;   // valeur arbitraire qui pourra etre remplacee par le y mesure par exemple
-		    //fgdet = true;
-		 
-		}
-	    }
-
-	   
-            if ( !fgdet ) continue;                     // creation de la liste d'etoiles
-            posx = i+0.5;  posy = j+0.5;                      // on utilise les caracteristiques de la carte
-	                                              // non filtree
-            pixmax = corin(i,j);
-	    SomPix(corin,i,j,sompix);
-	    flux = sompix;
-            fond = 0.;
-	    star = stl->Next();
-	    star->SetX(posx, posy, flux, fond, pixmax, sompix, 
-                       posx, posy, kCourRef);
-	    star->ClearFlag(BStar::flagAll, kCourRef);
-	    star->SetFlag(BStar::flagOK, kCourRef);
-	}
-    }
-    return(stl);
-}
-
-
Index: /trunk/SophyaLib/SkyT/gaussfilt.cc
===================================================================
--- /trunk/SophyaLib/SkyT/gaussfilt.cc	(revision 606)
+++ /trunk/SophyaLib/SkyT/gaussfilt.cc	(revision 607)
@@ -1,5 +1,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: gaussfilt.cc,v 1.1.1.1 1999-11-19 16:34:33 ansari Exp $
+//      $Id: gaussfilt.cc,v 1.2 1999-11-20 21:00:48 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/gaussfilt.h
===================================================================
--- /trunk/SophyaLib/SkyT/gaussfilt.h	(revision 606)
+++ /trunk/SophyaLib/SkyT/gaussfilt.h	(revision 607)
@@ -2,5 +2,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: gaussfilt.h,v 1.1.1.1 1999-11-19 16:34:33 ansari Exp $
+//      $Id: gaussfilt.h,v 1.2 1999-11-20 21:00:49 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/nupower.cc
===================================================================
--- /trunk/SophyaLib/SkyT/nupower.cc	(revision 606)
+++ /trunk/SophyaLib/SkyT/nupower.cc	(revision 607)
@@ -1,5 +1,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: nupower.cc,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: nupower.cc,v 1.2 1999-11-20 21:00:49 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/nupower.h
===================================================================
--- /trunk/SophyaLib/SkyT/nupower.h	(revision 606)
+++ /trunk/SophyaLib/SkyT/nupower.h	(revision 607)
@@ -2,5 +2,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: nupower.h,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: nupower.h,v 1.2 1999-11-20 21:00:49 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/radspec.cc
===================================================================
--- /trunk/SophyaLib/SkyT/radspec.cc	(revision 606)
+++ /trunk/SophyaLib/SkyT/radspec.cc	(revision 607)
@@ -1,5 +1,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: radspec.cc,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: radspec.cc,v 1.2 1999-11-20 21:00:50 ansari Exp $
 //
 // Description:
@@ -106,6 +106,7 @@
     _raypourfinteg = const_cast<RadSpectra *>(this);
     TrpzInteg I(RadSpectra_fluxFunction , f1, f2);  
-    _raypourfinteg = NULL;
-    return((double)I);        
+    double val = (double)I;
+    _raypourfinteg = NULL;  // On ne peut pas faire ca avant la destruction de I
+    return(val);        
 }
 double 
@@ -160,8 +161,9 @@
   _raypourfinteg = const_cast<RadSpectra *>(this);
   _filter = const_cast<SpectralResponse *>(&filter);
-  TrpzInteg I(RadSpectra_filteredFlux,f1,f2);  
+  TrpzInteg I(RadSpectra_filteredFlux,f1,f2);
+  double val = (double)I;
   _raypourfinteg = NULL;
   _filter = NULL;
-  return((double)I);        
+  return(val);        
 }
 
@@ -210,7 +212,8 @@
    _filter = const_cast<SpectralResponse *>(&filter);
    TrpzInteg I(RadSpectra_logFilteredFlux,f1Log,f2Log);  
+   double val = (double)I;
    _raypourfinteg = NULL;
    _filter = NULL;
-   return((double)I* log(10.));        
+   return(val* log(10.));        
 }
 
Index: /trunk/SophyaLib/SkyT/radspec.h
===================================================================
--- /trunk/SophyaLib/SkyT/radspec.h	(revision 606)
+++ /trunk/SophyaLib/SkyT/radspec.h	(revision 607)
@@ -2,5 +2,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: radspec.h,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: radspec.h,v 1.2 1999-11-20 21:00:50 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/radspecvector.cc
===================================================================
--- /trunk/SophyaLib/SkyT/radspecvector.cc	(revision 606)
+++ /trunk/SophyaLib/SkyT/radspecvector.cc	(revision 607)
@@ -1,5 +1,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: radspecvector.cc,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: radspecvector.cc,v 1.2 1999-11-20 21:00:50 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/radspecvector.h
===================================================================
--- /trunk/SophyaLib/SkyT/radspecvector.h	(revision 606)
+++ /trunk/SophyaLib/SkyT/radspecvector.h	(revision 607)
@@ -44,4 +44,8 @@
   virtual double flux(double nu) const;
 
+  // Acces to Nu and F(nu) vectors 
+  inline Vector& getNuVec() { return _vecOfNu; }
+  inline Vector& getFNuVec() { return _vecOfFDeNu; }
+
   virtual void   Print(ostream& os)  const;
 
Index: /trunk/SophyaLib/SkyT/skm.d
===================================================================
--- /trunk/SophyaLib/SkyT/skm.d	(revision 606)
+++ /trunk/SophyaLib/SkyT/skm.d	(revision 607)
@@ -1,2 +1,4 @@
+#  MAPPATH  PathForFITS files
+@MAPPATH /exp/eros/Reza/CartesRT
 #  SKYMIX  NbComponents  M_Gorski
 @SKYMIX  2  64
@@ -5,9 +7,12 @@
 
 #  Sky components 
-#  SCMFILE  FITSfilename [Normalisation]
-@SCMFILE1  comp1.fits  
-@SCMFILE2  comp2.fits    0.25 
+#  MAPFITSFILEi FITSfilename [Normalisation]
+@MAPFITSFILE1  map_essai.fits 
+@MAPFITSFILE2    comp2.fits    0.25 
 
-#  SCSPEC1  FITSfilename  Fmin Fmax 
-@SCSPEC1  spec1.fits  
-@SCSPEC2  spec2.fits
+#   SPECTRAFITSFILEi  FITSfilename  Fmin Fmax 
+@SPECTRAFITSFILE1  spec1.fits  
+@SPECTRAFUNC2  3. 4. 5.
+
+#  Define the Debug level
+@DEBUGLEVEL  5
Index: /trunk/SophyaLib/SkyT/skymixer.cc
===================================================================
--- /trunk/SophyaLib/SkyT/skymixer.cc	(revision 606)
+++ /trunk/SophyaLib/SkyT/skymixer.cc	(revision 607)
@@ -32,4 +32,15 @@
                   PixelMap<double>& mapToAdd, RadSpectra& rs, double K=1.);
 
+int CheckCards(DataCards & dc, string & msg);
+char * BuildFITSFileName(string const & fname);
+void RadSpec2Nt(RadSpectra & rs, POutPersist & so, string name);
+void SpectralResponse2Nt(SpectralResponse& sr, POutPersist & so, string name);
+
+//  ----- Variable globale ------------
+static char mapPath[256];     // Path for input maps
+static int  hp_nside = 32;    // HealPix NSide
+static int  nskycomp = 0;     // Number of sky components
+static int  debuglev = 0;     // debuglevel
+
 // -------------------------------------------------------------------------
 //                             main program 
@@ -37,6 +48,6 @@
 int main(int narg, char * arg[])
 {
-  if ((narg < 2) || (strcmp(arg[1], "-h") == 0) ) {
-    cout << " skymixer / Error args \n Usage: skymixer parameterFile " << endl;
+  if ((narg < 3) || ((narg > 1) && (strcmp(arg[1], "-h") == 0) )) {
+    cout << "  Usage: skymixer parameterFile outputfitsname [outppfname]" << endl;
     exit(0);
   }
@@ -46,5 +57,6 @@
 string msg;
 int rc = 0;
-  
+POutPersist * so = NULL;
+
 try {
   string dcard = arg[1];
@@ -52,51 +64,15 @@
   DataCards dc(dcard);
 
-  //  Cheking datacards
-  if ( (!dc.HasKey("SKYMIX")) || (!dc.HasKey("FILTER")) ) {
-     rc = 71; 
-     msg = "Invalid parameters  - NO @SKYMIX or @FILTER card ";
-     goto problem;
-  }
-
-  // Decoding number of component and pixelisation parameter
-  int mg = 32;
-  int ncomp = 0;
-  ncomp = dc.IParam("SKYMIX", 0, 0);
-  mg = dc.IParam("SKYMIX", 1, 32);
-  if (ncomp < 1)  {
-    msg = "Invalid parameters  - Check datacards @SKYMIX ";
-    rc = 72;
-    goto problem;
-  }
-
-  int kc;
-  string key;
-  char buff[256];
-  bool pb = false;
-  for(kc=0; kc<ncomp; kc++) {
-    sprintf(buff, "SCMFILE%d", kc+1);
-    key = buff;
-    if (dc.NbParam(key) < 1) {   
-      msg = "Missing or invalid card : " + key;
-      pb = true;  break;
-    }
-    sprintf(buff, "SCSPEC%d", kc+1);
-    key = buff;
-    if (dc.NbParam(key) < 1)  {   
-      msg = "Missing or invalid card : " + key;
-      pb = true;  break;
-    }
-
-    }
-
-  if (pb)  {
-    rc = 72;
-    goto problem;
-  }
-
-  cout << " skymix/Info : NComp = " <<  ncomp << " M_SphereGorski= " << mg << endl;
-
-  SphereGorski<float> outgs(mg);
-  cout << " Creating Output Gorski Map  NbPixels= " << outgs.NbPixels() << endl;
+  rc = CheckCards(dc, msg);
+  if (rc) goto Fin;
+
+  cout << " skymix/Info : NComp = " <<  nskycomp << " SphereGorski_NSide= " << hp_nside << endl;
+  cout << "  ... MapPath = " << (string)mapPath << "  DbgLev= " << debuglev << endl;
+
+// We create an output persist file for writing debug objects
+  if (debuglev > 0) so = new POutPersist("skymixdbg.ppf");
+
+  SphereGorski<float> outgs(hp_nside);
+  cout << " Output Gorski Map  created - NbPixels= " << outgs.NbPixels() << endl;
   outgs.SetPixels(0.);
 
@@ -111,15 +87,42 @@
   cout << filt << endl;
 
+// FOR debug
+  if (debuglev > 0)  SpectralResponse2Nt(filt, *so, "filter");
+
   PrtTim(" After FilterCreation ");
-  }
+
+  SphereGorski<float> * ings = NULL;  // Our input map  
+  FitsIoServer fios; // Our FITS IO Server
+  char * flnm, buff[64];
+  string key;
+
+  // Loop over sky component 
+  int sk;
+  for(sk = 0; sk<nskycomp; sk++) {
+    cout << " Processing sky component No " << sk+1 << endl;
+    if (ings) { delete ings;  ings = NULL; }
+    ings = new SphereGorski<float>(hp_nside);
+    sprintf(buff, "MAPFITSFILE%d", sk+1);
+    key = buff;
+    flnm = BuildFITSFileName(dc.SParam(key, 0));
+    cout << " Reading Input FITS map " << (string)flnm << endl;
+    fios.load(*ings, flnm, 1);
+
+    if (debuglev > 4) {  // Writing tne input map to the outppf
+      FIO_SphereGorski<float> fiog(ings);
+      fiog.Write(*so, key);
+      }  
+    }
+  }   // End of try block
 
 catch (PException exc) {
   msg = exc.Msg();
   cerr << " !!!! skymixer - Catched exception - Msg= " << exc.Msg() << endl;
-  rc = 70;
+  rc = 90;
   }   
 
 
-problem:
+Fin:
+if (so) delete so;  //  Closing the debug ppf file 
 if (rc == 0)  return(0);
 cerr << " Error condition -> Rc= " << rc << endl;
@@ -128,4 +131,92 @@
 }
 
+/* Nouvelle-Fonction */
+int CheckCards(DataCards & dc, string & msg)
+//   Function to check datacards
+{
+mapPath[0] = '\0';
+hp_nside = 32;
+nskycomp = 0;
+debuglev  = 0;
+
+int rc = 0;
+  //  Cheking datacards
+  if ( (!dc.HasKey("SKYMIX")) || (!dc.HasKey("FILTER")) ) {
+     rc = 71; 
+     msg = "Invalid parameters  - NO @SKYMIX or @FILTER card ";
+     return(rc);
+  }
+
+  // Decoding number of component and pixelisation parameter
+  int mg = 32;
+  int ncomp = 0;
+  ncomp = dc.IParam("SKYMIX", 0, 0);
+  mg = dc.IParam("SKYMIX", 1, 32);
+  if (ncomp < 1)  {
+    msg = "Invalid parameters  - Check datacards @SKYMIX ";
+    rc = 72;
+    return(rc);
+  }
+
+//  Checking input FITS file specifications 
+  int kc;
+  string key, key2;
+  char buff[256];
+  bool pb = false;
+  for(kc=0; kc<ncomp; kc++) {
+    sprintf(buff, "MAPFITSFILE%d", kc+1);
+    key = buff;
+    if (dc.NbParam(key) < 1) {   
+      msg = "Missing or invalid card : " + key;
+      pb = true;  break;
+    }
+    sprintf(buff, "SPECTRAFITSFILE%d", kc+1);
+    key = buff;
+    sprintf(buff, "SPECTRAFUNC%d", kc+1);
+    key2 = buff;
+    if ( (dc.NbParam(key) < 1) && (dc.NbParam(key2) < 2) )  {   
+      msg = "Missing card or invalid parameters : " + key + " or " + key2;
+      pb = true;  break;
+    }
+
+    }
+
+  if (pb)  {
+    rc = 72;
+    return(72);
+  }
+
+//  Checking detection filter specification 
+  key = "FILTER";
+  if (dc.NbParam(key) < 3) { 
+    msg = "Missing card or invalid parameters : " + key;
+    rc = 73;  return(rc); 
+    }
+
+// Initialiazing parameters
+  rc = 0;
+  msg = "OK";
+  nskycomp = ncomp;
+  hp_nside = mg;  
+
+// Checking for PATH definition card
+  key = "MAPPATH";
+  if (dc.NbParam(key) < 3)  strncpy(mapPath, dc.SParam(key, 0).c_str(), 255);
+  mapPath[255] = '\0';
+  key = "DEBUGLEVEL";
+  debuglev =  dc.IParam(key, 0, 0);
+  return(rc);
+}
+
+static char buff_flnm[1024];   // Mal protege !
+/* Nouvelle-Fonction */
+char* BuildFITSFileName(string const & fname)
+{
+if (mapPath[0] != '\0') sprintf(buff_flnm, "%s/%s", mapPath, fname.c_str());
+else sprintf(buff_flnm, "%s", fname.c_str());
+return(buff_flnm);
+}
+
+/* Nouvelle-Fonction */
 // template <class T> 
 void addComponent(SpectralResponse&  sr, PixelMap<float>& finalMap, 
@@ -144,4 +235,5 @@
 }
 
+/* Nouvelle-Fonction */
 void addComponent(SpectralResponse&  sr, PixelMap<double>& finalMap, 
                   PixelMap<double>& mapToAdd, RadSpectra& rs, double K)
@@ -158,2 +250,48 @@
     }
 }
+
+
+/* Nouvelle-Fonction */
+void RadSpec2Nt(RadSpectra & rs, POutPersist & so, string name)
+{
+  char *ntn[2] = {"nu","fnu"};
+  NTuple nt(2,ntn);  // Creation NTuple (AVEC new )
+  float xnt[2];
+  double nu;
+  double numin = rs.minFreq();
+  double numax = rs.maxFreq();
+  int nmax = 500;
+  double dnu = (numax-numin)/nmax;
+  for(int k=0; k<nmax; k++) {
+    nu = numin+k*dnu;
+    xnt[0] = nu;
+    xnt[1] = rs.flux(nu);
+    nt.Fill(xnt);
+  }
+  ObjFileIO<NTuple> oiont(nt);
+  oiont.Write(so, name);
+  return;
+}
+
+/* Nouvelle-Fonction */
+void SpectralResponse2Nt(SpectralResponse& sr, POutPersist & so, string name)
+{
+  char *ntn[2] = {"nu","tnu"};
+  NTuple nt(2,ntn);  // Creation NTuple (AVEC new )
+  float xnt[2];
+  double nu;
+  double numin = sr.minFreq();
+  double numax = sr.maxFreq();
+  int nmax = 500;
+  double dnu = (numax-numin)/nmax;
+  for(int k=0; k<nmax; k++) {
+    nu = numin+k*dnu;
+    xnt[0] = nu;
+    xnt[1] = sr.transmission(nu);
+    nt.Fill(xnt);
+  }
+  ObjFileIO<NTuple> oiont(nt);
+  oiont.Write(so, name);
+  return;
+}
+
Index: /trunk/SophyaLib/SkyT/specresp.cc
===================================================================
--- /trunk/SophyaLib/SkyT/specresp.cc	(revision 606)
+++ /trunk/SophyaLib/SkyT/specresp.cc	(revision 607)
@@ -1,5 +1,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: specresp.cc,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: specresp.cc,v 1.2 1999-11-20 21:00:52 ansari Exp $
 //
 // Description:
@@ -112,6 +112,7 @@
   if(numax >= _numax) numax = _numax;
   TrpzInteg I(SpectralResponse_transmission , numin, numax);  
-  return((double)I);
+  double val = (double)I;
   _mySpecResp= NULL;
+  return(val);
 }
 
@@ -137,6 +138,7 @@
   _myLogSpecResp = const_cast<SpectralResponse *>(this); 
   TrpzInteg I(SpectralResponse_logTransmission ,f1Log,f2Log); 
-  return((double)I*log(10.));
+  double val = (double)I;
   _myLogSpecResp= NULL;
+  return(val*log(10.));
 }
 
Index: /trunk/SophyaLib/SkyT/specresp.h
===================================================================
--- /trunk/SophyaLib/SkyT/specresp.h	(revision 606)
+++ /trunk/SophyaLib/SkyT/specresp.h	(revision 607)
@@ -2,5 +2,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: specresp.h,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: specresp.h,v 1.2 1999-11-20 21:00:52 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/specrespvector.cc
===================================================================
--- /trunk/SophyaLib/SkyT/specrespvector.cc	(revision 606)
+++ /trunk/SophyaLib/SkyT/specrespvector.cc	(revision 607)
@@ -1,5 +1,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: specrespvector.cc,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: specrespvector.cc,v 1.2 1999-11-20 21:00:53 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/specrespvector.h
===================================================================
--- /trunk/SophyaLib/SkyT/specrespvector.h	(revision 606)
+++ /trunk/SophyaLib/SkyT/specrespvector.h	(revision 607)
@@ -2,5 +2,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: specrespvector.h,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
+//      $Id: specrespvector.h,v 1.2 1999-11-20 21:00:53 ansari Exp $
 //
 // Description:
@@ -46,4 +46,8 @@
   virtual double transmission(double nu) const; 
 
+  // Acces to Nu and T(nu) vectors 
+  inline Vector& getNuVec() { return _vecOfNu; }
+  inline Vector& getTNuVec() { return _vecOfFDeNu; }
+
   virtual void      Print(ostream& os)  const;
 
Index: /trunk/SophyaLib/SkyT/squarefilt.cc
===================================================================
--- /trunk/SophyaLib/SkyT/squarefilt.cc	(revision 606)
+++ /trunk/SophyaLib/SkyT/squarefilt.cc	(revision 607)
@@ -1,5 +1,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: squarefilt.cc,v 1.1.1.1 1999-11-19 16:34:33 ansari Exp $
+//      $Id: squarefilt.cc,v 1.2 1999-11-20 21:00:53 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/squarefilt.h
===================================================================
--- /trunk/SophyaLib/SkyT/squarefilt.h	(revision 606)
+++ /trunk/SophyaLib/SkyT/squarefilt.h	(revision 607)
@@ -2,5 +2,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: squarefilt.h,v 1.1.1.1 1999-11-19 16:34:33 ansari Exp $
+//      $Id: squarefilt.h,v 1.2 1999-11-20 21:00:54 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/trianglefilt.cc
===================================================================
--- /trunk/SophyaLib/SkyT/trianglefilt.cc	(revision 606)
+++ /trunk/SophyaLib/SkyT/trianglefilt.cc	(revision 607)
@@ -1,5 +1,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: trianglefilt.cc,v 1.1.1.1 1999-11-19 16:34:33 ansari Exp $
+//      $Id: trianglefilt.cc,v 1.2 1999-11-20 21:00:54 ansari Exp $
 //
 // Description:
Index: /trunk/SophyaLib/SkyT/trianglefilt.h
===================================================================
--- /trunk/SophyaLib/SkyT/trianglefilt.h	(revision 606)
+++ /trunk/SophyaLib/SkyT/trianglefilt.h	(revision 607)
@@ -2,5 +2,5 @@
 //--------------------------------------------------------------------------
 // File and Version Information:
-//      $Id: trianglefilt.h,v 1.1.1.1 1999-11-19 16:34:33 ansari Exp $
+//      $Id: trianglefilt.h,v 1.2 1999-11-20 21:00:54 ansari Exp $
 //
 // Description:
