[3115] | 1 | #include "sopnamsp.h"
|
---|
| 2 | #include "machdefs.h"
|
---|
| 3 | #include <iostream>
|
---|
| 4 | #include <stdlib.h>
|
---|
| 5 | #include <stdio.h>
|
---|
| 6 | #include <string.h>
|
---|
| 7 | #include <math.h>
|
---|
| 8 | #include <unistd.h>
|
---|
| 9 | #include "timing.h"
|
---|
| 10 | #include "ntuple.h"
|
---|
| 11 | #include "matharr.h"
|
---|
| 12 |
|
---|
| 13 | #include "constcosmo.h"
|
---|
[3157] | 14 | #include "cosmocalc.h"
|
---|
[3115] | 15 | #include "schechter.h"
|
---|
| 16 | #include "geneutils.h"
|
---|
| 17 | #include "genefluct3d.h"
|
---|
| 18 |
|
---|
| 19 | void usage(void);
|
---|
| 20 | void usage(void)
|
---|
| 21 | {
|
---|
[3182] | 22 | cout<<"cmvobserv3d [...options...]"<<endl
|
---|
[3200] | 23 | <<" -a : auto init random seed (needed for multiple simul)"<<endl
|
---|
| 24 | <<" -0 : use ComputeFourier0 method (defaut: no, use normal way)"<<endl
|
---|
[3157] | 25 | <<" -G : compute Pk(z=0) and apply growth factor in real space"<<endl
|
---|
[3200] | 26 | <<" (default: no, spectrum Pk(z=z_median) for all cube)"<<endl
|
---|
[3289] | 27 | <<" -F : filter spectrum by pixel shape (0=no 1=yes(default)"<<endl
|
---|
[3200] | 28 | <<" -x nx,dx : size along x axis (npix,Mpc)"<<endl
|
---|
| 29 | <<" -y ny,dy : size along y axis (npix,Mpc)"<<endl
|
---|
| 30 | <<" if ny or dy <=0 take same value as for x"<<endl
|
---|
| 31 | <<" -z nz,dz : size along z axis (redshift axis, npix,Mpc)"<<endl
|
---|
| 32 | <<" -Z zref : redshift for the center of the simulation cube"<<endl
|
---|
[3271] | 33 | <<" -s snoise,evol : gaussian noise sigma in equivalent Msol"<<endl
|
---|
| 34 | <<" if evol>0 noise evolved with distance (def no)"<<endl
|
---|
[3200] | 35 | <<" -2 : compute also 2D spectrum (default: no)"<<endl
|
---|
[3322] | 36 | <<" -N scalecube,offsetcube: normalize cube before doing final spectrum (default: automatic)"<<endl
|
---|
[3193] | 37 | <<" -M schmin,schmax,nsch : min,max mass and nb points for schechter HI"<<endl
|
---|
[3322] | 38 | <<" If nsch<0 alors no,bre de points par decade"<<endl
|
---|
| 39 | <<" -Q naleagal : use quick method for turning ngal to mass"<<endl
|
---|
| 40 | <<" -R schmassdist.ppf : read mass distribution for trials from file"<<endl
|
---|
| 41 | <<" instead of computing it (ONLY if \"-Q\" option is activated)"<<endl
|
---|
[3200] | 42 | <<" -A <log10(S_agn in Jy at 1.4 GHz)>,sigma,powlaw :"<<endl
|
---|
| 43 | <<" AGN mean and sigma gaussian equiv. distrib. for solid angle of centeral pixel"<<endl
|
---|
| 44 | <<" powlaw: apply S_agn evolution as (Nu/1.4)^powlaw"<<endl
|
---|
| 45 | <<" -W : write cube in FITS format (complex cube is coded as real cube)"<<endl
|
---|
[3154] | 46 | <<" -P : write cube in PPF format"<<endl
|
---|
[3281] | 47 | <<" -S : write cube slices in PPF format"<<endl
|
---|
[3200] | 48 | <<" -V : compute variance from real space (for check, default: no)"<<endl
|
---|
[3281] | 49 | <<" -T nth : nombre de threads (si compil multi-thread, default: 0)"<<endl
|
---|
[3115] | 50 | <<endl;
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | int main(int narg,char *arg[])
|
---|
| 54 | {
|
---|
| 55 | InitTim();
|
---|
| 56 |
|
---|
| 57 | //-----------------------------------------------------------------
|
---|
| 58 | // *** Survey definition
|
---|
[3129] | 59 | long nx=360, ny=-1, nz=64; double dx=1., dy=-1., dz=-1.;
|
---|
| 60 | //long nx=1000, ny=-1, nz=128; double dx=3., dy=-1., dz=6.;
|
---|
| 61 | //long nx=1200, ny=-1, nz=128; double dx=1., dy=-1., dz=3;
|
---|
[3115] | 62 |
|
---|
| 63 | // *** Cosmography definition (WMAP)
|
---|
[3157] | 64 | unsigned short flat = 0;
|
---|
[3115] | 65 | double ob0 = 0.0444356;
|
---|
| 66 | double h100=0.71, om0=0.267804, or0=7.9e-05, ol0=0.73,w0=-1.;
|
---|
| 67 | double zref = 0.5;
|
---|
[3285] | 68 | double perc=0.01,dzinc=-1.,dzmax=-1.; unsigned short glorder=4;
|
---|
[3115] | 69 |
|
---|
| 70 | // *** Spectrum and variance definition
|
---|
| 71 | double ns = 1., as = 1.;
|
---|
| 72 | double R=8./h100, Rg=R/sqrt(5.);
|
---|
| 73 | double sigmaR = 1.;
|
---|
| 74 |
|
---|
| 75 | double kmin=1e-5,kmax=1000.;
|
---|
| 76 | int npt = 10000;
|
---|
| 77 | double lkmin=log10(kmin), lkmax=log10(kmax);
|
---|
| 78 | double eps=1.e-3;
|
---|
| 79 |
|
---|
| 80 | // *** Schechter mass function definition
|
---|
[3193] | 81 | double h75 = h100 / 0.75;
|
---|
| 82 | double nstar = 0.006*pow(h75,3.);
|
---|
[3115] | 83 | double mstar = pow(10.,9.8/(h75*h75)); // MSol
|
---|
| 84 | double alpha = -1.37;
|
---|
| 85 |
|
---|
[3322] | 86 | double schmin=1e8, schmax=1e13;
|
---|
| 87 | int schnpt = -100;
|
---|
| 88 | bool use_schmassdist = false;
|
---|
| 89 | long naleagal = 100000;
|
---|
| 90 | bool recompute_schmassdist = true;
|
---|
| 91 | string schmassdistfile = "";
|
---|
[3115] | 92 |
|
---|
| 93 | // *** Niveau de bruit
|
---|
| 94 | double snoise= 0.; // en equivalent MSol
|
---|
[3271] | 95 | int isnoise_evol = 0;
|
---|
[3115] | 96 |
|
---|
[3196] | 97 | // *** AGN
|
---|
| 98 | bool do_agn = false;
|
---|
[3199] | 99 | double lfjy_agn=-99., lsigma_agn=0.; // en Jy
|
---|
| 100 | double powlaw_agn = 0.;
|
---|
[3196] | 101 |
|
---|
[3115] | 102 | // *** type de generation
|
---|
| 103 | bool computefourier0=false;
|
---|
[3157] | 104 | bool use_growth_factor = false;
|
---|
[3281] | 105 | unsigned short nthread=0;
|
---|
[3289] | 106 | int filter_by_pixel = 1;
|
---|
[3115] | 107 |
|
---|
[3154] | 108 | // *** What to do
|
---|
| 109 | bool comp2dspec = false;
|
---|
| 110 | bool wfits = false;
|
---|
| 111 | bool wppf = false;
|
---|
[3281] | 112 | bool wslice = false;
|
---|
[3154] | 113 | bool compvarreal = false;
|
---|
[3322] | 114 | double scalecube = -1., offsetcube = 0.;
|
---|
[3154] | 115 |
|
---|
[3115] | 116 | // --- Decodage arguments
|
---|
[3262] | 117 | if(narg>0) {
|
---|
[3322] | 118 | cout<<"\n--- Arguments: "<<endl;
|
---|
[3262] | 119 | for(int i=0;i<narg;i++) cout<<arg[i]<<" ";
|
---|
| 120 | cout<<endl;
|
---|
| 121 | }
|
---|
[3115] | 122 |
|
---|
| 123 | char c;
|
---|
[3322] | 124 | while((c = getopt(narg,arg,"ha0PWSV2GF:x:y:z:s:Z:M:A:T:N:Q:R:")) != -1) {
|
---|
[3281] | 125 | int nth = 0;
|
---|
[3115] | 126 | switch (c) {
|
---|
| 127 | case 'a' :
|
---|
| 128 | Auto_Ini_Ranf(5);
|
---|
| 129 | break;
|
---|
| 130 | case '0' :
|
---|
| 131 | computefourier0 = true;
|
---|
| 132 | break;
|
---|
[3157] | 133 | case 'G' :
|
---|
| 134 | use_growth_factor = true;
|
---|
| 135 | break;
|
---|
[3289] | 136 | case 'F' :
|
---|
| 137 | sscanf(optarg,"%d",&filter_by_pixel);
|
---|
| 138 | break;
|
---|
[3115] | 139 | case 'x' :
|
---|
[3129] | 140 | sscanf(optarg,"%ld,%lf",&nx,&dx);
|
---|
[3115] | 141 | break;
|
---|
| 142 | case 'y' :
|
---|
[3129] | 143 | sscanf(optarg,"%ld,%lf",&ny,&dy);
|
---|
[3115] | 144 | break;
|
---|
| 145 | case 'z' :
|
---|
[3129] | 146 | sscanf(optarg,"%ld,%lf",&nz,&dz);
|
---|
[3115] | 147 | break;
|
---|
| 148 | case 's' :
|
---|
[3271] | 149 | sscanf(optarg,"%lf,%d",&snoise,&isnoise_evol);
|
---|
[3115] | 150 | break;
|
---|
| 151 | case 'Z' :
|
---|
| 152 | sscanf(optarg,"%lf",&zref);
|
---|
| 153 | break;
|
---|
[3154] | 154 | case '2' :
|
---|
| 155 | comp2dspec = true;
|
---|
| 156 | break;
|
---|
[3322] | 157 | case 'N' :
|
---|
| 158 | sscanf(optarg,"%lf,%lf",&scalecube,&offsetcube);
|
---|
| 159 | break;
|
---|
[3193] | 160 | case 'M' :
|
---|
| 161 | sscanf(optarg,"%lf,%lf,%d",&schmin,&schmax,&schnpt);
|
---|
| 162 | break;
|
---|
[3322] | 163 | case 'Q' :
|
---|
| 164 | use_schmassdist = true;
|
---|
| 165 | sscanf(optarg,"%ld",&naleagal);
|
---|
| 166 | break;
|
---|
| 167 | case 'R' :
|
---|
| 168 | schmassdistfile = optarg;
|
---|
| 169 | break;
|
---|
[3196] | 170 | case 'A' :
|
---|
| 171 | do_agn = true;
|
---|
[3199] | 172 | sscanf(optarg,"%lf,%lf,%lf",&lfjy_agn,&lsigma_agn,&powlaw_agn);
|
---|
[3196] | 173 | break;
|
---|
[3154] | 174 | case 'V' :
|
---|
| 175 | compvarreal = true;
|
---|
| 176 | break;
|
---|
| 177 | case 'W' :
|
---|
| 178 | wfits = true;
|
---|
| 179 | break;
|
---|
| 180 | case 'P' :
|
---|
| 181 | wppf = true;
|
---|
| 182 | break;
|
---|
[3281] | 183 | case 'S' :
|
---|
| 184 | wslice = true;
|
---|
| 185 | break;
|
---|
| 186 | case 'T' :
|
---|
| 187 | sscanf(optarg,"%d",&nth);
|
---|
| 188 | nthread = (nth<1)? 0: nth;
|
---|
| 189 | break;
|
---|
[3115] | 190 | case 'h' :
|
---|
| 191 | default :
|
---|
| 192 | usage(); return -1;
|
---|
| 193 | }
|
---|
| 194 | }
|
---|
| 195 |
|
---|
[3322] | 196 | double lschmin=log10(schmin), lschmax=log10(schmax);
|
---|
| 197 | if(schnpt<=0) { // alors c'est un nombre de points par decade
|
---|
| 198 | schnpt = long( (-schnpt)*(lschmax-lschmin+1.) + 0.5 );
|
---|
| 199 | if(schnpt<=2) schnpt = 1000;
|
---|
| 200 | }
|
---|
| 201 | if(naleagal<=2) naleagal = 100000;
|
---|
[3193] | 202 |
|
---|
[3115] | 203 | cout<<"zref="<<zref<<endl;
|
---|
| 204 | cout<<"nx="<<nx<<" dx="<<dx<<" ny="<<ny<<" dy="<<dy<<" nz="<<nz<<" dz="<<dz<<endl;
|
---|
| 205 | cout<<"kmin="<<kmin<<" ("<<lkmin<<"), kmax="<<kmax<<" ("<<lkmax<<") Mpc^-1"
|
---|
| 206 | <<", npt="<<npt<<endl;
|
---|
[3289] | 207 | cout<<"Filter by pixel = "<<filter_by_pixel<<endl;
|
---|
[3115] | 208 | cout<<"R="<<R<<" Rg="<<Rg<<" Mpc, sigmaR="<<sigmaR<<endl;
|
---|
[3246] | 209 | cout<<"nstar= "<<nstar<<" mstar="<<mstar<<" alpha="<<alpha<<endl;
|
---|
[3115] | 210 | cout<<"schmin="<<schmin<<" ("<<lschmin
|
---|
| 211 | <<"), schmax="<<schmax<<" ("<<lschmax<<") Msol"
|
---|
| 212 | <<", schnpt="<<schnpt<<endl;
|
---|
[3271] | 213 | cout<<"snoise="<<snoise<<" equivalent Msol, evolution="<<isnoise_evol<<endl;
|
---|
[3322] | 214 | cout<<"scalecube="<<scalecube<<", offsetcube="<<offsetcube<<endl;
|
---|
[3199] | 215 | if(do_agn)
|
---|
| 216 | cout<<"AGN: <log10(Jy)>="<<lfjy_agn<<" , sigma="<<lsigma_agn
|
---|
| 217 | <<" , powlaw="<<powlaw_agn<<endl;
|
---|
[3115] | 218 |
|
---|
[3322] | 219 | string tagobs = "cmvobserv3d.ppf";
|
---|
| 220 | POutPersist posobs(tagobs);
|
---|
| 221 |
|
---|
[3115] | 222 | //-----------------------------------------------------------------
|
---|
[3157] | 223 | cout<<endl<<"\n--- Create Cosmology"<<endl;
|
---|
[3115] | 224 |
|
---|
[3157] | 225 | CosmoCalc univ(flat,true,zref+1.);
|
---|
| 226 | univ.SetInteg(perc,dzinc,dzmax,glorder);
|
---|
| 227 | univ.SetDynParam(h100,om0,or0,ol0,w0);
|
---|
[3285] | 228 | univ.PrtInteg();
|
---|
[3157] | 229 | univ.Print();
|
---|
| 230 | double loscomref = univ.Dloscom(zref);
|
---|
[3193] | 231 | cout<<"\nzref = "<<zref<<" -> dloscom = "<<loscomref<<" Mpc"<<endl;
|
---|
| 232 | univ.Print(zref);
|
---|
[3157] | 233 |
|
---|
| 234 | //-----------------------------------------------------------------
|
---|
[3193] | 235 | cout<<endl<<"\n--- Create Spectrum"<<endl;
|
---|
[3157] | 236 |
|
---|
[3115] | 237 | InitialSpectrum pkini(ns,as);
|
---|
| 238 |
|
---|
| 239 | TransfertEisenstein tf(h100,om0-ob0,ob0,T_CMB_Par,false);
|
---|
| 240 | //tf.SetNoOscEnv(2);
|
---|
| 241 |
|
---|
[3157] | 242 | GrowthFactor growth(om0,ol0);
|
---|
[3193] | 243 | // GrowthFactor growth(1.,0.); // D(z) = 1/(1+z)
|
---|
[3283] | 244 | double growth_at_z = growth(zref);
|
---|
| 245 | cout<<"...Growth factor at z="<<zref<<" = "<<growth_at_z<<endl;
|
---|
[3115] | 246 |
|
---|
| 247 | PkSpectrum0 pk0(pkini,tf);
|
---|
| 248 |
|
---|
[3157] | 249 | PkSpectrumZ pkz(pk0,growth,zref);
|
---|
[3193] | 250 |
|
---|
[3115] | 251 | //-----------------------------------------------------------------
|
---|
| 252 | pkz.SetZ(0.);
|
---|
| 253 | cout<<endl<<"\n--- Compute variance for top-hat R="<<R
|
---|
| 254 | <<" at z="<<pkz.GetZ()<<endl;
|
---|
| 255 | VarianceSpectrum varpk_th(pkz,0);
|
---|
| 256 | double kfind_th = varpk_th.FindMaximum(R,kmin,kmax,eps);
|
---|
| 257 | double pkmax_th = varpk_th(kfind_th);
|
---|
| 258 | cout<<"kfind_th = "<<kfind_th<<" ("<<log10(kfind_th)<<"), integrand="<<pkmax_th<<endl;
|
---|
| 259 | double k1=kmin, k2=kmax;
|
---|
| 260 | int rc = varpk_th.FindLimits(R,pkmax_th/1.e4,k1,k2,eps);
|
---|
| 261 | cout<<"limit_th: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "
|
---|
| 262 | <<k2<<" ("<<log10(k2)<<")"<<endl;
|
---|
| 263 |
|
---|
| 264 | double ldlk = (log10(k2)-log10(k1))/npt;
|
---|
| 265 | varpk_th.SetInteg(0.01,ldlk,-1.,4);
|
---|
| 266 | double sr2 = varpk_th.Variance(R,k1,k2);
|
---|
| 267 | cout<<"varpk_th="<<sr2<<" -> sigma="<<sqrt(sr2)<<endl;
|
---|
| 268 |
|
---|
| 269 | double normpkz = sigmaR*sigmaR/sr2;
|
---|
| 270 | pkz.SetScale(normpkz);
|
---|
| 271 | cout<<"Spectrum normalisation = "<<pkz.GetScale()<<endl;
|
---|
| 272 |
|
---|
| 273 | pkz.SetZ(zref);
|
---|
| 274 |
|
---|
[3120] | 275 | Histo hpkz(lkmin,lkmax,npt); hpkz.ReCenterBin();
|
---|
[3115] | 276 | FuncToHisto(pkz,hpkz,true);
|
---|
| 277 | {
|
---|
| 278 | tagobs = "hpkz"; posobs.PutObject(hpkz,tagobs);
|
---|
| 279 | }
|
---|
| 280 |
|
---|
| 281 | //-----------------------------------------------------------------
|
---|
| 282 | cout<<endl<<"\n--- Compute variance for Pk at z="<<pkz.GetZ()<<endl;
|
---|
| 283 | VarianceSpectrum varpk_int(pkz,2);
|
---|
| 284 |
|
---|
| 285 | double kfind_int = varpk_int.FindMaximum(R,kmin,kmax,eps);
|
---|
| 286 | double pkmax_int = varpk_int(kfind_int);
|
---|
| 287 | cout<<"kfind_int = "<<kfind_int<<" ("<<log10(kfind_int)<<"), integrand="<<pkmax_int<<endl;
|
---|
| 288 | double k1int=kmin, k2int=kmax;
|
---|
| 289 | int rcint = varpk_int.FindLimits(R,pkmax_int/1.e4,k1int,k2int,eps);
|
---|
| 290 | cout<<"limit_int: rc="<<rcint<<" : "<<k1int<<" ("<<log10(k1int)<<") , "
|
---|
| 291 | <<k2int<<" ("<<log10(k2int)<<")"<<endl;
|
---|
| 292 |
|
---|
| 293 | double ldlkint = (log10(k2int)-log10(k1int))/npt;
|
---|
| 294 | varpk_int.SetInteg(0.01,ldlkint,-1.,4);
|
---|
| 295 | double sr2int = varpk_int.Variance(R,k1int,k2int);
|
---|
| 296 | cout<<"varpk_int="<<sr2int<<" -> sigma="<<sqrt(sr2int)<<endl;
|
---|
[3322] | 297 |
|
---|
[3115] | 298 | //-----------------------------------------------------------------
|
---|
[3322] | 299 | cout<<endl<<"\n--- Create mass function, compute number/mass density, init mass trials"<<endl;
|
---|
[3115] | 300 |
|
---|
[3322] | 301 | Schechter sch(nstar,mstar,alpha);
|
---|
| 302 | sch.Print();
|
---|
| 303 |
|
---|
[3115] | 304 | sch.SetOutValue(0);
|
---|
| 305 | cout<<"sch(mstar) = "<<sch(mstar)<<" /Mpc^3/Msol"<<endl;
|
---|
[3322] | 306 | double ngal_by_mpc3 = sch.Integrate(schmin,schmax,schnpt);
|
---|
[3115] | 307 | cout<<"Galaxy density number = "<<ngal_by_mpc3<<" /Mpc^3 between limits"<<endl;
|
---|
| 308 |
|
---|
| 309 | sch.SetOutValue(1);
|
---|
| 310 | cout<<"mstar*sch(mstar) = "<<sch(mstar)<<" Msol/Mpc^3/Msol"<<endl;
|
---|
[3322] | 311 | double mass_by_mpc3 = sch.Integrate(schmin,schmax,schnpt);
|
---|
[3115] | 312 | cout<<"Galaxy mass density= "<<mass_by_mpc3<<" Msol/Mpc^3 between limits"<<endl;
|
---|
[3193] | 313 | cout<<"Omega_HI at z=0 is "<<mass_by_mpc3/(univ.Rhoc(0.)*GCm3toMsolMpc3_Cst)<<endl
|
---|
| 314 | <<" at z="<<zref<<" is "<<mass_by_mpc3/(univ.Rhoc(zref)*GCm3toMsolMpc3_Cst)<<endl;
|
---|
[3115] | 315 |
|
---|
[3322] | 316 | SchechterMassDist schmdist(sch,schmin,schmax,schnpt);
|
---|
| 317 | if(use_schmassdist && schmassdistfile.size()>0) {
|
---|
| 318 | cout<<"\nWARNING: SchechterMassDist read from "<<schmassdistfile<<endl
|
---|
| 319 | <<" PLEASE CHECK CONSISTENCY WITH REQUESTED PARAMETERS"<<endl;
|
---|
| 320 | schmdist.ReadPPF(schmassdistfile);
|
---|
[3323] | 321 | recompute_schmassdist = false;
|
---|
[3322] | 322 | }
|
---|
| 323 | schmdist.Print();
|
---|
| 324 | Histo hmdndm = schmdist.GetHmDnDm();
|
---|
| 325 | FunRan tirhmdndm = schmdist.GetTmDnDm();
|
---|
| 326 | {
|
---|
| 327 | tagobs = "hmdndm"; posobs.PutObject(hmdndm,tagobs);
|
---|
| 328 | Histo hdum1(tirhmdndm);
|
---|
| 329 | tagobs = "tirhmdndm"; posobs.PutObject(hdum1,tagobs);
|
---|
| 330 | }
|
---|
| 331 |
|
---|
[3155] | 332 | PrtTim(">>>> End of definition");
|
---|
| 333 |
|
---|
[3115] | 334 | //-----------------------------------------------------------------
|
---|
| 335 | // FFTW3 (p26): faster if sizes 2^a 3^b 5^c 7^d 11^e 13^f with e+f=0 ou 1
|
---|
[3155] | 336 | cout<<endl<<"\n--- Initialisation de GeneFluct3D"<<endl;
|
---|
[3115] | 337 |
|
---|
| 338 | TArray< complex<r_8> > pkgen;
|
---|
[3141] | 339 | GeneFluct3D fluct3d(pkgen);
|
---|
[3155] | 340 | fluct3d.SetPrtLevel(2);
|
---|
[3115] | 341 | fluct3d.SetNThread(nthread);
|
---|
| 342 | fluct3d.SetSize(nx,ny,nz,dx,dy,dz);
|
---|
[3267] | 343 | fluct3d.SetObservator(zref,-nz/2.);
|
---|
[3157] | 344 | fluct3d.SetCosmology(univ);
|
---|
| 345 | fluct3d.SetGrowthFactor(growth);
|
---|
[3199] | 346 | fluct3d.LosComRedshift(0.001,-1);
|
---|
[3322] | 347 | //TArray<r_8>& rgen = fluct3d.GetRealArray();
|
---|
[3157] | 348 | cout<<endl; fluct3d.Print();
|
---|
[3322] | 349 | cout<<"\nMean number of galaxies per pixel = "<<ngal_by_mpc3*fluct3d.GetDVol()<<endl;
|
---|
| 350 | cout<<"Mean mass per pixel = "<<mass_by_mpc3*fluct3d.GetDVol()<<endl;
|
---|
[3141] | 351 |
|
---|
| 352 | double dkmin = fluct3d.GetKincMin();
|
---|
[3115] | 353 | double knyqmax = fluct3d.GetKmax();
|
---|
[3141] | 354 | long nherr = long(knyqmax/dkmin+0.5);
|
---|
[3322] | 355 | cout<<"\nFor HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl;
|
---|
[3115] | 356 |
|
---|
[3141] | 357 | double dktmin = fluct3d.GetKTincMin();
|
---|
| 358 | double ktnyqmax = fluct3d.GetKTmax();
|
---|
| 359 | long nherrt = long(ktnyqmax/dktmin+0.5);
|
---|
| 360 | double dkzmin = fluct3d.GetKinc()[2];
|
---|
| 361 | double kznyqmax = fluct3d.GetKnyq()[2];
|
---|
| 362 | long nherrz = long(kznyqmax/dkzmin+0.5);
|
---|
| 363 | cout<<"For Histo2DErr: d="<<dktmin<<","<<dkzmin
|
---|
| 364 | <<" max="<<ktnyqmax<<","<<kznyqmax<<" n="<<nherrt<<","<<nherrz<<endl;
|
---|
| 365 |
|
---|
[3157] | 366 | //-----------------------------------------------------------------
|
---|
[3115] | 367 | cout<<"\n--- Computing spectra variance up to Kmax at z="<<pkz.GetZ()<<endl;
|
---|
| 368 | // En fait on travaille sur un cube inscrit dans la sphere de rayon kmax:
|
---|
| 369 | // sphere: Vs = 4Pi/3 k^3 , cube inscrit (cote k*sqrt(2)): Vc = (k*sqrt(2))^3
|
---|
| 370 | // Vc/Vs = 0.675 -> keff = kmax * (0.675)^(1/3) = kmax * 0.877
|
---|
[3141] | 371 | double knyqmax_mod = 0.877*knyqmax;
|
---|
| 372 | ldlkint = (log10(knyqmax_mod)-log10(k1int))/npt;
|
---|
[3115] | 373 | varpk_int.SetInteg(0.01,ldlkint,-1.,4);
|
---|
[3141] | 374 | double sr2int_kmax = varpk_int.Variance(R,k1int,knyqmax_mod);
|
---|
| 375 | cout<<"varpk_int(<"<<knyqmax_mod<<")="<<sr2int_kmax<<" -> sigma="<<sqrt(sr2int_kmax)<<endl;
|
---|
[3115] | 376 |
|
---|
[3155] | 377 | PrtTim(">>>> End Initialisation de GeneFluct3D");
|
---|
| 378 |
|
---|
[3157] | 379 | //-----------------------------------------------------------------
|
---|
[3115] | 380 | cout<<"\n--- Computing a realization in Fourier space"<<endl;
|
---|
[3157] | 381 | if(use_growth_factor) pkz.SetZ(0.); else pkz.SetZ(zref);
|
---|
| 382 | cout<<"Power spectrum set at redshift: "<<pkz.GetZ()<<endl;
|
---|
[3141] | 383 | if(computefourier0) fluct3d.ComputeFourier0(pkz);
|
---|
| 384 | else fluct3d.ComputeFourier(pkz);
|
---|
[3155] | 385 | PrtTim(">>>> End Computing a realization in Fourier space");
|
---|
[3115] | 386 |
|
---|
[3316] | 387 | /*
|
---|
| 388 | // CMVTEST
|
---|
| 389 | for(int l=0;l<pkgen.SizeX();l++)
|
---|
| 390 | for(int j=0;j<pkgen.SizeY();j++)
|
---|
| 391 | for(int i=0;i<pkgen.SizeZ();i++) {
|
---|
| 392 | double k2 = fluct3d.Kx(i)*fluct3d.Kx(i)
|
---|
| 393 | +fluct3d.Ky(j)*fluct3d.Ky(j)
|
---|
| 394 | +fluct3d.Kz(l)*fluct3d.Kz(l);
|
---|
| 395 | double pk = (k2>0.)? 1./k2: 0.;
|
---|
| 396 | //pkgen(l,j,i) = ComplexGaussRan(sqrt(pk/2.));
|
---|
| 397 | //pkgen(l,j,i) = sqrt(pk/2.);
|
---|
| 398 | pkgen(l,j,i) = 1.;
|
---|
| 399 | }
|
---|
| 400 | // CMVTEST
|
---|
| 401 | */
|
---|
| 402 |
|
---|
[3289] | 403 | cout<<"\n--- Checking realization spectra"<<endl;
|
---|
| 404 | HistoErr hpkgen(0.,knyqmax,nherr);
|
---|
| 405 | hpkgen.ReCenterBin(); hpkgen.Zero();
|
---|
| 406 | hpkgen.Show();
|
---|
| 407 | fluct3d.ComputeSpectrum(hpkgen);
|
---|
| 408 | {
|
---|
| 409 | tagobs = "hpkgen"; posobs.PutObject(hpkgen,tagobs);
|
---|
[3115] | 410 | }
|
---|
[3289] | 411 | PrtTim(">>>> End Checking realization spectra");
|
---|
[3115] | 412 |
|
---|
[3154] | 413 | if(comp2dspec) {
|
---|
[3141] | 414 | cout<<"\n--- Checking realization 2D spectra"<<endl;
|
---|
| 415 | Histo2DErr hpkgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 416 | hpkgen2.ReCenterBin(); hpkgen2.Zero();
|
---|
| 417 | hpkgen2.Show();
|
---|
| 418 | fluct3d.ComputeSpectrum2D(hpkgen2);
|
---|
| 419 | {
|
---|
| 420 | tagobs = "hpkgen2"; posobs.PutObject(hpkgen2,tagobs);
|
---|
| 421 | }
|
---|
[3155] | 422 | PrtTim(">>>> End Checking realization 2D spectra");
|
---|
[3141] | 423 | }
|
---|
| 424 |
|
---|
[3289] | 425 | if(filter_by_pixel!=0) {
|
---|
[3115] | 426 | cout<<"\n--- Computing convolution by pixel shape"<<endl;
|
---|
| 427 | fluct3d.FilterByPixel();
|
---|
[3155] | 428 | PrtTim(">>>> End Computing convolution by pixel shape");
|
---|
[3115] | 429 |
|
---|
| 430 | cout<<"\n--- Checking realization spectra after pixel shape convol."<<endl;
|
---|
[3141] | 431 | HistoErr hpkgenf(0.,knyqmax,nherr);
|
---|
| 432 | hpkgenf.ReCenterBin(); hpkgenf.Zero();
|
---|
| 433 | hpkgenf.Show();
|
---|
[3115] | 434 | fluct3d.ComputeSpectrum(hpkgenf);
|
---|
| 435 | {
|
---|
| 436 | tagobs = "hpkgenf"; posobs.PutObject(hpkgenf,tagobs);
|
---|
| 437 | }
|
---|
[3155] | 438 | PrtTim(">>>> End Checking realization spectra");
|
---|
[3115] | 439 |
|
---|
[3289] | 440 | if(comp2dspec) {
|
---|
| 441 | cout<<"\n--- Checking realization 2D spectra after pixel shape convol."<<endl;
|
---|
| 442 | Histo2DErr hpkgenf2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 443 | hpkgenf2.ReCenterBin(); hpkgenf2.Zero();
|
---|
| 444 | hpkgenf2.Show();
|
---|
| 445 | fluct3d.ComputeSpectrum2D(hpkgenf2);
|
---|
| 446 | {
|
---|
| 447 | tagobs = "hpkgenf2"; posobs.PutObject(hpkgenf2,tagobs);
|
---|
| 448 | }
|
---|
| 449 | PrtTim(">>>> End Checking realization 2D spectra");
|
---|
[3141] | 450 | }
|
---|
[3115] | 451 | }
|
---|
| 452 |
|
---|
[3289] | 453 | if(wfits) {
|
---|
| 454 | fluct3d.WriteFits("!cmvobserv3d_k0.fits");
|
---|
| 455 | PrtTim(">>>> End WriteFits");
|
---|
| 456 | }
|
---|
| 457 | if(wppf) {
|
---|
| 458 | fluct3d.WritePPF("cmvobserv3d_k0.ppf",false);
|
---|
| 459 | PrtTim(">>>> End WritePPF");
|
---|
| 460 | }
|
---|
| 461 |
|
---|
[3157] | 462 | //-----------------------------------------------------------------
|
---|
[3115] | 463 | cout<<"\n--- Computing a realization in real space"<<endl;
|
---|
| 464 | fluct3d.ComputeReal();
|
---|
[3322] | 465 | double rmin,rmax; fluct3d.MinMax(rmin,rmax);
|
---|
[3115] | 466 | cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
|
---|
[3157] | 467 | PrtTim(">>>> End Computing a realization in real space");
|
---|
[3115] | 468 |
|
---|
[3157] | 469 | if(use_growth_factor) {
|
---|
| 470 | cout<<"\n--- Apply Growth factor"<<endl;
|
---|
| 471 | cout<<"...D(z=0)="<<growth(0.)<<" D(z="<<zref<<")="<<growth(zref)<<endl;
|
---|
[3199] | 472 | fluct3d.ApplyGrowthFactor();
|
---|
[3322] | 473 | fluct3d.MinMax(rmin,rmax);
|
---|
[3157] | 474 | cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
|
---|
| 475 | PrtTim(">>>> End Applying growth factor");
|
---|
| 476 | }
|
---|
| 477 |
|
---|
[3322] | 478 | int_8 nm;
|
---|
| 479 | double rmref,rs2ref;
|
---|
| 480 | cout<<"\n--- Computing reference variance in real space"<<endl;
|
---|
| 481 | nm = fluct3d.MeanSigma2(rmref,rs2ref);
|
---|
| 482 | cout<<" rs2ref= "<<rs2ref<<" , rmref="<<rmref<<" ("<<nm<<")"<<endl;
|
---|
| 483 | PrtTim(">>>> End Computing reference variance in real space");
|
---|
[3289] | 484 |
|
---|
[3155] | 485 | if(wfits) {
|
---|
| 486 | fluct3d.WriteFits("!cmvobserv3d_r0.fits");
|
---|
| 487 | PrtTim(">>>> End WriteFits");
|
---|
| 488 | }
|
---|
| 489 | if(wppf) {
|
---|
| 490 | fluct3d.WritePPF("cmvobserv3d_r0.ppf",true);
|
---|
| 491 | PrtTim(">>>> End WritePPF");
|
---|
| 492 | }
|
---|
[3281] | 493 | if(wslice) {
|
---|
| 494 | fluct3d.WriteSlicePPF("cmvobserv3d_s_r0.ppf");
|
---|
| 495 | PrtTim(">>>> End WriteSlicePPF");
|
---|
| 496 | }
|
---|
[3115] | 497 |
|
---|
[3289] | 498 | cout<<"\n--- Check mean and variance in real space"<<endl;
|
---|
| 499 | fluct3d.NumberOfBad(-1.,1e+200);
|
---|
[3322] | 500 | double rm,rs2;
|
---|
[3289] | 501 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
| 502 | PrtTim(">>>> End Check mean and variance in real space");
|
---|
[3141] | 503 |
|
---|
[3154] | 504 | if(compvarreal) {
|
---|
[3115] | 505 | cout<<"\n--- Check variance sigmaR in real space"<<endl;
|
---|
| 506 | double varr;
|
---|
[3262] | 507 | fluct3d.VarianceFrReal(R,varr);
|
---|
[3283] | 508 | cout<<"...Computed variance = "<<varr
|
---|
| 509 | <<" , Theorical variance at (z=0) = "<<pow(sigmaR,1.)
|
---|
| 510 | <<" , at (z="<<zref<<") = "<<pow(sigmaR*growth_at_z,1.)<<endl;
|
---|
[3155] | 511 | PrtTim(">>>> End Check variance sigmaR in real space");
|
---|
[3115] | 512 | }
|
---|
| 513 |
|
---|
[3322] | 514 | //STOP_HERE_FOR QUICK_DEBUG
|
---|
| 515 | // return -41;
|
---|
[3316] | 516 |
|
---|
[3115] | 517 | //-----------------------------------------------------------------
|
---|
| 518 | cout<<endl<<"\n--- Converting fluctuations into mass"<<endl;
|
---|
| 519 | fluct3d.TurnFluct2Mass();
|
---|
[3262] | 520 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
[3155] | 521 | PrtTim(">>>> End Converting fluctuations into mass");
|
---|
[3115] | 522 |
|
---|
[3322] | 523 | cout<<"\n--- Converting mass into galaxy number: gal per pixel ="
|
---|
| 524 | <<ngal_by_mpc3*fluct3d.GetDVol()<<endl;
|
---|
[3115] | 525 | rm = fluct3d.TurnMass2MeanNumber(ngal_by_mpc3);
|
---|
[3262] | 526 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
|
---|
| 527 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
|
---|
| 528 | PrtTim(">>>> End Converting mass into galaxy number");
|
---|
[3115] | 529 |
|
---|
[3261] | 530 | cout<<"\n--- Set negative and null pixels to BAD"<<endl;
|
---|
[3115] | 531 | nm = fluct3d.SetToVal(0.,1e+200,-999.);
|
---|
[3155] | 532 | PrtTim(">>>> End Set negative pixels to BAD etc...");
|
---|
[3115] | 533 |
|
---|
[3154] | 534 | cout<<"\n--- Apply poisson on galaxy number"<<endl;
|
---|
[3262] | 535 | fluct3d.ApplyPoisson();
|
---|
| 536 | nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
|
---|
| 537 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
|
---|
[3322] | 538 | double xgalmin,xgalmax; fluct3d.MinMax(xgalmin,xgalmax,0.1,1.e50);
|
---|
[3155] | 539 | PrtTim(">>>> End Apply poisson on galaxy number");
|
---|
[3281] | 540 | if(wslice) {
|
---|
| 541 | fluct3d.WriteSlicePPF("cmvobserv3d_s_rn.ppf");
|
---|
| 542 | PrtTim(">>>> End WriteSlicePPF");
|
---|
| 543 | }
|
---|
[3115] | 544 |
|
---|
[3154] | 545 | cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
|
---|
[3322] | 546 | double mhi = 0.;
|
---|
| 547 | if(use_schmassdist) {
|
---|
| 548 | if(recompute_schmassdist) {
|
---|
| 549 | int ngalmax = int(xgalmax+0.5);
|
---|
| 550 | schmdist.SetNgalLim(ngalmax,1,naleagal);
|
---|
| 551 | PrtTim(">>>> End creating tabulated histograms for trials");
|
---|
| 552 | }
|
---|
| 553 | mhi = fluct3d.TurnNGal2MassQuick(schmdist);
|
---|
| 554 | schmdist.PrintStatus();
|
---|
| 555 | } else {
|
---|
| 556 | mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
|
---|
[3115] | 557 | }
|
---|
| 558 | cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl;
|
---|
[3262] | 559 | nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
|
---|
| 560 | cout<<"Equivalent: "<<rm*nm/fluct3d.NPix()<<" Msol / pixels"<<endl;
|
---|
| 561 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
|
---|
[3155] | 562 | PrtTim(">>>> End Convert Galaxy number to HI mass");
|
---|
[3115] | 563 |
|
---|
| 564 | cout<<"\n--- Set BAD pixels to Zero"<<endl;
|
---|
| 565 | nm = fluct3d.SetToVal(-998.,1e+200,0.);
|
---|
[3155] | 566 | PrtTim(">>>> End Set BAD pixels to Zero etc...");
|
---|
[3115] | 567 |
|
---|
[3155] | 568 | if(wfits) {
|
---|
| 569 | fluct3d.WriteFits("!cmvobserv3d_r.fits");
|
---|
| 570 | PrtTim(">>>> End WriteFits");
|
---|
| 571 | }
|
---|
| 572 | if(wppf) {
|
---|
| 573 | fluct3d.WritePPF("cmvobserv3d_r.ppf",true);
|
---|
| 574 | PrtTim(">>>> End WritePPF");
|
---|
| 575 | }
|
---|
[3281] | 576 | if(wslice) {
|
---|
| 577 | fluct3d.WriteSlicePPF("cmvobserv3d_s_r.ppf");
|
---|
| 578 | PrtTim(">>>> End WriteSlicePPF");
|
---|
| 579 | }
|
---|
[3120] | 580 |
|
---|
[3196] | 581 | if(do_agn) {
|
---|
[3199] | 582 | cout<<"\n--- Add AGN: <log10(S Jy)>="<<lfjy_agn<<" , sigma="<<lsigma_agn
|
---|
| 583 | <<" , powlaw="<<powlaw_agn<<endl;
|
---|
| 584 | fluct3d.AddAGN(lfjy_agn,lsigma_agn,powlaw_agn);
|
---|
[3262] | 585 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
[3196] | 586 | PrtTim(">>>> End Add AGN");
|
---|
| 587 | }
|
---|
| 588 |
|
---|
[3193] | 589 | if(snoise>0.) {
|
---|
[3271] | 590 | cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<", evolution="<<isnoise_evol<<endl;
|
---|
| 591 | fluct3d.AddNoise2Real(snoise,(isnoise_evol>0? true:false));
|
---|
[3262] | 592 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
[3193] | 593 | PrtTim(">>>> End Add noise");
|
---|
| 594 | }
|
---|
[3115] | 595 |
|
---|
[3322] | 596 | if(scalecube!=0.) { // Si scalecube==0 pas de normalisation
|
---|
| 597 | cout<<"\n--- Scale cube rs2ref="<<rs2ref<<endl;
|
---|
| 598 | if(scalecube<0. && rs2ref>0.) { // si negatif on scale automatiquement
|
---|
| 599 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
| 600 | if(rs2>0.) {scalecube=sqrt(rs2ref)/sqrt(rs2); offsetcube=-rm;}
|
---|
| 601 | }
|
---|
| 602 | cout<<"...scale="<<scalecube<<" offset="<<offsetcube<<endl;
|
---|
| 603 | if(scalecube>0.) fluct3d.ScaleOffset(scalecube,offsetcube);
|
---|
| 604 | PrtTim(">>>> End Scale cube");
|
---|
[3283] | 605 | }
|
---|
| 606 |
|
---|
[3199] | 607 | if(wfits) {
|
---|
| 608 | fluct3d.WriteFits("!cmvobserv3d_rf.fits");
|
---|
| 609 | PrtTim(">>>> End WriteFits");
|
---|
| 610 | }
|
---|
| 611 | if(wppf) {
|
---|
| 612 | fluct3d.WritePPF("cmvobserv3d_rf.ppf",true);
|
---|
| 613 | PrtTim(">>>> End WritePPF");
|
---|
| 614 | }
|
---|
[3281] | 615 | if(wslice) {
|
---|
| 616 | fluct3d.WriteSlicePPF("cmvobserv3d_s_rf.ppf");
|
---|
| 617 | PrtTim(">>>> End WriteSlicePPF");
|
---|
| 618 | }
|
---|
[3199] | 619 |
|
---|
[3115] | 620 | //-----------------------------------------------------------------
|
---|
| 621 | // -- NE PAS FAIRE CA SI ON VEUT CONTINUER LA SIMULATION -> d_rho/rho ecrase
|
---|
[3141] | 622 |
|
---|
[3289] | 623 | cout<<endl<<"\n--- ReComputing spectrum from real space"<<endl;
|
---|
| 624 | fluct3d.ReComputeFourier();
|
---|
| 625 | PrtTim(">>>> End ReComputing spectrum");
|
---|
[3141] | 626 |
|
---|
[3155] | 627 | if(wfits) {
|
---|
| 628 | fluct3d.WriteFits("!cmvobserv3d_k.fits");
|
---|
| 629 | PrtTim(">>>> End WriteFits");
|
---|
| 630 | }
|
---|
| 631 | if(wppf) {
|
---|
| 632 | fluct3d.WritePPF("cmvobserv3d_k.ppf",false);
|
---|
| 633 | PrtTim(">>>> End WritePPF");
|
---|
| 634 | }
|
---|
[3154] | 635 |
|
---|
[3289] | 636 | cout<<endl<<"\n--- Computing final spectrum"<<endl;
|
---|
| 637 | HistoErr hpkrec(0.,knyqmax,nherr);
|
---|
| 638 | hpkrec.ReCenterBin();
|
---|
| 639 | hpkrec.Show();
|
---|
| 640 | fluct3d.ComputeSpectrum(hpkrec);
|
---|
| 641 | tagobs = "hpkrec"; posobs.PutObject(hpkrec,tagobs);
|
---|
| 642 | PrtTim(">>>> End Computing final spectrum");
|
---|
[3115] | 643 |
|
---|
[3154] | 644 | if(comp2dspec) {
|
---|
[3141] | 645 | cout<<"\n--- Computing final 2D spectrum"<<endl;
|
---|
| 646 | Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 647 | hpkrec2.ReCenterBin(); hpkrec2.Zero();
|
---|
| 648 | hpkrec2.Show();
|
---|
[3267] | 649 | fluct3d.ComputeSpectrum2D(hpkrec2);
|
---|
[3141] | 650 | {
|
---|
| 651 | tagobs = "hpkrec2"; posobs.PutObject(hpkrec2,tagobs);
|
---|
| 652 | }
|
---|
[3155] | 653 | PrtTim(">>>> End Computing final 2D spectrum");
|
---|
[3141] | 654 | }
|
---|
| 655 |
|
---|
[3155] | 656 | PrtTim(">>>> End Of Job");
|
---|
[3115] | 657 | return 0;
|
---|
| 658 | }
|
---|
| 659 |
|
---|