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

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

Mise en conformite / SOPHYA lib:

  1. on enleve #include "sopnamsp.h" dans les .cc de la librairie
  2. on encadre par "namespace SOPHYA { ... }" tout le code des .cc de la librairie y compris les fonctions
  3. on met les fcts des .h dans le "namespace SOPHYA { ... }"
  4. on met #include "sopnamsp.h" dans tous les cmv*.cc cad les main programs

cmv le mauvais eleve (sur les conseils de Reza) 13/09/2007

File size: 5.5 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.);
[3320]95 int_8 MinMax(double& xmin,double& xmax,double vmin=1.,double vmax=-1.);
[3134]96 int_8 NumberOfBad(double vmin=-1.e+150,double vmax=1.e+150);
97 int_8 SetToVal(double vmin, double vmax,double val0=0.);
[3283]98 void ScaleOffset(double scalecube=1.,double offsetcube=0.);
[3115]99
100 void TurnFluct2Mass(void);
101 double TurnMass2MeanNumber(double n_by_mpc3);
102 double ApplyPoisson(void);
103 double TurnNGal2Mass(FunRan& massdist,bool axeslog=false);
[3320]104 double TurnNGal2MassQuick(SchechterMassDist& schmdist);
[3115]105 double TurnMass2Flux(void);
[3199]106 void AddAGN(double lfjy,double lsigma,double powlaw=0.);
[3267]107 void AddNoise2Real(double snoise,bool with_evol=false);
[3115]108
[3141]109 void WriteFits(string cfname,int bitpix=FLOAT_IMG);
110 void ReadFits(string cfname);
111
112 void WritePPF(string cfname,bool write_real=true);
113 void ReadPPF(string cfname);
[3281]114 void WriteSlicePPF(string cfname);
[3141]115
[3150]116 void SetPrtLevel(int lp=0) {lp_ = lp;}
[3115]117 void Print(void);
118
[3199]119//-------------------------------------------------------------------
120
[3115]121protected:
[3141]122 void setsize(long nx,long ny,long nz,double dx,double dy,double dz);
123 void setalloc(void);
124 void setpointers(bool from_real);
[3154]125 void init_fftw(void);
[3129]126 long manage_coefficients(void);
[3115]127 double compute_power_carte(void);
[3141]128 void check_array_alloc(void);
[3120]129 inline double pixelfilter(double x)
130 {return (x<0.025) ? 1.-x*x/6.*(1.-x*x/20.): sin(x)/x;}
[3115]131
[3154]132 // valeurs dans l'espace reel
[3141]133 long Nx_,Ny_,Nz_; vector<long> N_;
[3129]134 long NCz_,NTz_;
[3134]135 int_8 NRtot_;
[3141]136
137 double Dx_,Dy_,Dz_; vector<double> D_;
138
[3154]139 // valeurs dans l'espace des K
[3141]140 double Dkx_,Dky_,Dkz_; vector<double> Dk_;
141 double Knyqx_,Knyqy_,Knyqz_; vector<double> Knyq_;
142 double Dk3_;
[3115]143 double dVol_, Vol_;
144
[3154]145 // la gestion de la FFT
[3115]146 fftw_plan pf_,pb_;
147 unsigned short nthread_;
[3150]148 int lp_;
[3115]149
[3154]150 // le stockage du Cube de donnees et les pointeurs
[3141]151 bool array_allocated_; // true if array has been allocated
152 TArray< complex<r_8> >& T_;
153 fftw_complex *fdata_;
154 TArray<r_8> R_;
155 double *data_;
[3154]156
157 // l'observateur
[3157]158 CosmoCalc *cosmo_;
159 GrowthFactor *growth_;
[3271]160 double redsh_ref_,kredsh_ref_,dred_ref_;
161 double loscom_ref_,dtrc_ref_, dlum_ref_, dang_ref_;
162 double nu_ref_, dnu_ref_ ;
[3157]163 double xobs_[3];
[3271]164 double loscom_min_, loscom_max_;
[3157]165 vector<double> zred_, loscom_;
[3199]166 double loscom2zred_min_, loscom2zred_max_;
167 vector<double> loscom2zred_;
168
[3115]169};
170
[3325]171} // Fin du namespace SOPHYA
[3115]172
173#endif
Note: See TracBrowser for help on using the repository browser.