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