source: Sophya/trunk/Cosmo/RadioBeam/specpk.h@ 4027

Last change on this file since 4027 was 4027, checked in by ansari, 14 years ago

Implementatiom prise en compte dA(z) ds la calcul de bruit Pnoise(k) - Reza 17/10/2011

File size: 5.4 KB
RevLine 
[3756]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
25class SpectralShape : public GenericFunc {
26public:
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)
[3825]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; }
[3756]35 int typ_;
[3825]36 double renorm_fac;
[3756]37};
38
39
40#define TF r_4
41
42// -- Four3DPk class : 3D fourier amplitudes and power spectrum
43class Four3DPk {
44public:
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);
[4027]48 virtual ~Four3DPk();
49
[3756]50 inline void SetCellSize(double dkx=DeuxPI, double dky=DeuxPI, double dkz=DeuxPI)
51 { dkx_=dkx; dky_=dky; dkz_=dkz; }
[3930]52 inline int SetPrtLevel(int lev=0, int prtmod=10)
53 { int olev=prtlev_; prtlev_=lev; prtmodulo_=prtmod; return olev; }
[3756]54 void ComputeFourierAmp(SpectralShape& pk);
[4026]55// angscale is a multiplicative factor converting transverse k (wave number) values to angular wave numbers
56// typically = ComovRadialDistance
57 void ComputeNoiseFourierAmp(Four2DResponse& resp, double angscale=1., bool crmask=false);
[4027]58 void ComputeNoiseFourierAmp(Four2DResponse& resp, double f0, double df, Vector& angscales);
[4026]59
[3756]60// Return the array size
61 inline sa_size_t NCells() { return fourAmp.Size(); }
[4027]62 inline sa_size_t SizeX() { return fourAmp.SizeX(); }
63 inline sa_size_t SizeY() { return fourAmp.SizeY(); }
64 inline sa_size_t SizeZ() { return fourAmp.SizeZ(); }
65
[3756]66// Set the cell size/step in Fourier Space
67// Return the fourier amplitude matrix
68 TArray< complex<TF> > GetFourierAmp()
69 { return fourAmp; }
70// Return the mass density matrix
71 TArray<TF> ComputeMassDens();
72
73// Return the reconstructed power spectrum as a profile histogram
[4027]74 HProf ComputePk(double s2cut=0., int nbin=256, double kmin=0., double kmax=-1., bool fgmodcnt=false);
75 void ComputePkCumul();
[3756]76
[4026]77// angscale is a multiplicative factor converting transverse k (wave number) values to angular wave numbers
78// typically = ComovRadialDistance
[4027]79 HProf ComputeNoisePk(Four2DResponse& resp, double angscale=1., double s2cut=0.,
80 int nbin=256, double kmin=0., double kmax=-1.);
[3947]81
[4027]82 // Fills a data table from the computed P(k) profile histogram and mode count
83 Histo FillPkDataTable(DataTable& dt);
84 inline HProf& GetPk() { return *hp_pk_p_; }
85
[3756]86protected:
87 // member attribute
88 RandomGeneratorInterface& rg_;
89 TArray< complex<TF> > fourAmp; // complex array of fourier coefficients
90 double dkx_, dky_, dkz_;
91 int prtlev_;
[3930]92 int prtmodulo_;
[4027]93 // Profile histograms for power spectrum and number of modes
94 HProf* hp_pk_p_;
95 Histo* hmcnt_p_;
96 Histo* hmcntok_p_;
97 double s2cut_;
[3756]98};
99
[3930]100// --- PkNoiseCalculator :
101// - Classe de calcul du spectre de bruit PNoise(k) determine par une reponse
102// 2D de l'instrument
103class PkNoiseCalculator
104{
105public:
106 PkNoiseCalculator(Four3DPk& pk3, Four2DResponse& rep, double s2cut=100., int ngen=1, const char* tit="PkNoise");
107
[4026]108 inline void SetFreqRange(double freq0=835.,double dfreq=0.5)
109 { freq0_=freq0; dfreq_=dfreq; }
110 inline void SetAngScaleConversion(double angscale=1.)
[4027]111 { angscales_=angscale; }
112 inline void SetAngScaleConversion(Vector& angscs)
113 { angscales_=angscs; }
[3930]114 inline void SetS2Cut(double s2cut=100.)
115 { S2CUT=s2cut; }
116 inline double GetS2Cut() { return S2CUT; }
[4027]117 HProf Compute(int nbin=256, double kmin=0., double kmax=-1.);
[3930]118 inline int SetPrtLevel(int lev=0, int prtmod=10)
119 { int olev=prtlev_; prtlev_=lev; prtmodulo_=prtmod; return olev; }
[3756]120
[3930]121protected:
122 Four3DPk& pkn3d;
123 Four2DResponse& frep;
[4026]124 double freq0_,dfreq_;
[4027]125 Vector angscales_;
[3930]126 double S2CUT;
127 int NGEN;
128 string title;
129 int prtlev_;
130 int prtmodulo_;
131};
132
133
134
[3756]135// -- MassDist2D class : 2D mass distribution
136class MassDist2D {
137public:
138// Constructor
139 MassDist2D(GenericFunc& pk, int size=1024, double meandens=1.);
140// Do the computation
141 void Compute();
142// Return the array size
143 inline sa_size_t ArrSize() { return sizeA; }
144// Return the fourier amplitude matrix
145 TMatrix< complex<r_8> > GetFourierAmp()
146 { if (!fg_fourAmp) ComputeFourierAmp(); return fourAmp; }
147// Return the mass density matrix
148 Matrix GetMassDens()
149 { if (!fg_massDens) ComputeMassDens(); return massDens; }
150
151// Return the reconstructed power spectrum as a profile histogram
152 HProf ReconstructPk(int nbin=0);
153protected:
154 void ComputeFourierAmp();
155 void ComputeMassDens();
156
157// member attribute
158 GenericFunc& pkSpec; // The spectralShape
159 sa_size_t sizeA; // 2D array size
160 double meanRho; // Mean Density
161 bool fg_fourAmp; // true -> fourAmp computed
162 TMatrix< complex<r_8> > fourAmp; // complex array of fourier coefficients
163 bool fg_massDens; // true -> MassDens computed
164 TMatrix< r_8 > massDens; // real array of d rho/rho
165};
166
167
168#endif
Note: See TracBrowser for help on using the repository browser.