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