[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;
|
---|
| 137 | cout<<"nstar= "<<nstar<<" mstar="<<mstar<<" alpha="<<alpha<<endl;
|
---|
| 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 | PrtTim("End of definition");
|
---|
| 207 |
|
---|
| 208 | //-----------------------------------------------------------------
|
---|
[3154] | 209 | cout<<endl<<"\n--- Compute galaxy density number"<<endl;
|
---|
[3115] | 210 |
|
---|
| 211 | sch.SetOutValue(0);
|
---|
| 212 | cout<<"sch(mstar) = "<<sch(mstar)<<" /Mpc^3/Msol"<<endl;
|
---|
| 213 | double ngal_by_mpc3 = IntegrateFuncLog(sch,lschmin,lschmax,0.01,dlsch,10.*dlsch,4);
|
---|
| 214 | cout<<"Galaxy density number = "<<ngal_by_mpc3<<" /Mpc^3 between limits"<<endl;
|
---|
| 215 |
|
---|
| 216 | sch.SetOutValue(1);
|
---|
| 217 | cout<<"mstar*sch(mstar) = "<<sch(mstar)<<" Msol/Mpc^3/Msol"<<endl;
|
---|
| 218 | double mass_by_mpc3 = IntegrateFuncLog(sch,lschmin,lschmax,0.01,dlsch,10.*dlsch,4);
|
---|
| 219 | cout<<"Galaxy mass density= "<<mass_by_mpc3<<" Msol/Mpc^3 between limits"<<endl;
|
---|
| 220 |
|
---|
| 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
|
---|
| 223 | cout<<endl<<"\n--- Compute Spectrum Realization"<<endl;
|
---|
| 224 |
|
---|
| 225 | pkz.SetZ(zref);
|
---|
| 226 | TArray< complex<r_8> > pkgen;
|
---|
[3141] | 227 | GeneFluct3D fluct3d(pkgen);
|
---|
[3150] | 228 | fluct3d.SetPrtLevel(3);
|
---|
[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 |
|
---|
| 258 | cout<<"\n--- Computing a realization in Fourier space"<<endl;
|
---|
[3141] | 259 | if(computefourier0) fluct3d.ComputeFourier0(pkz);
|
---|
| 260 | else fluct3d.ComputeFourier(pkz);
|
---|
[3115] | 261 |
|
---|
[3141] | 262 | if(1) {
|
---|
| 263 | cout<<"\n--- Checking realization spectra"<<endl;
|
---|
| 264 | HistoErr hpkgen(0.,knyqmax,nherr);
|
---|
| 265 | hpkgen.ReCenterBin(); hpkgen.Zero();
|
---|
| 266 | hpkgen.Show();
|
---|
| 267 | fluct3d.ComputeSpectrum(hpkgen);
|
---|
| 268 | {
|
---|
| 269 | tagobs = "hpkgen"; posobs.PutObject(hpkgen,tagobs);
|
---|
| 270 | }
|
---|
[3115] | 271 | }
|
---|
| 272 |
|
---|
[3154] | 273 | if(comp2dspec) {
|
---|
[3141] | 274 | cout<<"\n--- Checking realization 2D spectra"<<endl;
|
---|
| 275 | Histo2DErr hpkgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 276 | hpkgen2.ReCenterBin(); hpkgen2.Zero();
|
---|
| 277 | hpkgen2.Show();
|
---|
| 278 | fluct3d.ComputeSpectrum2D(hpkgen2);
|
---|
| 279 | {
|
---|
| 280 | tagobs = "hpkgen2"; posobs.PutObject(hpkgen2,tagobs);
|
---|
| 281 | }
|
---|
| 282 | }
|
---|
| 283 |
|
---|
| 284 | if(1) {
|
---|
[3115] | 285 | cout<<"\n--- Computing convolution by pixel shape"<<endl;
|
---|
| 286 | fluct3d.FilterByPixel();
|
---|
[3141] | 287 | }
|
---|
[3115] | 288 |
|
---|
[3154] | 289 | if(wfits) fluct3d.WriteFits("!cmvobserv3d_k0.fits");
|
---|
| 290 | if(wppf) fluct3d.WritePPF("cmvobserv3d_k0.ppf",false);
|
---|
[3141] | 291 |
|
---|
| 292 | if(1) {
|
---|
[3115] | 293 | cout<<"\n--- Checking realization spectra after pixel shape convol."<<endl;
|
---|
[3141] | 294 | HistoErr hpkgenf(0.,knyqmax,nherr);
|
---|
| 295 | hpkgenf.ReCenterBin(); hpkgenf.Zero();
|
---|
| 296 | hpkgenf.Show();
|
---|
[3115] | 297 | fluct3d.ComputeSpectrum(hpkgenf);
|
---|
| 298 | {
|
---|
| 299 | tagobs = "hpkgenf"; posobs.PutObject(hpkgenf,tagobs);
|
---|
| 300 | }
|
---|
| 301 | }
|
---|
| 302 |
|
---|
[3154] | 303 | if(comp2dspec) {
|
---|
[3141] | 304 | cout<<"\n--- Checking realization 2D spectra after pixel shape convol."<<endl;
|
---|
| 305 | Histo2DErr hpkgenf2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 306 | hpkgenf2.ReCenterBin(); hpkgenf2.Zero();
|
---|
| 307 | hpkgenf2.Show();
|
---|
| 308 | fluct3d.ComputeSpectrum2D(hpkgenf2);
|
---|
| 309 | {
|
---|
| 310 | tagobs = "hpkgenf2"; posobs.PutObject(hpkgenf2,tagobs);
|
---|
| 311 | }
|
---|
[3115] | 312 | }
|
---|
| 313 |
|
---|
| 314 | cout<<"\n--- Computing a realization in real space"<<endl;
|
---|
| 315 | fluct3d.ComputeReal();
|
---|
| 316 | double rmin,rmax; rgen.MinMax(rmin,rmax);
|
---|
| 317 | cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
|
---|
| 318 |
|
---|
[3154] | 319 | if(wfits) fluct3d.WriteFits("!cmvobserv3d_r0.fits");
|
---|
| 320 | if(wppf) fluct3d.WritePPF("cmvobserv3d_r0.ppf",true);
|
---|
[3115] | 321 |
|
---|
[3141] | 322 | int_8 nm;
|
---|
| 323 | double rm,rs2;
|
---|
[3115] | 324 | if(1) {
|
---|
[3141] | 325 | cout<<"\n--- Check mean and variance in real space"<<endl;
|
---|
| 326 | int_8 nlowone = fluct3d.NumberOfBad(-1.,1e+200);
|
---|
| 327 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
| 328 | cout<<"rgen:("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
| 329 | <<rs2<<" -> "<<sqrt(rs2)<<", n(<-1)="<<nlowone<<endl;
|
---|
| 330 | }
|
---|
| 331 |
|
---|
[3154] | 332 | if(compvarreal) {
|
---|
[3115] | 333 | cout<<"\n--- Check variance sigmaR in real space"<<endl;
|
---|
| 334 | double varr;
|
---|
[3134] | 335 | int_8 nvarr = fluct3d.VarianceFrReal(R,varr);
|
---|
[3115] | 336 | cout<<"R="<<R<<" : sigmaR^2="<<varr<<" -> "<<sqrt(varr)<<", n="<<nvarr<<endl;
|
---|
| 337 | }
|
---|
| 338 |
|
---|
| 339 | //-----------------------------------------------------------------
|
---|
| 340 | cout<<endl<<"\n--- Converting fluctuations into mass"<<endl;
|
---|
| 341 | fluct3d.TurnFluct2Mass();
|
---|
| 342 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
| 343 | cout<<"1+rgen: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
| 344 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
| 345 |
|
---|
| 346 | cout<<"\n--- Converting mass into galaxy number"<<endl;
|
---|
| 347 | rm = fluct3d.TurnMass2MeanNumber(ngal_by_mpc3);
|
---|
| 348 | cout<<rm<<" galaxies put into survey"<<endl;
|
---|
| 349 | nm = fluct3d.MeanSigma2(rm,rs2,0.);
|
---|
| 350 | cout<<"galaxy: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
| 351 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
| 352 |
|
---|
| 353 | cout<<"\n--- Set negative pixels to BAD"<<endl;
|
---|
| 354 | nm = fluct3d.SetToVal(0.,1e+200,-999.);
|
---|
| 355 | cout<<nm<<" negative in survey set to BAD"<<endl;
|
---|
| 356 | nm = fluct3d.MeanSigma2(rm,rs2,-998.);
|
---|
| 357 | cout<<"galaxy: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
| 358 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
| 359 |
|
---|
[3154] | 360 | cout<<"\n--- Apply poisson on galaxy number"<<endl;
|
---|
[3115] | 361 | nm = fluct3d.ApplyPoisson();
|
---|
| 362 | cout<<nm<<" galaxies into survey after poisson"<<endl;
|
---|
| 363 | nm = fluct3d.MeanSigma2(rm,rs2,-998.);
|
---|
| 364 | cout<<"galaxy: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
| 365 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
| 366 |
|
---|
[3154] | 367 | cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
|
---|
[3129] | 368 | long nhmdndm = long( (lschmax-lschmin+1.)*100. + 0.5);
|
---|
[3115] | 369 | Histo hmdndm(lschmin,lschmax,nhmdndm);
|
---|
| 370 | sch.SetOutValue(1);
|
---|
| 371 | FuncToHisto(sch,hmdndm,true);
|
---|
| 372 | FunRan tirhmdndm(hmdndm,true);
|
---|
| 373 | {
|
---|
| 374 | tagobs = "hmdndm"; posobs.PutObject(hmdndm,tagobs);
|
---|
| 375 | Histo hdum1(tirhmdndm);
|
---|
| 376 | tagobs = "tirhmdndm"; posobs.PutObject(hdum1,tagobs);
|
---|
| 377 | }
|
---|
| 378 | double mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
|
---|
| 379 | cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl;
|
---|
| 380 | nm = fluct3d.MeanSigma2(rm,rs2,0.);
|
---|
| 381 | cout<<"HI mass: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
| 382 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
| 383 | cout<<"Equivalent: "<<rm*nm/fluct3d.NPix()<<" Msol / pixels"<<endl;
|
---|
| 384 |
|
---|
| 385 | cout<<"\n--- Set BAD pixels to Zero"<<endl;
|
---|
| 386 | nm = fluct3d.SetToVal(-998.,1e+200,0.);
|
---|
| 387 | cout<<nm<<" BAD in survey set to zero"<<endl;
|
---|
| 388 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
| 389 | cout<<"galaxy: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
| 390 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
| 391 |
|
---|
[3154] | 392 | if(wfits) fluct3d.WriteFits("!cmvobserv3d_r.fits");
|
---|
| 393 | if(wppf) fluct3d.WritePPF("cmvobserv3d_r.ppf",true);
|
---|
[3120] | 394 |
|
---|
[3115] | 395 | cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<endl;
|
---|
| 396 | fluct3d.AddNoise2Real(snoise);
|
---|
| 397 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
| 398 | cout<<"HI mass with noise: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = "
|
---|
| 399 | <<rs2<<" -> "<<sqrt(rs2)<<endl;
|
---|
| 400 |
|
---|
| 401 | //-----------------------------------------------------------------
|
---|
| 402 | // -- NE PAS FAIRE CA SI ON VEUT CONTINUER LA SIMULATION -> d_rho/rho ecrase
|
---|
[3141] | 403 |
|
---|
[3115] | 404 | if(1) {
|
---|
| 405 | cout<<endl<<"\n--- ReComputing spectrum from real space"<<endl;
|
---|
| 406 | fluct3d.ReComputeFourier();
|
---|
[3141] | 407 | }
|
---|
| 408 |
|
---|
[3154] | 409 | if(wfits) fluct3d.WriteFits("!cmvobserv3d_k.fits");
|
---|
| 410 | if(wppf) fluct3d.WritePPF("cmvobserv3d_k.ppf",false);
|
---|
| 411 |
|
---|
[3141] | 412 | if(1) {
|
---|
| 413 | cout<<endl<<"\n--- Computing final spectrum"<<endl;
|
---|
| 414 | HistoErr hpkrec(0.,knyqmax,nherr);
|
---|
[3115] | 415 | hpkrec.ReCenterBin();
|
---|
[3141] | 416 | hpkrec.Show();
|
---|
[3115] | 417 | fluct3d.ComputeSpectrum(hpkrec);
|
---|
| 418 | tagobs = "hpkrec"; posobs.PutObject(hpkrec,tagobs);
|
---|
| 419 | }
|
---|
| 420 |
|
---|
[3154] | 421 | if(comp2dspec) {
|
---|
[3141] | 422 | cout<<"\n--- Computing final 2D spectrum"<<endl;
|
---|
| 423 | Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 424 | hpkrec2.ReCenterBin(); hpkrec2.Zero();
|
---|
| 425 | hpkrec2.Show();
|
---|
| 426 | fluct3d.ComputeSpectrum2D(hpkrec2);
|
---|
| 427 | {
|
---|
| 428 | tagobs = "hpkrec2"; posobs.PutObject(hpkrec2,tagobs);
|
---|
| 429 | }
|
---|
| 430 | }
|
---|
| 431 |
|
---|
[3115] | 432 | return 0;
|
---|
| 433 | }
|
---|
| 434 |
|
---|
| 435 | /*
|
---|
[3141] | 436 | ######################################################
|
---|
[3154] | 437 | readfits cmvobserv3d_k0.fits
|
---|
[3141] | 438 | readfits cmvobserv3d_k.fits
|
---|
| 439 | readfits cmvobserv3d_r0.fits
|
---|
| 440 | readfits cmvobserv3d_r.fits
|
---|
| 441 |
|
---|
[3154] | 442 | openppf cmvobserv3d_k0.ppf
|
---|
[3141] | 443 | openppf cmvobserv3d_k.ppf
|
---|
| 444 | openppf cmvobserv3d_r0.ppf
|
---|
| 445 | openppf cmvobserv3d_r.ppf
|
---|
| 446 |
|
---|
| 447 | # pour le plot 2D d'une slice en Z du 3D: to2d nom_obj3D num_slice
|
---|
| 448 | defscript to2d
|
---|
| 449 | objaoper $1 sliceyz $2
|
---|
| 450 | mv sliceyz_${2} ${1}_$2
|
---|
| 451 | disp ${1}_$2
|
---|
| 452 | echo display slice $2 of $1
|
---|
| 453 | endscript
|
---|
| 454 |
|
---|
| 455 | to2d $cobj 0
|
---|
| 456 |
|
---|
| 457 | ######################################################
|
---|
[3115] | 458 | openppf cmvobserv3d.ppf
|
---|
| 459 |
|
---|
[3141] | 460 | zone
|
---|
[3150] | 461 | set k pow(10.,x)
|
---|
| 462 | n/plot hpkz.val*$k*$k/(2*M_PI*M_PI)%x ! "connectpoints"
|
---|
| 463 |
|
---|
| 464 | zone
|
---|
[3120] | 465 | n/plot hpkz.val%x ! ! "nsta connectpoints"
|
---|
| 466 | n/plot hpkgen.val%log10(x) x>0 ! "nsta same red connectpoints"
|
---|
| 467 | n/plot hpkgenf.val%log10(x) x>0 ! "nsta same orange connectpoints"
|
---|
| 468 | n/plot hpkrec.val%log10(x) x>0 ! "nsta same blue connectpoints"
|
---|
[3115] | 469 |
|
---|
[3150] | 470 | disp hpkgen "hbincont err"
|
---|
| 471 | disp hpkgenf "hbincont err"
|
---|
| 472 | disp hpkrec "hbincont err"
|
---|
[3115] | 473 |
|
---|
[3141] | 474 | zone 2 2
|
---|
| 475 | imag hpkgen2
|
---|
| 476 | imag hpkgenf2
|
---|
| 477 | imag hpkrec2
|
---|
[3115] | 478 |
|
---|
[3150] | 479 | zone 2 1
|
---|
| 480 | disp hmdndm "nsta"
|
---|
| 481 | disp tirhmdndm "nsta"
|
---|
[3120] | 482 | addline 0 1 20 1 "red"
|
---|
| 483 |
|
---|
[3115] | 484 | */
|
---|