Changeset 899 in Sophya for trunk/SophyaProg/PMixer/skymixer.cc


Ignore:
Timestamp:
Apr 13, 2000, 9:44:30 AM (25 years ago)
Author:
ansari
Message:

Sophie: processing the components with a spectral index dependent
of the pixel of the map

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/PMixer/skymixer.cc

    r886 r899  
    103103 try {
    104104   string dcard = arg[1];
    105    cout << " Decoding parameters from file " << dcard << endl;
     105   if(printlev > 1) cout << " Decoding parameters from file " << dcard << endl;
    106106   dc.ReadFile(dcard);
    107107 
     
    134134     ifnm[255] = '\0';
    135135     cout << " Reading output HealPix map from FITS file " << (string)ifnm << endl;
    136      FITS_SphereHEALPix<float> fios(ifnm);
    137      outgs = (SphereHEALPix<float>)fios;
    138       cout << " Output HealPIx Map read - NbPixels= " << outgs.NbPixels() << endl;
     136     {
     137       FITS_SphereHEALPix<float> fios(ifnm);
     138       outgs = (SphereHEALPix<float>)fios;
     139     }
     140     if(printlev>0)
     141       cout << " Output HealPIx Map read - NbPixels= " <<
     142         outgs.NbPixels() << endl;
    139143      if (printlev > 0) {
    140144        MeanSig(outgs.DataBlock(), moy, sig );
    141         cout << " MeanSig for outpout map - Mean= " << moy << " Sigma= " << sig << endl;
     145        cout << " MeanSig for outpout map - Mean= " <<
     146          moy << " Sigma= " << sig << endl;
    142147      }
    143148    }
    144149    else {
    145       cout << " Output HealPix Map  created - NbPixels= " << outgs.NbPixels() << endl;
     150      if(printlev>0)
     151        cout << " Output HealPix Map  created - NbPixels= " <<
     152          outgs.NbPixels() << endl;
    146153      outgs.SetPixels(0.);
    147154    }
     
    160167    int sk;
    161168    for(sk = 0; sk<nskycomp; sk++) {
     169      cout << "------------------------------------" << endl;
    162170      cout << " Processing sky component No " << sk+1 << endl;
    163171     
     
    168176      K = dc.DParam(key, 1, 1.);
    169177     
    170       bool mapDependentOfFreq = false;
    171       key = (string)"BETAFITSFILE"+ buff;
    172       if(dc.HasKey(key))
    173         {
    174           mapDependentOfFreq = true;
    175         }
    176       cout << "the map has a mapDependentOfFreq = " <<
    177         mapDependentOfFreq << endl;
    178178     
    179179      cout << " Reading Input FITS map " << (string)flnm << endl;
    180       FITS_SphereHEALPix<float> fiosIn(flnm);
    181       SphereHEALPix<float> ings = (SphereHEALPix<float>)fiosIn;
    182      
     180      SphereHEALPix<float> ings(hp_nside);
     181      {
     182        FITS_SphereHEALPix<float> fiosIn(flnm);
     183        ings = (SphereHEALPix<float>)fiosIn;
     184      }
    183185      if (debuglev > 4) {  // Writing the input map to the outppf
    184186        FIO_SphereHEALPix<float> fiog(ings);
     
    189191        cout << " MeanSig for input map - Mean= " << moy << " Sigma= " << sig << endl;
    190192      }
     193      bool mapDependentOfFreq = false;
     194      key = (string)"BETAFITSFILE"+ buff;
     195      if(dc.HasKey(key))
     196        {
     197          mapDependentOfFreq = true;
     198        }
     199
    191200      // getting Emission spectra 
    192201      if(!mapDependentOfFreq)
     
    206215          if (printlev > 4) cout << "....BetaFits... NSide for Integration map = " << nSideForInt << endl;
    207216          cout << "....BetaFits...  Reading Beta FITS map " << (string)flnm << endl;
    208          
    209           FITS_SphereHEALPix<float> fiosBM(flnm);
    210           SphereHEALPix<float> betaMap = (SphereHEALPix<float>)fiosBM;
    211          
     217          SphereHEALPix<float> betaMap(hp_nside);
     218          {
     219            FITS_SphereHEALPix<float> fiosBM(flnm);
     220            betaMap = (SphereHEALPix<float>)fiosBM;
     221          }
     222          if (debuglev > 4) {  // Writing the input map to the outppf
     223            FIO_SphereHEALPix<float> fiogs(betaMap);
     224            fiogs.Write(*so, key);
     225          }
     226
    212227          if(nSideForInt<0) nSideForInt = sqrt((double)betaMap.NbPixels()/12);
    213          
    214228          bool bydefault = true;
    215229          if(!bydefault)
     
    220234              SphereHEALPix<float> intBetaMap(nSideForInt);
    221235              integratedMap(*sr, betaMap, normFreq, intBetaMap);
     236              if (debuglev > 4) {  // Writing the input map to the outppf
     237                FIO_SphereHEALPix<float> fiogs2(intBetaMap);
     238                fiogs2.Write(*so, "INTBETAMAP");
     239              }
     240
    222241              betaMap.Resize(8);
    223242              MeanSig(intBetaMap.DataBlock(), moy, sig );
     
    226245              addComponentBeta(outgs,ings,intBetaMap, K);
    227246            }
    228           MeanSig(outgs.DataBlock(), moy, sig );
    229           cout << " MeanSig for Sum map - Mean= " << moy << " Sigma= " << sig << endl;
    230247        }
    231248     
    232       if (printlev > 1) {
    233         MeanSig(outgs.DataBlock(), moy, sig );
    234         cout << " MeanSig for Sum map - Mean= " << moy << " Sigma= " << sig << endl;
    235       }
    236       sprintf(buff, "End of Proc. Comp. %d ", sk+1);
     249      MeanSig(outgs.DataBlock(), moy, sig );
     250      cout << " MeanSig for Sum map - Mean= " << moy << " Sigma= " << sig << endl;
     251      cout << "-------------------------------------------------" << endl;
     252     
     253      sprintf(buff, "End of Processing Component %d ", sk+1);
    237254      PrtTim(buff);
    238255    }
     
    250267 cout << "Output Map (SphereHEALPix<float>) written to FITS file "
    251268      << (string)(arg[2]) << endl;
    252  FITS_SphereHEALPix<float> fios2(outgs);
    253  fios2.Write(arg[2]);
     269 {
     270   FITS_SphereHEALPix<float> fios2(outgs);
     271   fios2.Write(arg[2]);
     272 }
    254273 PrtTim("End of WriteFITS ");
    255274 // Saving the output map in PPF format
     
    417436    }
    418437  if (filt == NULL) throw ParmError("datacard error ! No detection filter");
    419   cout << " Filter decoded - Created " << endl;
    420   cout << *filt << endl;
    421 
    422 // for debug
     438  if(printlev>0)
     439    {
     440      cout << endl;
     441      cout << " Filter decoded - Created " << endl;
     442      cout << *filt << endl;
     443    }
     444  // for debug
    423445  if (debuglev > 1)  SpectralResponse2Nt(*filt, *so, ppfname);
    424446  return(filt);
     
    542564                   SphereHEALPix<T>& intBetaMap)
    543565{
    544   //  int nbpix = intBetaMap.NbPixels();
    545   //  SphereHEALPix<T> newMap(sqrt((double)nbpix/12));
    546   Sph2Sph(betaMap,intBetaMap);
    547   for(int i=0; i<intBetaMap.NbPixels(); i++)
    548     {
    549       RadSpectra* rs =  new PowerLawSpectra
    550         (1.,-intBetaMap(i), 0., normFreq);
    551       double coeff = rs->filteredIntegratedFlux(sr);
    552       intBetaMap(i) = coeff;
     566  PowerLawSpectra rs(1.,-2., 0., normFreq);
     567 
     568  if(betaMap.NbPixels()!=intBetaMap.NbPixels())
     569    {
     570      Sph2Sph(betaMap,intBetaMap);
     571      for(int i=0; i<intBetaMap.NbPixels(); i++)
     572        {
     573          rs.setExp(-intBetaMap(i));
     574          double coeff = rs.filteredIntegratedFlux(sr);
     575          intBetaMap(i) = coeff;
     576        }
     577    }
     578  else
     579    {     
     580      for(int i=0; i<intBetaMap.NbPixels(); i++)
     581        {
     582          rs.setExp(-betaMap(i));
     583          double coeff = rs.filteredIntegratedFlux(sr);
     584          intBetaMap(i) = coeff;
     585        }
    553586    }
    554587}
     
    575608  if(nbpix != intBetaMap.NbPixels())
    576609    {
    577       cout << "nbpix != intBetaMap.NbPixels()" << endl;
    578       SphereHEALPix<T> bigBetaMap(sqrt((double)nbpix/12));
    579       cout << "new map with size corresponding to mapToAdd" <<  sqrt((double)nbpix/12) << endl;
    580       Sph2Sph(intBetaMap,bigBetaMap);
    581610      for(int i=0; i<finalMap.NbPixels();i++)
    582611        {
    583           finalMap(i) += coeff*mapToAdd(i)*bigBetaMap(i);
     612          double teta,phi,val;
     613          finalMap.PixThetaPhi(i, teta, phi);
     614          int pixel = intBetaMap.PixIndexSph(teta,phi);
     615          val = intBetaMap.PixVal(pixel);
     616          finalMap(i) += coeff*mapToAdd(i)*val;
    584617        }
    585618    }
     
    638671  delete[] cnt;
    639672 
    640   printf("Sph2Sph_Info NbPix In= %d  Out= %d CntMoy,Sig= %g %g\n",
    641          in.NbPixels(), out.NbPixels(), moy, sig);
    642   PrtTim("End of  Sph2Sph() ");
     673  if(printlev>2)
     674    {
     675      printf("Sph2Sph_Info NbPix In= %d  Out= %d CntMoy,Sig= %g %g\n",
     676             in.NbPixels(), out.NbPixels(), moy, sig);
     677      PrtTim("End of  Sph2Sph() ");
     678    }
    643679}
    644680
Note: See TracChangeset for help on using the changeset viewer.