Commit 083b198d authored by Martin Reinecke's avatar Martin Reinecke
Browse files

re-introduce Gauss-Legendre helper functions to ducc0.misc

parent 6de3387e
Pipeline #101563 passed with stages
in 17 minutes and 53 seconds
......@@ -33,6 +33,7 @@
#include "ducc0/infra/transpose.h"
#include "ducc0/math/fft.h"
#include "ducc0/math/constants.h"
#include "ducc0/math/gl_integrator.h"
#include "ducc0/bindings/pybind_utils.h"
namespace ducc0 {
......@@ -42,6 +43,28 @@ namespace detail_pymodule_misc {
using namespace std;
namespace py = pybind11;
py::array Py_GL_weights(size_t nlat, size_t nlon)
{
auto res = make_Pyarr<double>({nlat});
auto res2 = to_mav<double,1>(res, true);
GL_Integrator integ(nlat);
auto wgt = integ.weights();
for (size_t i=0; i<res2.shape(0); ++i)
res2.v(i) = wgt[i]*twopi/nlon;
return move(res);
}
py::array Py_GL_thetas(size_t nlat)
{
auto res = make_Pyarr<double>({nlat});
auto res2 = to_mav<double,1>(res, true);
GL_Integrator integ(nlat);
auto x = integ.coords();
for (size_t i=0; i<res2.shape(0); ++i)
res2.v(i) = acos(-x[i]);
return move(res);
}
void upsample_to_cc(const mav<double,2> &in, bool has_np, bool has_sp,
mav<double,2> &out)
{
......@@ -159,6 +182,9 @@ void add_misc(py::module_ &msup)
auto m = msup.def_submodule("misc");
m.doc() = misc_DS;
m.def("GL_weights",&Py_GL_weights, "nlat"_a, "nlon"_a);
m.def("GL_thetas",&Py_GL_thetas, "nlat"_a);
m.def("upsample_to_cc",&Py_upsample_to_cc, "in"_a, "nrings_out"_a,
"has_np"_a, "has_sp"_a, "out"_a=py::none());
......
......@@ -8,7 +8,7 @@ from setuptools import setup, Extension
import pybind11
pkgname = 'ducc0'
version = '0.10.0'
version = '0.10.1'
user_cflags = os.getenv("DUCC0_CFLAGS", "").split(" ")
user_cflags = [x for x in user_cflags if x != ""]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment