[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 |
|
---|
| 21 | namespace SOPHYA {
|
---|
| 22 |
|
---|
| 23 | //-----------------------------------------------------------------------------------
|
---|
| 24 | class GeneFluct3D {
|
---|
| 25 | public:
|
---|
[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));}
|
---|
[3330] | 53 | // On peut aussi adresser:
|
---|
| 54 | // TArray< complex<r_8> >& pk = gf3d.GetComplexArray();
|
---|
| 55 | // pk(k,j,i) avec k=[0,NCz_[ j=[0,Ny_[ i=[0,Nx_[
|
---|
| 56 | // pk[IndexC(i,j,k)]
|
---|
| 57 | // TArray<r_8>& rgen = gf3d.GetRealArray();
|
---|
| 58 | // rgen(k,j,i) avec k=[0,NTz_[ j=[0,Ny_[ i=[0,Nx_[
|
---|
| 59 | // mais seul k=[0,Nz_[ est utile
|
---|
| 60 | // rgen[IndexR(i,j,k)]
|
---|
| 61 | // ATTENTION: TArray adresse en memoire a l'envers du C !
|
---|
| 62 | // Tarray(n1,n2,n3) == Carray[n3][n2][n1]
|
---|
[3141] | 63 |
|
---|
| 64 | vector<long> GetNpix(void) {return N_;}
|
---|
| 65 | int_8 NPix(void) {return NRtot_;}
|
---|
[3330] | 66 | long GetNx(void) {return Nx_;}
|
---|
| 67 | long GetNy(void) {return Ny_;}
|
---|
| 68 | long GetNz(void) {return Nz_;}
|
---|
[3141] | 69 |
|
---|
[3290] | 70 | // Return |K_i| module relative to pixel indices
|
---|
| 71 | inline r_8 Kx(long i) {long ii=(i>Nx_/2)? Nx_-i :i; return ii*Dkx_;}
|
---|
| 72 | inline r_8 Ky(long j) {long jj=(j>Ny_/2)? Ny_-j :j; return jj*Dky_;}
|
---|
| 73 | inline r_8 Kz(long l) {return l*Dkz_;}
|
---|
| 74 |
|
---|
[3141] | 75 | vector<r_8> GetDinc(void) {return D_;}
|
---|
| 76 | double GetDVol(void) {return dVol_;}
|
---|
[3115] | 77 | double GetVol(void) {return Vol_;}
|
---|
[3141] | 78 |
|
---|
| 79 | vector<r_8> GetKinc(void) {return Dk_;}
|
---|
| 80 | vector<r_8> GetKnyq(void) {return Knyq_;}
|
---|
[3115] | 81 | double GetKmax(void) {return sqrt(Knyqx_*Knyqx_+Knyqy_*Knyqy_+Knyqz_*Knyqz_);}
|
---|
[3141] | 82 | double GetKTmax(void) {return sqrt(Knyqx_*Knyqx_+Knyqy_*Knyqy_);}
|
---|
| 83 | double GetKincMin(void)
|
---|
| 84 | {vector<r_8>::const_iterator it = min_element(Dk_.begin(), Dk_.end()); return *it;}
|
---|
[3289] | 85 | double GetKincMax(void)
|
---|
| 86 | {vector<r_8>::const_iterator it = max_element(Dk_.begin(), Dk_.end()); return *it;}
|
---|
[3141] | 87 | double GetKTincMin(void) {return min(Dk_[0],Dk_[1]);}
|
---|
[3289] | 88 | double GetKTincMax(void) {return max(Dk_[0],Dk_[1]);}
|
---|
[3115] | 89 |
|
---|
[3141] | 90 | void ComputeFourier0(GenericFunc& pk_at_z);
|
---|
| 91 | void ComputeFourier(GenericFunc& pk_at_z);
|
---|
[3115] | 92 | void FilterByPixel(void);
|
---|
[3141] | 93 |
|
---|
[3115] | 94 | void ComputeReal(void);
|
---|
[3331] | 95 | void ApplyGrowthFactor(int type_evol=1);
|
---|
[3141] | 96 |
|
---|
[3115] | 97 | void ReComputeFourier(void);
|
---|
| 98 |
|
---|
[3141] | 99 | int ComputeSpectrum(HistoErr& herr);
|
---|
| 100 | int ComputeSpectrum2D(Histo2DErr& herr);
|
---|
[3330] | 101 | int ComputeSpectrum(HistoErr& herr,double sigma,bool pixcor);
|
---|
| 102 | int ComputeSpectrum2D(Histo2DErr& herr,double sigma,bool pixcor);
|
---|
[3141] | 103 |
|
---|
[3134] | 104 | int_8 VarianceFrReal(double R,double& var);
|
---|
[3261] | 105 | int_8 MeanSigma2(double& rm,double& rs2,double vmin=1.,double vmax=-1.
|
---|
| 106 | ,bool useout=false,double vout=0.);
|
---|
[3320] | 107 | int_8 MinMax(double& xmin,double& xmax,double vmin=1.,double vmax=-1.);
|
---|
[3134] | 108 | int_8 NumberOfBad(double vmin=-1.e+150,double vmax=1.e+150);
|
---|
| 109 | int_8 SetToVal(double vmin, double vmax,double val0=0.);
|
---|
[3283] | 110 | void ScaleOffset(double scalecube=1.,double offsetcube=0.);
|
---|
[3115] | 111 |
|
---|
| 112 | void TurnFluct2Mass(void);
|
---|
[3329] | 113 | double TurnMass2HIMass(double m_by_mpc3);
|
---|
[3115] | 114 | double TurnMass2MeanNumber(double n_by_mpc3);
|
---|
| 115 | double ApplyPoisson(void);
|
---|
| 116 | double TurnNGal2Mass(FunRan& massdist,bool axeslog=false);
|
---|
[3320] | 117 | double TurnNGal2MassQuick(SchechterMassDist& schmdist);
|
---|
[3115] | 118 | double TurnMass2Flux(void);
|
---|
[3199] | 119 | void AddAGN(double lfjy,double lsigma,double powlaw=0.);
|
---|
[3331] | 120 | void AddNoise2Real(double snoise,int type_evol=0);
|
---|
[3115] | 121 |
|
---|
[3141] | 122 | void WriteFits(string cfname,int bitpix=FLOAT_IMG);
|
---|
| 123 | void ReadFits(string cfname);
|
---|
| 124 |
|
---|
| 125 | void WritePPF(string cfname,bool write_real=true);
|
---|
| 126 | void ReadPPF(string cfname);
|
---|
[3281] | 127 | void WriteSlicePPF(string cfname);
|
---|
[3141] | 128 |
|
---|
[3150] | 129 | void SetPrtLevel(int lp=0) {lp_ = lp;}
|
---|
[3115] | 130 | void Print(void);
|
---|
| 131 |
|
---|
[3199] | 132 | //-------------------------------------------------------------------
|
---|
| 133 |
|
---|
[3115] | 134 | protected:
|
---|
[3141] | 135 | void setsize(long nx,long ny,long nz,double dx,double dy,double dz);
|
---|
| 136 | void setalloc(void);
|
---|
| 137 | void setpointers(bool from_real);
|
---|
[3154] | 138 | void init_fftw(void);
|
---|
[3129] | 139 | long manage_coefficients(void);
|
---|
[3115] | 140 | double compute_power_carte(void);
|
---|
[3141] | 141 | void check_array_alloc(void);
|
---|
[3120] | 142 | inline double pixelfilter(double x)
|
---|
| 143 | {return (x<0.025) ? 1.-x*x/6.*(1.-x*x/20.): sin(x)/x;}
|
---|
[3115] | 144 |
|
---|
[3154] | 145 | // valeurs dans l'espace reel
|
---|
[3141] | 146 | long Nx_,Ny_,Nz_; vector<long> N_;
|
---|
[3129] | 147 | long NCz_,NTz_;
|
---|
[3134] | 148 | int_8 NRtot_;
|
---|
[3141] | 149 |
|
---|
| 150 | double Dx_,Dy_,Dz_; vector<double> D_;
|
---|
| 151 |
|
---|
[3154] | 152 | // valeurs dans l'espace des K
|
---|
[3141] | 153 | double Dkx_,Dky_,Dkz_; vector<double> Dk_;
|
---|
| 154 | double Knyqx_,Knyqy_,Knyqz_; vector<double> Knyq_;
|
---|
| 155 | double Dk3_;
|
---|
[3115] | 156 | double dVol_, Vol_;
|
---|
| 157 |
|
---|
[3154] | 158 | // la gestion de la FFT
|
---|
[3115] | 159 | fftw_plan pf_,pb_;
|
---|
| 160 | unsigned short nthread_;
|
---|
[3150] | 161 | int lp_;
|
---|
[3115] | 162 |
|
---|
[3154] | 163 | // le stockage du Cube de donnees et les pointeurs
|
---|
[3141] | 164 | bool array_allocated_; // true if array has been allocated
|
---|
| 165 | TArray< complex<r_8> >& T_;
|
---|
| 166 | fftw_complex *fdata_;
|
---|
| 167 | TArray<r_8> R_;
|
---|
| 168 | double *data_;
|
---|
[3154] | 169 |
|
---|
| 170 | // l'observateur
|
---|
[3157] | 171 | CosmoCalc *cosmo_;
|
---|
| 172 | GrowthFactor *growth_;
|
---|
[3271] | 173 | double redsh_ref_,kredsh_ref_,dred_ref_;
|
---|
| 174 | double loscom_ref_,dtrc_ref_, dlum_ref_, dang_ref_;
|
---|
| 175 | double nu_ref_, dnu_ref_ ;
|
---|
[3157] | 176 | double xobs_[3];
|
---|
[3271] | 177 | double loscom_min_, loscom_max_;
|
---|
[3157] | 178 | vector<double> zred_, loscom_;
|
---|
[3199] | 179 | double loscom2zred_min_, loscom2zred_max_;
|
---|
| 180 | vector<double> loscom2zred_;
|
---|
| 181 |
|
---|
[3115] | 182 | };
|
---|
| 183 |
|
---|
[3325] | 184 | } // Fin du namespace SOPHYA
|
---|
[3115] | 185 |
|
---|
| 186 | #endif
|
---|