| [1151] | 1 | #include <fstream>
 | 
|---|
 | 2 | #include "unitvector.h"
 | 
|---|
 | 3 | #include "lightptsrclevsinband.h"
 | 
|---|
 | 4 | 
 | 
|---|
 | 5 | 
 | 
|---|
 | 6 | LightPtSrcLevSInBand::LightPtSrcLevSInBand(char FileOfPtSrc[])
 | 
|---|
 | 7 | {       // le fichier de pointsource ordonn en Theta
 | 
|---|
 | 8 |         sprintf(Name, "Sources Ponctuelles du Level S");
 | 
|---|
 | 9 |         readLevSPtSrc(FileOfPtSrc);
 | 
|---|
 | 10 | }
 | 
|---|
 | 11 | 
 | 
|---|
 | 12 | void LightPtSrcLevSInBand::readLevSPtSrc(char PtSrcfile[])
 | 
|---|
 | 13 | {       char Line[200];
 | 
|---|
 | 14 |         
 | 
|---|
 | 15 |         double theta, phi; 
 | 
|---|
 | 16 |         float f30, f44, f70, f100, f143, f217, f352, f545, f857;
 | 
|---|
 | 17 |         LevSPtSrcData UneSource;
 | 
|---|
 | 18 |         UnitVector UnCoord;
 | 
|---|
 | 19 |         
 | 
|---|
 | 20 |         ifstream HFI(PtSrcfile);
 | 
|---|
 | 21 |         if (!HFI)
 | 
|---|
 | 22 |         {       cout<< "Erreur a l'ouverture du fichier de donnees :"<<PtSrcfile<< endl;
 | 
|---|
 | 23 |                 exit(-1);
 | 
|---|
 | 24 |         }
 | 
|---|
 | 25 |         
 | 
|---|
 | 26 |         long compteur=0;
 | 
|---|
 | 27 |         long compteur2=0;
 | 
|---|
 | 28 |         while (HFI)
 | 
|---|
 | 29 |         {       // Data in file in radian and Jansky
 | 
|---|
| [1191] | 30 |         //      cout<<compteur<<'\t'<<HFI.fail()<<'\n'<<endl;;
 | 
|---|
| [1151] | 31 |                 HFI>>theta;
 | 
|---|
 | 32 |                 HFI>>phi;
 | 
|---|
 | 33 |                 HFI>>f30;
 | 
|---|
 | 34 |                 HFI>>f44;
 | 
|---|
 | 35 |                 HFI>>f70;
 | 
|---|
 | 36 |                 HFI>>f100;
 | 
|---|
 | 37 |                 HFI>>f143;
 | 
|---|
 | 38 |                 HFI>>f217;
 | 
|---|
 | 39 |                 HFI>>f352;
 | 
|---|
 | 40 |                 HFI>>f545;
 | 
|---|
 | 41 |                 HFI>>f857;      
 | 
|---|
 | 42 |                 
 | 
|---|
 | 43 |                 compteur++;
 | 
|---|
 | 44 |                 if(HFI.fail())
 | 
|---|
 | 45 |                 {       HFI.clear();
 | 
|---|
 | 46 |                         HFI.getline(Line, 199); 
 | 
|---|
| [1191] | 47 |                         if(HFI.eof())           // Fin de lecture du fichier
 | 
|---|
| [1151] | 48 |                         {       cerr<< "Fin de lecture du fichier: "<<PtSrcfile<<endl;
 | 
|---|
 | 49 |                                 cerr<< "Point source number : "<<MapOfPtSrc.size()<<endl;
 | 
|---|
| [1191] | 50 |                                 HFI.close();
 | 
|---|
| [1151] | 51 |                                 break;
 | 
|---|
 | 52 |                         }
 | 
|---|
 | 53 |                         else cerr<<"erreur lecture ligne: "<<Line<<endl;
 | 
|---|
 | 54 |                 }
 | 
|---|
 | 55 |                 else
 | 
|---|
 | 56 |                 {       // cout<<theta<<'\t'<<phi<<'\t'<<f30<<'\t'<<f44<<'\t'<<f70<<'\t'<<f100;
 | 
|---|
 | 57 |                         // cout<<'\t'<<f143<<'\t'<<f217<<'\t'<<f352<<'\t'<<f545<<'\t'<<f857<<endl<<endl;
 | 
|---|
 | 58 |                         
 | 
|---|
 | 59 |                         // In Memory Power is sored in Watt, angles in Radian
 | 
|---|
 | 60 |                         UnitVector UnCoord(theta, phi);
 | 
|---|
 | 61 |                         UneSource.flux30G=f30*1.e-26;
 | 
|---|
 | 62 |                         UneSource.flux44G=f44*1.e-26;
 | 
|---|
 | 63 |                         UneSource.flux70G=f70*1.e-26;
 | 
|---|
 | 64 |                         UneSource.flux100G=f100*1.e-26;
 | 
|---|
 | 65 |                         UneSource.flux143G=f143*1.e-26;
 | 
|---|
 | 66 |                         UneSource.flux217G=f217*1.e-26;
 | 
|---|
 | 67 |                         UneSource.flux352G=f352*1.e-26;
 | 
|---|
 | 68 |                         UneSource.flux545G=f545*1.e-26;
 | 
|---|
 | 69 |                         UneSource.flux857G=f857*1.e-26;
 | 
|---|
 | 70 |                         
 | 
|---|
| [1191] | 71 |                         const pair<const UnitVector,LevSPtSrcData>UneValeur=make_pair(UnCoord, UneSource);
 | 
|---|
| [1151] | 72 |                         
 | 
|---|
 | 73 |                         MapOfPtSrc.insert(MapOfPtSrc.end(),UneValeur);
 | 
|---|
 | 74 |                         compteur2++;
 | 
|---|
 | 75 |                 }
 | 
|---|
 | 76 |         }
 | 
|---|
 | 77 |         cerr<< compteur<<'\t'<<compteur2<<endl;
 | 
|---|
 | 78 |         return;
 | 
|---|
 | 79 | }
 | 
