1 | #include <iostream>
|
---|
2 | #include "ptsrcinbandcalctools.h"
|
---|
3 | #include "lightptsrclevsinband.h"
|
---|
4 | #include "spherehealpix.h"
|
---|
5 |
|
---|
6 | PtSrcInBandCalTools::PtSrcInBandCalTools(LightPtSrcLevSInBand* pLightSource,MeanFreqLobe* pLob, LevSPanckBand thisBand)
|
---|
7 | :pLightSrc(pLightSource), Band(thisBand)
|
---|
8 | { pLobe=pLob;
|
---|
9 | FreqMax=pLobe->maxFreq();
|
---|
10 | FreqMin=pLobe->minFreq();
|
---|
11 | pFilter=pLob->pRespShape;
|
---|
12 | RAngComp = pLobe->lobeResol();
|
---|
13 | }
|
---|
14 |
|
---|
15 | double PtSrcInBandCalTools::compPixel(UnitVector& VP, UnitVector& VY)
|
---|
16 | { double OuvAng=pLobe->AngleMax();
|
---|
17 | double thetaPointe=VP.Theta();
|
---|
18 | double PhiPointe=VP.Phi();
|
---|
19 |
|
---|
20 | double ThetaMin=thetaPointe-OuvAng; if(ThetaMin<0.) ThetaMin=0.;
|
---|
21 | double ThetaMax=thetaPointe+OuvAng; if(ThetaMax>M_PI) ThetaMax=M_PI;
|
---|
22 |
|
---|
23 | /*
|
---|
24 | cout<< "test Passage"<<endl;
|
---|
25 | cout<<VP.Theta()<<'\t'<<VP.Phi()<<'\t'<<VY.Theta()<<'\t'<<VY.Phi()<<endl;
|
---|
26 | */
|
---|
27 | double deltaPhi;
|
---|
28 | { // Compute limits in Phi
|
---|
29 | double deltaPhi1;
|
---|
30 | if(ThetaMin!=0.) deltaPhi1=OuvAng/sin(ThetaMin);
|
---|
31 | else deltaPhi1=M_PI;
|
---|
32 | double deltaPhi2;
|
---|
33 | if(ThetaMax!=0.) deltaPhi2=OuvAng/sin(ThetaMax);
|
---|
34 | else deltaPhi2=M_PI;
|
---|
35 |
|
---|
36 | // Compute deltaPhi
|
---|
37 | if(deltaPhi1>deltaPhi2) deltaPhi=deltaPhi1;
|
---|
38 | else deltaPhi=deltaPhi2;
|
---|
39 | }
|
---|
40 | double PhiMin=PhiPointe-deltaPhi;
|
---|
41 | double PhiMax=PhiPointe+deltaPhi;
|
---|
42 |
|
---|
43 | /* // Useless!
|
---|
44 | if((PhiMin<-M_PI)||(PhiMax>M_PI))
|
---|
45 | { PhiMin=-M_PI;
|
---|
46 | PhiMax=M_PI;
|
---|
47 | }
|
---|
48 | */
|
---|
49 | double PowerTot=0.;
|
---|
50 |
|
---|
51 | const UnitVector VecBidon(ThetaMin,0.);
|
---|
52 | multimap <UnitVector,LevSPtSrcData,LevSPtSrcCmpUnitVec>::iterator iterlow=pLightSrc->MapOfPtSrc.lower_bound(VecBidon);
|
---|
53 | const UnitVector VecBidon2(ThetaMax,0.);
|
---|
54 | multimap <UnitVector,LevSPtSrcData,LevSPtSrcCmpUnitVec>::iterator iterhigh=pLightSrc->MapOfPtSrc.upper_bound(VecBidon2);
|
---|
55 |
|
---|
56 | multimap <UnitVector,LevSPtSrcData,LevSPtSrcCmpUnitVec>::iterator iter;
|
---|
57 | double PhiSrc;
|
---|
58 |
|
---|
59 | // long compteur=0;
|
---|
60 | // long compteur2=0;
|
---|
61 |
|
---|
62 | for(iter=iterlow; iter!=iterhigh; iter++)
|
---|
63 | { PhiSrc=(*iter).first.Phi();
|
---|
64 | if( (PhiSrc>PhiMin) && (PhiSrc<PhiMax) )
|
---|
65 | { double poid=pLobe->weigthAmpl((*iter).first,VP,VY);
|
---|
66 | PowerTot+=(*iter).second.getPower(Band)*poid;
|
---|
67 | // compteur++;
|
---|
68 | // if (poid!=0.) compteur2++;
|
---|
69 | }
|
---|
70 | }
|
---|
71 | return PowerTot;
|
---|
72 | }
|
---|
73 |
|
---|
74 | double PtSrcInBandCalTools::CalcLobeSize(double frequency)
|
---|
75 | // I KNOW! Awfully heavy. But It's the cost of generality.
|
---|
76 | // This function should be called only once!
|
---|
77 | { double AngMax=pLobe->AngleMax();
|
---|
78 |
|
---|
79 | // On cherche la resolution healpix correspondante
|
---|
80 | double x= 0.5*M_PI/RAngComp;
|
---|
81 | long nlat=1;
|
---|
82 | while (x>1.)
|
---|
83 | {x/=2.; nlat*=2;}
|
---|
84 |
|
---|
85 | // On reserve une sphere pour en connaitres les coordonnes
|
---|
86 | SphereHEALPix<uint_2> dummSphere(nlat);
|
---|
87 |
|
---|
88 | double SolidAngPixel = dummSphere.PixSolAngle();
|
---|
89 | long Nbtranch = dummSphere.NbThetaSlices()*AngMax/M_PI;
|
---|
90 | double thetaStep=M_PI/Nbtranch+1.;
|
---|
91 |
|
---|
92 | TVector<uint_2> VecValues;
|
---|
93 | TVector<int_4> VecIndice;
|
---|
94 | r_8 dumTheta;
|
---|
95 | r_8 dumPhi;
|
---|
96 |
|
---|
97 | double AngSolid=0.;
|
---|
98 | UnitVector VZ(0.,0.,1.);
|
---|
99 |
|
---|
100 | for(double ThetaAnn=0.5*thetaStep;ThetaAnn<AngMax; ThetaAnn+=thetaStep)
|
---|
101 | { // Obtient l'indice d'un pixel sur l'anneau theta=ThetaAnn
|
---|
102 | int_4 index=dummSphere.PixIndexSph(ThetaAnn,0.);
|
---|
103 | dummSphere.GetThetaSlice(index,dumTheta,dumPhi,VecIndice,VecValues);
|
---|
104 |
|
---|
105 | double theta,phi;
|
---|
106 | // Somme la valeur du lobe sur les pointe d'un anneau
|
---|
107 | for(long index=0; index<VecIndice.Size(); index++)
|
---|
108 | { int_4 ind=VecIndice(index);
|
---|
109 | dummSphere.PixThetaPhi(ind,theta,phi);
|
---|
110 | UnitVector VInteg(theta, phi);
|
---|
111 | UnitVector VY=VZ^VInteg;
|
---|
112 |
|
---|
113 | AngSolid+= pLobe->weigthAmpl(VInteg,VZ,VY)*SolidAngPixel;
|
---|
114 | }
|
---|
115 | }
|
---|
116 | cout<<AngSolid<<endl;
|
---|
117 |
|
---|
118 | return AngSolid;
|
---|
119 | }
|
---|
120 |
|
---|
121 | /*
|
---|
122 | double PtSrcInBandCalTools::powerInteg(double ThetaMin, double ThetaMax,
|
---|
123 | double PhiMin, double PhiMax, UnitVector& VP, UnitVector& VY, bool InvLog)
|
---|
124 | {
|
---|
125 | const UnitVector VecBidon(ThetaMin,0.);
|
---|
126 | multimap <UnitVector,LevSPtSrcData,LevSPtSrcCmpUnitVec>::iterator iterlow=pLightSrc->MapOfPtSrc.lower_bound(VecBidon);
|
---|
127 | const UnitVector VecBidon2(ThetaMax,0.);
|
---|
128 | multimap <UnitVector,LevSPtSrcData,LevSPtSrcCmpUnitVec>::iterator iterhigh=pLightSrc->MapOfPtSrc.upper_bound(VecBidon2);
|
---|
129 |
|
---|
130 | multimap <UnitVector,LevSPtSrcData,LevSPtSrcCmpUnitVec>::iterator iter;
|
---|
131 | double Power=0.;
|
---|
132 | double PhiSrc;
|
---|
133 | bool test;
|
---|
134 |
|
---|
135 | // long compteur=0;
|
---|
136 | // long compteur2=0;
|
---|
137 |
|
---|
138 | for(iter=iterlow; iter!=iterhigh; iter++)
|
---|
139 | { PhiSrc=(*iter).first.Phi();
|
---|
140 | test=(PhiSrc>PhiMin) && (PhiSrc<PhiMax);
|
---|
141 | if (InvLog) test= (!test);
|
---|
142 | if(test)
|
---|
143 | { double poid=pLobe->weigthAmpl((*iter).first,VP,VY);
|
---|
144 | Power+=(*iter).second.getPower(Band)*poid;
|
---|
145 | // compteur++;
|
---|
146 | // if (poid!=0.) compteur2++;
|
---|
147 | }
|
---|
148 | }
|
---|
149 | return Power;
|
---|
150 | }
|
---|
151 | */
|
---|