[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:
|
---|
[3349] | 26 | GeneFluct3D(long nx,long ny,long nz,double dx,double dy,double dz,unsigned short nthread=0,int lp=0); // Mpc
|
---|
| 27 | GeneFluct3D(unsigned short nthread=0);
|
---|
[3115] | 28 | virtual ~GeneFluct3D(void);
|
---|
| 29 |
|
---|
[3271] | 30 | // Distance los comobile a l'observateur
|
---|
[3157] | 31 | void SetObservator(double redshref=0.,double kredshref=0.);
|
---|
[3271] | 32 | inline double DXcom(long i) {return i*Dx_ - xobs_[0];}
|
---|
| 33 | inline double DYcom(long j) {return j*Dy_ - xobs_[1];}
|
---|
| 34 | inline double DZcom(long k) {return k*Dz_ - xobs_[2];}
|
---|
| 35 | inline double Dcom(long i,long j,long k) {
|
---|
| 36 | double dx=DXcom(i), dy=DYcom(j), dz=DZcom(k);
|
---|
| 37 | return sqrt(dx*dx+dy*dy+dz*dz);
|
---|
| 38 | }
|
---|
[3157] | 39 | void SetCosmology(CosmoCalc& cosmo);
|
---|
| 40 | void SetGrowthFactor(GrowthFactor& growth);
|
---|
[3199] | 41 | long LosComRedshift(double zinc=0.001,long npoints=-1);
|
---|
[3115] | 42 |
|
---|
[3141] | 43 | TArray< complex<r_8> >& GetComplexArray(void) {return T_;}
|
---|
| 44 | fftw_complex* GetComplexPointer(void) {return fdata_;}
|
---|
| 45 | TArray<r_8>& GetRealArray(void) {return R_;}
|
---|
| 46 | r_8* GetRealPointer(void) {return data_;}
|
---|
| 47 |
|
---|
| 48 | // Pour adressage data_[ip]
|
---|
| 49 | inline int_8 IndexR(long i,long j,long k) {return (int_8)(k+NTz_*(j+Ny_*i));}
|
---|
| 50 | // Pour adressage fdata_[ip][0-1]
|
---|
| 51 | inline int_8 IndexC(long i,long j,long k) {return (int_8)(k+NCz_*(j+Ny_*i));}
|
---|
[3330] | 52 | // On peut aussi adresser:
|
---|
| 53 | // TArray< complex<r_8> >& pk = gf3d.GetComplexArray();
|
---|
| 54 | // pk(k,j,i) avec k=[0,NCz_[ j=[0,Ny_[ i=[0,Nx_[
|
---|
| 55 | // pk[IndexC(i,j,k)]
|
---|
| 56 | // TArray<r_8>& rgen = gf3d.GetRealArray();
|
---|
| 57 | // rgen(k,j,i) avec k=[0,NTz_[ j=[0,Ny_[ i=[0,Nx_[
|
---|
| 58 | // mais seul k=[0,Nz_[ est utile
|
---|
| 59 | // rgen[IndexR(i,j,k)]
|
---|
| 60 | // ATTENTION: TArray adresse en memoire a l'envers du C !
|
---|
| 61 | // Tarray(n1,n2,n3) == Carray[n3][n2][n1]
|
---|
[3141] | 62 |
|
---|
| 63 | vector<long> GetNpix(void) {return N_;}
|
---|
| 64 | int_8 NPix(void) {return NRtot_;}
|
---|
[3330] | 65 | long GetNx(void) {return Nx_;}
|
---|
| 66 | long GetNy(void) {return Ny_;}
|
---|
| 67 | long GetNz(void) {return Nz_;}
|
---|
[3141] | 68 |
|
---|
[3290] | 69 | // Return |K_i| module relative to pixel indices
|
---|
| 70 | inline r_8 Kx(long i) {long ii=(i>Nx_/2)? Nx_-i :i; return ii*Dkx_;}
|
---|
| 71 | inline r_8 Ky(long j) {long jj=(j>Ny_/2)? Ny_-j :j; return jj*Dky_;}
|
---|
| 72 | inline r_8 Kz(long l) {return l*Dkz_;}
|
---|
| 73 |
|
---|
[3141] | 74 | vector<r_8> GetDinc(void) {return D_;}
|
---|
| 75 | double GetDVol(void) {return dVol_;}
|
---|
[3115] | 76 | double GetVol(void) {return Vol_;}
|
---|
[3141] | 77 |
|
---|
| 78 | vector<r_8> GetKinc(void) {return Dk_;}
|
---|
| 79 | vector<r_8> GetKnyq(void) {return Knyq_;}
|
---|
[3115] | 80 | double GetKmax(void) {return sqrt(Knyqx_*Knyqx_+Knyqy_*Knyqy_+Knyqz_*Knyqz_);}
|
---|
[3141] | 81 | double GetKTmax(void) {return sqrt(Knyqx_*Knyqx_+Knyqy_*Knyqy_);}
|
---|
| 82 | double GetKincMin(void)
|
---|
| 83 | {vector<r_8>::const_iterator it = min_element(Dk_.begin(), Dk_.end()); return *it;}
|
---|
[3289] | 84 | double GetKincMax(void)
|
---|
| 85 | {vector<r_8>::const_iterator it = max_element(Dk_.begin(), Dk_.end()); return *it;}
|
---|
[3141] | 86 | double GetKTincMin(void) {return min(Dk_[0],Dk_[1]);}
|
---|
[3289] | 87 | double GetKTincMax(void) {return max(Dk_[0],Dk_[1]);}
|
---|
[3115] | 88 |
|
---|
[3141] | 89 | void ComputeFourier0(GenericFunc& pk_at_z);
|
---|
| 90 | void ComputeFourier(GenericFunc& pk_at_z);
|
---|
[3115] | 91 | void FilterByPixel(void);
|
---|
[3141] | 92 |
|
---|
[3115] | 93 | void ComputeReal(void);
|
---|
[3331] | 94 | void ApplyGrowthFactor(int type_evol=1);
|
---|
[3141] | 95 |
|
---|
[3115] | 96 | void ReComputeFourier(void);
|
---|
| 97 |
|
---|
[3141] | 98 | int ComputeSpectrum(HistoErr& herr);
|
---|
| 99 | int ComputeSpectrum2D(Histo2DErr& herr);
|
---|
[3330] | 100 | int ComputeSpectrum(HistoErr& herr,double sigma,bool pixcor);
|
---|
| 101 | int ComputeSpectrum2D(Histo2DErr& herr,double sigma,bool pixcor);
|
---|
[3141] | 102 |
|
---|
[3134] | 103 | int_8 VarianceFrReal(double R,double& var);
|
---|
[3261] | 104 | int_8 MeanSigma2(double& rm,double& rs2,double vmin=1.,double vmax=-1.
|
---|
| 105 | ,bool useout=false,double vout=0.);
|
---|
[3320] | 106 | int_8 MinMax(double& xmin,double& xmax,double vmin=1.,double vmax=-1.);
|
---|
[3134] | 107 | int_8 NumberOfBad(double vmin=-1.e+150,double vmax=1.e+150);
|
---|
| 108 | int_8 SetToVal(double vmin, double vmax,double val0=0.);
|
---|
[3283] | 109 | void ScaleOffset(double scalecube=1.,double offsetcube=0.);
|
---|
[3115] | 110 |
|
---|
| 111 | void TurnFluct2Mass(void);
|
---|
[3349] | 112 | double TurnMass2MeanNumber(double val_by_mpc3);
|
---|
[3115] | 113 | double ApplyPoisson(void);
|
---|
| 114 | double TurnNGal2Mass(FunRan& massdist,bool axeslog=false);
|
---|
[3320] | 115 | double TurnNGal2MassQuick(SchechterMassDist& schmdist);
|
---|
[3115] | 116 | double TurnMass2Flux(void);
|
---|
[3349] | 117 | //void AddAGN(double lfjy,double lsigma,double powlaw=0.);
|
---|
[3331] | 118 | void AddNoise2Real(double snoise,int type_evol=0);
|
---|
[3115] | 119 |
|
---|
[3141] | 120 | void WriteFits(string cfname,int bitpix=FLOAT_IMG);
|
---|
| 121 | void ReadFits(string cfname);
|
---|
| 122 |
|
---|
| 123 | void WritePPF(string cfname,bool write_real=true);
|
---|
| 124 | void ReadPPF(string cfname);
|
---|
[3281] | 125 | void WriteSlicePPF(string cfname);
|
---|
[3141] | 126 |
|
---|
[3150] | 127 | void SetPrtLevel(int lp=0) {lp_ = lp;}
|
---|
[3115] | 128 | void Print(void);
|
---|
| 129 |
|
---|
[3199] | 130 | //-------------------------------------------------------------------
|
---|
| 131 |
|
---|
[3115] | 132 | protected:
|
---|
[3349] | 133 | void init_default(void);
|
---|
[3141] | 134 | void setsize(long nx,long ny,long nz,double dx,double dy,double dz);
|
---|
| 135 | void setalloc(void);
|
---|
| 136 | void setpointers(bool from_real);
|
---|
[3154] | 137 | void init_fftw(void);
|
---|
[3349] | 138 | void delete_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
|
---|
[3349] | 159 | bool is_set_fftw_plan;
|
---|
[3115] | 160 | fftw_plan pf_,pb_;
|
---|
| 161 | unsigned short nthread_;
|
---|
[3150] | 162 | int lp_;
|
---|
[3115] | 163 |
|
---|
[3154] | 164 | // le stockage du Cube de donnees et les pointeurs
|
---|
[3141] | 165 | bool array_allocated_; // true if array has been allocated
|
---|
[3349] | 166 | TArray< complex<r_8> > T_;
|
---|
[3141] | 167 | fftw_complex *fdata_;
|
---|
| 168 | TArray<r_8> R_;
|
---|
| 169 | double *data_;
|
---|
[3154] | 170 |
|
---|
| 171 | // l'observateur
|
---|
[3157] | 172 | CosmoCalc *cosmo_;
|
---|
| 173 | GrowthFactor *growth_;
|
---|
[3271] | 174 | double redsh_ref_,kredsh_ref_,dred_ref_;
|
---|
| 175 | double loscom_ref_,dtrc_ref_, dlum_ref_, dang_ref_;
|
---|
| 176 | double nu_ref_, dnu_ref_ ;
|
---|
[3157] | 177 | double xobs_[3];
|
---|
[3271] | 178 | double loscom_min_, loscom_max_;
|
---|
[3157] | 179 | vector<double> zred_, loscom_;
|
---|
[3199] | 180 | double loscom2zred_min_, loscom2zred_max_;
|
---|
| 181 | vector<double> loscom2zred_;
|
---|
| 182 |
|
---|
[3115] | 183 | };
|
---|
| 184 |
|
---|
[3325] | 185 | } // Fin du namespace SOPHYA
|
---|
[3115] | 186 |
|
---|
| 187 | #endif
|
---|