Changeset 4027 in Sophya for trunk/Cosmo/RadioBeam/pknoise.cc
- Timestamp:
- Oct 17, 2011, 10:56:41 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/RadioBeam/pknoise.cc
r4026 r4027 6 6 7 7 Usage: pknoise pknoise [-parname value] Diameter/Four2DRespTableFile OutPPFName 8 -parname : -noise , -renmax , -scut , -ngen , -z , -bsize , -cszmpc ,-prt8 -parname : -noise , -renmax, -scut, -ngen, -z, -bsize, -cszmpc, -nbin -prt 9 9 --------------------------------------------------------------- */ 10 10 … … 30 30 #include "timing.h" 31 31 #include "ctimer.h" 32 #include "slininterp.h" 32 33 33 34 typedef DR48RandGen RandomGenerator ; … … 47 48 << " NGen=-1 -> Call ComputeNoisePk(), dont change Four3DPk cell size \n" 48 49 << " -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=3x3x 3) \n"50 << " -z z,dA,H_z : redshift,ComovDist(z),H(z) (default=1.0,3330,120.5) \n"50 << " -cszmpc sx,sy,sz : 3D real space box cell size in Mpc (default=3x3x1.5) \n" 51 << " -z redshift : redshift (default=1.0) \n" 51 52 << " -scut SCutValue (default= -100.) \n" 52 53 << " if SCutValue<0. ==> SCut=MinNoisePower*(-SCutValue) \n" 53 << " -prt PrtLev,PrtModulo (default=0,10) " << endl; 54 << " -prt PrtLev,PrtModulo (default=0,10) \n" 55 << " -nbin PkNBin : nomber of histogram bins for Pnoise(k) (default= 256) \n" 56 << " NOTE : this program needs redshift_da.txt andredshift_Hz.txt files" << endl; 54 57 return; 55 58 } … … 87 90 double H_z=120.5; // Hubble_param(z) 88 91 int box3dsz[3]={512,512,256}; 89 double cellsz[3]={3. 5,3.5,3.5};90 92 double cellsz[3]={3.,3.,1.5}; 93 int NBINPK=256; 91 94 int prtlev=0; 92 95 int prtmod=10; … … 109 112 } 110 113 else if (strcmp(arg[ka],"-z")==0) { 111 sscanf(arg[ka+1],"%lg,%lg,%lg",&z_Redshift,&comov_dA_z,&H_z); ka+=2;114 z_Redshift=atof(arg[ka+1]); ka+=2; 112 115 } 113 116 else if (strcmp(arg[ka],"-bsize")==0) { … … 116 119 else if (strcmp(arg[ka],"-cszmpc")==0) { 117 120 sscanf(arg[ka+1],"%lg,%lg,%lg",cellsz,cellsz+1,cellsz+2); ka+=2; 121 } 122 else if (strcmp(arg[ka],"-nbin")==0) { 123 NBINPK=atoi(arg[ka+1]); ka+=2; 118 124 } 119 125 else if (strcmp(arg[ka],"-prt")==0) { … … 147 153 cout << " pknoise[0] : Executing, output file= " << outfile << endl; 148 154 POutPersist po(outfile); 155 156 cout << " pknoise[0.b] : Creating interpolating objects from redshift_da.txt and redshift_Hz.txt " << endl; 157 SLinInterp1D redshift2da; 158 string interpfilename="redshift_da.txt"; 159 redshift2da.ReadXYFromFile(interpfilename); 160 SLinInterp1D redshift2hz; 161 interpfilename="redshift_hz.txt"; 162 redshift2hz.ReadXYFromFile(interpfilename); 163 comov_dA_z=redshift2da(z_Redshift); 164 H_z=redshift2hz(z_Redshift); 165 cout << " Redshift= " << z_Redshift << " -> ComovdA= " << comov_dA_z 166 << " Mpc H(z)= " << H_z << " km/s/Mpc " << endl; 149 167 150 168 H21Conversions conv; … … 184 202 RandomGenerator rg; 185 203 204 double dfreq=H_z*cellsz[2]/(1+z_Redshift)/lambda/1000.; 205 double freq0=conv.getFrequency()-dfreq*box3dsz[2]/2; 206 186 207 double dkxmpc=2.*DeuxPI; 187 208 double dkympc=2.*DeuxPI; 188 209 double dkzmpc=2.*DeuxPI; 189 210 double angscale=1.; 211 Vector angscales(box3dsz[2]); 212 angscales=angscale; 190 213 if (NMAX<0) { box3dsz[0]=256; box3dsz[1]=256; box3dsz[3]=128; } 191 214 else { 192 215 angscale=comov_dA_z; 216 for(int kz=0; kz<box3dsz[2]; kz++) angscales(kz)=redshift2da(1420.4/(freq0+(double)kz*dfreq)-1.); 193 217 dkxmpc = DeuxPI/(double)box3dsz[0]/cellsz[0]; 194 218 dkympc = DeuxPI/(double)box3dsz[1]/cellsz[1]; 195 219 dkzmpc = DeuxPI/(double)box3dsz[2]/cellsz[2]; 196 220 } 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] << "," 221 cout << " pknoise[2.b]: ComovDist=" << comov_dA_z << " Mpc H(z)=" << H_z << " Mpc/km/s -> angscale=" << angscale << endl; 222 cout << " pknoise[2.c]: Freq0=" << freq0 << " dFreq=" << dfreq << " freq(z=" << z_Redshift << ")=" 223 << conv.getFrequency() << " zmin=" << 1420.4/freq0-1. << " zmax=" << 1420.4/(freq0+box3dsz[2]*dfreq)-1. << endl; 224 cout << " pknoise[2.d]: Four3DPk m3d(rg," << box3dsz[0]/2 << "," << box3dsz[1] << "," 199 225 << box3dsz[2] << ")" << endl; 200 226 Four3DPk m3d(rg,box3dsz[0]/2,box3dsz[1],box3dsz[2]); … … 203 229 m3d.SetPrtLevel(prtlev,prtmod); 204 230 205 cout << " pknoise[3]: Computing Noise P(k) using PkNoiseCalculator ..." << endl;206 231 if (NMAX>0) { 232 cout << " pknoise[3]: Computing Noise P(k) using PkNoiseCalculator ..." << endl; 207 233 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 234 pkn.SetFreqRange(freq0, dfreq); 213 pkn.SetAngScaleConversion(angscale );235 pkn.SetAngScaleConversion(angscales); 214 236 pkn.SetPrtLevel(prtlev,prtmod); 215 HProf hpn = pkn.Compute(); 216 cout << " pknoise[3.c]: writing hpn noise profile to " << outfile << endl; 217 po << hpn; 237 HProf hpn = pkn.Compute(NBINPK); 218 238 } 219 239 else { 220 Histo fracmodok; 221 DataTable dtnoise; 222 HProf hpn = m3d.ComputeNoisePk(*(arep_p),fracmodok,dtnoise,angscale,SCut); 223 HProf h1dnoise=arep_p->GetProjNoiseLevel(); 224 HProf h1drep=arep_p->GetProjResponse(); 225 cout << " pknoise[3.b]: writing dtnoise,hpn,h2rep... with tags to " << outfile << endl; 226 po << PPFNameTag("dtnoise") << dtnoise; 227 po << PPFNameTag("hpnoise") << hpn; 228 po << PPFNameTag("fracmodok") << fracmodok; 229 po << PPFNameTag("h1dnoise") << h1dnoise; 230 po << PPFNameTag("h1drep") << h1drep; 231 po << PPFNameTag("h2drep") << h2drep; 232 } 240 cout << " pknoise[3]: Computing Noise P(k) m3d.ComputeNoisePk(...) " << endl; 241 HProf hpn = m3d.ComputeNoisePk(*(arep_p),angscale,SCut,NBINPK); 242 } 243 244 HProf hpnoise=m3d.GetPk(); 245 DataTable dtnoise; 246 Histo fracmodok=m3d.FillPkDataTable(dtnoise); 247 HProf h1dnoise=arep_p->GetProjNoiseLevel(); 248 HProf h1drep=arep_p->GetProjResponse(); 249 cout << " pknoise[3.b]: writing dtnoise,hpn,h2rep... with tags to " << outfile << endl; 250 po << PPFNameTag("dtnoise") << dtnoise; 251 po << PPFNameTag("hpnoise") << hpnoise; 252 po << PPFNameTag("fracmodok") << fracmodok; 253 po << PPFNameTag("h1dnoise") << h1dnoise; 254 po << PPFNameTag("h1drep") << h1drep; 255 po << PPFNameTag("h2drep") << h2drep; 256 233 257 rc = 0; 234 258 } // End of try bloc
Note:
See TracChangeset
for help on using the changeset viewer.