source: Sophya/trunk/Cosmo/SimLSS/genefluct3d.h@ 3290

Last change on this file since 3290 was 3290, checked in by cmv, 18 years ago

add inline pour retourner |K_i| cmv 08/08/2007

File size: 5.4 KB
RevLine 
[3115]1#ifndef GENEFLUCT3D_SEEN
2#define GENEFLUCT3D_SEEN
3
4#include "machdefs.h"
[3289]5#include <math.h>
[3115]6#include "genericfunc.h"
7#include "tarray.h"
[3141]8#include "histerr.h"
9#include "hist2err.h"
[3115]10#include "perandom.h"
11
[3141]12#include "FFTW/fftw3.h"
13#include "FitsIO/fitsio.h"
14
[3115]15#include <vector>
16
[3157]17#include "cosmocalc.h"
[3115]18#include "pkspectrum.h"
19
20
21namespace SOPHYA {
22
23//-----------------------------------------------------------------------------------
24class GeneFluct3D {
25public:
[3141]26 GeneFluct3D(TArray< complex<r_8 > >& T);
[3115]27 virtual ~GeneFluct3D(void);
28
29 void SetNThread(unsigned short nthread=0) {nthread_ = nthread;}
[3129]30 void SetSize(long nx,long ny,long nz,double dx,double dy,double dz); // Mpc
[3271]31 // Distance los comobile a l'observateur
[3157]32 void SetObservator(double redshref=0.,double kredshref=0.);
[3271]33 inline double DXcom(long i) {return i*Dx_ - xobs_[0];}
34 inline double DYcom(long j) {return j*Dy_ - xobs_[1];}
35 inline double DZcom(long k) {return k*Dz_ - xobs_[2];}
36 inline double Dcom(long i,long j,long k) {
37 double dx=DXcom(i), dy=DYcom(j), dz=DZcom(k);
38 return sqrt(dx*dx+dy*dy+dz*dz);
39 }
[3157]40 void SetCosmology(CosmoCalc& cosmo);
41 void SetGrowthFactor(GrowthFactor& growth);
[3199]42 long LosComRedshift(double zinc=0.001,long npoints=-1);
[3115]43
[3141]44 TArray< complex<r_8> >& GetComplexArray(void) {return T_;}
45 fftw_complex* GetComplexPointer(void) {return fdata_;}
46 TArray<r_8>& GetRealArray(void) {return R_;}
47 r_8* GetRealPointer(void) {return data_;}
48
49 // Pour adressage data_[ip]
50 inline int_8 IndexR(long i,long j,long k) {return (int_8)(k+NTz_*(j+Ny_*i));}
51 // Pour adressage fdata_[ip][0-1]
52 inline int_8 IndexC(long i,long j,long k) {return (int_8)(k+NCz_*(j+Ny_*i));}
53 // - On peut aussi adresser:
54 // TArray< complex<r_8> >& pk = gf3d.GetComplexArray(); pk(i,j,k) = ...;
55 // TArray<r_8>& rgen = gf3d.GetRealArray(); rgen(i,j,k) = ...;
56
57 vector<long> GetNpix(void) {return N_;}
58 int_8 NPix(void) {return NRtot_;}
59
[3290]60 // Return |K_i| module relative to pixel indices
61 inline r_8 Kx(long i) {long ii=(i>Nx_/2)? Nx_-i :i; return ii*Dkx_;}
62 inline r_8 Ky(long j) {long jj=(j>Ny_/2)? Ny_-j :j; return jj*Dky_;}
63 inline r_8 Kz(long l) {return l*Dkz_;}
64
[3141]65 vector<r_8> GetDinc(void) {return D_;}
66 double GetDVol(void) {return dVol_;}
[3115]67 double GetVol(void) {return Vol_;}
[3141]68
69 vector<r_8> GetKinc(void) {return Dk_;}
70 vector<r_8> GetKnyq(void) {return Knyq_;}
[3115]71 double GetKmax(void) {return sqrt(Knyqx_*Knyqx_+Knyqy_*Knyqy_+Knyqz_*Knyqz_);}
[3141]72 double GetKTmax(void) {return sqrt(Knyqx_*Knyqx_+Knyqy_*Knyqy_);}
73 double GetKincMin(void)
74 {vector<r_8>::const_iterator it = min_element(Dk_.begin(), Dk_.end()); return *it;}
[3289]75 double GetKincMax(void)
76 {vector<r_8>::const_iterator it = max_element(Dk_.begin(), Dk_.end()); return *it;}
[3141]77 double GetKTincMin(void) {return min(Dk_[0],Dk_[1]);}
[3289]78 double GetKTincMax(void) {return max(Dk_[0],Dk_[1]);}
[3115]79
[3141]80 void ComputeFourier0(GenericFunc& pk_at_z);
81 void ComputeFourier(GenericFunc& pk_at_z);
[3115]82 void FilterByPixel(void);
[3141]83
[3115]84 void ComputeReal(void);
[3141]85
[3115]86 void ReComputeFourier(void);
87
[3141]88 int ComputeSpectrum(HistoErr& herr);
89 int ComputeSpectrum2D(Histo2DErr& herr);
[3199]90 void ApplyGrowthFactor(void);
[3141]91
[3134]92 int_8 VarianceFrReal(double R,double& var);
[3261]93 int_8 MeanSigma2(double& rm,double& rs2,double vmin=1.,double vmax=-1.
94 ,bool useout=false,double vout=0.);
[3134]95 int_8 NumberOfBad(double vmin=-1.e+150,double vmax=1.e+150);
96 int_8 SetToVal(double vmin, double vmax,double val0=0.);
[3283]97 void ScaleOffset(double scalecube=1.,double offsetcube=0.);
[3115]98
99 void TurnFluct2Mass(void);
100 double TurnMass2MeanNumber(double n_by_mpc3);
101 double ApplyPoisson(void);
102 double TurnNGal2Mass(FunRan& massdist,bool axeslog=false);
103 double TurnMass2Flux(void);
[3199]104 void AddAGN(double lfjy,double lsigma,double powlaw=0.);
[3267]105 void AddNoise2Real(double snoise,bool with_evol=false);
[3115]106
[3141]107 void WriteFits(string cfname,int bitpix=FLOAT_IMG);
108 void ReadFits(string cfname);
109
110 void WritePPF(string cfname,bool write_real=true);
111 void ReadPPF(string cfname);
[3281]112 void WriteSlicePPF(string cfname);
[3141]113
[3150]114 void SetPrtLevel(int lp=0) {lp_ = lp;}
[3115]115 void Print(void);
116
[3199]117//-------------------------------------------------------------------
118
[3115]119protected:
[3141]120 void setsize(long nx,long ny,long nz,double dx,double dy,double dz);
121 void setalloc(void);
122 void setpointers(bool from_real);
[3154]123 void init_fftw(void);
[3129]124 long manage_coefficients(void);
[3115]125 double compute_power_carte(void);
[3141]126 void check_array_alloc(void);
[3120]127 inline double pixelfilter(double x)
128 {return (x<0.025) ? 1.-x*x/6.*(1.-x*x/20.): sin(x)/x;}
[3115]129
[3154]130 // valeurs dans l'espace reel
[3141]131 long Nx_,Ny_,Nz_; vector<long> N_;
[3129]132 long NCz_,NTz_;
[3134]133 int_8 NRtot_;
[3141]134
135 double Dx_,Dy_,Dz_; vector<double> D_;
136
[3154]137 // valeurs dans l'espace des K
[3141]138 double Dkx_,Dky_,Dkz_; vector<double> Dk_;
139 double Knyqx_,Knyqy_,Knyqz_; vector<double> Knyq_;
140 double Dk3_;
[3115]141 double dVol_, Vol_;
142
[3154]143 // la gestion de la FFT
[3115]144 fftw_plan pf_,pb_;
145 unsigned short nthread_;
[3150]146 int lp_;
[3115]147
[3154]148 // le stockage du Cube de donnees et les pointeurs
[3141]149 bool array_allocated_; // true if array has been allocated
150 TArray< complex<r_8> >& T_;
151 fftw_complex *fdata_;
152 TArray<r_8> R_;
153 double *data_;
[3154]154
155 // l'observateur
[3157]156 CosmoCalc *cosmo_;
157 GrowthFactor *growth_;
[3271]158 double redsh_ref_,kredsh_ref_,dred_ref_;
159 double loscom_ref_,dtrc_ref_, dlum_ref_, dang_ref_;
160 double nu_ref_, dnu_ref_ ;
[3157]161 double xobs_[3];
[3271]162 double loscom_min_, loscom_max_;
[3157]163 vector<double> zred_, loscom_;
[3199]164 double loscom2zred_min_, loscom2zred_max_;
165 vector<double> loscom2zred_;
166
[3115]167};
168
169} // Fin du namespace
170
171#endif
Note: See TracBrowser for help on using the repository browser.