Changeset 3830 in Sophya
- Timestamp:
- Aug 4, 2010, 1:59:10 PM (15 years ago)
- Location:
- trunk/Cosmo/RadioBeam
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/RadioBeam/calcpk2.cc
r3796 r3830 43 43 int main(int narg, const char* arg[]) 44 44 { 45 if (narg<6) { 46 cout << " Usage: calcpk2 InMapLSS convFacLSS InMapSync convFacSync OutPkFile \n" 47 << " [PixNoiseLevel] [Diameter/Four2DRespTableFile] [TargetBeamArcmin] [NSigSrcThr]" << endl; 48 return 1; 45 if ( (narg<6)||((narg>1)&&(strcmp(arg[1],"-h")==0)) ) { 46 cout << " Usage: calcpk2 InMapLSS convFacLSS InMapFgnd convFacFgnd OutPkFile \n" 47 << " [PixNoiseLevel] [D_Dish/Four2DRespTableFile CorBeamDoL] \n" 48 << " [NSigSrcThr] [P2/P1] [RecMapFile] " << endl; 49 if ((narg>1)&&(strcmp(arg[1],"-h")==0)) { 50 cout << "- InMapLSS: Input 3D LSS cube (PPF file name) \n " 51 << "- convFacLSS: LSS cube conversion factor to mK (milliKelvin) \n" 52 << "- InMapFgnd: Input 3D foreground cube (PPF file name) \n" 53 << "- convFacFgnd: Foreground cube conversion factor to mK (milliKelvin) \n" 54 << "- PixNoiseLevel: White noise level per pixel (mK) (default=0.) \n" 55 << "- D_Dish/Four2DRespTableFile: Dish diameter or 2D (u,v) plane response (PPF file name) \n" 56 << "- CorBeamDoL: Beam correction target Diameter/Lambda \n" 57 << " These two parameters are used to correct for beam effect for a \n" 58 << " target beam (independent of frequency) defined by D/Lambda \n" 59 << " DoL = 100 --> beam ~ 35 arcmin (D=30m @ z~0.5) \n" 60 << " default : no beam correction applied \n " 61 << " - NSigSrcThr: Point source cleaning, Nb_Sigmas on stacked 2D temperature \n" 62 << " default : no point source cleaning, use NSigSrcThr ~ 3..5 \n" 63 << " - P2/P1: 2nd/first degree polynomial fit on ln(Temp) = f(ln(freq)) \n " 64 << " foreground subtraction. default is P2 \n" 65 << "- RecMapFile: output PPF file for reconstructed foreground template \n" 66 << " (Temperature,SpectralIndex) and extracted LSS cube \n" 67 << endl; 68 return 1; 69 } 70 else cout << " calcpk2 -h for detailed usage " << endl; 71 return 2; 49 72 } 50 73 Timer tm("calcpk2"); … … 79 102 } 80 103 } 81 double tbeamDoL= 135;104 double tbeamDoL=0.; 82 105 if (narg>8) { 83 106 tbeamDoL=atof(arg[8]); … … 90 113 if (nsigsrc<1.e-6) fgclnsrc=false; 91 114 } 92 115 bool fgpoly2=true; // true -> soustraction polynome degre 2 116 if ((narg>0)&&(strcmp(arg[10],"P1")==0)) fgpoly2=false; 117 bool fgsavemaps=false; 118 string outmap_ppfname="extlss.ppf"; 119 if (narg>11) { 120 outmap_ppfname=arg[11]; 121 fgsavemaps=true; 122 } 123 93 124 TArray<r_4> maplss, mapsync; 94 125 const char * tits[2]={"LSS", "Sync/RadioSrc"}; … … 165 196 cout << "calcpk2[4] : calling cleaner.extractLSSCube(...) " << endl; 166 197 TArray<r_4> synctemp, specidx; 167 TArray<r_4> exlss = cleaner.extractLSSCube(synctemp, specidx); 198 TArray<r_4> exlss; 199 if (fgpoly2) exlss = cleaner.extractLSSCubeP2(synctemp, specidx); 200 else exlss = cleaner.extractLSSCubeP1(synctemp, specidx); 168 201 169 202 MeanSigma(exlss, mean, sigma); … … 188 221 189 222 tm.Split(" Done ComputePk "); 190 223 { 191 224 cout << "calcpk2[7.a] : writing profile P(k) to " << outname << endl; 192 225 POutPersist po(outname); 193 226 po << hp; 194 outname = "fgm_" + outname; 195 cout << "calcpk2[7.b] : writing foreground maps to " << outname << endl; 196 POutPersist pom(outname); 197 pom << PPFNameTag("Tsync") << synctemp; 198 pom << PPFNameTag("async") << specidx; 227 } 228 if (fgsavemaps) { 229 cout << "calcpk2[7.b] : writing foreground maps and extracted LSS to " << outmap_ppfname << endl; 230 POutPersist pom(outmap_ppfname); 231 pom << PPFNameTag("Tsync") << synctemp; 232 pom << PPFNameTag("async") << specidx; 233 pom << PPFNameTag("extlss") << exlss; 234 } 199 235 200 236 } // End of try bloc -
trunk/Cosmo/RadioBeam/fgndsub.cc
r3789 r3830 9 9 #include "cubedef.h" 10 10 #include "matharr.h" 11 #include "poly.h" 11 12 12 13 #include "ctimer.h" … … 90 91 91 92 /* --Methode-- */ 92 TArray< TF > ForegroundCleaner::extractLSSCube (TArray< TF >& synctemp, TArray< TF >& specidx)93 { 94 Timer tm("ForegroundCleaner::extractLSSCube ");93 TArray< TF > ForegroundCleaner::extractLSSCubeP1(TArray< TF >& synctemp, TArray< TF >& specidx) 94 { 95 Timer tm("ForegroundCleaner::extractLSSCubeP1"); 95 96 // Inputs : maplss, mapsyc, freq0, dfreq 96 97 // Outputs : synctemp, specidx (reconstructed foreground temperature and spectral index … … 130 131 bool fgnan = false; 131 132 if (!isfinite(alpha)||(!isfinite(beta))) { 132 cout << "extractLSSCube [" << i << "," << j << "]/ Not finite alpha, beta - (mapsync="133 cout << "extractLSSCubeP1[" << i << "," << j << "]/ Not finite alpha, beta - (mapsync=" 133 134 << skycube_(i,j,0) << " ... " << skycube_(i,j,skycube_.SizeZ()-1) << ")" << endl; 134 135 alpha=beta=-999.; … … 140 141 141 142 if ((axp1<-70.)||(axp1>70.)||(axp2<-70.)||(axp2>70.)) { 142 cout << "extractLSSCube [" << i << "," << j << "] BAD alpha=" << alpha143 cout << "extractLSSCubeP1[" << i << "," << j << "] BAD alpha=" << alpha 143 144 << " beta=" << beta << " T0=" << T0 << " - (mapsync=" 144 145 << skycube_(i,j,0) << " ... " << skycube_(i,j,skycube_.SizeZ()-1) << ")" << endl; … … 147 148 } 148 149 if ((i%imodprt==0)&&(j%jmodprt==0)) 149 cout << "extractLSSCube [" << i << "," << j << "]: T0=" << T0 << " alpha=" << alpha150 cout << "extractLSSCubeP1[" << i << "," << j << "]: T0=" << T0 << " alpha=" << alpha 150 151 << " (mapsync=" << skycube_(i,j,0) << " ... " << skycube_(i,j,skycube_.SizeZ()-1) << ")" << endl; 151 152 synctemp(i,j) = T0; … … 161 162 } 162 163 } 163 cout << " ForegroundCleaner::extractLSSCube () - NbNan alpha/beta=" << nbinfini << " NbBAD =" << nbbad << endl;164 cout << " ForegroundCleaner::extractLSSCubeP1() - NbNan alpha/beta=" << nbinfini << " NbBAD =" << nbbad << endl; 164 165 return omap; 165 166 } 166 167 168 /* 169 static inline val_polyn2(double alpha, double beta, double gamma, double x) 170 { 171 return (beta+alpha*x+gamma*x*x); 172 } 173 */ 174 175 /* --Methode-- */ 176 TArray< TF > ForegroundCleaner::extractLSSCubeP2(TArray< TF >& synctemp, TArray< TF >& specidx) 177 { 178 Timer tm("ForegroundCleaner::extractLSSCubeP2"); 179 // Inputs : maplss, mapsyc, freq0, dfreq 180 // Outputs : synctemp, specidx (reconstructed foreground temperature and spectral index 181 // Return_Array : foreground subtracted LSS signal 182 sa_size_t sz[5]; sz[0]=skycube_.SizeX(); sz[1]=skycube_.SizeY(); 183 synctemp.SetSize(2, sz); 184 specidx.SetSize(2, sz); 185 TArray<r_4> omap; 186 omap.SetSize(skycube_, true); 187 Vector vlnf(skycube_.SizeZ()); 188 Vector vlnT(skycube_.SizeZ()); 189 int nprt = 0; 190 // double freq0 : Frequence premier index en k (MHz) 191 // double dfreq : // largeur en frequence de chaque plan (Mhz) 192 for(sa_size_t k=0; k<skycube_.SizeZ(); k++) 193 vlnf(k)=log((double)k*dfreq_+freq0_); 194 vlnf -= vlnf(0); 195 // cout << " DBG*extractLSSCubeP2 vlnf(0)=" << vlnf(0) << " vlnf(1)=" << vlnf(1) 196 // << "vlnf(last)=" << vlnf(vlnf.Size()-1) << endl; 197 sa_size_t nbinfini=0; 198 sa_size_t nbbad=0; 199 sa_size_t imodprt=skycube_.SizeX()/6; 200 sa_size_t jmodprt=skycube_.SizeY()/6; 201 for(sa_size_t i=0; i<skycube_.SizeX(); i++) 202 for(sa_size_t j=0; j<skycube_.SizeY(); j++) { 203 vlnT = -12.; 204 Poly polyn; 205 for(sa_size_t k=0; k<skycube_.SizeZ(); k++) { 206 double lnf = vlnf(k); 207 double ttot=(r_8)(skycube_(i,j,k)); 208 if (ttot < 1.e-5) continue; 209 vlnT(k)=log(ttot); 210 } 211 polyn.Fit(vlnf,vlnT,2); 212 double beta = polyn[0]; 213 double alpha = polyn[1]; 214 double gamma = polyn[2]; 215 double T0 = exp(polyn(vlnf(0))); // exp( val_polyn2(alpha, beta, gamma, vlnf(0)) ); 216 217 bool fgnan = false; 218 if (!isfinite(alpha)||(!isfinite(beta))||(!isfinite(gamma))) { 219 cout << "extractLSSCubeP2[" << i << "," << j << "]/ Not finite alpha, beta - (mapsync=" 220 << skycube_(i,j,0) << " ... " << skycube_(i,j,skycube_.SizeZ()-1) << ")" << endl; 221 alpha=beta=gamma=-999.; 222 fgnan = true; nbinfini++; 223 } 224 else { 225 double axp1 = polyn(vlnf(0)); 226 double axp2 = polyn(vlnf(vlnf.Size()-1)); 227 228 if ((axp1<-70.)||(axp1>70.)||(axp2<-70.)||(axp2>70.)) { 229 cout << "extractLSSCubeP2[" << i << "," << j << "] BAD alpha=" << alpha 230 // << " beta=" << beta << " gamma=" << gamma << " T0=" << T0 << " axp1=" << axp1 << " axp2=" << axp2 231 << " beta=" << beta << " gamma=" << gamma << " T0=" << T0 << " - (mapsync=" << skycube_(i,j,0) 232 << " ... " << skycube_(i,j,skycube_.SizeZ()-1) << ")" << endl; 233 fgnan = true; nbbad++; 234 } 235 } 236 if ((i%imodprt==0)&&(j%jmodprt==0)) 237 cout << "extractLSSCubeP2[" << i << "," << j << "]: T0=" << T0 << " alpha=" << alpha << " gamma=" << gamma 238 << " (mapsync=" << skycube_(i,j,0) << " ... " << skycube_(i,j,skycube_.SizeZ()-1) << ")" << endl; 239 synctemp(i,j) = T0; 240 specidx(i,j) = alpha; 241 if (fgnan) { 242 for(sa_size_t k=0; k<skycube_.SizeZ(); k++) omap(i,j,k) = 0.; 243 } 244 else { 245 for(sa_size_t k=0; k<skycube_.SizeZ(); k++) { 246 r_4 fittedtemp = (r_4)( exp(polyn(vlnf(k))) ); 247 omap(i,j,k) = skycube_(i,j,k)-fittedtemp; 248 } 249 } 250 } 251 cout << " ForegroundCleaner::extractLSSCubeP2() - NbNan alpha/beta=" << nbinfini << " NbBAD =" << nbbad << endl; 252 return omap; 253 } 254 -
trunk/Cosmo/RadioBeam/fgndsub.h
r3789 r3830 29 29 int CleanNegatives(TF seuil=1.e-6); 30 30 int CleanPointSources(double nsigmas=5.); 31 TArray< TF > extractLSSCube(TArray< TF >& synctemp, TArray< TF >& specidx); 31 // Ajustement d'une droite (a x + b) sur ln(Temp) = f(ln(Freq)) 32 TArray< TF > extractLSSCubeP1(TArray< TF >& synctemp, TArray< TF >& specidx); 33 // Ajustement d'une parabole (a x^2 + b x + c) sur ln(Temp) = f(ln(Freq)) 34 TArray< TF > extractLSSCubeP2(TArray< TF >& synctemp, TArray< TF >& specidx); 32 35 33 36 Four2DResponse& arrep_; // Array/Instrument beam response -
trunk/Cosmo/RadioBeam/subtractradsrc.cmd
r3829 r3830 84 84 85 85 # 4.c/ Extract LSS P(k) from Foreground+LSS+noise , after cleaning/subtraction without beam 86 csh> ./Objs/calcpk2 lsscube.ppf 0.2 fgndcube.ppf 1000 subpk.ppf 0.35 50. 0. 0. 86 csh> ./Objs/calcpk2 lsscube.ppf 0.2 fgndcube.ppf 1000 subpk.ppf 0.35 50. 0. 0. P2 87 87 # 4.d / Extract LSS P(k) from Foreground+LSS+noise and beam effect, without beam correction 88 csh> ./Objs/calcpk2 lsscube_lobe.ppf 0.2 fgndcube_lobe.ppf 1000 subpklobe.ppf 0.35 50. 0. 3. 88 csh> ./Objs/calcpk2 lsscube_lobe.ppf 0.2 fgndcube_lobe.ppf 1000 subpklobe.ppf 0.35 50. 0. 3. P2 89 89 # 4.e / Extract LSS P(k) from Foreground+LSS+noise and beam effect - correcting to a beam of Diam/Lambda = 130 90 csh> ./Objs/calcpk2 lsscube_lobe.ppf 0.2 fgndcube_lobe.ppf 1000 subpkcorlobe.ppf 0.35 50. 130. 3. 90 csh> ./Objs/calcpk2 lsscube_lobe.ppf 0.2 fgndcube_lobe.ppf 1000 subpkcorlobe.ppf 0.35 50. 130. 3. P2 91 # Or using a linear fit for foreground subtraction (old version) 92 csh> ./Objs/calcpk2 lsscube_lobe.ppf 0.2 fgndcube_lobe.ppf 1000 subpkcorlobep1.ppf 0.35 50. 130. 3. P1 91 93 # 4.f / Estimate residual noise from Foreground removal : 92 csh> ./Objs/calcpk2 zerolss.ppf 0. fgndcube_lobe.ppf 1000 subpknolss.ppf 0.35 50. 130. 3. 94 csh> ./Objs/calcpk2 zerolss.ppf 0. fgndcube_lobe.ppf 1000 subpknolss.ppf 0.35 50. 130. 3. P2 93 95 csh> ./Objs/calcpk2 zerolss.ppf 0. fgndcube_lobe.ppf 1000 subpknolssnocor.ppf 0.35 50. 0. 3. 94 96 … … 103 105 openppf lsspklobewn.ppf 104 106 openppf subpklobe.ppf 107 105 108 openppf subpkcorlobe.ppf 109 openppf subpknolss.ppf 106 110 107 openppf subpknolss.ppf 108 openppf subpknolssnocor.ppf 111 # openppf subpknolssnocor.ppf 109 112 110 113 disp lsspk 'logx logy nsta xylimits=0.005,2.,4e-11,8e-6 gold' … … 113 116 settitle ' Pk[LSS] - without normalisation' ' ' 'font=helvetica,bold,16 black' 114 117 115 # Calcul du volume total en Mpc^3116 set VOL 3*3*3*360*360*256117 plot2d lsspklobe x val*$VOL 1 'same nsta orange'118 plot2d lsspklobe x val*$VOL 1 'same nsta orange'119 118 120 119 disp fgndpk 'logx logy nsta xylimits=0.005,2.,1e-10,1. navyblue' … … 123 122 disp lsspk 'same nsta gold' 124 123 disp lsspklobewn 'same nsta siennared' 125 settitle 'Pk[LSS] , Pk[Foreground] and lobe effect (Dish D=50 m)' ' ' 'font=helvetica,bold,18' 124 # settitle 'Pk[LSS] , Pk[Foreground] and lobe effect (Dish D=50 m)' ' ' 'font=helvetica,bold,18' 125 settitle 'Pk[LSS] , Pk[Foreground=GSM] and lobe effect (Dish D=50 m)' ' ' 'font=helvetica,bold,18' 126 126 127 set lines ( 'Pk[Foreground]' 'Pk[fgnd]*Lobe' 'Pk[fgnd]*Lobe/Corrected' 'Pk[LSS]' 'Pk[LSS]*Lobe+Noise' ) 127 128 set cols ( navyblue blue skyblue gold siennared ) 128 129 textdrawer lines cols 'font=helvetica,bold,16 frame' 130 129 131 130 132 disp lsspk 'logx logy nsta xylimits=0.005,2.,4e-9,4e-5 gold' … … 141 143 plot2d subpknolss x val*$VOL 1 'same nsta cpts marker=box,5 green' 142 144 145 # settitle 'Recovered Pk[LSS] In=LSS+(GSM) (D=50 m)' ' ' 'font=helvetica,bold,18' 143 146 settitle 'Recovered Pk[LSS] In=LSS+(Haslam+North20cm) (D=50 m)' ' ' 'font=helvetica,bold,18' 144 147 setaxelabels 'k (Mpc^-1) h=0.7' 'P(k) (mK^2 Mpc^3)' 'font=helvetica,bolditalic,16'
Note:
See TracChangeset
for help on using the changeset viewer.