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