[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>
|
---|
[3615] | 9 | #include "sophyainit.h"
|
---|
[3115] | 10 | #include "timing.h"
|
---|
| 11 | #include "ntuple.h"
|
---|
| 12 | #include "matharr.h"
|
---|
[3615] | 13 | #include "randfmt.h"
|
---|
| 14 | //#include "randr48.h"
|
---|
| 15 | #include "srandgen.h"
|
---|
[3115] | 16 |
|
---|
| 17 | #include "constcosmo.h"
|
---|
[3157] | 18 | #include "cosmocalc.h"
|
---|
[3115] | 19 | #include "geneutils.h"
|
---|
| 20 | #include "genefluct3d.h"
|
---|
| 21 |
|
---|
| 22 | void usage(void);
|
---|
| 23 | void usage(void)
|
---|
| 24 | {
|
---|
[3182] | 25 | cout<<"cmvobserv3d [...options...]"<<endl
|
---|
[3200] | 26 | <<" -a : auto init random seed (needed for multiple simul)"<<endl
|
---|
| 27 | <<" -0 : use ComputeFourier0 method (defaut: no, use normal way)"<<endl
|
---|
[3331] | 28 | <<" -G typevol: compute Pk(z=0) and apply growth factor in real space"<<endl
|
---|
[3557] | 29 | <<" typevol=1 evolved with distance / observateur (def)"<<endl
|
---|
| 30 | <<" typevol=2 evolved with distance to middle of Z planes"<<endl
|
---|
| 31 | <<" else : no evol, spectrum Pk(z=z_median) for all cube (def)"<<endl
|
---|
[3289] | 32 | <<" -F : filter spectrum by pixel shape (0=no 1=yes(default)"<<endl
|
---|
[3524] | 33 | <<" -U typ =0 compute <NGal>, poisson fluctuate then convert to HI mass (def)"<<endl
|
---|
| 34 | <<" >0 compute directly <HI mass>, do NOT poisson fluctuate with <Ngal>"<<endl
|
---|
| 35 | <<" <0 just multiply dRho/Rho by mass_by_pixel (possible negative pixel values)"<<endl
|
---|
[3200] | 36 | <<" -x nx,dx : size along x axis (npix,Mpc)"<<endl
|
---|
| 37 | <<" -y ny,dy : size along y axis (npix,Mpc)"<<endl
|
---|
| 38 | <<" if ny or dy <=0 take same value as for x"<<endl
|
---|
| 39 | <<" -z nz,dz : size along z axis (redshift axis, npix,Mpc)"<<endl
|
---|
| 40 | <<" -Z zref : redshift for the center of the simulation cube"<<endl
|
---|
[3331] | 41 | <<" -s snoise,typevol : gaussian noise sigma in equivalent Msol"<<endl
|
---|
| 42 | <<" typevol=0 no evolution (def)"<<endl
|
---|
| 43 | <<" typevol=1 noise evolved with distance / observateur"<<endl
|
---|
| 44 | <<" typevol=2 noise evolved with distance to middle of Z planes"<<endl
|
---|
[3200] | 45 | <<" -2 : compute also 2D spectrum (default: no)"<<endl
|
---|
[3353] | 46 | <<" -N scalemass: facteur d\'unite pour la masse (default: -1)"<<endl
|
---|
[3351] | 47 | <<" ex: si on veut unites 10^8 Msol -> scalemass=1.e-8"<<endl
|
---|
| 48 | <<" si <0 alors facteur=-scalemass*Mpix"<<endl
|
---|
[3193] | 49 | <<" -M schmin,schmax,nsch : min,max mass and nb points for schechter HI"<<endl
|
---|
[3322] | 50 | <<" If nsch<0 alors no,bre de points par decade"<<endl
|
---|
| 51 | <<" -Q naleagal : use quick method for turning ngal to mass"<<endl
|
---|
| 52 | <<" -R schmassdist.ppf : read mass distribution for trials from file"<<endl
|
---|
| 53 | <<" instead of computing it (ONLY if \"-Q\" option is activated)"<<endl
|
---|
[3354] | 54 | <<" -8 sigmaR,R : normalisation du spectre de puissance, R en Mpc"<<endl
|
---|
| 55 | <<" (default sigmaR=1, R=8/h100 Mpc)"<<endl
|
---|
[3200] | 56 | <<" -W : write cube in FITS format (complex cube is coded as real cube)"<<endl
|
---|
[3154] | 57 | <<" -P : write cube in PPF format"<<endl
|
---|
[3583] | 58 | <<" -O a,b,c,d,e : tell what you want to write (with the -W and -P options)"<<endl
|
---|
| 59 | <<" a=1 : write generated fourier cube (_k0)"<<endl
|
---|
| 60 | <<" b=1 : write real space cube dRho/Rho at z (_r0)"<<endl
|
---|
| 61 | <<" c=1 : write real space cube conv to gal,poiss,mass etc... (_r)"<<endl
|
---|
| 62 | <<" d=1 : write previous real space cube + noise (_rf)"<<endl
|
---|
| 63 | <<" e=1 : write fourier transform of previous cube (_k)"<<endl
|
---|
[3281] | 64 | <<" -S : write cube slices in PPF format"<<endl
|
---|
[3594] | 65 | <<" -o root_name_out : root string for output file name (def: cmvobserv3d)"<<endl
|
---|
[3200] | 66 | <<" -V : compute variance from real space (for check, default: no)"<<endl
|
---|
[3281] | 67 | <<" -T nth : nombre de threads (si compil multi-thread, default: 0)"<<endl
|
---|
[3115] | 68 | <<endl;
|
---|
[3349] | 69 | ////<<" -A <log10(S_agn in Jy at 1.4 GHz)>,sigma,powlaw :"<<endl
|
---|
| 70 | ////<<" AGN mean and sigma gaussian equiv. distrib. for solid angle of centeral pixel"<<endl
|
---|
| 71 | ////<<" powlaw: apply S_agn evolution as (Nu/1.4)^powlaw"<<endl
|
---|
[3115] | 72 | }
|
---|
| 73 |
|
---|
| 74 | int main(int narg,char *arg[])
|
---|
| 75 | {
|
---|
[3615] | 76 | SophyaInit();
|
---|
[3115] | 77 | InitTim();
|
---|
| 78 |
|
---|
| 79 | //-----------------------------------------------------------------
|
---|
| 80 | // *** Survey definition
|
---|
[3129] | 81 | long nx=360, ny=-1, nz=64; double dx=1., dy=-1., dz=-1.;
|
---|
| 82 | //long nx=1000, ny=-1, nz=128; double dx=3., dy=-1., dz=6.;
|
---|
| 83 | //long nx=1200, ny=-1, nz=128; double dx=1., dy=-1., dz=3;
|
---|
[3115] | 84 |
|
---|
| 85 | // *** Cosmography definition (WMAP)
|
---|
[3157] | 86 | unsigned short flat = 0;
|
---|
[3115] | 87 | double ob0 = 0.0444356;
|
---|
| 88 | double h100=0.71, om0=0.267804, or0=7.9e-05, ol0=0.73,w0=-1.;
|
---|
| 89 | double zref = 0.5;
|
---|
[3285] | 90 | double perc=0.01,dzinc=-1.,dzmax=-1.; unsigned short glorder=4;
|
---|
[3115] | 91 |
|
---|
| 92 | // *** Spectrum and variance definition
|
---|
| 93 | double ns = 1., as = 1.;
|
---|
| 94 | double R=8./h100, Rg=R/sqrt(5.);
|
---|
| 95 | double sigmaR = 1.;
|
---|
| 96 |
|
---|
| 97 | double kmin=1e-5,kmax=1000.;
|
---|
| 98 | int npt = 10000;
|
---|
| 99 | double lkmin=log10(kmin), lkmax=log10(kmax);
|
---|
| 100 | double eps=1.e-3;
|
---|
| 101 |
|
---|
| 102 | // *** Schechter mass function definition
|
---|
[3193] | 103 | double h75 = h100 / 0.75;
|
---|
| 104 | double nstar = 0.006*pow(h75,3.);
|
---|
[3343] | 105 | double mstar = pow(10.,9.8); // MSol
|
---|
[3115] | 106 | double alpha = -1.37;
|
---|
| 107 |
|
---|
[3344] | 108 | double schmin=1.e7, schmax=1.e13;
|
---|
[3322] | 109 | int schnpt = -100;
|
---|
| 110 | bool use_schmassdist = false;
|
---|
| 111 | long naleagal = 100000;
|
---|
| 112 | bool recompute_schmassdist = true;
|
---|
| 113 | string schmassdistfile = "";
|
---|
[3524] | 114 | int no_poisson_type = 0;
|
---|
[3115] | 115 |
|
---|
[3353] | 116 | double scalemass = -1.;
|
---|
[3351] | 117 |
|
---|
[3115] | 118 | // *** Niveau de bruit
|
---|
| 119 | double snoise= 0.; // en equivalent MSol
|
---|
[3331] | 120 | int noise_evol = 0;
|
---|
[3115] | 121 |
|
---|
[3349] | 122 | //// *** AGN
|
---|
| 123 | ////bool do_agn = false;
|
---|
| 124 | ////double lfjy_agn=-99., lsigma_agn=0.; // en Jy
|
---|
| 125 | ////double powlaw_agn = 0.;
|
---|
[3196] | 126 |
|
---|
[3115] | 127 | // *** type de generation
|
---|
| 128 | bool computefourier0=false;
|
---|
[3331] | 129 | int use_growth_factor = 0;
|
---|
[3281] | 130 | unsigned short nthread=0;
|
---|
[3289] | 131 | int filter_by_pixel = 1;
|
---|
[3115] | 132 |
|
---|
[3154] | 133 | // *** What to do
|
---|
| 134 | bool comp2dspec = false;
|
---|
| 135 | bool wfits = false;
|
---|
| 136 | bool wppf = false;
|
---|
[3281] | 137 | bool wslice = false;
|
---|
[3154] | 138 | bool compvarreal = false;
|
---|
[3583] | 139 | unsigned short whattowrt[5] = {1,1,1,1,1};
|
---|
[3594] | 140 | string rootnameout = "cmvobserv3d";
|
---|
[3583] | 141 |
|
---|
[3768] | 142 | // *** Number of entries in control NTuple
|
---|
[3524] | 143 | unsigned long ntnent = 10000; // 0 = do not fill NTuple
|
---|
[3154] | 144 |
|
---|
[3115] | 145 | // --- Decodage arguments
|
---|
[3262] | 146 | if(narg>0) {
|
---|
[3322] | 147 | cout<<"\n--- Arguments: "<<endl;
|
---|
[3262] | 148 | for(int i=0;i<narg;i++) cout<<arg[i]<<" ";
|
---|
| 149 | cout<<endl;
|
---|
| 150 | }
|
---|
[3590] | 151 | system("date -u");
|
---|
[3115] | 152 |
|
---|
[3615] | 153 | // --- Choix du generateur aleatoire (a faire ICI imperativement avant AutoInitRand)
|
---|
| 154 | FMTRandGen *RandGen = new FMTRandGen;
|
---|
| 155 | RandGen->SelectGaussianAlgo(C_Gaussian_RandLibSNorm);
|
---|
| 156 | RandGen->SelectPoissonAlgo(C_Poisson_Ahrens);
|
---|
| 157 | RandomGeneratorInterface::SetGlobalRandGenP(RandGen);
|
---|
| 158 |
|
---|
| 159 | // --- Decodage des arguments
|
---|
[3115] | 160 | char c;
|
---|
[3594] | 161 | while((c = getopt(narg,arg,"ha0PWSV2U:G:F:x:y:z:s:Z:M:A:T:N:Q:R:8:O:o:")) != -1) {
|
---|
[3281] | 162 | int nth = 0;
|
---|
[3115] | 163 | switch (c) {
|
---|
| 164 | case 'a' :
|
---|
[3615] | 165 | AutoInitRand(5);
|
---|
[3115] | 166 | break;
|
---|
| 167 | case '0' :
|
---|
| 168 | computefourier0 = true;
|
---|
| 169 | break;
|
---|
[3157] | 170 | case 'G' :
|
---|
[3331] | 171 | sscanf(optarg,"%d",&use_growth_factor);
|
---|
[3157] | 172 | break;
|
---|
[3329] | 173 | case 'U' :
|
---|
[3363] | 174 | sscanf(optarg,"%d",&no_poisson_type);
|
---|
[3329] | 175 | break;
|
---|
[3289] | 176 | case 'F' :
|
---|
| 177 | sscanf(optarg,"%d",&filter_by_pixel);
|
---|
| 178 | break;
|
---|
[3115] | 179 | case 'x' :
|
---|
[3129] | 180 | sscanf(optarg,"%ld,%lf",&nx,&dx);
|
---|
[3115] | 181 | break;
|
---|
| 182 | case 'y' :
|
---|
[3129] | 183 | sscanf(optarg,"%ld,%lf",&ny,&dy);
|
---|
[3115] | 184 | break;
|
---|
| 185 | case 'z' :
|
---|
[3129] | 186 | sscanf(optarg,"%ld,%lf",&nz,&dz);
|
---|
[3115] | 187 | break;
|
---|
| 188 | case 's' :
|
---|
[3331] | 189 | sscanf(optarg,"%lf,%d",&snoise,&noise_evol);
|
---|
[3115] | 190 | break;
|
---|
| 191 | case 'Z' :
|
---|
| 192 | sscanf(optarg,"%lf",&zref);
|
---|
| 193 | break;
|
---|
[3154] | 194 | case '2' :
|
---|
| 195 | comp2dspec = true;
|
---|
| 196 | break;
|
---|
[3322] | 197 | case 'N' :
|
---|
[3351] | 198 | sscanf(optarg,"%lf",&scalemass);
|
---|
| 199 | if(scalemass==0.) scalemass = 1.;
|
---|
[3322] | 200 | break;
|
---|
[3193] | 201 | case 'M' :
|
---|
| 202 | sscanf(optarg,"%lf,%lf,%d",&schmin,&schmax,&schnpt);
|
---|
| 203 | break;
|
---|
[3322] | 204 | case 'Q' :
|
---|
| 205 | use_schmassdist = true;
|
---|
| 206 | sscanf(optarg,"%ld",&naleagal);
|
---|
| 207 | break;
|
---|
| 208 | case 'R' :
|
---|
| 209 | schmassdistfile = optarg;
|
---|
| 210 | break;
|
---|
[3349] | 211 | //// case 'A' :
|
---|
| 212 | ////do_agn = true;
|
---|
| 213 | ////sscanf(optarg,"%lf,%lf,%lf",&lfjy_agn,&lsigma_agn,&powlaw_agn);
|
---|
| 214 | ////break;
|
---|
[3354] | 215 | case '8' :
|
---|
| 216 | sscanf(optarg,"%lf,%lf",&sigmaR,&R);
|
---|
| 217 | break;
|
---|
[3154] | 218 | case 'V' :
|
---|
| 219 | compvarreal = true;
|
---|
| 220 | break;
|
---|
| 221 | case 'W' :
|
---|
| 222 | wfits = true;
|
---|
| 223 | break;
|
---|
| 224 | case 'P' :
|
---|
| 225 | wppf = true;
|
---|
| 226 | break;
|
---|
[3583] | 227 | case 'O' :
|
---|
| 228 | sscanf(optarg,"%hu,%hu,%hu,%hu,%hu"
|
---|
| 229 | ,&whattowrt[0],&whattowrt[1],&whattowrt[2],&whattowrt[3],&whattowrt[4]);
|
---|
| 230 | break;
|
---|
[3281] | 231 | case 'S' :
|
---|
| 232 | wslice = true;
|
---|
| 233 | break;
|
---|
[3594] | 234 | case 'o' :
|
---|
| 235 | rootnameout = optarg;
|
---|
| 236 | break;
|
---|
[3281] | 237 | case 'T' :
|
---|
| 238 | sscanf(optarg,"%d",&nth);
|
---|
| 239 | nthread = (nth<1)? 0: nth;
|
---|
| 240 | break;
|
---|
[3115] | 241 | case 'h' :
|
---|
| 242 | default :
|
---|
| 243 | usage(); return -1;
|
---|
| 244 | }
|
---|
| 245 | }
|
---|
| 246 |
|
---|
[3746] | 247 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
| 248 | try {
|
---|
| 249 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
| 250 |
|
---|
[3322] | 251 | double lschmin=log10(schmin), lschmax=log10(schmax);
|
---|
| 252 | if(schnpt<=0) { // alors c'est un nombre de points par decade
|
---|
| 253 | schnpt = long( (-schnpt)*(lschmax-lschmin+1.) + 0.5 );
|
---|
| 254 | if(schnpt<=2) schnpt = 1000;
|
---|
| 255 | }
|
---|
| 256 | if(naleagal<=2) naleagal = 100000;
|
---|
[3193] | 257 |
|
---|
[3115] | 258 | cout<<"zref="<<zref<<endl;
|
---|
| 259 | cout<<"nx="<<nx<<" dx="<<dx<<" ny="<<ny<<" dy="<<dy<<" nz="<<nz<<" dz="<<dz<<endl;
|
---|
| 260 | cout<<"kmin="<<kmin<<" ("<<lkmin<<"), kmax="<<kmax<<" ("<<lkmax<<") Mpc^-1"
|
---|
| 261 | <<", npt="<<npt<<endl;
|
---|
[3289] | 262 | cout<<"Filter by pixel = "<<filter_by_pixel<<endl;
|
---|
[3115] | 263 | cout<<"R="<<R<<" Rg="<<Rg<<" Mpc, sigmaR="<<sigmaR<<endl;
|
---|
[3331] | 264 | cout<<"Use_growth_factor = "<<use_growth_factor<<endl;
|
---|
[3246] | 265 | cout<<"nstar= "<<nstar<<" mstar="<<mstar<<" alpha="<<alpha<<endl;
|
---|
[3115] | 266 | cout<<"schmin="<<schmin<<" ("<<lschmin
|
---|
| 267 | <<"), schmax="<<schmax<<" ("<<lschmax<<") Msol"
|
---|
| 268 | <<", schnpt="<<schnpt<<endl;
|
---|
[3524] | 269 | if(no_poisson_type!=0) cout<<"No poisson fluctuation, direct conversion to HI mass, typ="
|
---|
| 270 | <<no_poisson_type<<endl;
|
---|
[3331] | 271 | cout<<"snoise="<<snoise<<" equivalent Msol, evolution="<<noise_evol<<endl;
|
---|
[3351] | 272 | cout<<"scalemass="<<scalemass<<endl;
|
---|
[3349] | 273 | ////if(do_agn)
|
---|
| 274 | //// cout<<"AGN: <log10(Jy)>="<<lfjy_agn<<" , sigma="<<lsigma_agn
|
---|
| 275 | //// <<" , powlaw="<<powlaw_agn<<endl;
|
---|
[3583] | 276 | cout<<"wfits="<<wfits<<" wppf="<<wppf<<" wslice="<<wslice<<" what?="
|
---|
| 277 | <<whattowrt[0]<<","<<whattowrt[1]<<","<<whattowrt[2]<<","<<whattowrt[3]<<","
|
---|
| 278 | <<whattowrt[4]<<endl;
|
---|
[3594] | 279 | cout<<"rootnameout="<<rootnameout<<endl;
|
---|
[3615] | 280 | ShowRandom();
|
---|
| 281 | cout<<" First random is: "<<drand01()<<endl;
|
---|
[3115] | 282 |
|
---|
[3594] | 283 | string tagobs = rootnameout + ".ppf";
|
---|
[3322] | 284 | POutPersist posobs(tagobs);
|
---|
| 285 |
|
---|
[3115] | 286 | //-----------------------------------------------------------------
|
---|
[3157] | 287 | cout<<endl<<"\n--- Create Cosmology"<<endl;
|
---|
[3115] | 288 |
|
---|
[3157] | 289 | CosmoCalc univ(flat,true,zref+1.);
|
---|
| 290 | univ.SetInteg(perc,dzinc,dzmax,glorder);
|
---|
| 291 | univ.SetDynParam(h100,om0,or0,ol0,w0);
|
---|
[3285] | 292 | univ.PrtInteg();
|
---|
[3157] | 293 | univ.Print();
|
---|
| 294 | double loscomref = univ.Dloscom(zref);
|
---|
[3193] | 295 | cout<<"\nzref = "<<zref<<" -> dloscom = "<<loscomref<<" Mpc"<<endl;
|
---|
| 296 | univ.Print(zref);
|
---|
[3157] | 297 |
|
---|
| 298 | //-----------------------------------------------------------------
|
---|
[3193] | 299 | cout<<endl<<"\n--- Create Spectrum"<<endl;
|
---|
[3157] | 300 |
|
---|
[3115] | 301 | InitialSpectrum pkini(ns,as);
|
---|
| 302 |
|
---|
| 303 | TransfertEisenstein tf(h100,om0-ob0,ob0,T_CMB_Par,false);
|
---|
| 304 | //tf.SetNoOscEnv(2);
|
---|
| 305 |
|
---|
[3157] | 306 | GrowthFactor growth(om0,ol0);
|
---|
[3193] | 307 | // GrowthFactor growth(1.,0.); // D(z) = 1/(1+z)
|
---|
[3283] | 308 | double growth_at_z = growth(zref);
|
---|
| 309 | cout<<"...Growth factor at z="<<zref<<" = "<<growth_at_z<<endl;
|
---|
[3115] | 310 |
|
---|
| 311 | PkSpectrum0 pk0(pkini,tf);
|
---|
| 312 |
|
---|
[3157] | 313 | PkSpectrumZ pkz(pk0,growth,zref);
|
---|
[3193] | 314 |
|
---|
[3115] | 315 | //-----------------------------------------------------------------
|
---|
| 316 | pkz.SetZ(0.);
|
---|
| 317 | cout<<endl<<"\n--- Compute variance for top-hat R="<<R
|
---|
| 318 | <<" at z="<<pkz.GetZ()<<endl;
|
---|
[3349] | 319 | VarianceSpectrum varpk_th(pkz,R,VarianceSpectrum::TOPHAT);
|
---|
| 320 | double kfind_th = varpk_th.FindMaximum(kmin,kmax,eps);
|
---|
[3115] | 321 | double pkmax_th = varpk_th(kfind_th);
|
---|
| 322 | cout<<"kfind_th = "<<kfind_th<<" ("<<log10(kfind_th)<<"), integrand="<<pkmax_th<<endl;
|
---|
| 323 | double k1=kmin, k2=kmax;
|
---|
[3349] | 324 | int rc = varpk_th.FindLimits(pkmax_th/1.e4,k1,k2,eps);
|
---|
[3115] | 325 | cout<<"limit_th: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "
|
---|
| 326 | <<k2<<" ("<<log10(k2)<<")"<<endl;
|
---|
| 327 |
|
---|
| 328 | double ldlk = (log10(k2)-log10(k1))/npt;
|
---|
| 329 | varpk_th.SetInteg(0.01,ldlk,-1.,4);
|
---|
[3349] | 330 | double sr2 = varpk_th.Variance(k1,k2);
|
---|
[3115] | 331 | cout<<"varpk_th="<<sr2<<" -> sigma="<<sqrt(sr2)<<endl;
|
---|
| 332 |
|
---|
| 333 | double normpkz = sigmaR*sigmaR/sr2;
|
---|
| 334 | pkz.SetScale(normpkz);
|
---|
| 335 | cout<<"Spectrum normalisation = "<<pkz.GetScale()<<endl;
|
---|
| 336 |
|
---|
[3363] | 337 | {
|
---|
| 338 | Histo hpkz0(lkmin,lkmax,npt); hpkz0.ReCenterBin();
|
---|
| 339 | FuncToHisto(pkz,hpkz0,true);
|
---|
| 340 | tagobs = "hpkz0"; posobs.PutObject(hpkz0,tagobs);
|
---|
| 341 | }
|
---|
| 342 |
|
---|
[3115] | 343 | pkz.SetZ(zref);
|
---|
| 344 |
|
---|
[3363] | 345 | {
|
---|
[3120] | 346 | Histo hpkz(lkmin,lkmax,npt); hpkz.ReCenterBin();
|
---|
[3115] | 347 | FuncToHisto(pkz,hpkz,true);
|
---|
| 348 | tagobs = "hpkz"; posobs.PutObject(hpkz,tagobs);
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | //-----------------------------------------------------------------
|
---|
| 352 | cout<<endl<<"\n--- Compute variance for Pk at z="<<pkz.GetZ()<<endl;
|
---|
[3349] | 353 | VarianceSpectrum varpk_int(pkz,R,VarianceSpectrum::NOFILTER);
|
---|
[3115] | 354 |
|
---|
[3349] | 355 | double kfind_int = varpk_int.FindMaximum(kmin,kmax,eps);
|
---|
[3115] | 356 | double pkmax_int = varpk_int(kfind_int);
|
---|
| 357 | cout<<"kfind_int = "<<kfind_int<<" ("<<log10(kfind_int)<<"), integrand="<<pkmax_int<<endl;
|
---|
| 358 | double k1int=kmin, k2int=kmax;
|
---|
[3349] | 359 | int rcint = varpk_int.FindLimits(pkmax_int/1.e4,k1int,k2int,eps);
|
---|
[3115] | 360 | cout<<"limit_int: rc="<<rcint<<" : "<<k1int<<" ("<<log10(k1int)<<") , "
|
---|
| 361 | <<k2int<<" ("<<log10(k2int)<<")"<<endl;
|
---|
| 362 |
|
---|
| 363 | double ldlkint = (log10(k2int)-log10(k1int))/npt;
|
---|
| 364 | varpk_int.SetInteg(0.01,ldlkint,-1.,4);
|
---|
[3349] | 365 | double sr2int = varpk_int.Variance(k1int,k2int);
|
---|
[3115] | 366 | cout<<"varpk_int="<<sr2int<<" -> sigma="<<sqrt(sr2int)<<endl;
|
---|
[3322] | 367 |
|
---|
[3115] | 368 | //-----------------------------------------------------------------
|
---|
[3322] | 369 | cout<<endl<<"\n--- Create mass function, compute number/mass density, init mass trials"<<endl;
|
---|
[3115] | 370 |
|
---|
[3322] | 371 | Schechter sch(nstar,mstar,alpha);
|
---|
| 372 | sch.Print();
|
---|
| 373 |
|
---|
[3115] | 374 | sch.SetOutValue(0);
|
---|
| 375 | cout<<"sch(mstar) = "<<sch(mstar)<<" /Mpc^3/Msol"<<endl;
|
---|
[3322] | 376 | double ngal_by_mpc3 = sch.Integrate(schmin,schmax,schnpt);
|
---|
[3115] | 377 | cout<<"Galaxy density number = "<<ngal_by_mpc3<<" /Mpc^3 between limits"<<endl;
|
---|
| 378 |
|
---|
| 379 | sch.SetOutValue(1);
|
---|
| 380 | cout<<"mstar*sch(mstar) = "<<sch(mstar)<<" Msol/Mpc^3/Msol"<<endl;
|
---|
[3322] | 381 | double mass_by_mpc3 = sch.Integrate(schmin,schmax,schnpt);
|
---|
[3115] | 382 | cout<<"Galaxy mass density= "<<mass_by_mpc3<<" Msol/Mpc^3 between limits"<<endl;
|
---|
[3193] | 383 | cout<<"Omega_HI at z=0 is "<<mass_by_mpc3/(univ.Rhoc(0.)*GCm3toMsolMpc3_Cst)<<endl
|
---|
| 384 | <<" at z="<<zref<<" is "<<mass_by_mpc3/(univ.Rhoc(zref)*GCm3toMsolMpc3_Cst)<<endl;
|
---|
[3115] | 385 |
|
---|
[3322] | 386 | SchechterMassDist schmdist(sch,schmin,schmax,schnpt);
|
---|
| 387 | if(use_schmassdist && schmassdistfile.size()>0) {
|
---|
[3345] | 388 | cout<<"\nSchechterMassDist read from "<<schmassdistfile<<endl;
|
---|
[3322] | 389 | schmdist.ReadPPF(schmassdistfile);
|
---|
[3345] | 390 | bool compsch = IsCompatible(sch,schmdist.GetSchechter());
|
---|
| 391 | double m1,m2; schmdist.GetMassLim(m1,m2);
|
---|
| 392 | if( !compsch || fabs(m1-schmin)>1e-4*schmin || fabs(m2-schmax)>1e-4*schmax) {
|
---|
| 393 | cout<<"FATAL_ERROR: INCONSISTENT SchechterMassDist file / Schechter or limits"<<endl;
|
---|
| 394 | cout<<"Schechter:"<<endl; sch.Print();
|
---|
| 395 | cout<<"schmin="<<schmin<<" schmax="<<schmax<<endl;
|
---|
| 396 | cout<<"SchechterMassDist:"<<endl; schmdist.Print();
|
---|
| 397 | return -10;
|
---|
| 398 | }
|
---|
[3323] | 399 | recompute_schmassdist = false;
|
---|
[3322] | 400 | }
|
---|
| 401 | schmdist.Print();
|
---|
| 402 | Histo hmdndm = schmdist.GetHmDnDm();
|
---|
| 403 | FunRan tirhmdndm = schmdist.GetTmDnDm();
|
---|
| 404 | {
|
---|
| 405 | tagobs = "hmdndm"; posobs.PutObject(hmdndm,tagobs);
|
---|
| 406 | Histo hdum1(tirhmdndm);
|
---|
| 407 | tagobs = "tirhmdndm"; posobs.PutObject(hdum1,tagobs);
|
---|
| 408 | }
|
---|
| 409 |
|
---|
[3155] | 410 | PrtTim(">>>> End of definition");
|
---|
| 411 |
|
---|
[3115] | 412 | //-----------------------------------------------------------------
|
---|
| 413 | // FFTW3 (p26): faster if sizes 2^a 3^b 5^c 7^d 11^e 13^f with e+f=0 ou 1
|
---|
[3155] | 414 | cout<<endl<<"\n--- Initialisation de GeneFluct3D"<<endl;
|
---|
[3115] | 415 |
|
---|
[3349] | 416 | GeneFluct3D fluct3d(nx,ny,nz,dx,dy,dz,nthread,2);
|
---|
[3157] | 417 | fluct3d.SetCosmology(univ);
|
---|
| 418 | fluct3d.SetGrowthFactor(growth);
|
---|
[3768] | 419 | fluct3d.SetObservator(zref,-nz/2.);
|
---|
[3199] | 420 | fluct3d.LosComRedshift(0.001,-1);
|
---|
[3583] | 421 | //TArray< complex<GEN3D_TYPE> >& pkgen = fluct3d.GetComplexArray();
|
---|
| 422 | //TArray<GEN3D_TYPE>& rgen = fluct3d.GetRealArray();
|
---|
[3157] | 423 | cout<<endl; fluct3d.Print();
|
---|
[3322] | 424 | cout<<"\nMean number of galaxies per pixel = "<<ngal_by_mpc3*fluct3d.GetDVol()<<endl;
|
---|
[3351] | 425 | double mass_by_pixel = mass_by_mpc3 * fluct3d.GetDVol();
|
---|
| 426 | cout<<"Mean mass per pixel = "<<mass_by_pixel<<endl;
|
---|
[3141] | 427 |
|
---|
| 428 | double dkmin = fluct3d.GetKincMin();
|
---|
[3115] | 429 | double knyqmax = fluct3d.GetKmax();
|
---|
[3141] | 430 | long nherr = long(knyqmax/dkmin+0.5);
|
---|
[3322] | 431 | cout<<"\nFor HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl;
|
---|
[3115] | 432 |
|
---|
[3141] | 433 | double dktmin = fluct3d.GetKTincMin();
|
---|
| 434 | double ktnyqmax = fluct3d.GetKTmax();
|
---|
| 435 | long nherrt = long(ktnyqmax/dktmin+0.5);
|
---|
| 436 | double dkzmin = fluct3d.GetKinc()[2];
|
---|
| 437 | double kznyqmax = fluct3d.GetKnyq()[2];
|
---|
| 438 | long nherrz = long(kznyqmax/dkzmin+0.5);
|
---|
| 439 | cout<<"For Histo2DErr: d="<<dktmin<<","<<dkzmin
|
---|
| 440 | <<" max="<<ktnyqmax<<","<<kznyqmax<<" n="<<nherrt<<","<<nherrz<<endl;
|
---|
| 441 |
|
---|
[3157] | 442 | //-----------------------------------------------------------------
|
---|
[3115] | 443 | cout<<"\n--- Computing spectra variance up to Kmax at z="<<pkz.GetZ()<<endl;
|
---|
| 444 | // En fait on travaille sur un cube inscrit dans la sphere de rayon kmax:
|
---|
| 445 | // sphere: Vs = 4Pi/3 k^3 , cube inscrit (cote k*sqrt(2)): Vc = (k*sqrt(2))^3
|
---|
| 446 | // Vc/Vs = 0.675 -> keff = kmax * (0.675)^(1/3) = kmax * 0.877
|
---|
[3141] | 447 | double knyqmax_mod = 0.877*knyqmax;
|
---|
| 448 | ldlkint = (log10(knyqmax_mod)-log10(k1int))/npt;
|
---|
[3115] | 449 | varpk_int.SetInteg(0.01,ldlkint,-1.,4);
|
---|
[3349] | 450 | double sr2int_kmax = varpk_int.Variance(k1int,knyqmax_mod);
|
---|
[3141] | 451 | cout<<"varpk_int(<"<<knyqmax_mod<<")="<<sr2int_kmax<<" -> sigma="<<sqrt(sr2int_kmax)<<endl;
|
---|
[3115] | 452 |
|
---|
[3155] | 453 | PrtTim(">>>> End Initialisation de GeneFluct3D");
|
---|
| 454 |
|
---|
[3157] | 455 | //-----------------------------------------------------------------
|
---|
[3115] | 456 | cout<<"\n--- Computing a realization in Fourier space"<<endl;
|
---|
[3331] | 457 | if(use_growth_factor>0) pkz.SetZ(0.); else pkz.SetZ(zref);
|
---|
[3157] | 458 | cout<<"Power spectrum set at redshift: "<<pkz.GetZ()<<endl;
|
---|
[3141] | 459 | if(computefourier0) fluct3d.ComputeFourier0(pkz);
|
---|
| 460 | else fluct3d.ComputeFourier(pkz);
|
---|
[3524] | 461 | fluct3d.NTupleCheck(posobs,string("ntpkgen"),ntnent);
|
---|
[3155] | 462 | PrtTim(">>>> End Computing a realization in Fourier space");
|
---|
[3115] | 463 |
|
---|
[3289] | 464 | cout<<"\n--- Checking realization spectra"<<endl;
|
---|
| 465 | HistoErr hpkgen(0.,knyqmax,nherr);
|
---|
| 466 | hpkgen.ReCenterBin(); hpkgen.Zero();
|
---|
| 467 | hpkgen.Show();
|
---|
| 468 | fluct3d.ComputeSpectrum(hpkgen);
|
---|
| 469 | {
|
---|
| 470 | tagobs = "hpkgen"; posobs.PutObject(hpkgen,tagobs);
|
---|
[3115] | 471 | }
|
---|
[3289] | 472 | PrtTim(">>>> End Checking realization spectra");
|
---|
[3115] | 473 |
|
---|
[3154] | 474 | if(comp2dspec) {
|
---|
[3141] | 475 | cout<<"\n--- Checking realization 2D spectra"<<endl;
|
---|
| 476 | Histo2DErr hpkgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 477 | hpkgen2.ReCenterBin(); hpkgen2.Zero();
|
---|
| 478 | hpkgen2.Show();
|
---|
| 479 | fluct3d.ComputeSpectrum2D(hpkgen2);
|
---|
| 480 | {
|
---|
| 481 | tagobs = "hpkgen2"; posobs.PutObject(hpkgen2,tagobs);
|
---|
| 482 | }
|
---|
[3155] | 483 | PrtTim(">>>> End Checking realization 2D spectra");
|
---|
[3141] | 484 | }
|
---|
| 485 |
|
---|
[3289] | 486 | if(filter_by_pixel!=0) {
|
---|
[3115] | 487 | cout<<"\n--- Computing convolution by pixel shape"<<endl;
|
---|
| 488 | fluct3d.FilterByPixel();
|
---|
[3524] | 489 | fluct3d.NTupleCheck(posobs,string("ntpkgenf"),ntnent);
|
---|
[3155] | 490 | PrtTim(">>>> End Computing convolution by pixel shape");
|
---|
[3115] | 491 |
|
---|
| 492 | cout<<"\n--- Checking realization spectra after pixel shape convol."<<endl;
|
---|
[3330] | 493 | HistoErr hpkgenfb(0.,knyqmax,nherr);
|
---|
| 494 | hpkgenfb.ReCenterBin(); hpkgenfb.Zero();
|
---|
| 495 | hpkgenfb.Show();
|
---|
| 496 | fluct3d.ComputeSpectrum(hpkgenfb);
|
---|
[3115] | 497 | {
|
---|
[3330] | 498 | tagobs = "hpkgenfb"; posobs.PutObject(hpkgenfb,tagobs);
|
---|
[3115] | 499 | }
|
---|
[3155] | 500 | PrtTim(">>>> End Checking realization spectra");
|
---|
[3115] | 501 |
|
---|
[3330] | 502 | cout<<"\n--- Checking realization spectra after pixel shape convol. with pixel correc."<<endl;
|
---|
| 503 | HistoErr hpkgenf(hpkgenfb); hpkgenf.Zero();
|
---|
| 504 | fluct3d.ComputeSpectrum(hpkgenf,0.,filter_by_pixel);
|
---|
| 505 | {
|
---|
| 506 | tagobs = "hpkgenf"; posobs.PutObject(hpkgenf,tagobs);
|
---|
| 507 | }
|
---|
| 508 | PrtTim(">>>> End Checking realization spectra with pixel correc.");
|
---|
| 509 |
|
---|
[3289] | 510 | if(comp2dspec) {
|
---|
| 511 | cout<<"\n--- Checking realization 2D spectra after pixel shape convol."<<endl;
|
---|
[3330] | 512 | Histo2DErr hpkgenfb2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 513 | hpkgenfb2.ReCenterBin(); hpkgenfb2.Zero();
|
---|
| 514 | hpkgenfb2.Show();
|
---|
| 515 | fluct3d.ComputeSpectrum2D(hpkgenfb2);
|
---|
[3289] | 516 | {
|
---|
[3330] | 517 | tagobs = "hpkgenfb2"; posobs.PutObject(hpkgenfb2,tagobs);
|
---|
| 518 | }
|
---|
| 519 | PrtTim(">>>> End Checking realization 2D spectra");
|
---|
| 520 |
|
---|
| 521 | cout<<"\n--- Checking realization 2D spectra after pixel shape convol. with pixel correc."<<endl;
|
---|
| 522 | Histo2DErr hpkgenf2(hpkgenfb2); hpkgenf2.Zero();
|
---|
| 523 | fluct3d.ComputeSpectrum2D(hpkgenf2,0.,filter_by_pixel);
|
---|
| 524 | {
|
---|
[3289] | 525 | tagobs = "hpkgenf2"; posobs.PutObject(hpkgenf2,tagobs);
|
---|
| 526 | }
|
---|
[3330] | 527 | PrtTim(">>>> End Checking realization 2D spectra with pixel correc.");
|
---|
[3141] | 528 | }
|
---|
[3115] | 529 | }
|
---|
| 530 |
|
---|
[3583] | 531 | if(whattowrt[0]==1) {
|
---|
[3289] | 532 | if(wfits) {
|
---|
[3594] | 533 | tagobs = "!" + rootnameout + "_k0.fits";
|
---|
| 534 | fluct3d.WriteFits(tagobs);
|
---|
[3289] | 535 | PrtTim(">>>> End WriteFits");
|
---|
| 536 | }
|
---|
| 537 | if(wppf) {
|
---|
[3594] | 538 | tagobs = rootnameout + "_k0.ppf";
|
---|
| 539 | fluct3d.WritePPF(tagobs,false);
|
---|
[3289] | 540 | PrtTim(">>>> End WritePPF");
|
---|
| 541 | }
|
---|
[3583] | 542 | }
|
---|
[3289] | 543 |
|
---|
[3157] | 544 | //-----------------------------------------------------------------
|
---|
[3115] | 545 | cout<<"\n--- Computing a realization in real space"<<endl;
|
---|
| 546 | fluct3d.ComputeReal();
|
---|
[3322] | 547 | double rmin,rmax; fluct3d.MinMax(rmin,rmax);
|
---|
[3115] | 548 | cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
|
---|
[3524] | 549 | fluct3d.NTupleCheck(posobs,string("ntreal"),ntnent);
|
---|
[3157] | 550 | PrtTim(">>>> End Computing a realization in real space");
|
---|
[3115] | 551 |
|
---|
[3331] | 552 | if(use_growth_factor>0) {
|
---|
[3157] | 553 | cout<<"\n--- Apply Growth factor"<<endl;
|
---|
| 554 | cout<<"...D(z=0)="<<growth(0.)<<" D(z="<<zref<<")="<<growth(zref)<<endl;
|
---|
[3331] | 555 | fluct3d.ApplyGrowthFactor(use_growth_factor);
|
---|
[3322] | 556 | fluct3d.MinMax(rmin,rmax);
|
---|
[3157] | 557 | cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
|
---|
[3524] | 558 | fluct3d.NTupleCheck(posobs,string("ntgrow"),ntnent);
|
---|
[3157] | 559 | PrtTim(">>>> End Applying growth factor");
|
---|
| 560 | }
|
---|
| 561 |
|
---|
[3322] | 562 | int_8 nm;
|
---|
| 563 | double rmref,rs2ref;
|
---|
| 564 | cout<<"\n--- Computing reference variance in real space"<<endl;
|
---|
| 565 | nm = fluct3d.MeanSigma2(rmref,rs2ref);
|
---|
| 566 | cout<<" rs2ref= "<<rs2ref<<" , rmref="<<rmref<<" ("<<nm<<")"<<endl;
|
---|
| 567 | PrtTim(">>>> End Computing reference variance in real space");
|
---|
[3289] | 568 |
|
---|
[3583] | 569 | if(whattowrt[1]==1) {
|
---|
[3155] | 570 | if(wfits) {
|
---|
[3594] | 571 | tagobs = "!" + rootnameout + "_r0.fits";
|
---|
| 572 | fluct3d.WriteFits(tagobs);
|
---|
[3155] | 573 | PrtTim(">>>> End WriteFits");
|
---|
| 574 | }
|
---|
| 575 | if(wppf) {
|
---|
[3594] | 576 | tagobs = rootnameout + "_r0.ppf";
|
---|
| 577 | fluct3d.WritePPF(tagobs,true);
|
---|
[3155] | 578 | PrtTim(">>>> End WritePPF");
|
---|
| 579 | }
|
---|
[3281] | 580 | if(wslice) {
|
---|
[3594] | 581 | tagobs = rootnameout + "_s_r0.ppf";
|
---|
| 582 | fluct3d.WriteSlicePPF(tagobs);
|
---|
[3281] | 583 | PrtTim(">>>> End WriteSlicePPF");
|
---|
| 584 | }
|
---|
[3583] | 585 | }
|
---|
[3115] | 586 |
|
---|
[3289] | 587 | cout<<"\n--- Check mean and variance in real space"<<endl;
|
---|
| 588 | fluct3d.NumberOfBad(-1.,1e+200);
|
---|
[3322] | 589 | double rm,rs2;
|
---|
[3289] | 590 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
| 591 | PrtTim(">>>> End Check mean and variance in real space");
|
---|
[3141] | 592 |
|
---|
[3154] | 593 | if(compvarreal) {
|
---|
[3115] | 594 | cout<<"\n--- Check variance sigmaR in real space"<<endl;
|
---|
| 595 | double varr;
|
---|
[3262] | 596 | fluct3d.VarianceFrReal(R,varr);
|
---|
[3283] | 597 | cout<<"...Computed variance = "<<varr
|
---|
[3353] | 598 | <<" , Theorical variance at (z=0) = "<<pow(sigmaR,2.)
|
---|
| 599 | <<" , at (z="<<zref<<") = "<<pow(sigmaR*growth_at_z,2.)<<endl;
|
---|
[3155] | 600 | PrtTim(">>>> End Check variance sigmaR in real space");
|
---|
[3115] | 601 | }
|
---|
[3583] | 602 |
|
---|
[3115] | 603 | //-----------------------------------------------------------------
|
---|
[3524] | 604 | if(no_poisson_type!=0) {
|
---|
[3329] | 605 | cout<<"\n--- Converting !!!DIRECTLY!!! mass into HI mass: mass per pixel ="
|
---|
[3351] | 606 | <<mass_by_pixel<<endl;
|
---|
[3363] | 607 | if(no_poisson_type<0) {
|
---|
| 608 | cout<<"!!!WARNING!!! dRho/Rho is just multiplied by "<<mass_by_pixel<<endl;
|
---|
| 609 | fluct3d.ScaleOffset(mass_by_pixel);
|
---|
| 610 | } else {
|
---|
| 611 | rm = fluct3d.TurnFluct2MeanNumber(mass_by_mpc3); // ici on doit donner Msol/Mpc^3
|
---|
| 612 | }
|
---|
[3524] | 613 | fluct3d.NTupleCheck(posobs,string("ntmhi"),ntnent);
|
---|
[3329] | 614 | } else {
|
---|
| 615 | cout<<"\n--- Converting mass into galaxy number: gal per pixel ="
|
---|
| 616 | <<ngal_by_mpc3*fluct3d.GetDVol()<<endl;
|
---|
[3358] | 617 | rm = fluct3d.TurnFluct2MeanNumber(ngal_by_mpc3); // ici on doit donner Ngal/Mpc^3
|
---|
[3524] | 618 | fluct3d.NTupleCheck(posobs,string("ntmeang"),ntnent);
|
---|
[3349] | 619 | }
|
---|
| 620 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
|
---|
| 621 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
[3358] | 622 | if(rm>0.) cout<<"normalised sigma(dM/M) is "<<sqrt(rs2)/rm<<endl;
|
---|
[3349] | 623 | PrtTim(">>>> End Converting mass into galaxy number or mass");
|
---|
[3329] | 624 |
|
---|
[3524] | 625 | if( no_poisson_type==0 ) {
|
---|
[3329] | 626 |
|
---|
| 627 | cout<<"\n--- Apply poisson on galaxy number"<<endl;
|
---|
| 628 | fluct3d.ApplyPoisson();
|
---|
[3349] | 629 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
|
---|
| 630 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
[3329] | 631 | double xgalmin,xgalmax; fluct3d.MinMax(xgalmin,xgalmax,0.1,1.e50);
|
---|
[3524] | 632 | fluct3d.NTupleCheck(posobs,string("ntpois"),ntnent);
|
---|
[3329] | 633 | PrtTim(">>>> End Apply poisson on galaxy number");
|
---|
| 634 | if(wslice) {
|
---|
[3594] | 635 | tagobs = rootnameout + "_s_rn.ppf";
|
---|
| 636 | fluct3d.WriteSlicePPF(tagobs);
|
---|
[3329] | 637 | PrtTim(">>>> End WriteSlicePPF");
|
---|
[3322] | 638 | }
|
---|
[3329] | 639 |
|
---|
| 640 | cout<<"\n--- Convert Galaxy number to HI mass"<<endl;
|
---|
| 641 | double mhi = 0.;
|
---|
| 642 | if(use_schmassdist) {
|
---|
| 643 | if(recompute_schmassdist) {
|
---|
| 644 | int ngalmax = int(xgalmax+0.5);
|
---|
| 645 | schmdist.SetNgalLim(ngalmax,1,naleagal);
|
---|
| 646 | PrtTim(">>>> End creating tabulated histograms for trials");
|
---|
| 647 | }
|
---|
| 648 | mhi = fluct3d.TurnNGal2MassQuick(schmdist);
|
---|
| 649 | schmdist.PrintStatus();
|
---|
| 650 | } else {
|
---|
| 651 | mhi = fluct3d.TurnNGal2Mass(tirhmdndm,true);
|
---|
| 652 | }
|
---|
| 653 | cout<<mhi<<" MSol in survey / "<<mass_by_mpc3*fluct3d.GetVol()<<endl;
|
---|
[3349] | 654 | nm = fluct3d.MeanSigma2(rm,rs2,0.,1e200);
|
---|
[3329] | 655 | cout<<"Equivalent: "<<rm*nm/fluct3d.NPix()<<" Msol / pixels"<<endl;
|
---|
[3349] | 656 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
[3524] | 657 | fluct3d.NTupleCheck(posobs,string("ntmhi"),ntnent);
|
---|
[3329] | 658 | PrtTim(">>>> End Convert Galaxy number to HI mass");
|
---|
| 659 |
|
---|
[3115] | 660 | }
|
---|
| 661 |
|
---|
[3351] | 662 | //-----------------------------------------------------------------
|
---|
[3583] | 663 | if(whattowrt[2]==1) {
|
---|
[3155] | 664 | if(wfits) {
|
---|
[3594] | 665 | tagobs = "!" + rootnameout + "_r.fits";
|
---|
| 666 | fluct3d.WriteFits(tagobs);
|
---|
[3155] | 667 | PrtTim(">>>> End WriteFits");
|
---|
| 668 | }
|
---|
| 669 | if(wppf) {
|
---|
[3594] | 670 | tagobs = rootnameout + "_r.ppf";
|
---|
| 671 | fluct3d.WritePPF(tagobs,true);
|
---|
[3155] | 672 | PrtTim(">>>> End WritePPF");
|
---|
| 673 | }
|
---|
[3281] | 674 | if(wslice) {
|
---|
[3594] | 675 | tagobs = rootnameout + "_s_r.ppf";
|
---|
| 676 | fluct3d.WriteSlicePPF(tagobs);
|
---|
[3281] | 677 | PrtTim(">>>> End WriteSlicePPF");
|
---|
| 678 | }
|
---|
[3583] | 679 | }
|
---|
[3120] | 680 |
|
---|
[3329] | 681 | //-----------------------------------------------------------------
|
---|
[3349] | 682 | ////if(do_agn) {
|
---|
| 683 | //// cout<<"\n--- Add AGN: <log10(S Jy)>="<<lfjy_agn<<" , sigma="<<lsigma_agn
|
---|
| 684 | //// <<" , powlaw="<<powlaw_agn<<endl;
|
---|
| 685 | //// fluct3d.AddAGN(lfjy_agn,lsigma_agn,powlaw_agn);
|
---|
| 686 | //// nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
[3524] | 687 | //// fluct3d.NTupleCheck(posobs,string("ntagn"),ntnent);
|
---|
| 688 | //// PrtTim(">>>> End Add AGN");
|
---|
[3349] | 689 | ////}
|
---|
[3196] | 690 |
|
---|
[3329] | 691 | //-----------------------------------------------------------------
|
---|
[3330] | 692 | double snoisesave = 0.;
|
---|
[3193] | 693 | if(snoise>0.) {
|
---|
[3331] | 694 | cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<", evolution="<<noise_evol<<endl;
|
---|
| 695 | fluct3d.AddNoise2Real(snoise,noise_evol);
|
---|
[3330] | 696 | snoisesave = snoise;
|
---|
[3262] | 697 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
[3524] | 698 | fluct3d.NTupleCheck(posobs,string("ntnois"),ntnent);
|
---|
[3193] | 699 | PrtTim(">>>> End Add noise");
|
---|
| 700 | }
|
---|
[3115] | 701 |
|
---|
[3349] | 702 | //-----------------------------------------------------------------
|
---|
[3351] | 703 | if(scalemass!=0. && scalemass!=1.) { // Si scalemass==0 pas de normalisation
|
---|
| 704 | if(scalemass<0.) scalemass = 1. / (-scalemass * mass_by_pixel);
|
---|
| 705 | cout<<"\n--- Scale cube scale="<<scalemass<<endl;
|
---|
| 706 | fluct3d.ScaleOffset(scalemass);
|
---|
| 707 | snoisesave *= scalemass;
|
---|
[3322] | 708 | nm = fluct3d.MeanSigma2(rm,rs2);
|
---|
| 709 | PrtTim(">>>> End Scale cube");
|
---|
[3283] | 710 | }
|
---|
[3524] | 711 | fluct3d.NTupleCheck(posobs,string("ntfin"),ntnent);
|
---|
[3351] | 712 |
|
---|
| 713 | //-----------------------------------------------------------------
|
---|
[3583] | 714 | if(whattowrt[3]==1) {
|
---|
[3199] | 715 | if(wfits) {
|
---|
[3594] | 716 | tagobs = "!" + rootnameout + "_rf.fits";
|
---|
| 717 | fluct3d.WriteFits(tagobs);
|
---|
[3199] | 718 | PrtTim(">>>> End WriteFits");
|
---|
| 719 | }
|
---|
| 720 | if(wppf) {
|
---|
[3594] | 721 | tagobs = rootnameout + "_rf.ppf";
|
---|
| 722 | fluct3d.WritePPF(tagobs,true);
|
---|
[3199] | 723 | PrtTim(">>>> End WritePPF");
|
---|
| 724 | }
|
---|
[3281] | 725 | if(wslice) {
|
---|
[3594] | 726 | tagobs = rootnameout + "_s_rf.ppf";
|
---|
| 727 | fluct3d.WriteSlicePPF(tagobs);
|
---|
[3281] | 728 | PrtTim(">>>> End WriteSlicePPF");
|
---|
| 729 | }
|
---|
[3583] | 730 | }
|
---|
[3199] | 731 |
|
---|
[3115] | 732 | //-----------------------------------------------------------------
|
---|
| 733 | // -- NE PAS FAIRE CA SI ON VEUT CONTINUER LA SIMULATION -> d_rho/rho ecrase
|
---|
[3141] | 734 |
|
---|
[3289] | 735 | cout<<endl<<"\n--- ReComputing spectrum from real space"<<endl;
|
---|
| 736 | fluct3d.ReComputeFourier();
|
---|
[3524] | 737 | fluct3d.NTupleCheck(posobs,string("ntpkrec"),ntnent);
|
---|
[3289] | 738 | PrtTim(">>>> End ReComputing spectrum");
|
---|
[3141] | 739 |
|
---|
[3583] | 740 | if(whattowrt[4]==1) {
|
---|
[3155] | 741 | if(wfits) {
|
---|
[3594] | 742 | tagobs = "!" + rootnameout + "_k.fits";
|
---|
| 743 | fluct3d.WriteFits(tagobs);
|
---|
[3155] | 744 | PrtTim(">>>> End WriteFits");
|
---|
| 745 | }
|
---|
| 746 | if(wppf) {
|
---|
[3594] | 747 | tagobs = rootnameout + "_k.ppf";
|
---|
| 748 | fluct3d.WritePPF(tagobs,false);
|
---|
[3155] | 749 | PrtTim(">>>> End WritePPF");
|
---|
| 750 | }
|
---|
[3583] | 751 | }
|
---|
[3154] | 752 |
|
---|
[3289] | 753 | cout<<endl<<"\n--- Computing final spectrum"<<endl;
|
---|
[3330] | 754 | HistoErr hpkrecb(0.,knyqmax,nherr); hpkrecb.Zero();
|
---|
| 755 | hpkrecb.ReCenterBin();
|
---|
| 756 | hpkrecb.Show();
|
---|
| 757 | fluct3d.ComputeSpectrum(hpkrecb);
|
---|
| 758 | {
|
---|
| 759 | tagobs = "hpkrecb"; posobs.PutObject(hpkrecb,tagobs);
|
---|
| 760 | }
|
---|
[3289] | 761 | PrtTim(">>>> End Computing final spectrum");
|
---|
[3115] | 762 |
|
---|
[3330] | 763 | cout<<endl<<"\n--- Computing final spectrum with pixel deconv."<<endl;
|
---|
| 764 | HistoErr hpkrec(hpkrecb); hpkrec.Zero();
|
---|
| 765 | fluct3d.ComputeSpectrum(hpkrec,snoisesave,filter_by_pixel);
|
---|
| 766 | {
|
---|
| 767 | tagobs = "hpkrec"; posobs.PutObject(hpkrec,tagobs);
|
---|
| 768 | }
|
---|
| 769 | PrtTim(">>>> End Computing final spectrum with pixel deconv.");
|
---|
| 770 |
|
---|
[3154] | 771 | if(comp2dspec) {
|
---|
[3141] | 772 | cout<<"\n--- Computing final 2D spectrum"<<endl;
|
---|
[3330] | 773 | Histo2DErr hpkrecb2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz);
|
---|
| 774 | hpkrecb2.ReCenterBin(); hpkrecb2.Zero();
|
---|
| 775 | hpkrecb2.Show();
|
---|
| 776 | fluct3d.ComputeSpectrum2D(hpkrecb2);
|
---|
[3141] | 777 | {
|
---|
[3330] | 778 | tagobs = "hpkrecb2"; posobs.PutObject(hpkrecb2,tagobs);
|
---|
| 779 | }
|
---|
| 780 | PrtTim(">>>> End Computing final 2D spectrum");
|
---|
| 781 |
|
---|
| 782 | cout<<"\n--- Computing final 2D spectrum with pixel deconv."<<endl;
|
---|
| 783 | Histo2DErr hpkrec2(hpkrecb2); hpkrec2.Zero();
|
---|
| 784 | fluct3d.ComputeSpectrum2D(hpkrec2,snoisesave,filter_by_pixel);
|
---|
| 785 | {
|
---|
[3141] | 786 | tagobs = "hpkrec2"; posobs.PutObject(hpkrec2,tagobs);
|
---|
| 787 | }
|
---|
[3330] | 788 | PrtTim(">>>> End Computing final 2D spectrum with pixel deconv.");
|
---|
| 789 |
|
---|
[3141] | 790 | }
|
---|
| 791 |
|
---|
[3615] | 792 | //-----------------------------------------------------------------
|
---|
| 793 | delete RandGen;
|
---|
[3155] | 794 | PrtTim(">>>> End Of Job");
|
---|
[3615] | 795 |
|
---|
[3746] | 796 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
| 797 | } catch (PException& exc) {
|
---|
| 798 | cerr<<"cmvobserv3d.cc catched PException"<<exc.Msg()<<endl;
|
---|
| 799 | return 77;
|
---|
| 800 | } catch (std::exception& sex) {
|
---|
| 801 | cerr << "cmvobserv3d.cc std::exception :"
|
---|
| 802 | << (string)typeid(sex).name() << "\n msg= "
|
---|
| 803 | << sex.what() << endl;
|
---|
| 804 | return 78;
|
---|
| 805 | } catch (...) {
|
---|
| 806 | cerr << "cmvobserv3d.cc catched unknown (...) exception " << endl;
|
---|
| 807 | return 79;
|
---|
| 808 | }
|
---|
| 809 | //----TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH-TRY-CATCH
|
---|
| 810 |
|
---|
[3115] | 811 | return 0;
|
---|
| 812 | }
|
---|
| 813 |
|
---|