Commit 856a8d59 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

first steps towards HarmonicOperator

parent 8daf1615
Pipeline #12146 passed with stage
in 5 minutes and 43 seconds
......@@ -40,7 +40,7 @@ class FFTOperator(LinearOperator):
default_codomain_dictionary = {RGSpace: RGSpace,
HPSpace: LMSpace,
GLSpace: LMSpace,
LMSpace: HPSpace,
LMSpace: GLSpace,
}
transformation_dictionary = {(RGSpace, RGSpace): RGRGTransformation,
......@@ -52,7 +52,7 @@ class FFTOperator(LinearOperator):
# ---Overwritten properties and methods---
def __init__(self, domain=(), target=None, module=None,
def __init__(self, domain, target=None, module=None,
domain_dtype=None, target_dtype=None):
# Initialize domain and target
......@@ -81,6 +81,8 @@ class FFTOperator(LinearOperator):
self._backward_transformation = TransformationCache.create(
backward_class, self.target[0], self.domain[0], module=module)
#MR FIXME: these defaults do not work for SHTs as they are currently
# implemented. Should have either float or complex on both sides.
# Store the dtype information
if domain_dtype is None:
self.logger.info("Setting domain_dtype to np.float.")
......@@ -118,7 +120,7 @@ class FFTOperator(LinearOperator):
return result_field
def _inverse_times(self, x, spaces):
def _adjoint_times(self, x, spaces):
spaces = utilities.cast_axis_to_tuple(spaces, len(x.domain))
if spaces is None:
# this case means that x lives on only one space, which is
......@@ -158,7 +160,7 @@ class FFTOperator(LinearOperator):
@property
def unitary(self):
return True
return False
# ---Added properties and methods---
......
......@@ -98,7 +98,7 @@ class HPLMTransformation(SlicingTransformation):
if issubclass(inp.dtype.type, np.complexfloating):
[resultReal,
resultImag] = [pyHealpix.map2alm_iter(x, lmax, mmax, 3)
resultImag] = [pyHealpix.map2alm(x, lmax, mmax)
for x in (inp.real, inp.imag)]
[resultReal,
......@@ -108,7 +108,7 @@ class HPLMTransformation(SlicingTransformation):
result = self._combine_complex_result(resultReal, resultImag)
else:
result = pyHealpix.map2alm_iter(inp, lmax, mmax, 3)
result = pyHealpix.map2alm(inp, lmax, mmax)
result = lm_transformation_helper.buildIdx(result, lmax=lmax)
return result
......@@ -143,7 +143,7 @@ class SmoothingOperator(EndomorphicOperator):
transformed_x.val.set_local_data(local_transformed_x, copy=False)
smoothed_x = Transformator.inverse_times(transformed_x, spaces=spaces)
smoothed_x = Transformator.adjoint_times(transformed_x, spaces=spaces)
result = x.copy_empty()
result.set_val(smoothed_x, copy=False)
......
......@@ -80,7 +80,7 @@ class Misc_Tests(unittest.TestCase):
target_dtype=_harmonic_type(itp), module=module)
inp = Field.from_random(domain=a, random_type='normal', std=7, mean=3,
dtype=itp)
out = fft.inverse_times(fft.times(inp))
out = fft.adjoint_times(fft.times(inp))
assert_allclose(inp.val, out.val, rtol=tol, atol=tol)
@expand(product(["numpy", "fftw"], [10, 11], [9, 12], [False, True],
......@@ -96,7 +96,7 @@ class Misc_Tests(unittest.TestCase):
target_dtype=_harmonic_type(itp), module=module)
inp = Field.from_random(domain=a, random_type='normal', std=7, mean=3,
dtype=itp)
out = fft.inverse_times(fft.times(inp))
out = fft.adjoint_times(fft.times(inp))
assert_allclose(inp.val, out.val, rtol=tol, atol=tol)
@expand(product([0, 3, 6, 11, 30],
......@@ -110,7 +110,7 @@ class Misc_Tests(unittest.TestCase):
fft = FFTOperator(domain=a, target=b, domain_dtype=tp, target_dtype=tp)
inp = Field.from_random(domain=a, random_type='normal', std=7, mean=3,
dtype=tp)
out = fft.inverse_times(fft.times(inp))
out = fft.adjoint_times(fft.times(inp))
assert_allclose(inp.val, out.val, rtol=tol, atol=tol)
@expand(product([128, 256],
......@@ -123,5 +123,5 @@ class Misc_Tests(unittest.TestCase):
fft = FFTOperator(domain=a, target=b, domain_dtype=tp, target_dtype=tp)
inp = Field.from_random(domain=a, random_type='normal', std=1, mean=0,
dtype=tp)
out = fft.inverse_times(fft.times(inp))
assert_allclose(inp.val, out.val, rtol=1e-3, atol=1e-3)
out = fft.adjoint_times(fft.times(inp))
assert_allclose(inp.val, out.val, rtol=1e-3, atol=1e-1)
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