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