Implemented power spectrum support in Euclidian/Healpix
This commit is contained in:
parent
db6831e594
commit
cc7996175c
5 changed files with 178 additions and 16 deletions
|
@ -1,13 +1,23 @@
|
|||
#include "yorick.hpp"
|
||||
#include <gsl/gsl_rng.h>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include "fourier/euclidian.hpp"
|
||||
|
||||
using namespace CosmoTool;
|
||||
using namespace std;
|
||||
|
||||
double spectrum_generator(double k)
|
||||
{
|
||||
return 1/(0.1+pow(k, 3.0));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
EuclidianFourierTransform_2d<double> dft(128,128,1.0,1.0);
|
||||
EuclidianSpectrum_1D<double> spectrum(spectrum_generator);
|
||||
double volume = 128*128;
|
||||
gsl_rng *rng = gsl_rng_alloc(gsl_rng_default);
|
||||
|
||||
dft.realSpace().eigen().setRandom();
|
||||
dft.analysis();
|
||||
|
@ -15,6 +25,17 @@ int main()
|
|||
cout << "Fourier dot-product = " << dft.fourierSpace().dot_product(dft.fourierSpace()).real()*volume << endl;
|
||||
dft.synthesis();
|
||||
cout << "Resynthesis dot-product = " << dft.realSpace().dot_product(dft.realSpace()) << endl;
|
||||
|
||||
dft.realSpace().scale(2.0);
|
||||
dft.fourierSpace().scale(0.2);
|
||||
|
||||
SpectrumFunction<double>::FourierMapPtr m = spectrum.newRandomFourier(rng, dft.fourierSpace());
|
||||
dft.fourierSpace() = *m.get();
|
||||
dft.synthesis();
|
||||
|
||||
uint32_t dims[2] = { 128, 128 };
|
||||
CosmoTool::saveArray("generated_map.nc", dft.realSpace().data(), dims, 2);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using namespace std;
|
|||
|
||||
int main()
|
||||
{
|
||||
HealpixFourierTransform<double> dft(128,3*128,3*128, 40);
|
||||
HealpixFourierTransform<double> dft(128,2*128,2*128, 40);
|
||||
long Npix = dft.realSpace().size();
|
||||
|
||||
dft.realSpace().eigen().setRandom();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue