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