Commit e611fb11 authored by Matthijs's avatar Matthijs
Browse files

prevent numpy ComplexWarnings

parent fcee5c09
...@@ -3,6 +3,7 @@ from .array_tools import shifted_fft, shifted_ifft, roll_to_pos ...@@ -3,6 +3,7 @@ from .array_tools import shifted_fft, shifted_ifft, roll_to_pos
__all__ = ['fourier_interpolate'] __all__ = ['fourier_interpolate']
def fourier_interpolate(arr: np.ndarray, factor: any = 2., **kwargs) -> np.ndarray: def fourier_interpolate(arr: np.ndarray, factor: any = 2., **kwargs) -> np.ndarray:
""" """
Interpolation by padding in the Fourier domain. Interpolation by padding in the Fourier domain.
...@@ -30,7 +31,10 @@ def fourier_interpolate(arr: np.ndarray, factor: any = 2., **kwargs) -> np.ndarr ...@@ -30,7 +31,10 @@ def fourier_interpolate(arr: np.ndarray, factor: any = 2., **kwargs) -> np.ndarr
out = fourier_interpolate_3d(arr, factor=factor, **kwargs) out = fourier_interpolate_3d(arr, factor=factor, **kwargs)
else: else:
raise NotImplementedError('Can only interpolate 2d or 3d arrays as of now') raise NotImplementedError('Can only interpolate 2d or 3d arrays as of now')
return out.astype(arr.dtype, casting='unsafe') if np.isrealobj(arr):
return out.real.astype(arr.dtype, casting='unsafe')
else:
return out.astype(arr.dtype, casting='unsafe')
def fourier_interpolate_2d_nonsquare(arr: np.ndarray, factor: tuple = (1., 2.), def fourier_interpolate_2d_nonsquare(arr: np.ndarray, factor: tuple = (1., 2.),
......
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