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