Changeset 4026 in Sophya for trunk/Cosmo/RadioBeam/specpk.cc
- Timestamp:
- Oct 10, 2011, 11:31:03 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.