Commit 2f3f3889 authored by Philipp Arras's avatar Philipp Arras
Browse files

Remove FFTInterpolator

parent b43edde6
Pipeline #93849 failed with stages
in 6 minutes and 15 seconds
......@@ -28,7 +28,6 @@ from .operators.domain_tuple_field_inserter import DomainTupleFieldInserter
from .operators.einsum import LinearEinsum, MultiLinearEinsum
from .operators.contraction_operator import ContractionOperator, IntegrationOperator
from .operators.linear_interpolation import LinearInterpolator
from .operators.fft_interpolation import FFTInterpolator
from .operators.endomorphic_operator import EndomorphicOperator
from .operators.harmonic_operators import (
FFTOperator, HartleyOperator, SHTOperator, HarmonicTransformOperator,
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <>.
# Copyright(C) 2013-2021 Max-Planck-Society
# Authors: Vincent Eberle und Philipp Arras
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import numpy as np
from ..library.nft import FinuFFT
from ..sugar import makeDomain, makeField
from .harmonic_operators import HartleyOperator
from import RGSpace
from .linear_operator import LinearOperator
class FFTInterpolator(LinearOperator):
"""FFT Interpolation using FinuFFT and HartleyOperator
domain : RGSpace
sampling_points : numpy.ndarray
Positions at which to interpolate, shape (dim, ndata)
eps :
nthreads :
#FIXME Documentation from Philipp
def __init__(self, domain, pos, eps=2e-12):
self._domain = makeDomain(domain)
if not isinstance(pos, np.ndarray):
raise TypeError("sampling_points need to be a numpy.ndarray")
if pos.ndim != 2:
raise ValueError("sampling_points must be a 2D array")
dist = [list(dom.distances) for dom in self.domain]
dist = np.array(dist).reshape(-1, 1)
pos = pos / dist
finudom = RGSpace(self.domain.shape)
self._finu = FinuFFT(finudom, pos.T, eps)
self._ht = HartleyOperator(self._domain)
self._capability = self.TIMES | self.ADJOINT_TIMES
self._target = self._finu.domain
def apply(self, x, mode):
self._check_input(x, mode)
ht = self._ht
finu = self._finu
if mode == self.TIMES:
x = ht(x)
x = makeField(, np.fft.fftshift(x.val))
x = finu.adjoint(x)
x = x.real + x.imag
x = finu(x + 1j*x)
x = makeField(, np.fft.ifftshift(x.val))
x = ht.adjoint(x)
return x/self.domain.total_volume()
......@@ -23,7 +23,7 @@ import nifty7 as ift
pmp = pytest.mark.parametrize
@pmp("interpolator", ["FFTInterpolator", "LinearInterpolator"])
@pmp("interpolator", "LinearInterpolator")
def test_grid_points(interpolator):
res = 64
vol = 2
......@@ -41,6 +41,3 @@ def test_grid_points(interpolator):
inp = ift.from_random(R.domain)
out = R(inp).val
np.testing.assert_allclose(out, inp.val.reshape(-1), rtol=1e-7)
#TODO Generate one Fourriermode, read out between gridpoints, check if right value
Supports Markdown
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