Index: /trunk/SophyaLib/SkyT/RSextract.d
===================================================================
--- /trunk/SophyaLib/SkyT/RSextract.d	(revision 704)
+++ /trunk/SophyaLib/SkyT/RSextract.d	(revision 704)
@@ -0,0 +1,88 @@
+#  EXT_RS  NbComponents  NSide_HealPix
+@EXT_RS  31 
+
+#  RD_EXT_PATH  PathForFITS   
+#  path for input Sky Component FITS files , from which the RadSpec
+#  will be extracted
+@RS_EXT_PATH /tmp_mnt/exp/planck/CartesRT/supertango/templates/
+
+#  ----    Sky map for different frequencies        ---------
+#  ----    From which will be extracted the radspectra   ----
+#  RADSPECMAPi FITSfilename freq(MHz)
+@RADSPECMAP1 	eran102_441_00015000mhz.fits
+@RADSPECMAP2 	eran102_441_00018884mhz.fits 
+@RADSPECMAP3 	eran102_441_00023773mhz.fits 
+@RADSPECMAP4	eran102_441_00029929mhz.fits 
+@RADSPECMAP5 	eran102_441_00037678mhz.fits 
+@RADSPECMAP6 	eran102_441_00047434mhz.fits 
+@RADSPECMAP7 	eran102_441_00059716mhz.fits 
+@RADSPECMAP8  	eran102_441_00075178mhz.fits 
+@RADSPECMAP9 	eran102_441_00094644mhz.fits 
+@RADSPECMAP10 	eran102_441_00119149mhz.fits 
+@RADSPECMAP11 	eran102_441_00150000mhz.fits
+@RADSPECMAP12 	eran102_441_00188839mhz.fits	
+@RADSPECMAP13 	eran102_441_00237734mhz.fits	00237734
+@RADSPECMAP14 	eran102_441_00299289mhz.fits 
+@RADSPECMAP15 	eran102_441_00376783mhz.fits
+@RADSPECMAP16 	eran102_441_00474342mhz.fits
+@RADSPECMAP17 	eran102_441_00597161mhz.fits
+@RADSPECMAP18 	eran102_441_00751781mhz.fits
+@RADSPECMAP19 	eran102_441_00946436mhz.fits
+@RADSPECMAP20 	eran102_441_01191492mhz.fits
+@RADSPECMAP21 	eran102_441_01500000mhz.fits	
+@RADSPECMAP22 	eran102_441_01888388mhz.fits	
+@RADSPECMAP23 	eran102_441_02377340mhz.fits
+@RADSPECMAP24 	eran102_441_02992893mhz.fits	
+@RADSPECMAP25 	eran102_441_03767830mhz.fits	
+@RADSPECMAP26 	eran102_441_04743416mhz.fits
+@RADSPECMAP27 	eran102_441_05971608mhz.fits	
+@RADSPECMAP28 	eran102_441_07517809mhz.fits	
+@RADSPECMAP29 	eran102_441_09464360mhz.fits
+@RADSPECMAP30 	eran102_441_11914924mhz.fits		
+@RADSPECMAP31 	eran102_441_15000000mhz.fits
+
+
+#  ----   Source point map for different frequencies        ---------
+#  ----    From which will be extracted the radspectra   ----
+#  SOURCEPTMAPi FITSfilename freq(MHz)
+@SOURCEPTMAP1 	eran102_441_00015000mhz.s_rare
+@SOURCEPTMAP2 	eran102_441_00018884mhz.s_rare
+@SOURCEPTMAP3 	eran102_441_00023773mhz.s_rare
+@SOURCEPTMAP4	eran102_441_00029929mhz.s_rare
+@SOURCEPTMAP5 	eran102_441_00037678mhz.s_rare
+@SOURCEPTMAP6 	eran102_441_00047434mhz.s_rare 
+@SOURCEPTMAP7 	eran102_441_00059716mhz.s_rare 	
+@SOURCEPTMAP8  	eran102_441_00075178mhz.s_rare 
+@SOURCEPTMAP9 	eran102_441_00094644mhz.s_rare 
+@SOURCEPTMAP10 	eran102_441_00119149mhz.s_rare
+@SOURCEPTMAP11 	eran102_441_00150000mhz.s_rare
+@SOURCEPTMAP12 	eran102_441_00188839mhz.s_rare	
+@SOURCEPTMAP13 	eran102_441_00237734mhz.s_rare
+@SOURCEPTMAP14 	eran102_441_00299289mhz.s_rare 
+@SOURCEPTMAP15 	eran102_441_00376783mhz.s_rare	
+@SOURCEPTMAP16 	eran102_441_00474342mhz.s_rare	
+@SOURCEPTMAP17 	eran102_441_00597161mhz.s_rare	
+@SOURCEPTMAP18 	eran102_441_00751781mhz.s_rare
+@SOURCEPTMAP19 	eran102_441_00946436mhz.s_rare
+@SOURCEPTMAP20 	eran102_441_01191492mhz.s_rare
+@SOURCEPTMAP21 	eran102_441_01500000mhz.s_rare
+@SOURCEPTMAP22 	eran102_441_01888388mhz.s_rare
+@SOURCEPTMAP23 	eran102_441_02377340mhz.s_rare
+@SOURCEPTMAP24 	eran102_441_02992893mhz.s_rare
+@SOURCEPTMAP25 	eran102_441_03767830mhz.s_rare
+@SOURCEPTMAP26 	eran102_441_04743416mhz.s_rare	
+@SOURCEPTMAP27 	eran102_441_05971608mhz.s_rare
+@SOURCEPTMAP28 	eran102_441_07517809mhz.s_rare
+@SOURCEPTMAP29 	eran102_441_09464360mhz.s_rare
+@SOURCEPTMAP30 	eran102_441_11914924mhz.s_rare		
+@SOURCEPTMAP31 	eran102_441_15000000mhz.s_rare
+
+
+# Filter definition now !!
+# define the detector (only one)
+@GAUSSFILTER 143 12 0.84 50. 300.
+
+#  ---- wanna print a lot of stuff..---------
+#  ----  let's try PRINTLEVEL 5          ----
+@PRINTLEVEL  0
+
Index: /trunk/SophyaLib/SkyT/exclude
===================================================================
--- /trunk/SophyaLib/SkyT/exclude	(revision 703)
+++ /trunk/SophyaLib/SkyT/exclude	(revision 704)
@@ -1,2 +1,3 @@
+extractRS.cc
 easyTest.cc
 tgrsr.cc
Index: /trunk/SophyaLib/SkyT/extractRS.cc
===================================================================
--- /trunk/SophyaLib/SkyT/extractRS.cc	(revision 704)
+++ /trunk/SophyaLib/SkyT/extractRS.cc	(revision 704)
@@ -0,0 +1,508 @@
+#include "machdefs.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <fstream.h>
+#include <iostream.h>
+#include <math.h>
+
+#include <string>
+#include <vector>
+
+#include "tmatrix.h"
+#include "tvector.h"
+#include "vector3d.h"
+
+#include "timing.h"
+#include "sambainit.h"
+#include "pexceptions.h"
+#include "datacards.h"
+#include "fitsioserver.h"
+
+#include "radspecvector.h"
+#include "blackbody.h"
+#include "nupower.h"
+
+#include "squarefilt.h"
+#include "trianglefilt.h"
+#include "specrespvector.h"
+#include "gaussfilt.h"
+
+// -----------------------------------------------------------------
+// ------------- Function declaration ------------------------------
+int CheckCards(DataCards & dc, string & msg);
+char * BuildFITSFileName(string const & fname);
+SpectralResponse * getSpectralResponse(DataCards & dc);
+template <class T>
+void addComponent(SpectralResponse&  sr, PixelMap<T>& finalMap, 
+                  PixelMap<T>& mapToAdd, RadSpectra& rs, double K=1.);
+template <class T>
+void  MeanSig(NDataBlock<T> const & dbl, double& gmoy, double& gsig);
+float ComputeFrequency(DataCards &,string&);
+
+// -----------------------------------------------------------------
+
+//  ----- Global (static) variables ------------
+static bool rdmap = false;    // true -> Read map first 
+static char mapPath[256];     // Path for input maps
+static int  nskycomp = 0;     // Number of sky components
+static int  debuglev = 0;     // Debug Level
+static int  printlev = 0;     // Print Level
+static POutPersist * so = NULL;  // Debug PPFOut file
+
+// -------------------------------------------------------------------------
+//                             main program 
+// -------------------------------------------------------------------------
+int main(int narg, char * arg[])
+{
+  if ((narg < 4) || ((narg > 1) && (strcmp(arg[1], "-h") == 0) )) {
+    cout << "  Usage: extractRS parameterFile outputfitsnameformaps  outputfitsnameforsource [outppfname]" << endl;
+    exit(0);
+  }
+  
+  InitTim();
+  
+  string msg;
+  int rc = 0;
+  RadSpectra * es = NULL;
+  SpectralResponse * sr = NULL;
+  double moy, sig;
+  
+  DataCards dc;
+  so = NULL;
+  
+  try {
+    string dcard = arg[1];
+    cout << " Decoding parameters from file " << dcard << endl;
+    dc.ReadFile(dcard);
+    
+    rc = CheckCards(dc, msg);
+    if (rc) { 
+      cerr << " Error condition -> Rc= " << rc << endl;
+      cerr << " Msg= " << msg << endl;
+      return(rc);
+    }
+  }
+  catch (PException exc) {
+    msg = exc.Msg();
+    cerr << " !!!! extractRS/ Readcard - Catched exception - Msg= " << exc.Msg() << endl;
+    return(90);
+  }   
+  
+  
+  cout << " extractRS/Info : NComp = " <<  nskycomp << endl;
+  cout << "  ... MapPath = " << (string)mapPath << "  DebugLev= " << debuglev 
+       << "  PrintLev= " << printlev << endl;
+  
+
+  // We create an output persist file for writing debug objects
+  if (debuglev > 0) so = new POutPersist("extrRSdbg.ppf");
+  
+  
+  TMatrix<float> outgs;
+  bool okout = false;
+  
+  try {
+    
+    FitsIoServer fios; // Our FITS IO Server
+    char * flnm, buff[90];
+    string key;
+    string key2;
+   
+    double K = 1.;
+    
+    // Loop over sky frequencies components
+    int maxOfSkyComp = nskycomp;
+    int nbOfPix;
+    int sk;
+    Vector freq(maxOfSkyComp);
+    TMatrix<float> spectrum;
+    TMatrix<float> fdenu; //par freq et par pixel
+    int nb_source;
+    TMatrix<float> rareSource; //par freq et par numero de source
+	
+    for(sk = 0; sk<maxOfSkyComp; sk++) 
+      {
+	
+	TMatrix<float> ings;	
+	// Opening the file containing the map
+	
+	if (printlev > 2) cout << " Processing map's frequency component No " << sk+1 << endl;
+	sprintf(buff, "%d", sk+1);
+	key = (string)"RADSPECMAP" + buff;
+	
+	flnm = BuildFITSFileName(dc.SParam(key,0));
+	if (printlev > 2) cout << " Reading Input FITS map " << (string)flnm << endl;
+	
+	fios.load(ings, flnm) ;
+	if (printlev > 2) 
+	  {
+	    MeanSig(ings.DataBlock(), moy, sig );
+	    cout << " MeanSig for input map - Mean= " << moy << " Sigma= " << sig << endl;
+	  }
+
+	// Computing the frequency according to the name of the file
+	freq(sk) =  ComputeFrequency(dc,key);
+	if (printlev > 2)  cout << "filling spectrum for freq = " << freq(sk) << endl;
+	// Opening the file containing the point source
+	sprintf(buff, "%d", sk+1);
+	key2 = (string)"SOURCEPTMAP" + buff;
+	flnm = BuildFITSFileName(dc.SParam(key2,0));
+	const char* nameOfFile = flnm ;
+	if (printlev > 2) cout << " Reading Input FITS map " << nameOfFile << endl;
+	ifstream from(nameOfFile);
+	char ch;
+	string dum;
+	from >> nb_source >> dum;
+	if(sk==0) rareSource.ReSize(maxOfSkyComp,nb_source);
+	for (int ii=0; ii< nb_source; ii++)
+	  {
+	    double value = 0;
+	    from >> value;
+	    rareSource(sk,ii) = value*1.e-26; //for Jansky->W
+	  }
+	from.close();
+
+	nbOfPix = ings.NRows()*ings.NCols();
+	spectrum.ReSize(ings.NRows(),ings.NCols());
+	if(sk==0) fdenu.ReSize(maxOfSkyComp,nbOfPix);
+	int xy=0;
+	for(int x=0;x<ings.NRows(); x++)
+	  {
+	    for(int y=0;x<ings.NCols(); x++)
+	      {
+		spectrum(x,y) = ings(x,y)*1.e-26; //for Jansky->W
+		fdenu(sk,xy) = spectrum(x,y);  
+		xy += 1;
+	      }
+	  }
+	if (printlev > 2) 
+	  {
+	    MeanSig(spectrum.DataBlock(), moy, sig );
+	    cout << " MeanSig for spectrum  map - Mean= " << moy << " Sigma= " << sig << endl;
+	  }
+	
+	
+	K = dc.DParam(key, 1, 1.);
+	if (debuglev > 4) {  // Writing the input map to the outppf
+	  FIO_TMatrix<float> fiog;
+	  fiog.Write(*so, key);
+	}
+	
+	if(printlev>2) 
+	  {	
+	    sprintf(buff, "End of Proc. Comp. %d ", sk+1);
+	    cout << " --------------------------------------- \n" << endl;    
+	    PrtTim(buff);
+	  }
+      }   // End of sky component loop 
+    
+    // ---------------------------------------------------------------------
+    //      Integration in the detector band of the maps
+    // ---------------------------------------------------------------------
+    SpectralResponse* sr = NULL;
+    sr = getSpectralResponse(dc);
+  
+    if (printlev > 2)  cout  << "SpectralResponse!" << *sr << endl;
+    TVector<float> outCoeff(nbOfPix);
+
+    for(int pix=1;pix<nbOfPix;pix++)
+      {
+	Vector smallFDeNu(maxOfSkyComp);
+	for(sk = 0; sk<maxOfSkyComp; sk++) 
+	  {
+	    smallFDeNu(sk) =  fdenu(sk,pix);
+	  }
+	
+	RadSpectraVec radSV(freq,smallFDeNu);
+	if (printlev > 10)  cout << "RadiationSpectra" << radSV << endl;
+
+ 	TVector<float> smallFDeNuT(maxOfSkyComp);
+ 	for(sk = 0; sk<maxOfSkyComp; sk++) 
+ 	  {
+ 	    smallFDeNuT(sk) = smallFDeNu(sk);
+ 	  }
+	outCoeff(pix) = radSV.filteredIntegratedFlux(*sr);
+      }
+
+    FitsIoServer fiosrs;
+    fiosrs.save(outCoeff,arg[2]);
+    cout << "Output Map (TMatrix<float>) written to FITS file "  
+	 << arg[2]<< endl;
+    cout << endl;
+
+    // ---------------------------------------------------------------------
+    //      Integration in the detector band of the sources
+    // ---------------------------------------------------------------------
+    TVector<float> sourceCoeff(nb_source);
+    for(int nsource=0;nsource<nb_source;nsource++)
+      {
+	Vector SourceFDeNu(maxOfSkyComp);
+	for(sk = 0; sk<maxOfSkyComp; sk++) 
+	  {
+	    SourceFDeNu(sk) =  rareSource(sk,nsource);
+	  }
+	RadSpectraVec radSV_Source(freq,SourceFDeNu);
+	sourceCoeff(nsource) = radSV_Source.filteredIntegratedFlux(*sr);
+      }
+    FitsIoServer fiosrs_source;
+    fiosrs_source.save(sourceCoeff,arg[3]);
+    cout << "Output Map (TMatrix<float>) written to FITS file "  
+	 << arg[3]<< endl;
+    cout << endl;
+
+    // ---------------------------------------------------------------------
+    //     Check of write/read on FITS file
+    // ---------------------------------------------------------------------
+    if (printlev > 2)
+    {
+      cout << " Check of write/read on FITS file for skymap!" << endl;
+      TVector<float> outout;
+      FitsIoServer fiotest;
+      fiotest.load(outout, arg[2]);
+      cout << "Coeff(2)" << outout(2) << " ? " << outCoeff(2) << endl;
+      cout << endl;
+    }
+    if (printlev > 2)
+    {
+      cout << " Check of write/read on FITS file for sources!" << endl;
+      FitsIoServer fiotest;
+      TVector<float> outout2;
+      fiotest.load(outout2, arg[3]);
+      cout << "sourceCoeff(2)" << outout2(2) << " ? " << sourceCoeff(2) << endl;
+    }
+
+
+  }   // End of try block
+  
+  
+  catch (PException exc) {
+    msg = exc.Msg();
+    cerr << " !!!! extractRS - Catched PException  - Msg= " << exc.Msg() << endl;
+    rc = 50;
+  }   
+  catch (PThrowable exc) {
+    msg = exc.Msg();
+    cerr << " !!!! extractRS - Catched PThrowable  - Msg= " << exc.Msg() << endl;
+    rc = 50;
+  }   
+  catch (...) {
+    cerr << " Une exception de type inconnue !!! " << endl;
+    exit(99);
+  }
+  
+  // Saving the output map in FITS format 
+  if (okout) {
+    FitsIoServer fios;
+    fios.save(outgs, arg[2]);
+    cout << "Output Map (TMatrix<float>) written to FITS file " 
+	 << (string)(arg[2]) << endl;
+    if(printlev>2) PrtTim("End of WriteFITS ");
+    // Saving the output map in PPF format 
+    if (narg > 3) {
+      POutPersist s(arg[3]); 
+      FIO_TMatrix<float> fiog ;
+      fiog.Write(s);
+      cout << "Output Map (TMatrix<float>) written to POutPersist file "  
+	   << (string)(arg[3]) << endl;
+      if(printlev>2) PrtTim("End of WritePPF ");
+    }
+  }
+  if (so) delete so;  //  Closing the debug ppf file 
+  return(rc);
+}
+
+
+
+/* Nouvelle-Fonction */
+int CheckCards(DataCards & dc, string & msg)
+  //   Function to check datacards
+{
+  rdmap = false;
+  mapPath[0] = '\0';
+  nskycomp = 0;
+  debuglev  = 0;
+  printlev = 0;
+  
+  int rc = 0;
+  string key, key2;
+  
+  //  Checking datacards
+  if (dc.NbParam("EXT_RS") < 1)   {
+     rc = 71; 
+     msg = "Invalid parameters  - Check @EXT_RS card ";
+     return(rc);
+  }
+  int kc;
+  char buff[256];
+  bool pb = false;
+  string key3;
+  int ncomp = 0;
+  ncomp = dc.IParam("EXT_RS", 0);
+  
+  for(kc=0; kc<ncomp; kc++) 
+    {
+      key = "RS_EXT_PATH";
+      if (dc.NbParam(key) < 3)  strncpy(mapPath, dc.SParam(key, 0).c_str(), 255);
+      mapPath[255] = '\0';
+      sprintf(buff, "RADSPECMAP%d", kc+1);
+      key = buff;
+      
+      if (dc.NbParam(key) < 1) {   
+	msg = "Missing or invalid card : " + key;
+	pb = true;  break;
+      }
+    }
+  
+  //  Checking detection filter specification 
+
+  key = "GAUSSFILTER";
+  key2 = "FILTERFITSFILE";
+  if ( (dc.NbParam(key) < 5) && (dc.NbParam(key2) < 3)) { 
+    msg = "Missing card or parameters : Check @GAUSSFILTER or @FILTERFITSFILE";
+    rc = 73;  return(rc); 
+  }
+  
+  if (pb)  {
+    rc = 75;
+    return(75);
+  }
+  
+  
+  // Initialiazing parameters
+  rc = 0;
+  msg = "OK";
+  nskycomp = ncomp;
+  
+  // Checking for PATH definition card
+  key = "RS_EXT_PATH";
+  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);
+  key = "PRINTLEVEL";
+  printlev =  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  MeanSig(NDataBlock<T> const & dbl, double& gmoy, double& gsig)
+
+{
+  gmoy=0.;
+  gsig = 0.; 
+  double valok;
+  for(int k=0; k<(int)dbl.Size(); k++) {
+    valok = dbl(k);
+    gmoy += valok;  gsig += valok*valok; 
+  }
+  gmoy /= (double)dbl.Size();
+  gsig = gsig/(double)dbl.Size() - gmoy*gmoy;
+  if (gsig >= 0.) gsig = sqrt(gsig);
+}
+/* Nouvelle-Fonction */
+template <class T> 
+void addComponent(SpectralResponse&  sr, PixelMap<T>& finalMap, 
+                  PixelMap<T>& mapToAdd, RadSpectra& rs, double K)
+{
+  // finalMap = finalMap + coeff* mapToAdd
+  // coeff    =  convolution of sr and rs 
+  // compute the coefficient corresponding to mapToAdd
+  if (finalMap.NbPixels() != mapToAdd.NbPixels())   
+    throw SzMismatchError("addComponent()/Error: Unequal number of Input/Output map pixels");
+  double coeff = rs.filteredIntegratedFlux(sr) * K;
+  if (printlev > 1) 
+    cout << " addComponent - Coeff= " << coeff << " (K= " << K << ")" << endl; 
+  for(int i=0; i<finalMap.NbPixels(); i++)
+    {
+      finalMap(i) += coeff * mapToAdd(i);
+    }
+}
+
+
+/* Nouvelle-Fonction */
+SpectralResponse * getSpectralResponse(DataCards & dc)
+{
+  SpectralResponse * filt = NULL;
+
+  string key = "FILTERFITSFILE";
+  string key2 = "GAUSSFILTER";
+  string ppfname = "filter";
+
+  if (dc.HasKey(key) ) {      // Reading FITS filter file
+    FitsIoServer fios;
+    char ifnm[256];
+    strncpy(ifnm, dc.SParam(key, 1).c_str(), 255);
+    ifnm[255] = '\0';
+    Matrix mtx(2,10);
+    fios.load(mtx, ifnm);
+    double numin = dc.DParam(key, 2, 1.);
+    double numax = dc.DParam(key, 3, 9999.);
+    Vector nu(mtx.NCols());
+    Vector fnu(mtx.NCols());
+    for(int k=0; k<mtx.NCols(); k++) {
+      nu(k) = mtx(0, k);
+      fnu(k) = mtx(1, k);
+    }
+  filt = new SpecRespVec(nu, fnu, numin, numax);
+  ppfname = key;
+  }
+  else if (dc.HasKey(key2) ) {   // creating GaussianFilter 
+    double nu0 = dc.DParam(key2, 0, 10.);
+    double s = dc.DParam(key2, 1, 1.);
+    double a = dc.DParam(key2, 2, 1.);
+    double numin = dc.DParam(key2, 3, 0.1);
+    double numax = dc.DParam(key2, 4, 9999);
+    filt = new GaussianFilter(nu0, s, a, numin, numax);
+    ppfname = key2;
+    }
+  if (filt == NULL) throw ParmError("datacard error ! No detection filter");
+  cout << " Filter decoded - Created " << endl;
+  cout << *filt << endl;
+
+// for debug
+  //  if (debuglev > 1)  SpectralResponse2Nt(*filt, *so, ppfname);
+  return(filt);
+}
+
+
+float ComputeFrequency(DataCards & dc,string& key)
+{
+  ofstream filename("temp_filename");
+  filename << dc.SParam(key,0) << '\n';
+  filename.close();
+  
+  ifstream fromtempfile("temp_filename");
+  char chtemp;
+  string temp_str;
+  int count = 0;
+  do { 
+    fromtempfile.get(chtemp);    
+    if(count> 12 && count < 20)
+      {
+	temp_str+= chtemp; 
+      }
+    count+=1;
+  } while(chtemp!='\n'); 
+  fromtempfile.close();
+  
+  ofstream filename2("temp_filename");
+  filename2 << temp_str << '\n';
+  filename2.close();
+  
+  int frequency;
+  ifstream fromtempfile2("temp_filename");
+  fromtempfile2 >> frequency;
+  fromtempfile2.close();
+  return ((float)frequency/1000.);
+}
