1 | // Class examples to generate mass distribution
|
---|
2 | // R.A. for A. Abate , Nov. 2008
|
---|
3 |
|
---|
4 | #ifndef SPECPK_SEEN
|
---|
5 | #define SPECPK_SEEN
|
---|
6 |
|
---|
7 | #include "machdefs.h"
|
---|
8 | #include "sopnamsp.h"
|
---|
9 | #include <math.h>
|
---|
10 | #include <iostream>
|
---|
11 | #include <vector>
|
---|
12 | #include <string>
|
---|
13 |
|
---|
14 | #include "genericfunc.h"
|
---|
15 | #include "array.h"
|
---|
16 | #include "histats.h"
|
---|
17 | #include "fftwserver.h"
|
---|
18 | #include "randinterf.h"
|
---|
19 |
|
---|
20 | #include "mdish.h"
|
---|
21 |
|
---|
22 | #define DeuxPI 2.*M_PI
|
---|
23 |
|
---|
24 | // -- SpectralShape class : test P(k) class
|
---|
25 | class SpectralShape : public GenericFunc {
|
---|
26 | public:
|
---|
27 | SpectralShape(int typ);
|
---|
28 | // Return the value of power spectrum for wave number wk
|
---|
29 | virtual double operator() (double wk);
|
---|
30 | inline double Value(double wk) { return((*this)(wk)); }
|
---|
31 | // Return a vector representing the power spectrum (for checking)
|
---|
32 | Histo GetPk(int n=256);
|
---|
33 | double Sommek2Pk(double kmax=1000., int n=5000);
|
---|
34 | inline void SetRenormFac(double f=1.) { renorm_fac=f; }
|
---|
35 | int typ_;
|
---|
36 | double renorm_fac;
|
---|
37 | };
|
---|
38 |
|
---|
39 |
|
---|
40 | #define TF r_4
|
---|
41 |
|
---|
42 | // -- Four3DPk class : 3D fourier amplitudes and power spectrum
|
---|
43 | class Four3DPk {
|
---|
44 | public:
|
---|
45 | // Constructor
|
---|
46 | Four3DPk(TArray< complex<TF> > & fourcoedd, RandomGeneratorInterface& rg);
|
---|
47 | Four3DPk(RandomGeneratorInterface& rg, sa_size_t szx=128, sa_size_t szy=256, sa_size_t szz=128);
|
---|
48 | inline void SetCellSize(double dkx=DeuxPI, double dky=DeuxPI, double dkz=DeuxPI)
|
---|
49 | { dkx_=dkx; dky_=dky; dkz_=dkz; }
|
---|
50 | inline int SetPrtLevel(int lev=0, int prtmod=10)
|
---|
51 | { int olev=prtlev_; prtlev_=lev; prtmodulo_=prtmod; return olev; }
|
---|
52 | void ComputeFourierAmp(SpectralShape& pk);
|
---|
53 | // angscale is a multiplicative factor converting transverse k (wave number) values to angular wave numbers
|
---|
54 | // typically = ComovRadialDistance
|
---|
55 | void ComputeNoiseFourierAmp(Four2DResponse& resp, double angscale=1., bool crmask=false);
|
---|
56 | void ComputeNoiseFourierAmp(Four2DResponse& resp, double f0, double df, double angscale=1.);
|
---|
57 |
|
---|
58 | // Return the array size
|
---|
59 | inline sa_size_t NCells() { return fourAmp.Size(); }
|
---|
60 | // Set the cell size/step in Fourier Space
|
---|
61 | // Return the fourier amplitude matrix
|
---|
62 | TArray< complex<TF> > GetFourierAmp()
|
---|
63 | { return fourAmp; }
|
---|
64 | // Return the mass density matrix
|
---|
65 | TArray<TF> ComputeMassDens();
|
---|
66 |
|
---|
67 | // Return the reconstructed power spectrum as a profile histogram
|
---|
68 | HProf ComputePk(double s2cut=0., int nbin=256, double kmin=0., double kmax=-1.);
|
---|
69 | void ComputePkCumul(HProf& hp, double s2cut=0.);
|
---|
70 |
|
---|
71 | // angscale is a multiplicative factor converting transverse k (wave number) values to angular wave numbers
|
---|
72 | // typically = ComovRadialDistance
|
---|
73 | HProf ComputeNoisePk(Four2DResponse& resp, Histo& fracmodok, DataTable& dt, double angscale=1.,
|
---|
74 | double s2cut=0., int nbin=256, double kmin=0., double kmax=-1.);
|
---|
75 |
|
---|
76 | protected:
|
---|
77 | // member attribute
|
---|
78 | RandomGeneratorInterface& rg_;
|
---|
79 | TArray< complex<TF> > fourAmp; // complex array of fourier coefficients
|
---|
80 | double dkx_, dky_, dkz_;
|
---|
81 | int prtlev_;
|
---|
82 | int prtmodulo_;
|
---|
83 | };
|
---|
84 |
|
---|
85 | // --- PkNoiseCalculator :
|
---|
86 | // - Classe de calcul du spectre de bruit PNoise(k) determine par une reponse
|
---|
87 | // 2D de l'instrument
|
---|
88 | class PkNoiseCalculator
|
---|
89 | {
|
---|
90 | public:
|
---|
91 | PkNoiseCalculator(Four3DPk& pk3, Four2DResponse& rep, double s2cut=100., int ngen=1, const char* tit="PkNoise");
|
---|
92 |
|
---|
93 | inline void SetFreqRange(double freq0=835.,double dfreq=0.5)
|
---|
94 | { freq0_=freq0; dfreq_=dfreq; }
|
---|
95 | inline void SetAngScaleConversion(double angscale=1.)
|
---|
96 | { angscale_=angscale; }
|
---|
97 | inline void SetS2Cut(double s2cut=100.)
|
---|
98 | { S2CUT=s2cut; }
|
---|
99 | inline double GetS2Cut() { return S2CUT; }
|
---|
100 | HProf Compute();
|
---|
101 | inline int SetPrtLevel(int lev=0, int prtmod=10)
|
---|
102 | { int olev=prtlev_; prtlev_=lev; prtmodulo_=prtmod; return olev; }
|
---|
103 |
|
---|
104 | protected:
|
---|
105 | Four3DPk& pkn3d;
|
---|
106 | Four2DResponse& frep;
|
---|
107 | double freq0_,dfreq_;
|
---|
108 | double angscale_;
|
---|
109 | double S2CUT;
|
---|
110 | int NGEN;
|
---|
111 | string title;
|
---|
112 | int prtlev_;
|
---|
113 | int prtmodulo_;
|
---|
114 | };
|
---|
115 |
|
---|
116 |
|
---|
117 |
|
---|
118 | // -- MassDist2D class : 2D mass distribution
|
---|
119 | class MassDist2D {
|
---|
120 | public:
|
---|
121 | // Constructor
|
---|
122 | MassDist2D(GenericFunc& pk, int size=1024, double meandens=1.);
|
---|
123 | // Do the computation
|
---|
124 | void Compute();
|
---|
125 | // Return the array size
|
---|
126 | inline sa_size_t ArrSize() { return sizeA; }
|
---|
127 | // Return the fourier amplitude matrix
|
---|
128 | TMatrix< complex<r_8> > GetFourierAmp()
|
---|
129 | { if (!fg_fourAmp) ComputeFourierAmp(); return fourAmp; }
|
---|
130 | // Return the mass density matrix
|
---|
131 | Matrix GetMassDens()
|
---|
132 | { if (!fg_massDens) ComputeMassDens(); return massDens; }
|
---|
133 |
|
---|
134 | // Return the reconstructed power spectrum as a profile histogram
|
---|
135 | HProf ReconstructPk(int nbin=0);
|
---|
136 | protected:
|
---|
137 | void ComputeFourierAmp();
|
---|
138 | void ComputeMassDens();
|
---|
139 |
|
---|
140 | // member attribute
|
---|
141 | GenericFunc& pkSpec; // The spectralShape
|
---|
142 | sa_size_t sizeA; // 2D array size
|
---|
143 | double meanRho; // Mean Density
|
---|
144 | bool fg_fourAmp; // true -> fourAmp computed
|
---|
145 | TMatrix< complex<r_8> > fourAmp; // complex array of fourier coefficients
|
---|
146 | bool fg_massDens; // true -> MassDens computed
|
---|
147 | TMatrix< r_8 > massDens; // real array of d rho/rho
|
---|
148 | };
|
---|
149 |
|
---|
150 |
|
---|
151 | #endif
|
---|