[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 |
|
---|
[3289] | 345 | cout<<"\n--- Checking realization spectra"<<endl;
|
---|
| 346 | HistoErr hpkgen(0.,knyqmax,nherr);
|
---|
| 347 | hpkgen.ReCenterBin(); hpkgen.Zero();
|
---|
| 348 | hpkgen.Show();
|
---|
| 349 | fluct3d.ComputeSpectrum(hpkgen);
|
---|
| 350 | {
|
---|
| 351 | tagobs = "hpkgen"; posobs.PutObject(hpkgen,tagobs);
|
---|
[3115] | 352 | }
|
---|
[3289] | 353 | PrtTim(">>>> End Checking realization spectra");
|
---|
[3115] | 354 |
|
---|
[3154] | 355 | if(comp2dspec) {
|
---|
[3141] | 356 | cout<<"\n--- Checking realization 2D spectra"<<endl;
|
---|
| 357 | Histo2DErr hpkgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 358 | hpkgen2.ReCenterBin(); hpkgen2.Zero();
|
---|
| 359 | hpkgen2.Show();
|
---|
| 360 | fluct3d.ComputeSpectrum2D(hpkgen2);
|
---|
| 361 | {
|
---|
| 362 | tagobs = "hpkgen2"; posobs.PutObject(hpkgen2,tagobs);
|
---|
| 363 | }
|
---|
[3155] | 364 | PrtTim(">>>> End Checking realization 2D spectra");
|
---|
[3141] | 365 | }
|
---|
| 366 |
|
---|
[3289] | 367 | if(filter_by_pixel!=0) {
|
---|
| 368 | // A_FAIRE (???) ne faut-il pas dans le cas ou on demande
|
---|
| 369 | // use_growth_factor filtrer uniquement apres avoir appliquer
|
---|
| 370 | // le facteur de croissance ??????
|
---|
[3115] | 371 | cout<<"\n--- Computing convolution by pixel shape"<<endl;
|
---|
| 372 | fluct3d.FilterByPixel();
|
---|
[3155] | 373 | PrtTim(">>>> End Computing convolution by pixel shape");
|
---|
[3115] | 374 |
|
---|
| 375 | cout<<"\n--- Checking realization spectra after pixel shape convol."<<endl;
|
---|
[3141] | 376 | HistoErr hpkgenf(0.,knyqmax,nherr);
|
---|
| 377 | hpkgenf.ReCenterBin(); hpkgenf.Zero();
|
---|
| 378 | hpkgenf.Show();
|
---|
[3115] | 379 | fluct3d.ComputeSpectrum(hpkgenf);
|
---|
| 380 | {
|
---|
| 381 | tagobs = "hpkgenf"; posobs.PutObject(hpkgenf,tagobs);
|
---|
| 382 | }
|
---|
[3155] | 383 | PrtTim(">>>> End Checking realization spectra");
|
---|
[3115] | 384 |
|
---|
[3289] | 385 | if(comp2dspec) {
|
---|
| 386 | cout<<"\n--- Checking realization 2D spectra after pixel shape convol."<<endl;
|
---|
| 387 | Histo2DErr hpkgenf2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 388 | hpkgenf2.ReCenterBin(); hpkgenf2.Zero();
|
---|
| 389 | hpkgenf2.Show();
|
---|
| 390 | fluct3d.ComputeSpectrum2D(hpkgenf2);
|
---|
| 391 | {
|
---|
| 392 | tagobs = "hpkgenf2"; posobs.PutObject(hpkgenf2,tagobs);
|
---|
| 393 | }
|
---|
| 394 | PrtTim(">>>> End Checking realization 2D spectra");
|
---|
[3141] | 395 | }
|
---|
[3115] | 396 | }
|
---|
| 397 |
|
---|
[3289] | 398 | if(wfits) {
|
---|
| 399 | fluct3d.WriteFits("!cmvobserv3d_k0.fits");
|
---|
| 400 | PrtTim(">>>> End WriteFits");
|
---|
| 401 | }
|
---|
| 402 | if(wppf) {
|
---|
| 403 | fluct3d.WritePPF("cmvobserv3d_k0.ppf",false);
|
---|
| 404 | PrtTim(">>>> End WritePPF");
|
---|
| 405 | }
|
---|
| 406 |
|
---|
[3157] | 407 | //-----------------------------------------------------------------
|
---|
[3115] | 408 | cout<<"\n--- Computing a realization in real space"<<endl;
|
---|
| 409 | fluct3d.ComputeReal();
|
---|
| 410 | double rmin,rmax; rgen.MinMax(rmin,rmax);
|
---|
| 411 | cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
|
---|
[3157] | 412 | PrtTim(">>>> End Computing a realization in real space");
|
---|
[3115] | 413 |
|
---|
[3157] | 414 | if(use_growth_factor) {
|
---|
| 415 | cout<<"\n--- Apply Growth factor"<<endl;
|
---|
| 416 | cout<<"...D(z=0)="<<growth(0.)<<" D(z="<<zref<<")="<<growth(zref)<<endl;
|
---|
[3199] | 417 | fluct3d.ApplyGrowthFactor();
|
---|
[3252] | 418 | rgen.MinMax(rmin,rmax);
|
---|
[3157] | 419 | cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
|
---|
| 420 | PrtTim(">>>> End Applying growth factor");
|
---|
[3289] | 421 | // A_FAIRE (???) ne faut-il pas maintenant retourner dans fourier
|
---|
| 422 | // appliquer les filtre des pixels et re-retourner dans reel ?
|
---|
[3157] | 423 | }
|
---|
| 424 |
|
---|
[3289] | 425 |
|
---|
[3155] | 426 | if(wfits) {
|
---|
| 427 | fluct3d.WriteFits("!cmvobserv3d_r0.fits");
|
---|
| 428 | PrtTim(">>>> End WriteFits");
|
---|
| 429 | }
|
---|
| 430 | if(wppf) {
|
---|
| 431 | fluct3d.WritePPF("cmvobserv3d_r0.ppf",true);
|
---|
| 432 | PrtTim(">>>> End WritePPF");
|
---|
| 433 | }
|
---|
[3281] | 434 | if(wslice) {
|
---|
| 435 | fluct3d.WriteSlicePPF("cmvobserv3d_s_r0.ppf");
|
---|
| 436 | PrtTim(">>>> End WriteSlicePPF");
|
---|
| 437 | }
|
---|
[3115] | 438 |
|
---|
[3141] | 439 | int_8 nm;
|
---|
| 440 | double rm,rs2;
|
---|
[3289] | 441 | cout<<"\n--- Check mean and variance in real space"<<endl;
|
---|
| 442 | fluct3d.NumberOfBad(-1.,1e+200);
|
---|
| 443 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
| 444 | PrtTim(">>>> End Check mean and variance in real space");
|
---|
[3141] | 445 |
|
---|
[3154] | 446 | if(compvarreal) {
|
---|
[3115] | 447 | cout<<"\n--- Check variance sigmaR in real space"<<endl;
|
---|
| 448 | double varr;
|
---|
[3262] | 449 | fluct3d.VarianceFrReal(R,varr);
|
---|
[3283] | 450 | cout<<"...Computed variance = "<<varr
|
---|
| 451 | <<" , Theorical variance at (z=0) = "<<pow(sigmaR,1.)
|
---|
| 452 | <<" , at (z="<<zref<<") = "<<pow(sigmaR*growth_at_z,1.)<<endl;
|
---|
[3155] | 453 | PrtTim(">>>> End Check variance sigmaR in real space");
|
---|
[3115] | 454 | }
|
---|
| 455 |
|
---|
| 456 | //-----------------------------------------------------------------
|
---|
| 457 | cout<<endl<<"\n--- Converting fluctuations into mass"<<endl;
|
---|
| 458 | fluct3d.TurnFluct2Mass();
|
---|
[3262] | 459 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
[3155] | 460 | PrtTim(">>>> End Converting fluctuations into mass");
|
---|
[3115] | 461 |
|
---|
| 462 | cout<<"\n--- Converting mass into galaxy number"<<endl;
|
---|
| 463 | rm = fluct3d.TurnMass2MeanNumber(ngal_by_mpc3);
|
---|
[3262] | 464 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
|
---|
| 465 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
|
---|
| 466 | PrtTim(">>>> End Converting mass into galaxy number");
|
---|
[3115] | 467 |
|
---|
[3261] | 468 | cout<<"\n--- Set negative and null pixels to BAD"<<endl;
|
---|
[3115] | 469 | nm = fluct3d.SetToVal(0.,1e+200,-999.);
|
---|
[3155] | 470 | PrtTim(">>>> End Set negative pixels to BAD etc...");
|
---|
[3115] | 471 |
|
---|
[3154] | 472 | cout<<"\n--- Apply poisson on galaxy number"<<endl;
|
---|
[3262] | 473 | fluct3d.ApplyPoisson();
|
---|
| 474 | nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
|
---|
| 475 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
|
---|
[3155] | 476 | PrtTim(">>>> End Apply poisson on galaxy number");
|
---|
[3281] | 477 | if(wslice) {
|
---|
| 478 | fluct3d.WriteSlicePPF("cmvobserv3d_s_rn.ppf");
|
---|
| 479 | PrtTim(">>>> End WriteSlicePPF");
|
---|
| 480 | }
|
---|
[3115] | 481 |
|
---|
[3154] | 482 | cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
|
---|
[3129] | 483 | long nhmdndm = long( (lschmax-lschmin+1.)*100. + 0.5);
|
---|
[3115] | 484 | Histo hmdndm(lschmin,lschmax,nhmdndm);
|
---|
| 485 | sch.SetOutValue(1);
|
---|
| 486 | FuncToHisto(sch,hmdndm,true);
|
---|
| 487 | FunRan tirhmdndm(hmdndm,true);
|
---|
| 488 | {
|
---|
| 489 | tagobs = "hmdndm"; posobs.PutObject(hmdndm,tagobs);
|
---|
| 490 | Histo hdum1(tirhmdndm);
|
---|
| 491 | tagobs = "tirhmdndm"; posobs.PutObject(hdum1,tagobs);
|
---|
| 492 | }
|
---|
| 493 | double mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
|
---|
| 494 | cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl;
|
---|
[3262] | 495 | nm = fluct3d.MeanSigma2(rm,rs2,-998.,1e200);
|
---|
| 496 | cout<<"Equivalent: "<<rm*nm/fluct3d.NPix()<<" Msol / pixels"<<endl;
|
---|
| 497 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200,true,0.);
|
---|
[3155] | 498 | PrtTim(">>>> End Convert Galaxy number to HI mass");
|
---|
[3115] | 499 |
|
---|
| 500 | cout<<"\n--- Set BAD pixels to Zero"<<endl;
|
---|
| 501 | nm = fluct3d.SetToVal(-998.,1e+200,0.);
|
---|
[3155] | 502 | PrtTim(">>>> End Set BAD pixels to Zero etc...");
|
---|
[3115] | 503 |
|
---|
[3155] | 504 | if(wfits) {
|
---|
| 505 | fluct3d.WriteFits("!cmvobserv3d_r.fits");
|
---|
| 506 | PrtTim(">>>> End WriteFits");
|
---|
| 507 | }
|
---|
| 508 | if(wppf) {
|
---|
| 509 | fluct3d.WritePPF("cmvobserv3d_r.ppf",true);
|
---|
| 510 | PrtTim(">>>> End WritePPF");
|
---|
| 511 | }
|
---|
[3281] | 512 | if(wslice) {
|
---|
| 513 | fluct3d.WriteSlicePPF("cmvobserv3d_s_r.ppf");
|
---|
| 514 | PrtTim(">>>> End WriteSlicePPF");
|
---|
| 515 | }
|
---|
[3120] | 516 |
|
---|
[3196] | 517 | if(do_agn) {
|
---|
[3199] | 518 | cout<<"\n--- Add AGN: <log10(S Jy)>="<<lfjy_agn<<" , sigma="<<lsigma_agn
|
---|
| 519 | <<" , powlaw="<<powlaw_agn<<endl;
|
---|
| 520 | fluct3d.AddAGN(lfjy_agn,lsigma_agn,powlaw_agn);
|
---|
[3262] | 521 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
[3196] | 522 | PrtTim(">>>> End Add AGN");
|
---|
| 523 | }
|
---|
| 524 |
|
---|
[3283] | 525 | double scalecube = -1., offsetcube=0.;
|
---|
[3193] | 526 | if(snoise>0.) {
|
---|
[3271] | 527 | cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<", evolution="<<isnoise_evol<<endl;
|
---|
| 528 | fluct3d.AddNoise2Real(snoise,(isnoise_evol>0? true:false));
|
---|
[3262] | 529 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
[3283] | 530 | if(rs2>0. && sr2int>0.) scalecube = sqrt(sr2int)/sqrt(rs2);
|
---|
| 531 | offsetcube = -rm;
|
---|
[3193] | 532 | PrtTim(">>>> End Add noise");
|
---|
| 533 | }
|
---|
[3115] | 534 |
|
---|
[3283] | 535 | if(scalecube>0.) {
|
---|
| 536 | cout<<"\n--- Scale and offset scale="<<scalecube
|
---|
| 537 | <<" off="<<offsetcube<<endl;
|
---|
| 538 | fluct3d.ScaleOffset(scalecube,offsetcube);
|
---|
| 539 | }
|
---|
| 540 |
|
---|
[3199] | 541 | if(wfits) {
|
---|
| 542 | fluct3d.WriteFits("!cmvobserv3d_rf.fits");
|
---|
| 543 | PrtTim(">>>> End WriteFits");
|
---|
| 544 | }
|
---|
| 545 | if(wppf) {
|
---|
| 546 | fluct3d.WritePPF("cmvobserv3d_rf.ppf",true);
|
---|
| 547 | PrtTim(">>>> End WritePPF");
|
---|
| 548 | }
|
---|
[3281] | 549 | if(wslice) {
|
---|
| 550 | fluct3d.WriteSlicePPF("cmvobserv3d_s_rf.ppf");
|
---|
| 551 | PrtTim(">>>> End WriteSlicePPF");
|
---|
| 552 | }
|
---|
[3199] | 553 |
|
---|
[3115] | 554 | //-----------------------------------------------------------------
|
---|
| 555 | // -- NE PAS FAIRE CA SI ON VEUT CONTINUER LA SIMULATION -> d_rho/rho ecrase
|
---|
[3141] | 556 |
|
---|
[3289] | 557 | cout<<endl<<"\n--- ReComputing spectrum from real space"<<endl;
|
---|
| 558 | fluct3d.ReComputeFourier();
|
---|
| 559 | PrtTim(">>>> End ReComputing spectrum");
|
---|
[3141] | 560 |
|
---|
[3155] | 561 | if(wfits) {
|
---|
| 562 | fluct3d.WriteFits("!cmvobserv3d_k.fits");
|
---|
| 563 | PrtTim(">>>> End WriteFits");
|
---|
| 564 | }
|
---|
| 565 | if(wppf) {
|
---|
| 566 | fluct3d.WritePPF("cmvobserv3d_k.ppf",false);
|
---|
| 567 | PrtTim(">>>> End WritePPF");
|
---|
| 568 | }
|
---|
[3154] | 569 |
|
---|
[3289] | 570 | cout<<endl<<"\n--- Computing final spectrum"<<endl;
|
---|
| 571 | HistoErr hpkrec(0.,knyqmax,nherr);
|
---|
| 572 | hpkrec.ReCenterBin();
|
---|
| 573 | hpkrec.Show();
|
---|
| 574 | fluct3d.ComputeSpectrum(hpkrec);
|
---|
| 575 | tagobs = "hpkrec"; posobs.PutObject(hpkrec,tagobs);
|
---|
| 576 | PrtTim(">>>> End Computing final spectrum");
|
---|
[3115] | 577 |
|
---|
[3154] | 578 | if(comp2dspec) {
|
---|
[3141] | 579 | cout<<"\n--- Computing final 2D spectrum"<<endl;
|
---|
| 580 | Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 581 | hpkrec2.ReCenterBin(); hpkrec2.Zero();
|
---|
| 582 | hpkrec2.Show();
|
---|
[3267] | 583 | fluct3d.ComputeSpectrum2D(hpkrec2);
|
---|
[3141] | 584 | {
|
---|
| 585 | tagobs = "hpkrec2"; posobs.PutObject(hpkrec2,tagobs);
|
---|
| 586 | }
|
---|
[3155] | 587 | PrtTim(">>>> End Computing final 2D spectrum");
|
---|
[3141] | 588 | }
|
---|
| 589 |
|
---|
[3155] | 590 | PrtTim(">>>> End Of Job");
|
---|
[3115] | 591 | return 0;
|
---|
| 592 | }
|
---|
| 593 |
|
---|
| 594 | /*
|
---|
[3141] | 595 | ######################################################
|
---|
[3154] | 596 | readfits cmvobserv3d_k0.fits
|
---|
[3141] | 597 | readfits cmvobserv3d_k.fits
|
---|
| 598 | readfits cmvobserv3d_r0.fits
|
---|
| 599 | readfits cmvobserv3d_r.fits
|
---|
[3199] | 600 | readfits cmvobserv3d_rf.fits
|
---|
[3141] | 601 |
|
---|
[3154] | 602 | openppf cmvobserv3d_k0.ppf
|
---|
[3141] | 603 | openppf cmvobserv3d_k.ppf
|
---|
| 604 | openppf cmvobserv3d_r0.ppf
|
---|
| 605 | openppf cmvobserv3d_r.ppf
|
---|
[3199] | 606 | openppf cmvobserv3d_rf.ppf
|
---|
[3141] | 607 |
|
---|
[3199] | 608 | # pour le plot 2D d'une slice en Z du 3D: xy2d nom_obj3D num_slice
|
---|
| 609 | defscript xy2d
|
---|
[3141] | 610 | objaoper $1 sliceyz $2
|
---|
[3199] | 611 | mv sliceyz_${2} ${1}_Z_$2
|
---|
| 612 | disp ${1}_Z_$2
|
---|
| 613 | echo display slice $2 of $1 name is ${1}_Z_$2
|
---|
| 614 | endscript
|
---|
| 615 |
|
---|
| 616 | # pour le plot 2D d'une slice en Y du 3D: xz2d nom_obj3D num_slice
|
---|
| 617 | defscript xz2d
|
---|
| 618 | objaoper $1 slicexy $2
|
---|
| 619 | mv slicexy_${2} ${1}_Y_$2
|
---|
| 620 | disp ${1}_Y_$2
|
---|
| 621 | echo display slice $2 of $1 name is ${1}_Y_$2
|
---|
[3141] | 622 | endscript
|
---|
[3199] | 623 |
|
---|
| 624 | # pour le plot 2D d'une slice en X du 3D: yz2d nom_obj3D num_slice
|
---|
| 625 | defscript yz2d
|
---|
| 626 | objaoper $1 slicexz $2
|
---|
| 627 | mv slicexz_${2} ${1}_X_$2
|
---|
| 628 | disp ${1}_X_$2
|
---|
| 629 | echo display slice $2 of $1 name is ${1}_X_$2
|
---|
| 630 | endscript
|
---|
[3141] | 631 |
|
---|
[3199] | 632 | xy2d $cobj 0
|
---|
| 633 | xz2d $cobj 0
|
---|
| 634 | yz2d $cobj 0
|
---|
[3141] | 635 |
|
---|
| 636 | ######################################################
|
---|
[3281] | 637 | openppf cmvobserv3d_s_r0.ppf
|
---|
| 638 | openppf cmvobserv3d_s_rn.ppf
|
---|
| 639 | openppf cmvobserv3d_s_r.ppf
|
---|
| 640 | openppf cmvobserv3d_s_rf.ppf
|
---|
| 641 |
|
---|
| 642 | ######################################################
|
---|
[3115] | 643 | openppf cmvobserv3d.ppf
|
---|
| 644 |
|
---|
[3141] | 645 | zone
|
---|
[3150] | 646 | set k pow(10.,x)
|
---|
| 647 | n/plot hpkz.val*$k*$k/(2*M_PI*M_PI)%x ! "connectpoints"
|
---|
| 648 |
|
---|
[3199] | 649 | echo ${hpkgen.sum}
|
---|
| 650 | echo ${hpkgenf.sum}
|
---|
| 651 | echo ${hpkrec.sum}
|
---|
| 652 |
|
---|
[3150] | 653 | zone
|
---|
[3120] | 654 | n/plot hpkz.val%x ! ! "nsta connectpoints"
|
---|
| 655 | n/plot hpkgen.val%log10(x) x>0 ! "nsta same red connectpoints"
|
---|
| 656 | n/plot hpkgenf.val%log10(x) x>0 ! "nsta same orange connectpoints"
|
---|
| 657 | n/plot hpkrec.val%log10(x) x>0 ! "nsta same blue connectpoints"
|
---|
[3115] | 658 |
|
---|
[3150] | 659 | disp hpkgen "hbincont err"
|
---|
| 660 | disp hpkgenf "hbincont err"
|
---|
| 661 | disp hpkrec "hbincont err"
|
---|
[3115] | 662 |
|
---|
[3141] | 663 | zone 2 2
|
---|
| 664 | imag hpkgen2
|
---|
| 665 | imag hpkgenf2
|
---|
| 666 | imag hpkrec2
|
---|
[3115] | 667 |
|
---|
[3150] | 668 | zone 2 1
|
---|
| 669 | disp hmdndm "nsta"
|
---|
| 670 | disp tirhmdndm "nsta"
|
---|
[3120] | 671 | addline 0 1 20 1 "red"
|
---|
| 672 |
|
---|
[3115] | 673 | */
|
---|