Changeset 4026 in Sophya for trunk/Cosmo
- Timestamp:
- Oct 10, 2011, 11:31:03 PM (14 years ago)
- Location:
- trunk/Cosmo/RadioBeam
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/RadioBeam/README
r3973 r4026 24 24 - gsm2cube.cc : Computes 3D temperature cube from a set of GSM (Global Sky Model) healpix PPF maps 25 25 - tjyk.cc : test de la classe H21Conversions 26 - ckpowl.cc : Programme de verification comportement en loi de puissance 26 27 27 28 A.3/ List of other common files : -
trunk/Cosmo/RadioBeam/pknoise.cc
r3948 r4026 6 6 7 7 Usage: pknoise pknoise [-parname value] Diameter/Four2DRespTableFile OutPPFName 8 -parname : -noise , -renmax , -scut , -ngen , -z , - prt8 -parname : -noise , -renmax , -scut , -ngen , -z , -bsize , -cszmpc , -prt 9 9 --------------------------------------------------------------- */ 10 10 … … 45 45 << " -ngen NGen (default=0) number of noise fourier amp generations \n" 46 46 << " NGen=0 -> Call ComputeNoisePk(), else generate Fourier Amplitudes (random) \n" 47 << " -z redshift (default=0.7) \n" 47 << " NGen=-1 -> Call ComputeNoisePk(), dont change Four3DPk cell size \n" 48 << " -bsize sx,sy,sz : 3D real space box size (default=512x512x256) \n" 49 << " -cszmpc sx,sy,sz : 3D real space box cell size in Mpc (default=3x3x3) \n" 50 << " -z z,dA,H_z : redshift,ComovDist(z),H(z) (default=1.0,3330,120.5) \n" 48 51 << " -scut SCutValue (default= -100.) \n" 49 52 << " if SCutValue<0. ==> SCut=MinNoisePower*(-SCutValue) \n" … … 80 83 bool fgautoscut=true; 81 84 double FacSCut=-SCut; 82 double z_Redshift=0.7 ; // 21 cm at z=0.7 -> 0.357 m 85 double z_Redshift=1.0 ; // z=0.7 : 21 cm at z=0.7 -> 0.357 m 86 double comov_dA_z=3330.; // Comoving radial distance = (1+z)dA 87 double H_z=120.5; // Hubble_param(z) 88 int box3dsz[3]={512,512,256}; 89 double cellsz[3]={3.5,3.5,3.5}; 90 83 91 int prtlev=0; 84 92 int prtmod=10; … … 101 109 } 102 110 else if (strcmp(arg[ka],"-z")==0) { 103 z_Redshift=atof(arg[ka+1]); ka+=2; 111 sscanf(arg[ka+1],"%lg,%lg,%lg",&z_Redshift,&comov_dA_z,&H_z); ka+=2; 112 } 113 else if (strcmp(arg[ka],"-bsize")==0) { 114 sscanf(arg[ka+1],"%d,%d,%d",box3dsz,box3dsz+1,box3dsz+2); ka+=2; 115 } 116 else if (strcmp(arg[ka],"-cszmpc")==0) { 117 sscanf(arg[ka+1],"%lg,%lg,%lg",cellsz,cellsz+1,cellsz+2); ka+=2; 104 118 } 105 119 else if (strcmp(arg[ka],"-prt")==0) { … … 169 183 cout << " pknoise[2]: Instanciating object type Four3DPk " << endl; 170 184 RandomGenerator rg; 171 Four3DPk m3d(rg); 172 m3d.SetCellSize(2.*DeuxPI, 2.*DeuxPI, 2.*DeuxPI); 185 186 double dkxmpc=2.*DeuxPI; 187 double dkympc=2.*DeuxPI; 188 double dkzmpc=2.*DeuxPI; 189 double angscale=1.; 190 if (NMAX<0) { box3dsz[0]=256; box3dsz[1]=256; box3dsz[3]=128; } 191 else { 192 angscale=comov_dA_z; 193 dkxmpc = DeuxPI/(double)box3dsz[0]/cellsz[0]; 194 dkympc = DeuxPI/(double)box3dsz[1]/cellsz[1]; 195 dkzmpc = DeuxPI/(double)box3dsz[2]/cellsz[2]; 196 } 197 cout << " pknoise[2.b]: ComovDist" << comov_dA_z << " Mpc H(z)=" << H_z << " Mpc/km/s -> angscale=" << angscale << endl; 198 cout << " pknoise[2.c]: Four3DPk m3d(rg," << box3dsz[0]/2 << "," << box3dsz[1] << "," 199 << box3dsz[2] << ")" << endl; 200 Four3DPk m3d(rg,box3dsz[0]/2,box3dsz[1],box3dsz[2]); 201 cout << " pknoise[2.d]: m3d.SetCellSize(" << dkxmpc << "," << dkympc << "," << dkzmpc << endl; 202 m3d.SetCellSize(dkxmpc, dkympc, dkzmpc); 173 203 m3d.SetPrtLevel(prtlev,prtmod); 174 204 … … 176 206 if (NMAX>0) { 177 207 PkNoiseCalculator pkn(m3d, *(arep_p), SCut, NMAX, tits.c_str()); 208 double dfreq=H_z*cellsz[2]/(1+z_Redshift)/lambda/1000.; 209 double freq0=conv.getFrequency()-dfreq*box3dsz[2]/2; 210 cout << " pknoise[3.b]: Freq0=" << freq0 << " dFreq=" << dfreq << " freq(z=" << z_Redshift << ")=" 211 << conv.getFrequency() << " AngScale=" << angscale << endl; 212 pkn.SetFreqRange(freq0, dfreq); 213 pkn.SetAngScaleConversion(angscale); 178 214 pkn.SetPrtLevel(prtlev,prtmod); 179 215 HProf hpn = pkn.Compute(); 180 cout << " pknoise[3. b]: writing hpn noise profile to " << outfile << endl;216 cout << " pknoise[3.c]: writing hpn noise profile to " << outfile << endl; 181 217 po << hpn; 182 218 } … … 184 220 Histo fracmodok; 185 221 DataTable dtnoise; 186 HProf hpn = m3d.ComputeNoisePk(*(arep_p),fracmodok,dtnoise, SCut);222 HProf hpn = m3d.ComputeNoisePk(*(arep_p),fracmodok,dtnoise,angscale,SCut); 187 223 HProf h1dnoise=arep_p->GetProjNoiseLevel(); 188 224 HProf h1drep=arep_p->GetProjResponse(); -
trunk/Cosmo/RadioBeam/specpk.cc
r3947 r4026 6 6 7 7 #include "specpk.h" 8 #include "radutil.h" 8 9 #include "randr48.h" 9 10 #include "ctimer.h" … … 162 163 } 163 164 165 164 166 // Generate mass field Fourier Coefficient 165 void Four3DPk::ComputeNoiseFourierAmp(Four2DResponse& resp, bool crmask) 167 void Four3DPk::ComputeNoiseFourierAmp(Four2DResponse& resp, double angscale, bool crmask) 168 // angscale is a multiplicative factor converting transverse k (wave number) values to angular wave numbers 169 // typically = ComovRadialDistance 166 170 { 167 171 TMatrix<r_4> mask(fourAmp.SizeY(), fourAmp.SizeX()); … … 176 180 for(sa_size_t kx=0; kx<fourAmp.SizeX(); kx++) { 177 181 kxx=(double)kx*dkx_; 178 rep = resp(kxx , kyy);182 rep = resp(kxx*angscale, kyy*angscale); 179 183 if (crmask&&(kz==0)) mask(ky,kx)=((rep<1.e-8)?9.e9:(1./rep)); 180 184 if (rep<1.e-8) fourAmp(kx, ky, kz) = complex<TF>(9.e9,0.); … … 193 197 if (prtlev_>0) 194 198 cout << " Four3DPk::ComputeNoiseFourierAmp() done ..." << endl; 199 } 200 201 // Generate mass field Fourier Coefficient 202 void Four3DPk::ComputeNoiseFourierAmp(Four2DResponse& resp, double f0, double df, double angscale) 203 // angscale is a multiplicative factor converting transverse k (wave number) values to angular wave numbers 204 // typically = ComovRadialDistance 205 { 206 H21Conversions conv; 207 // fourAmp represent 3-D fourier transform of a real input array. 208 // The second half of the array along Y and Z contain negative frequencies 209 double kxx, kyy, kzz, rep, amp; 210 // sa_size_t is large integer type 211 for(sa_size_t kz=0; kz<fourAmp.SizeZ(); kz++) { 212 conv.setFrequency(f0+kz*df); 213 resp.setLambda(conv.getLambda()); 214 for(sa_size_t ky=0; ky<fourAmp.SizeY(); ky++) { 215 kyy = (ky>fourAmp.SizeY()/2) ? -(double)(fourAmp.SizeY()-ky)*dky_ : (double)ky*dky_; 216 for(sa_size_t kx=0; kx<fourAmp.SizeX(); kx++) { 217 kxx=(double)kx*dkx_; 218 rep = resp(kxx*angscale, kyy*angscale); 219 if (rep<1.e-8) fourAmp(kx, ky, kz) = complex<TF>(9.e9,0.); 220 else { 221 amp = 1./sqrt(rep)/sqrt(2.); 222 fourAmp(kx, ky, kz) = complex<TF>(rg_.Gaussian(amp), rg_.Gaussian(amp)); 223 } 224 } 225 } 226 } 227 228 if (prtlev_>1) 229 cout << " Four3DPk::ComputeNoiseFourierAmp(...) Computing FFT along frequency ..." << endl; 230 TVector< complex<TF> > veczin(fourAmp.SizeZ()), veczout(fourAmp.SizeZ()); 231 FFTWServer ffts(true); 232 ffts.setNormalize(true); 233 234 for(sa_size_t ky=0; ky<fourAmp.SizeY(); ky++) { 235 for(sa_size_t kx=0; kx<fourAmp.SizeX(); kx++) { 236 // veczin=fourAmp(Range(kx), Range(ky), Range::all()); 237 for(sa_size_t kz=0; kz<fourAmp.SizeZ(); kz++) veczin(kz)=fourAmp(kx,ky,kz); 238 ffts.FFTBackward(veczin,veczout); 239 veczout /= (TF)sqrt((double)fourAmp.SizeZ()); 240 // fourAmp(Range(kx), Range(ky), Range::all())=veczout; 241 for(sa_size_t kz=0; kz<fourAmp.SizeZ(); kz++) fourAmp(kx,ky,kz)=veczout(kz); 242 } 243 } 244 245 if (prtlev_>2) fourAmp.Show(); 246 if (prtlev_>0) 247 cout << " Four3DPk::ComputeNoiseFourierAmp(Four2DResponse& resp, double f0, double df) done ..." << endl; 195 248 } 196 249 … … 270 323 // cells with amp^2=re^2+im^2>s2cut are ignored 271 324 // Output : noise power spectrum (profile histogram) 325 // angscale is a multiplicative factor converting transverse k (wave number) values to angular wave numbers 326 // typically = ComovRadialDistance 272 327 HProf Four3DPk::ComputeNoisePk(Four2DResponse& resp, Histo& fracmodok, DataTable& dt, 273 double s2cut, int nbin, double kmin, double kmax)328 double angscale, double s2cut, int nbin, double kmin, double kmax) 274 329 { 275 330 // The second half of the array along Y (matrix rows) contain … … 305 360 double kxx=(double)kx*dkx_; 306 361 double wk = sqrt(kxx*kxx+kyy*kyy+kzz*kzz); 307 double amp2 = 1./resp(kxx, kyy); 362 double rep=resp(kxx*angscale, kyy*angscale); 363 double amp2 = (rep>1.e-19)?1./rep:1.e19; 308 364 hmcnt.Add(wk); 309 365 if ((s2cut>1.e-9)&&(amp2>s2cut)) continue; … … 349 405 : pkn3d(pk3), frep(rep), S2CUT(s2cut), NGEN(ngen), title(tit) 350 406 { 407 SetFreqRange(); 408 SetAngScaleConversion(); 351 409 SetPrtLevel(); 352 410 } … … 357 415 tm.Nop(); 358 416 HProf hnd; 359 cout << "PkNoiseCalculator::Compute() " << title << " NGEN=" << NGEN << " S2CUT=" << S2CUT << endl; 417 cout << "PkNoiseCalculator::Compute() " << title << " NGEN=" << NGEN << " S2CUT=" << S2CUT 418 << " Freq0=" << freq0_ << " dFreq=" << dfreq_ << " angscale=" << angscale_ << endl; 360 419 for(int igen=0; igen<NGEN; igen++) { 361 pkn3d.ComputeNoiseFourierAmp(frep );420 pkn3d.ComputeNoiseFourierAmp(frep, freq0_, dfreq_, angscale_); 362 421 if (igen==0) hnd = pkn3d.ComputePk(S2CUT); 363 422 else pkn3d.ComputePkCumul(hnd,S2CUT); -
trunk/Cosmo/RadioBeam/specpk.h
r3947 r4026 51 51 { int olev=prtlev_; prtlev_=lev; prtmodulo_=prtmod; return olev; } 52 52 void ComputeFourierAmp(SpectralShape& pk); 53 void ComputeNoiseFourierAmp(Four2DResponse& resp, bool crmask=false); 53 // angscale is a multiplicative factor converting transverse k (wave number) values to angular wave numbers 54 // typically = ComovRadialDistance 55 void ComputeNoiseFourierAmp(Four2DResponse& resp, double angscale=1., bool crmask=false); 56 void ComputeNoiseFourierAmp(Four2DResponse& resp, double f0, double df, double angscale=1.); 57 54 58 // Return the array size 55 59 inline sa_size_t NCells() { return fourAmp.Size(); } … … 65 69 void ComputePkCumul(HProf& hp, double s2cut=0.); 66 70 67 HProf ComputeNoisePk(Four2DResponse& resp, Histo& fracmodok, DataTable& dt, 71 // angscale is a multiplicative factor converting transverse k (wave number) values to angular wave numbers 72 // typically = ComovRadialDistance 73 HProf ComputeNoisePk(Four2DResponse& resp, Histo& fracmodok, DataTable& dt, double angscale=1., 68 74 double s2cut=0., int nbin=256, double kmin=0., double kmax=-1.); 69 75 … … 85 91 PkNoiseCalculator(Four3DPk& pk3, Four2DResponse& rep, double s2cut=100., int ngen=1, const char* tit="PkNoise"); 86 92 93 inline void SetFreqRange(double freq0=835.,double dfreq=0.5) 94 { freq0_=freq0; dfreq_=dfreq; } 95 inline void SetAngScaleConversion(double angscale=1.) 96 { angscale_=angscale; } 87 97 inline void SetS2Cut(double s2cut=100.) 88 98 { S2CUT=s2cut; } … … 95 105 Four3DPk& pkn3d; 96 106 Four2DResponse& frep; 107 double freq0_,dfreq_; 108 double angscale_; 97 109 double S2CUT; 98 110 int NGEN;
Note:
See TracChangeset
for help on using the changeset viewer.