[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
|
---|
| 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 | int typ_;
|
---|
| 34 | };
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | #define TF r_4
|
---|
| 38 |
|
---|
| 39 | // -- Four3DPk class : 3D fourier amplitudes and power spectrum
|
---|
| 40 | class Four3DPk {
|
---|
| 41 | public:
|
---|
| 42 | // Constructor
|
---|
| 43 | Four3DPk(TArray< complex<TF> > & fourcoedd, RandomGeneratorInterface& rg);
|
---|
| 44 | Four3DPk(RandomGeneratorInterface& rg, sa_size_t szx=128, sa_size_t szy=256, sa_size_t szz=128);
|
---|
| 45 | inline void SetCellSize(double dkx=DeuxPI, double dky=DeuxPI, double dkz=DeuxPI)
|
---|
| 46 | { dkx_=dkx; dky_=dky; dkz_=dkz; }
|
---|
| 47 | inline int SetPrtLevel(int lev=0)
|
---|
| 48 | { int olev=prtlev_; prtlev_=lev; return olev; }
|
---|
| 49 | void ComputeFourierAmp(SpectralShape& pk);
|
---|
| 50 | void ComputeNoiseFourierAmp(Four2DResponse& resp, bool crmask=false);
|
---|
| 51 | // Return the array size
|
---|
| 52 | inline sa_size_t NCells() { return fourAmp.Size(); }
|
---|
| 53 | // Set the cell size/step in Fourier Space
|
---|
| 54 | // Return the fourier amplitude matrix
|
---|
| 55 | TArray< complex<TF> > GetFourierAmp()
|
---|
| 56 | { return fourAmp; }
|
---|
| 57 | // Return the mass density matrix
|
---|
| 58 | TArray<TF> ComputeMassDens();
|
---|
| 59 |
|
---|
| 60 | // Return the reconstructed power spectrum as a profile histogram
|
---|
[3769] | 61 | HProf ComputePk(double s2cut=0., int nbin=256, double kmin=0., double kmax=-1.);
|
---|
[3756] | 62 | void ComputePkCumul(HProf& hp, double s2cut=0.);
|
---|
| 63 |
|
---|
| 64 | protected:
|
---|
| 65 | // member attribute
|
---|
| 66 | RandomGeneratorInterface& rg_;
|
---|
| 67 | TArray< complex<TF> > fourAmp; // complex array of fourier coefficients
|
---|
| 68 | double dkx_, dky_, dkz_;
|
---|
| 69 | int prtlev_;
|
---|
| 70 | };
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | // -- MassDist2D class : 2D mass distribution
|
---|
| 74 | class MassDist2D {
|
---|
| 75 | public:
|
---|
| 76 | // Constructor
|
---|
| 77 | MassDist2D(GenericFunc& pk, int size=1024, double meandens=1.);
|
---|
| 78 | // Do the computation
|
---|
| 79 | void Compute();
|
---|
| 80 | // Return the array size
|
---|
| 81 | inline sa_size_t ArrSize() { return sizeA; }
|
---|
| 82 | // Return the fourier amplitude matrix
|
---|
| 83 | TMatrix< complex<r_8> > GetFourierAmp()
|
---|
| 84 | { if (!fg_fourAmp) ComputeFourierAmp(); return fourAmp; }
|
---|
| 85 | // Return the mass density matrix
|
---|
| 86 | Matrix GetMassDens()
|
---|
| 87 | { if (!fg_massDens) ComputeMassDens(); return massDens; }
|
---|
| 88 |
|
---|
| 89 | // Return the reconstructed power spectrum as a profile histogram
|
---|
| 90 | HProf ReconstructPk(int nbin=0);
|
---|
| 91 | protected:
|
---|
| 92 | void ComputeFourierAmp();
|
---|
| 93 | void ComputeMassDens();
|
---|
| 94 |
|
---|
| 95 | // member attribute
|
---|
| 96 | GenericFunc& pkSpec; // The spectralShape
|
---|
| 97 | sa_size_t sizeA; // 2D array size
|
---|
| 98 | double meanRho; // Mean Density
|
---|
| 99 | bool fg_fourAmp; // true -> fourAmp computed
|
---|
| 100 | TMatrix< complex<r_8> > fourAmp; // complex array of fourier coefficients
|
---|
| 101 | bool fg_massDens; // true -> MassDens computed
|
---|
| 102 | TMatrix< r_8 > massDens; // real array of d rho/rho
|
---|
| 103 | };
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 | #endif
|
---|