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