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

Last change on this file since 3930 was 3930, checked in by ansari, 15 years ago

ajout config double hexagon + programme calcul pknoise a partir du resultat de repicon.cc, Reza 22/12/2010

File size: 4.0 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);
48 inline void SetCellSize(double dkx=DeuxPI, double dky=DeuxPI, double dkz=DeuxPI)
49 { dkx_=dkx; dky_=dky; dkz_=dkz; }
[3930]50 inline int SetPrtLevel(int lev=0, int prtmod=10)
51 { int olev=prtlev_; prtlev_=lev; prtmodulo_=prtmod; return olev; }
[3756]52 void ComputeFourierAmp(SpectralShape& pk);
53 void ComputeNoiseFourierAmp(Four2DResponse& resp, bool crmask=false);
54// Return the array size
55 inline sa_size_t NCells() { return fourAmp.Size(); }
56// Set the cell size/step in Fourier Space
57// Return the fourier amplitude matrix
58 TArray< complex<TF> > GetFourierAmp()
59 { return fourAmp; }
60// Return the mass density matrix
61 TArray<TF> ComputeMassDens();
62
63// Return the reconstructed power spectrum as a profile histogram
[3769]64 HProf ComputePk(double s2cut=0., int nbin=256, double kmin=0., double kmax=-1.);
[3756]65 void ComputePkCumul(HProf& hp, double s2cut=0.);
66
67protected:
68 // member attribute
69 RandomGeneratorInterface& rg_;
70 TArray< complex<TF> > fourAmp; // complex array of fourier coefficients
71 double dkx_, dky_, dkz_;
72 int prtlev_;
[3930]73 int prtmodulo_;
[3756]74};
75
[3930]76// --- PkNoiseCalculator :
77// - Classe de calcul du spectre de bruit PNoise(k) determine par une reponse
78// 2D de l'instrument
79class PkNoiseCalculator
80{
81public:
82 PkNoiseCalculator(Four3DPk& pk3, Four2DResponse& rep, double s2cut=100., int ngen=1, const char* tit="PkNoise");
83
84 inline void SetS2Cut(double s2cut=100.)
85 { S2CUT=s2cut; }
86 inline double GetS2Cut() { return S2CUT; }
87 HProf Compute();
88 inline int SetPrtLevel(int lev=0, int prtmod=10)
89 { int olev=prtlev_; prtlev_=lev; prtmodulo_=prtmod; return olev; }
[3756]90
[3930]91protected:
92 Four3DPk& pkn3d;
93 Four2DResponse& frep;
94 double S2CUT;
95 int NGEN;
96 string title;
97 int prtlev_;
98 int prtmodulo_;
99};
100
101
102
[3756]103// -- MassDist2D class : 2D mass distribution
104class MassDist2D {
105public:
106// Constructor
107 MassDist2D(GenericFunc& pk, int size=1024, double meandens=1.);
108// Do the computation
109 void Compute();
110// Return the array size
111 inline sa_size_t ArrSize() { return sizeA; }
112// Return the fourier amplitude matrix
113 TMatrix< complex<r_8> > GetFourierAmp()
114 { if (!fg_fourAmp) ComputeFourierAmp(); return fourAmp; }
115// Return the mass density matrix
116 Matrix GetMassDens()
117 { if (!fg_massDens) ComputeMassDens(); return massDens; }
118
119// Return the reconstructed power spectrum as a profile histogram
120 HProf ReconstructPk(int nbin=0);
121protected:
122 void ComputeFourierAmp();
123 void ComputeMassDens();
124
125// member attribute
126 GenericFunc& pkSpec; // The spectralShape
127 sa_size_t sizeA; // 2D array size
128 double meanRho; // Mean Density
129 bool fg_fourAmp; // true -> fourAmp computed
130 TMatrix< complex<r_8> > fourAmp; // complex array of fourier coefficients
131 bool fg_massDens; // true -> MassDens computed
132 TMatrix< r_8 > massDens; // real array of d rho/rho
133};
134
135
136#endif
Note: See TracBrowser for help on using the repository browser.