Changeset 3141 in Sophya for trunk/Cosmo/SimLSS
- Timestamp:
- Jan 17, 2007, 6:44:04 PM (19 years ago)
- Location:
- trunk/Cosmo/SimLSS
- Files:
-
- 1 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/Makefile
r3120 r3141 19 19 $(EXE)cmvtstsch $(EXE)cmvtstblack $(EXE)cmvtvarspec \ 20 20 $(EXE)cmvdefsurv $(EXE)cmvobserv3d $(EXE)cmvtintfun \ 21 $(EXE)cmvtpoisson $(EXE)cmvconch prof21 $(EXE)cmvtpoisson $(EXE)cmvconcherr 22 22 #$(EXE)cmvtluc 23 23 … … 26 26 $(OBJ)cmvtstsch.o $(OBJ)cmvtstblack.o $(OBJ)cmvtvarspec.o $(OBJ)cmvdefsurv.o \ 27 27 $(OBJ)cmvobserv3d.o $(OBJ)cmvtintfun.o \ 28 $(OBJ)cmvtpoisson.o $(OBJ)cmvconch prof.o $(OBJ)cmvtluc.o28 $(OBJ)cmvtpoisson.o $(OBJ)cmvconcherr.o $(OBJ)cmvtluc.o 29 29 30 30 LIBROBJ = \ … … 148 148 149 149 ############################################################################## 150 cmvconch prof: $(EXE)cmvconchprof150 cmvconcherr: $(EXE)cmvconcherr 151 151 echo $@ " done" 152 $(EXE)cmvconch prof: $(OBJ)cmvconchprof.o $(LIB)libcmvsimbao.a153 $(CXXLINK) $(CXXREP) -o $@ $(OBJ)cmvconch prof.o $(MYLIB)154 $(OBJ)cmvconch prof.o: cmvconchprof.cc155 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ cmvconch prof.cc152 $(EXE)cmvconcherr: $(OBJ)cmvconcherr.o $(LIB)libcmvsimbao.a 153 $(CXXLINK) $(CXXREP) -o $@ $(OBJ)cmvconcherr.o $(MYLIB) 154 $(OBJ)cmvconcherr.o: cmvconcherr.cc 155 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ cmvconcherr.cc 156 156 157 157 -
trunk/Cosmo/SimLSS/arrctcast.h
r3115 r3141 69 69 TArray<T> ArrCastC2R(TArray< complex<T> > & a) 70 70 { 71 T x ;71 T x = 0; 72 72 return ArrayCast(a, x); 73 73 } … … 78 78 TArray< complex<T> > ArrCastR2C(TArray< T > & a) 79 79 { 80 complex<T> x ;80 complex<T> x = 0; 81 81 // return ArrayCast< TArray< T > , complex<T> > (a, x); 82 82 return ArrayCast(a, x); … … 89 89 TArray<T> SDRealPart(TArray< complex<T> > & a) 90 90 { 91 T x ;91 T x = 0; 92 92 return ArrayCast(a, x, 0, 2); 93 93 } … … 98 98 TArray<T> SDImagPart(TArray< complex<T> > & a) 99 99 { 100 T x ;100 T x = 0; 101 101 return ArrayCast(a, x, 1, 2); 102 102 } -
trunk/Cosmo/SimLSS/cmvobserv3d.cc
r3134 r3141 10 10 #include "ntuple.h" 11 11 #include "matharr.h" 12 #include "srandgen.h"13 #include "perandom.h"14 #include "fabtwriter.h"15 16 #include "arrctcast.h"17 12 18 13 #include "constcosmo.h" … … 208 203 pkz.SetZ(zref); 209 204 TArray< complex<r_8> > pkgen; 210 GeneFluct3D fluct3d(pkgen ,pkz);205 GeneFluct3D fluct3d(pkgen); 211 206 fluct3d.SetNThread(nthread); 212 207 fluct3d.SetSize(nx,ny,nz,dx,dy,dz); 208 TArray<r_8>& rgen = fluct3d.GetRealArray(); 213 209 fluct3d.Print(); 210 211 double dkmin = fluct3d.GetKincMin(); 214 212 double knyqmax = fluct3d.GetKmax(); 215 double dkmin = fluct3d.GetKinc()[0]; 213 long nherr = long(knyqmax/dkmin+0.5); 214 cout<<"For HistoErr: d="<<dkmin<<" max="<<knyqmax<<" n="<<nherr<<endl; 215 216 double dktmin = fluct3d.GetKTincMin(); 217 double ktnyqmax = fluct3d.GetKTmax(); 218 long nherrt = long(ktnyqmax/dktmin+0.5); 219 double dkzmin = fluct3d.GetKinc()[2]; 220 double kznyqmax = fluct3d.GetKnyq()[2]; 221 long nherrz = long(kznyqmax/dkzmin+0.5); 222 cout<<"For Histo2DErr: d="<<dktmin<<","<<dkzmin 223 <<" max="<<ktnyqmax<<","<<kznyqmax<<" n="<<nherrt<<","<<nherrz<<endl; 216 224 217 225 cout<<"\n--- Computing spectra variance up to Kmax at z="<<pkz.GetZ()<<endl; … … 219 227 // sphere: Vs = 4Pi/3 k^3 , cube inscrit (cote k*sqrt(2)): Vc = (k*sqrt(2))^3 220 228 // Vc/Vs = 0.675 -> keff = kmax * (0.675)^(1/3) = kmax * 0.877 221 knyqmax *= 0.877;222 ldlkint = (log10(knyqmax )-log10(k1int))/npt;229 double knyqmax_mod = 0.877*knyqmax; 230 ldlkint = (log10(knyqmax_mod)-log10(k1int))/npt; 223 231 varpk_int.SetInteg(0.01,ldlkint,-1.,4); 224 double sr2int_kmax = varpk_int.Variance(R,k1int,knyqmax );225 cout<<"varpk_int(<"<<knyqmax <<")="<<sr2int_kmax<<" -> sigma="<<sqrt(sr2int_kmax)<<endl;232 double sr2int_kmax = varpk_int.Variance(R,k1int,knyqmax_mod); 233 cout<<"varpk_int(<"<<knyqmax_mod<<")="<<sr2int_kmax<<" -> sigma="<<sqrt(sr2int_kmax)<<endl; 226 234 227 235 cout<<"\n--- Computing a realization in Fourier space"<<endl; 228 if(computefourier0) fluct3d.ComputeFourier0(); 229 else fluct3d.ComputeFourier(); 230 231 cout<<"\n--- Checking realization spectra"<<endl; 232 long nhprof = long(fluct3d.GetKmax()/dkmin+0.5); 233 HProf hpkgen(0.,fluct3d.GetKmax(),nhprof); 234 hpkgen.ReCenterBin(); 235 fluct3d.ComputeSpectrum(hpkgen); 236 { 237 tagobs = "hpkgen"; posobs.PutObject(hpkgen,tagobs); 236 if(computefourier0) fluct3d.ComputeFourier0(pkz); 237 else fluct3d.ComputeFourier(pkz); 238 239 if(1) { 240 cout<<"\n--- Checking realization spectra"<<endl; 241 HistoErr hpkgen(0.,knyqmax,nherr); 242 hpkgen.ReCenterBin(); hpkgen.Zero(); 243 hpkgen.Show(); 244 fluct3d.ComputeSpectrum(hpkgen); 245 { 246 tagobs = "hpkgen"; posobs.PutObject(hpkgen,tagobs); 247 } 248 } 249 250 if(1) { 251 cout<<"\n--- Checking realization 2D spectra"<<endl; 252 Histo2DErr hpkgen2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); 253 hpkgen2.ReCenterBin(); hpkgen2.Zero(); 254 hpkgen2.Show(); 255 fluct3d.ComputeSpectrum2D(hpkgen2); 256 { 257 tagobs = "hpkgen2"; posobs.PutObject(hpkgen2,tagobs); 258 } 238 259 } 239 260 … … 241 262 cout<<"\n--- Computing convolution by pixel shape"<<endl; 242 263 fluct3d.FilterByPixel(); 243 264 } 265 266 if(1) fluct3d.WriteFits("!cmvobserv3d_k.fits"); 267 if(1) fluct3d.WritePPF("cmvobserv3d_k.ppf",false); 268 269 if(1) { 244 270 cout<<"\n--- Checking realization spectra after pixel shape convol."<<endl; 245 HProf hpkgenf(hpkgen); hpkgenf.Zero(); 271 HistoErr hpkgenf(0.,knyqmax,nherr); 272 hpkgenf.ReCenterBin(); hpkgenf.Zero(); 273 hpkgenf.Show(); 246 274 fluct3d.ComputeSpectrum(hpkgenf); 247 275 { … … 250 278 } 251 279 252 if(0) { 253 cout<<"\n--- Writing cmvobserv3dk.ppf"<<endl; 254 string tag = "cmvobserv3dk.ppf"; 255 POutPersist pos(tag); 256 tag = "pkgen"; pos.PutObject(pkgen,tag); 280 if(1) { 281 cout<<"\n--- Checking realization 2D spectra after pixel shape convol."<<endl; 282 Histo2DErr hpkgenf2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); 283 hpkgenf2.ReCenterBin(); hpkgenf2.Zero(); 284 hpkgenf2.Show(); 285 fluct3d.ComputeSpectrum2D(hpkgenf2); 286 { 287 tagobs = "hpkgenf2"; posobs.PutObject(hpkgenf2,tagobs); 288 } 257 289 } 258 290 259 291 cout<<"\n--- Computing a realization in real space"<<endl; 260 292 fluct3d.ComputeReal(); 261 r_8 undouble=0.;262 TArray<r_8> rgen = ArrayCast(pkgen,undouble);263 293 double rmin,rmax; rgen.MinMax(rmin,rmax); 264 294 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl; 265 295 266 cout<<"\n--- Check mean and variance in real space"<<endl; 267 int_8 nlowone = fluct3d.NumberOfBad(-1.,1e+200); 268 double rm,rs2; int_8 nm; 269 nm = fluct3d.MeanSigma2(rm,rs2); 270 cout<<"rgen:("<<nm<<") Mean = "<<rm<<", Sigma^2 = " 271 <<rs2<<" -> "<<sqrt(rs2)<<", n(<-1)="<<nlowone<<endl; 296 if(1) fluct3d.WriteFits("!cmvobserv3d_r0.fits"); 297 if(1) fluct3d.WritePPF("cmvobserv3d_r0.ppf",true); 298 299 int_8 nm; 300 double rm,rs2; 301 if(1) { 302 cout<<"\n--- Check mean and variance in real space"<<endl; 303 int_8 nlowone = fluct3d.NumberOfBad(-1.,1e+200); 304 nm = fluct3d.MeanSigma2(rm,rs2); 305 cout<<"rgen:("<<nm<<") Mean = "<<rm<<", Sigma^2 = " 306 <<rs2<<" -> "<<sqrt(rs2)<<", n(<-1)="<<nlowone<<endl; 307 } 272 308 273 309 if(1) { … … 331 367 <<rs2<<" -> "<<sqrt(rs2)<<endl; 332 368 333 if(1) { 334 cout<<"\n---Writing Cube to Fits file"<<endl; 335 FitsImg3DWriter fwrt("!cmvobserv3dr.fits",FLOAT_IMG,5); 336 fwrt.WriteKey("ZREF",zref," redshift"); 337 vector<long> n = fluct3d.GetNpix(); 338 fwrt.WriteKey("NX",n[0]," axe transverse 1"); 339 fwrt.WriteKey("NY",n[1]," axe transverse 2"); 340 fwrt.WriteKey("NZ",n[2]," axe longitudinal (redshift)"); 341 vector<r_8> d; 342 d = fluct3d.GetDinc(); 343 fwrt.WriteKey("DX",d[0]," Mpc"); 344 fwrt.WriteKey("DY",d[1]," Mpc"); 345 fwrt.WriteKey("DZ",d[2]," Mpc"); 346 d = fluct3d.GetKinc(); 347 fwrt.WriteKey("DKX",d[0]," Mpc^-1"); 348 fwrt.WriteKey("DKY",d[1]," Mpc^-1"); 349 fwrt.WriteKey("DKZ",d[2]," Mpc^-1"); 350 fwrt.WriteKey("SNOISE",snoise," Msol"); 351 fwrt.Write(rgen); 352 } 369 if(1) fluct3d.WriteFits("!cmvobserv3d_r.fits"); 370 if(1) fluct3d.WritePPF("cmvobserv3d_r.ppf",true); 353 371 354 372 cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<endl; … … 358 376 <<rs2<<" -> "<<sqrt(rs2)<<endl; 359 377 360 if(0) {361 cout<<"\n--- Writing cmvobserv3dr.ppf"<<endl;362 string tag = "cmvobserv3dr.ppf";363 POutPersist pos(tag);364 tag = "rgen"; pos.PutObject(rgen,tag);365 }366 367 378 //----------------------------------------------------------------- 368 379 // -- NE PAS FAIRE CA SI ON VEUT CONTINUER LA SIMULATION -> d_rho/rho ecrase 380 369 381 if(1) { 370 382 cout<<endl<<"\n--- ReComputing spectrum from real space"<<endl; 371 383 fluct3d.ReComputeFourier(); 372 HProf hpkrec(0.,fluct3d.GetKmax(),nhprof); 384 } 385 386 if(1) { 387 cout<<endl<<"\n--- Computing final spectrum"<<endl; 388 HistoErr hpkrec(0.,knyqmax,nherr); 373 389 hpkrec.ReCenterBin(); 390 hpkrec.Show(); 374 391 fluct3d.ComputeSpectrum(hpkrec); 375 392 tagobs = "hpkrec"; posobs.PutObject(hpkrec,tagobs); 376 393 } 377 394 395 if(1) { 396 cout<<"\n--- Computing final 2D spectrum"<<endl; 397 Histo2DErr hpkrec2(0.,ktnyqmax,nherrt,0.,kznyqmax,nherrz); 398 hpkrec2.ReCenterBin(); hpkrec2.Zero(); 399 hpkrec2.Show(); 400 fluct3d.ComputeSpectrum2D(hpkrec2); 401 { 402 tagobs = "hpkrec2"; posobs.PutObject(hpkrec2,tagobs); 403 } 404 } 405 378 406 return 0; 379 407 } 380 408 381 409 /* 382 openppf cmvobserv3dk.ppf 383 openppf cmvobserv3dr.ppf 410 ###################################################### 411 readfits cmvobserv3d_k.fits 412 readfits cmvobserv3d_r0.fits 413 readfits cmvobserv3d_r.fits 414 415 openppf cmvobserv3d_k.ppf 416 openppf cmvobserv3d_r0.ppf 417 openppf cmvobserv3d_r.ppf 418 419 # pour le plot 2D d'une slice en Z du 3D: to2d nom_obj3D num_slice 420 defscript to2d 421 objaoper $1 sliceyz $2 422 mv sliceyz_${2} ${1}_$2 423 disp ${1}_$2 424 echo display slice $2 of $1 425 endscript 426 427 to2d $cobj 0 428 429 ###################################################### 384 430 openppf cmvobserv3d.ppf 385 431 386 objaoper pkgen sliceyz 0 387 432 zone 388 433 n/plot hpkz.val%x ! ! "nsta connectpoints" 389 434 n/plot hpkgen.val%log10(x) x>0 ! "nsta same red connectpoints" … … 394 439 n/plot hpkz.val*$k*$k/(2*M_PI*M_PI)%x ! "connectpoints" 395 440 396 defscript rgensl 397 objaoper rgen sliceyz $1 398 disp sliceyz_$1 399 endscript 400 401 rgensl 0 402 441 zone 2 2 442 imag hpkgen2 443 imag hpkgenf2 444 imag hpkrec2 445 446 zone 403 447 disp hmdndm 404 448 disp tirhmdndm -
trunk/Cosmo/SimLSS/genefluct3d.cc
r3134 r3141 14 14 #include "srandgen.h" 15 15 16 #include "fabtcolread.h" 17 #include "fabtwriter.h" 18 #include "fioarr.h" 19 20 #include "arrctcast.h" 21 16 22 #include "constcosmo.h" 17 23 #include "integfunc.h" … … 25 31 26 32 //------------------------------------------------------- 27 GeneFluct3D::GeneFluct3D(TArray< complex<r_8 > >& T ,PkSpectrumZ& pkz)28 : T_(T) , pkz_(pkz)33 GeneFluct3D::GeneFluct3D(TArray< complex<r_8 > >& T) 34 : T_(T) , array_allocated_(false) 29 35 { 30 36 SetNThread(); 31 SetSize(1,-1,1,1.,-1.,1.);32 37 } 33 38 … … 44 49 void GeneFluct3D::SetSize(long nx,long ny,long nz,double dx,double dy,double dz) 45 50 { 46 if(nx<=0 || dx<=0. ) { 51 setsize(nx,ny,nz,dx,dy,dz); 52 setalloc(); 53 setpointers(false); 54 } 55 56 void GeneFluct3D::setsize(long nx,long ny,long nz,double dx,double dy,double dz) 57 { 58 if(nx<=0 || dx<=0.) { 47 59 cout<<"GeneFluct3D::SetSize_Error: bad value(s)"<<endl; 48 60 throw ParmError("GeneFluct3D::SetSize_Error: bad value(s)"); 49 61 } 50 62 51 Tcontent_ = 0; 52 53 // Les taille des tableaux 63 // Les tailles des tableaux 54 64 Nx_ = nx; 55 65 Ny_ = ny; if(Ny_ <= 0) Ny_ = Nx_; 56 66 Nz_ = nz; if(Nz_ <= 0) Nz_ = Nx_; 67 N_.resize(0); N_.push_back(Nx_); N_.push_back(Ny_); N_.push_back(Nz_); 57 68 NRtot_ = Nx_*Ny_*Nz_; // nombre de pixels dans le survey 58 69 NCz_ = Nz_/2 +1; 59 70 NTz_ = 2*NCz_; 60 SzK_[2] = Nx_; SzK_[1] = Ny_; SzK_[0] = NCz_; // a l'envers61 71 62 72 // le pas dans l'espace (Mpc) … … 64 74 Dy_ = dy; if(Dy_ <= 0.) Dy_ = Dx_; 65 75 Dz_ = dz; if(Dz_ <= 0.) Dz_ = Dx_; 76 D_.resize(0); D_.push_back(Dx_); D_.push_back(Dy_); D_.push_back(Dz_); 66 77 dVol_ = Dx_*Dy_*Dz_; 67 78 Vol_ = (Nx_*Dx_)*(Ny_*Dy_)*(Nz_*Dz_); … … 71 82 Dky_ = 2.*M_PI/(Ny_*Dy_); 72 83 Dkz_ = 2.*M_PI/(Nz_*Dz_); 84 Dk_.resize(0); Dk_.push_back(Dkx_); Dk_.push_back(Dky_); Dk_.push_back(Dkz_); 73 85 Dk3_ = Dkx_*Dky_*Dkz_; 74 86 … … 77 89 Knyqy_ = M_PI/Dy_; 78 90 Knyqz_ = M_PI/Dz_; 79 91 Knyq_.resize(0); Knyq_.push_back(Knyqx_); Knyq_.push_back(Knyqy_); Knyq_.push_back(Knyqz_); 92 } 93 94 void GeneFluct3D::setalloc(void) 95 { 96 // Dimensionnement du tableau complex<r_8> 97 // ATTENTION: TArray adresse en memoire a l'envers du C 98 // Tarray(n1,n2,n3) == Carray[n3][n2][n1] 99 sa_size_t SzK_[3] = {NCz_,Ny_,Nx_}; // a l'envers 100 try { 101 T_.ReSize(3,SzK_); 102 array_allocated_ = true; 103 } catch (...) { 104 cout<<"GeneFluct3D::SetSize_Error: Problem allocating T_"<<endl; 105 } 106 T_.SetMemoryMapping(BaseArray::CMemoryMapping); 107 } 108 109 void GeneFluct3D::setpointers(bool from_real) 110 { 111 if(from_real) T_ = ArrCastR2C(R_); 112 else R_ = ArrCastC2R(T_); 113 // On remplit les pointeurs 114 fdata_ = (fftw_complex *) (&T_(0,0,0)); 115 data_ = (double *) (&R_(0,0,0)); 116 } 117 118 void GeneFluct3D::check_array_alloc(void) 119 // Pour tester si le tableau T_ est alloue 120 { 121 if(array_allocated_) return; 122 char bla[90]; 123 sprintf(bla,"GeneFluct3D::check_array_alloc_Error: array is not allocated"); 124 cout<<bla<<endl; 125 throw ParmError(bla); 126 } 127 128 129 //------------------------------------------------------- 130 void GeneFluct3D::WriteFits(string cfname,int bitpix) 131 { 132 cout<<"GeneFluct3D::WriteFits: Writing Cube to "<<cfname<<endl; 133 try { 134 FitsImg3DWriter fwrt(cfname.c_str(),bitpix,5); 135 fwrt.WriteKey("NX",Nx_," axe transverse 1"); 136 fwrt.WriteKey("NY",Ny_," axe transverse 2"); 137 fwrt.WriteKey("NZ",Nz_," axe longitudinal (redshift)"); 138 fwrt.WriteKey("DX",Dx_," Mpc"); 139 fwrt.WriteKey("DY",Dy_," Mpc"); 140 fwrt.WriteKey("DZ",Dz_," Mpc"); 141 fwrt.WriteKey("DKX",Dkx_," Mpc^-1"); 142 fwrt.WriteKey("DKY",Dky_," Mpc^-1"); 143 fwrt.WriteKey("DKZ",Dkz_," Mpc^-1"); 144 fwrt.Write(R_); 145 } catch (PThrowable & exc) { 146 cout<<"Exception : "<<(string)typeid(exc).name() 147 <<" - Msg= "<<exc.Msg()<<endl; 148 return; 149 } catch (...) { 150 cout<<" some other exception was caught !"<<endl; 151 return; 152 } 153 } 154 155 void GeneFluct3D::ReadFits(string cfname) 156 { 157 cout<<"GeneFluct3D::ReadFits: Reading Cube from "<<cfname<<endl; 158 try { 159 FitsImg3DRead fimg(cfname.c_str(),0,5); 160 fimg.Read(R_); 161 long nx = fimg.ReadKeyL("NX"); 162 long ny = fimg.ReadKeyL("NY"); 163 long nz = fimg.ReadKeyL("NZ"); 164 double dx = fimg.ReadKey("DX"); 165 double dy = fimg.ReadKey("DY"); 166 double dz = fimg.ReadKey("DZ"); 167 setsize(nx,ny,nz,dx,dy,dz); 168 setpointers(true); 169 } catch (PThrowable & exc) { 170 cout<<"Exception : "<<(string)typeid(exc).name() 171 <<" - Msg= "<<exc.Msg()<<endl; 172 return; 173 } catch (...) { 174 cout<<" some other exception was caught !"<<endl; 175 return; 176 } 177 } 178 179 void GeneFluct3D::WritePPF(string cfname,bool write_real) 180 // On ecrit soit le TArray<r_8> ou le TArray<complex <r_8> > 181 { 182 cout<<"GeneFluct3D::WritePPF: Writing Cube (real="<<write_real<<") to "<<cfname<<endl; 183 try { 184 R_.Info()["NX"] = (int_8)Nx_; 185 R_.Info()["NY"] = (int_8)Ny_; 186 R_.Info()["NZ"] = (int_8)Nz_; 187 R_.Info()["DX"] = (r_8)Dx_; 188 R_.Info()["DY"] = (r_8)Dy_; 189 R_.Info()["DZ"] = (r_8)Dz_; 190 POutPersist pos(cfname.c_str()); 191 if(write_real) pos << PPFNameTag("rgen") << R_; 192 else pos << PPFNameTag("pkgen") << T_; 193 } catch (PThrowable & exc) { 194 cout<<"Exception : "<<(string)typeid(exc).name() 195 <<" - Msg= "<<exc.Msg()<<endl; 196 return; 197 } catch (...) { 198 cout<<" some other exception was caught !"<<endl; 199 return; 200 } 201 } 202 203 void GeneFluct3D::ReadPPF(string cfname) 204 { 205 cout<<"GeneFluct3D::ReadPPF: Reading Cube from "<<cfname<<endl; 206 try { 207 bool from_real = true; 208 PInPersist pis(cfname.c_str()); 209 string name_tag_k = "pkgen"; 210 bool found_tag_k = pis.GotoNameTag("pkgen"); 211 if(found_tag_k) { 212 cout<<" ...reading spectrun into TArray<complex <r_8> >"<<endl; 213 pis >> PPFNameTag("pkgen") >> T_; 214 from_real = false; 215 } else { 216 cout<<" ...reading space into TArray<r_8>"<<endl; 217 pis >> PPFNameTag("rgen") >> R_; 218 } 219 int_8 nx = R_.Info()["NX"]; 220 int_8 ny = R_.Info()["NY"]; 221 int_8 nz = R_.Info()["NZ"]; 222 r_8 dx = R_.Info()["DX"]; 223 r_8 dy = R_.Info()["DY"]; 224 r_8 dz = R_.Info()["DZ"]; 225 setsize(nx,ny,nz,dx,dy,dz); 226 setpointers(from_real); 227 } catch (PThrowable & exc) { 228 cout<<"Exception : "<<(string)typeid(exc).name() 229 <<" - Msg= "<<exc.Msg()<<endl; 230 return; 231 } catch (...) { 232 cout<<" some other exception was caught !"<<endl; 233 return; 234 } 80 235 } 81 236 … … 83 238 void GeneFluct3D::Print(void) 84 239 { 85 cout<<"GeneFluct3D(T_ typ="<<Tcontent_<<"): z="<<pkz_.GetZ()<<endl;240 cout<<"GeneFluct3D(T_alloc="<<array_allocated_<<"):"<<endl; 86 241 cout<<"Space Size : nx="<<Nx_<<" ny="<<Ny_<<" nz="<<Nz_<<" ("<<NTz_<<") size=" 87 242 <<NRtot_<<endl; … … 98 253 99 254 //------------------------------------------------------- 100 void GeneFluct3D::ComputeFourier0( void)255 void GeneFluct3D::ComputeFourier0(GenericFunc& pk_at_z) 101 256 // cf ComputeFourier() mais avec autre methode de realisation du spectre 102 257 // (attention on fait une fft pour realiser le spectre) … … 104 259 int lp=2; 105 260 106 T_.ReSize(3,SzK_);107 T_.SetMemoryMapping(BaseArray::CMemoryMapping);108 109 261 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init) 110 262 if(lp>1) PrtTim("--- ComputeFourier0: before fftw_plan ---"); 111 fftw_complex *fdata = (fftw_complex *) (&T_(0,0,0));112 double *data = (double *) (&T_(0,0,0));113 263 #ifdef FFTW_THREAD 114 264 if(nthread_>0) { … … 118 268 } 119 269 #endif 120 pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data ,fdata,FFTW_ESTIMATE);121 pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata ,data,FFTW_ESTIMATE);270 pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE); 271 pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE); 122 272 if(lp>1) PrtTim("--- ComputeFourier0: after fftw_plan ---"); 123 273 … … 127 277 double sntot = sqrt((double)NRtot_); 128 278 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) { 129 int_8 ip = l+NTz_*(j+Ny_*i);130 data [ip] = NorRand()/sntot;279 int_8 ip = IndexR(i,j,l); 280 data_[ip] = NorRand()/sntot; 131 281 } 132 282 if(lp>1) PrtTim("--- ComputeFourier0: after gaussian filling ---"); … … 153 303 double k = sqrt(kx+ky+kz); 154 304 // cf normalisation: Peacock, Cosmology, formule 16.38 p504 155 double pk = pk z_(k)/Vol_;305 double pk = pk_at_z(k)/Vol_; 156 306 // ici pas de "/2" a cause de la remarque ci-dessus 157 307 T_(l,j,i) *= sqrt(pk); … … 165 315 if(lp>1) PrtTim("--- ComputeFourier0: after Computing power ---"); 166 316 167 Tcontent_ = 1;168 169 317 } 170 318 171 319 //------------------------------------------------------- 172 void GeneFluct3D::ComputeFourier( void)173 // Calcule une realisation du spectre "pk z_"320 void GeneFluct3D::ComputeFourier(GenericFunc& pk_at_z) 321 // Calcule une realisation du spectre "pk_at_z" 174 322 // Attention: dans TArray le premier indice varie le + vite 175 323 // Explication normalisation: see Coles & Lucchin, Cosmology, p264-265 … … 181 329 { 182 330 int lp=2; 183 184 // --- Dimensionnement du tableau185 // ATTENTION: TArray adresse en memoire a l'envers du C186 // Tarray(n1,n2,n3) == Carray[n3][n2][n1]187 T_.ReSize(3,SzK_);188 T_.SetMemoryMapping(BaseArray::CMemoryMapping);189 331 190 332 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init) 191 333 if(lp>1) PrtTim("--- ComputeFourier: before fftw_plan ---"); 192 fftw_complex *fdata = (fftw_complex *) (&T_(0,0,0));193 double *data = (double *) (&T_(0,0,0));194 334 #ifdef FFTW_THREAD 195 335 if(nthread_>0) { … … 199 339 } 200 340 #endif 201 pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data ,fdata,FFTW_ESTIMATE);202 pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata ,data,FFTW_ESTIMATE);341 pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE); 342 pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE); 203 343 //fftw_print_plan(pb_); cout<<endl; 204 344 if(lp>1) PrtTim("--- ComputeFourier: after fftw_plan ---"); … … 222 362 double k = sqrt(kx+ky+kz); 223 363 // cf normalisation: Peacock, Cosmology, formule 16.38 p504 224 double pk = pk z_(k)/Vol_;364 double pk = pk_at_z(k)/Vol_; 225 365 // Explication de la division par 2: voir perandom.cc 226 366 // ou egalement Coles & Lucchin, Cosmology formula 13.7.2 p279 … … 238 378 if(lp>1) PrtTim("--- ComputeFourier: after before Computing power ---"); 239 379 240 Tcontent_ = 1;241 242 380 } 243 381 … … 246 384 // because we want a realization of a real data in real space 247 385 { 248 fftw_complex *fdata = (fftw_complex *) (&T_(0,0,0));386 check_array_alloc(); 249 387 250 388 // 1./ Le Continu et Nyquist sont reels … … 259 397 long i=0; 260 398 if(ii==1) {if( Nx_%2!=0) continue; else i = Nx_/2;} 261 int_8 ip = k+NCz_*(j+Ny_*i);262 //cout<<"i="<<i<<" j="<<j<<" k="<<k<<" = ("<<fdata [ip][0]<<","<<fdata[ip][1]<<")"<<endl;263 fdata [ip][1] = 0.; fdata[ip][0] *= M_SQRT2;399 int_8 ip = IndexC(i,j,k); 400 //cout<<"i="<<i<<" j="<<j<<" k="<<k<<" = ("<<fdata_[ip][0]<<","<<fdata_[ip][1]<<")"<<endl; 401 fdata_[ip][1] = 0.; fdata_[ip][0] *= M_SQRT2; 264 402 nreal++; 265 403 } … … 279 417 if(jj==1) {if( Ny_%2!=0) continue; else j = Ny_/2;} 280 418 for(long i=1;i<(Nx_+1)/2;i++) { 281 int_8 ip = k+NCz_*(j+Ny_*i);282 int_8 ip1 = k+NCz_*(j+Ny_*(Nx_-i));283 fdata [ip1][0] = fdata[ip][0]; fdata[ip1][1] = -fdata[ip][1];419 int_8 ip = IndexC(i,j,k); 420 int_8 ip1 = IndexC(Nx_-i,j,k); 421 fdata_[ip1][0] = fdata_[ip][0]; fdata_[ip1][1] = -fdata_[ip][1]; 284 422 nconj1++; 285 423 } … … 289 427 if(ii==1) {if( Nx_%2!=0) continue; else i = Nx_/2;} 290 428 for(long j=1;j<(Ny_+1)/2;j++) { 291 int_8 ip = k+NCz_*(j+Ny_*i);292 int_8 ip1 = k+NCz_*((Ny_-j)+Ny_*i);293 fdata [ip1][0] = fdata[ip][0]; fdata[ip1][1] = -fdata[ip][1];429 int_8 ip = IndexC(i,j,k); 430 int_8 ip1 = IndexC(i,Ny_-j,k); 431 fdata_[ip1][0] = fdata_[ip][0]; fdata_[ip1][1] = -fdata_[ip][1]; 294 432 nconj1++; 295 433 } … … 307 445 for(long i=1;i<Nx_;i++) { 308 446 if(Nx_%2==0 && i==Nx_/2) continue; // on ne retraite pas nyquist en i 309 int_8 ip = k+NCz_*(j+Ny_*i);310 int_8 ip1 = k+NCz_*((Ny_-j)+Ny_*(Nx_-i));311 fdata [ip1][0] = fdata[ip][0]; fdata[ip1][1] = -fdata[ip][1];447 int_8 ip = IndexC(i,j,k); 448 int_8 ip1 = IndexC(Nx_-i,Ny_-j,k); 449 fdata_[ip1][0] = fdata_[ip][0]; fdata_[ip1][1] = -fdata_[ip][1]; 312 450 nconj2++; 313 451 } … … 324 462 // Calcul la puissance de la realisation du spectre Pk 325 463 { 464 check_array_alloc(); 465 326 466 double s2 = 0.; 327 467 for(long l=0;l<NCz_;l++) … … 351 491 { 352 492 int lp=2; 493 check_array_alloc(); 494 353 495 if(lp>1) PrtTim("--- FilterByPixel: before ---"); 354 496 … … 356 498 long ii = (i>Nx_/2) ? Nx_-i : i; 357 499 double kx = ii*Dkx_ *Dx_/2; 358 double pk x = pixelfilter(kx);500 double pk_x = pixelfilter(kx); 359 501 for(long j=0;j<Ny_;j++) { 360 502 long jj = (j>Ny_/2) ? Ny_-j : j; 361 503 double ky = jj*Dky_ *Dy_/2; 362 double pk y = pixelfilter(ky);504 double pk_y = pixelfilter(ky); 363 505 for(long l=0;l<NCz_;l++) { 364 506 double kz = l*Dkz_ *Dz_/2; 365 double pk z = pixelfilter(kz);366 T_(l,j,i) *= pk x*pky*pkz;507 double pk_z = pixelfilter(kz); 508 T_(l,j,i) *= pk_x*pk_y*pk_z; 367 509 } 368 510 } … … 377 519 { 378 520 int lp=2; 379 380 if( Tcontent_==0 ) { 381 cout<<"GeneFluct3D::ComputeReal_Error: empty array"<<endl; 382 throw ParmError("GeneFluct3D::ComputeReal_Error: empty array"); 383 } 521 check_array_alloc(); 384 522 385 523 // On fait la FFT … … 387 525 fftw_execute(pb_); 388 526 if(lp>1) PrtTim("--- ComputeReal: after fftw backward ---"); 389 390 Tcontent_ = 2;391 527 } 392 528 … … 395 531 { 396 532 int lp=2; 533 check_array_alloc(); 397 534 398 535 // On fait la FFT … … 405 542 for(long l=0;l<NCz_;l++) T_(l,j,i) /= complex<r_8>(v); 406 543 407 Tcontent_ = 3;408 544 if(lp>1) PrtTim("--- ComputeReal: after fftw forward ---"); 409 545 } 410 546 411 547 //------------------------------------------------------------------- 412 int GeneFluct3D::ComputeSpectrum(H Prof& hp)413 // Compute spectrum from "T" and fill H Prof "hp"548 int GeneFluct3D::ComputeSpectrum(HistoErr& herr) 549 // Compute spectrum from "T" and fill HistoErr "herr" 414 550 // T : dans le format standard de GeneFuct3D: T(nz,ny,nx) 415 551 // cad T(kz,ky,kx) avec 0<kz<kz_nyq -ky_nyq<ky<ky_nyq -kx_nyq<kx<kx_nyq 416 552 { 417 418 if(hp.NBins()<0) return -1; 419 hp.Zero();420 h p.SetErrOpt(false);553 check_array_alloc(); 554 555 if(herr.NBins()<0) return -1; 556 herr.Zero(); 421 557 422 558 // Attention a l'ordre … … 431 567 double k = sqrt(kx+ky+kz); 432 568 double pk = MODULE2(T_(l,j,i)); 433 h p.Add(k,pk);434 } 435 } 436 } 437 h p.UpdateHisto();569 herr.Add(k,pk); 570 } 571 } 572 } 573 herr.ToCorrel(); 438 574 439 575 // renormalize to directly compare to original spectrum 440 576 double norm = Vol_; 441 hp *= norm; 577 herr *= norm; 578 579 return 0; 580 } 581 582 int GeneFluct3D::ComputeSpectrum2D(Histo2DErr& herr) 583 { 584 check_array_alloc(); 585 586 if(herr.NBinX()<0 || herr.NBinY()<0) return -1; 587 herr.Zero(); 588 589 // Attention a l'ordre 590 for(long i=0;i<Nx_;i++) { 591 long ii = (i>Nx_/2) ? Nx_-i : i; 592 double kx = ii*Dkx_; kx *= kx; 593 for(long j=0;j<Ny_;j++) { 594 long jj = (j>Ny_/2) ? Ny_-j : j; 595 double ky = jj*Dky_; ky *= ky; 596 double kt = sqrt(kx+ky); 597 for(long l=0;l<NCz_;l++) { 598 double kz = l*Dkz_; 599 double pk = MODULE2(T_(l,j,i)); 600 herr.Add(kt,kz,pk); 601 } 602 } 603 } 604 herr.ToCorrel(); 605 606 // renormalize to directly compare to original spectrum 607 double norm = Vol_; 608 herr *= norm; 442 609 443 610 return 0; … … 449 616 { 450 617 int lp=2; 618 check_array_alloc(); 619 451 620 if(lp>1) PrtTim("--- VarianceFrReal: before computation ---"); 452 621 453 double *data = (double *) (&T_(0,0,0));454 622 long dnx = long(R/Dx_+0.5); if(dnx<=0) dnx = 1; 455 623 long dny = long(R/Dy_+0.5); if(dny<=0) dny = 1; … … 470 638 double z = (ll-l)*Dz_; z *= z; 471 639 if(x+y+z>r2) continue; 472 int_8 ip = ll+NTz_*(jj+Ny_*ii);473 s += 1.+data [ip];640 int_8 ip = IndexR(ii,jj,ll); 641 s += 1.+data_[ip]; 474 642 n++; 475 643 } … … 500 668 // -> vmin and vmax are considered as bad 501 669 { 502 double *data = (double *) (&T_(0,0,0));670 check_array_alloc(); 503 671 504 672 int_8 nbad = 0; 505 673 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) { 506 int_8 ip = l+NTz_*(j+Ny_*i);507 double v = data [ip];674 int_8 ip = IndexR(i,j,l); 675 double v = data_[ip]; 508 676 if(v<=vmin || v>=vmax) nbad++; 509 677 } … … 516 684 // -> mean and sigma^2 are NOT computed with pixels values vmin and vmax 517 685 { 518 double *data = (double *) (&T_(0,0,0));686 check_array_alloc(); 519 687 520 688 int_8 n = 0; … … 522 690 523 691 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) { 524 int_8 ip = l+NTz_*(j+Ny_*i);525 double v = data [ip];692 int_8 ip = IndexR(i,j,l); 693 double v = data_[ip]; 526 694 if(v<=vmin || v>=vmax) continue; 527 695 rm += v; … … 542 710 // -> vmin and vmax are set to val0 543 711 { 544 double *data = (double *) (&T_(0,0,0));712 check_array_alloc(); 545 713 546 714 int_8 nbad = 0; 547 715 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) { 548 int_8 ip = l+NTz_*(j+Ny_*i);549 double v = data [ip];550 if(v<=vmin || v>=vmax) {data [ip] = val0; nbad++;}716 int_8 ip = IndexR(i,j,l); 717 double v = data_[ip]; 718 if(v<=vmin || v>=vmax) {data_[ip] = val0; nbad++;} 551 719 } 552 720 … … 559 727 { 560 728 int lp=2; 729 check_array_alloc(); 730 561 731 if(lp>1) PrtTim("--- TurnFluct2Mass: before computation ---"); 562 double *data = (double *) (&T_(0,0,0));563 732 564 733 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) { 565 int_8 ip = l+NTz_*(j+Ny_*i); 566 data[ip] += 1.; 567 } 568 569 Tcontent_ = 4; 734 int_8 ip = IndexR(i,j,l); 735 data_[ip] += 1.; 736 } 737 570 738 if(lp>1) PrtTim("--- TurnFluct2Mass: after computation ---"); 571 739 } … … 576 744 int lp=2; 577 745 if(lp>1) PrtTim("--- TurnMass2MeanNumber: before computation ---"); 578 579 double *data = (double *) (&T_(0,0,0));580 746 581 747 double m,s2; … … 596 762 double sum = 0.; 597 763 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) { 598 int_8 ip = l+NTz_*(j+Ny_*i);599 data [ip] *= dn; // par coherence on multiplie aussi les <=0600 if(data [ip]>0.) sum += data[ip]; // mais on ne les compte pas764 int_8 ip = IndexR(i,j,l); 765 data_[ip] *= dn; // par coherence on multiplie aussi les <=0 766 if(data_[ip]>0.) sum += data_[ip]; // mais on ne les compte pas 601 767 } 602 768 if(lp) cout<<sum<<" galaxies put into survey / "<<n_by_mpc3*Vol_<<endl; 603 769 604 Tcontent_ = 6;605 770 if(lp>1) PrtTim("--- TurnMass2MeanNumber: after computation ---"); 606 771 return sum; … … 611 776 { 612 777 int lp=2; 778 check_array_alloc(); 779 613 780 if(lp>1) PrtTim("--- ApplyPoisson: before computation ---"); 614 615 double *data = (double *) (&T_(0,0,0));616 781 617 782 double sum = 0.; 618 783 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) { 619 int_8 ip = l+NTz_*(j+Ny_*i);620 double v = data [ip];784 int_8 ip = IndexR(i,j,l); 785 double v = data_[ip]; 621 786 if(v>0.) { 622 787 unsigned long dn = PoissRandLimit(v,10.); 623 data [ip] = (double)dn;788 data_[ip] = (double)dn; 624 789 sum += (double)dn; 625 790 } 626 791 } 627 792 if(lp) cout<<sum<<" galaxies put into survey"<<endl; 628 Tcontent_ = 8;629 793 630 794 if(lp>1) PrtTim("--- ApplyPoisson: before computation ---"); … … 641 805 { 642 806 int lp=2; 807 check_array_alloc(); 808 643 809 if(lp>1) PrtTim("--- TurnNGal2Mass: before computation ---"); 644 645 double *data = (double *) (&T_(0,0,0));646 810 647 811 double sum = 0.; 648 812 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) { 649 int_8 ip = l+NTz_*(j+Ny_*i);650 double v = data [ip];813 int_8 ip = IndexR(i,j,l); 814 double v = data_[ip]; 651 815 if(v>0.) { 652 816 long ngal = long(v+0.1); 653 data [ip] = 0.;817 data_[ip] = 0.; 654 818 for(long i=0;i<ngal;i++) { 655 819 double m = massdist.RandomInterp(); // massdist.Random(); 656 820 if(axeslog) m = pow(10.,m); 657 data [ip] += m;658 } 659 sum += data [ip];821 data_[ip] += m; 822 } 823 sum += data_[ip]; 660 824 } 661 825 } 662 826 if(lp) cout<<sum<<" MSol HI mass put into survey"<<endl; 663 Tcontent_ = 10;664 827 665 828 if(lp>1) PrtTim("--- TurnNGal2Mass: after computation ---"); … … 671 834 { 672 835 int lp=2; 836 check_array_alloc(); 837 673 838 if(lp>1) PrtTim("--- AddNoise2Real: before computation ---"); 674 839 675 double *data = (double *) (&T_(0,0,0));676 677 840 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) for(long l=0;l<Nz_;l++) { 678 int_8 ip = l+NTz_*(j+Ny_*i); 679 data[ip] += snoise*NorRand(); 680 } 681 Tcontent_ = 12; 841 int_8 ip = IndexR(i,j,l); 842 data_[ip] += snoise*NorRand(); 843 } 682 844 683 845 if(lp>1) PrtTim("--- AddNoise2Real: after computation ---"); -
trunk/Cosmo/SimLSS/genefluct3d.h
r3134 r3141 5 5 #include "genericfunc.h" 6 6 #include "tarray.h" 7 #include "hisprof.h" 7 #include "histerr.h" 8 #include "hist2err.h" 8 9 #include "perandom.h" 10 11 #include "FFTW/fftw3.h" 12 #include "FitsIO/fitsio.h" 9 13 10 14 #include <vector> … … 12 16 #include "pkspectrum.h" 13 17 14 #include "FFTW/fftw3.h"15 18 16 19 namespace SOPHYA { … … 19 22 class GeneFluct3D { 20 23 public: 21 GeneFluct3D(TArray< complex<r_8 > >& T ,PkSpectrumZ& pkz);24 GeneFluct3D(TArray< complex<r_8 > >& T); 22 25 virtual ~GeneFluct3D(void); 23 26 … … 25 28 void SetSize(long nx,long ny,long nz,double dx,double dy,double dz); // Mpc 26 29 27 inline void SetZ(double z) {pkz_.SetZ(z);} 28 double GetZ(void) {return pkz_.GetZ();} 30 TArray< complex<r_8> >& GetComplexArray(void) {return T_;} 31 fftw_complex* GetComplexPointer(void) {return fdata_;} 32 TArray<r_8>& GetRealArray(void) {return R_;} 33 r_8* GetRealPointer(void) {return data_;} 34 35 // Pour adressage data_[ip] 36 inline int_8 IndexR(long i,long j,long k) {return (int_8)(k+NTz_*(j+Ny_*i));} 37 // Pour adressage fdata_[ip][0-1] 38 inline int_8 IndexC(long i,long j,long k) {return (int_8)(k+NCz_*(j+Ny_*i));} 39 // - On peut aussi adresser: 40 // TArray< complex<r_8> >& pk = gf3d.GetComplexArray(); pk(i,j,k) = ...; 41 // TArray<r_8>& rgen = gf3d.GetRealArray(); rgen(i,j,k) = ...; 42 43 vector<long> GetNpix(void) {return N_;} 44 int_8 NPix(void) {return NRtot_;} 45 46 vector<r_8> GetDinc(void) {return D_;} 47 double GetDVol(void) {return dVol_;} 29 48 double GetVol(void) {return Vol_;} 30 double GetDVol(void) {return dVol_;} 31 int_8 NPix(void) {return NRtot_;} 49 50 vector<r_8> GetKinc(void) {return Dk_;} 51 vector<r_8> GetKnyq(void) {return Knyq_;} 32 52 double GetKmax(void) {return sqrt(Knyqx_*Knyqx_+Knyqy_*Knyqy_+Knyqz_*Knyqz_);} 33 vector<r_8> GetKinc(void) 34 {vector<r_8> dk; dk.push_back(Dkx_); dk.push_back(Dky_); dk.push_back(Dkz_); return dk;} 35 vector<r_8> GetKnyq(void) 36 {vector<r_8> kn; kn.push_back(Knyqx_); kn.push_back(Knyqy_); kn.push_back(Knyqz_); return kn;} 37 vector<r_8> GetDinc(void) 38 {vector<r_8> d; d.push_back(Dx_); d.push_back(Dy_); d.push_back(Dz_); return d;} 39 vector<long> GetNpix(void) 40 {vector<long> d; d.push_back(Nx_); d.push_back(Ny_); d.push_back(Nz_); return d;} 53 double GetKTmax(void) {return sqrt(Knyqx_*Knyqx_+Knyqy_*Knyqy_);} 54 double GetKincMin(void) 55 {vector<r_8>::const_iterator it = min_element(Dk_.begin(), Dk_.end()); return *it;} 56 double GetKTincMin(void) {return min(Dk_[0],Dk_[1]);} 41 57 42 void ComputeFourier0( void);43 void ComputeFourier( void);58 void ComputeFourier0(GenericFunc& pk_at_z); 59 void ComputeFourier(GenericFunc& pk_at_z); 44 60 void FilterByPixel(void); 45 int ComputeSpectrum(HProf& hp); 61 46 62 void ComputeReal(void); 63 47 64 void ReComputeFourier(void); 65 66 int ComputeSpectrum(HistoErr& herr); 67 int ComputeSpectrum2D(Histo2DErr& herr); 48 68 49 69 int_8 VarianceFrReal(double R,double& var); … … 59 79 void AddNoise2Real(double snoise); 60 80 81 void WriteFits(string cfname,int bitpix=FLOAT_IMG); 82 void ReadFits(string cfname); 83 84 void WritePPF(string cfname,bool write_real=true); 85 void ReadPPF(string cfname); 86 61 87 void Print(void); 62 88 63 89 protected: 90 void setsize(long nx,long ny,long nz,double dx,double dy,double dz); 91 void setalloc(void); 92 void setpointers(bool from_real); 64 93 long manage_coefficients(void); 65 94 double compute_power_carte(void); 95 void check_array_alloc(void); 66 96 inline double pixelfilter(double x) 67 97 {return (x<0.025) ? 1.-x*x/6.*(1.-x*x/20.): sin(x)/x;} 68 98 69 99 70 long Nx_,Ny_,Nz_; 71 sa_size_t SzK_[3]; 100 long Nx_,Ny_,Nz_; vector<long> N_; 72 101 long NCz_,NTz_; 73 102 int_8 NRtot_; 74 double Dx_,Dy_,Dz_; 103 104 double Dx_,Dy_,Dz_; vector<double> D_; 105 106 double Dkx_,Dky_,Dkz_; vector<double> Dk_; 107 double Knyqx_,Knyqy_,Knyqz_; vector<double> Knyq_; 108 double Dk3_; 75 109 double dVol_, Vol_; 76 double Dkx_,Dky_,Dkz_;77 double Knyqx_,Knyqy_,Knyqz_;78 double Dk3_;79 110 80 111 fftw_plan pf_,pb_; 81 112 unsigned short nthread_; 82 113 83 // = 0 : T_ vide 84 // = 1 : T_ contient une realisation du spectre (espace fourier) 85 // = 2 : T_ contient une realisation dans l'espace reel 86 // = 3 : T_ contient la TF d'une realisation dans l'espace reel (d_rho/rho) 87 // = 4 : T_ contient (1 + d_rho/rho) 88 // = ... etc ... 89 unsigned short Tcontent_; 114 bool array_allocated_; // true if array has been allocated 90 115 91 TArray< complex<r_8 > >& T_; 92 PkSpectrumZ& pkz_; 116 TArray< complex<r_8> >& T_; 117 fftw_complex *fdata_; 118 TArray<r_8> R_; 119 double *data_; 93 120 }; 94 121 -
trunk/Cosmo/SimLSS/genericfunc.h
r3115 r3141 3 3 4 4 #include "pexceptions.h" 5 #include <vector> 5 6 6 7 namespace SOPHYA { … … 32 33 } 33 34 35 virtual double operator()(vector<double>& x) { 36 cout<<"GenericFunc::operator(vector<double>&) not implemented"<<endl; 37 throw NotAvailableOperation("GenericFunc::operator(vector<double>&) not implemented"); 38 } 39 34 40 }; 35 41
Note:
See TracChangeset
for help on using the changeset viewer.