|---|
| [1191] | 80 | 
 | 
|---|
 | 81 | #include "fitsspherehealpix.h"
 | 
|---|
 | 82 | 
 | 
|---|
 | 83 | void LightPtSrcLevSInBand::DumpMap(LevSPanckBand band)
 | 
|---|
 | 84 | {       // Write a Mollweide projection of the Point Sources Sky
 | 
|---|
 | 85 |         // power in the LevSPanckBand band
 | 
|---|
 | 86 |         SphereHEALPix <r_4> Sphere(128);
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 |         multimap <UnitVector,LevSPtSrcData,LevSPtSrcCmpUnitVec>::iterator iter;
 | 
|---|
 | 89 |         multimap <UnitVector,LevSPtSrcData,LevSPtSrcCmpUnitVec>::iterator iterBegin=MapOfPtSrc.begin();
 | 
|---|
 | 90 |         multimap <UnitVector,LevSPtSrcData,LevSPtSrcCmpUnitVec>::iterator iterEnd=MapOfPtSrc.end();
 | 
|---|
 | 91 |         
 | 
|---|
 | 92 |         long indexSphere;
 | 
|---|
 | 93 |         double theta;
 | 
|---|
 | 94 |         double phi;
 | 
|---|
 | 95 |         double power;
 | 
|---|
 | 96 |         
 | 
|---|
 | 97 |         for(iter=iterBegin; !(iter==iterEnd); iter++)
 | 
|---|
 | 98 |         {       theta=(*iter).first.Theta();
 | 
|---|
 | 99 |                 phi=(*iter).first.Phi();
 | 
|---|
 | 100 |                 power=(*iter).second.getPower(band);
 | 
|---|
 | 101 |                 
 | 
|---|
 | 102 |                 indexSphere=Sphere.PixIndexSph(theta,phi);
 | 
|---|
 | 103 |                 Sphere(indexSphere) += power;
 | 
|---|
 | 104 |         }
 | 
|---|
 | 105 |         
 | 
|---|
 | 106 |         FITS_SphereHEALPix <r_4> FSphere(Sphere);
 | 
|---|
 | 107 |         FSphere.Mollweide_picture_projection("SkyOfPtSrcInBandMollweide.fits");
 | 
|---|
 | 108 | 
 | 
|---|
 | 109 |         return;
 | 
|---|
 | 110 | } | 
|---|