diff --git a/SciDataTool/Functions/fft_functions.py b/SciDataTool/Functions/fft_functions.py index bbbbdb6e..0bd3680d 100644 --- a/SciDataTool/Functions/fft_functions.py +++ b/SciDataTool/Functions/fft_functions.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from numpy import prod, mean, hanning, linspace, argmin, abs, where, isclose -from numpy.fft import fft, rfftn, ifftn, fftn, fftshift, ifftshift, rfft2 +from numpy.fft import fft, ifft, rfftn, ifftn, fftn, fftshift, ifftshift, rfft2 from numpy import ( pi, zeros, @@ -143,10 +143,15 @@ def comp_fft(values): ------- Complex Fourier Transform """ - values_FT = fftn(values) - values_shape = values_FT.shape - values_FT[tuple(zeros(len(values_shape), dtype=int))] *= 0.5 - values_FT = 2.0 * fftshift(values_FT) / float(prod(values_shape)) +# values_FT = fftn(values, axes=axes) +# values_shape = values_FT.shape +# size = len(values_shape) +# print(values_shape) +# values_FT[tuple([0 if i in axes else None for i in range(size)])] *= 0.5 +# values_FT = 2.0 * fftshift(values_FT, axes=axes) / float(prod([shape for i,shape in enumerate(values_shape) if i in axes])) + values_FT = fft(values) + values_FT[0] *= 0.5 + values_FT = 2.0 * fftshift(values_FT) / len(values) return values_FT @@ -160,8 +165,8 @@ def comp_ifft(values): ------- ndarray of the field """ - values_shape = values.shape - values = ifftn(ifftshift(values)) * float(prod(values_shape)) / 2.0 + + values = ifft(ifftshift(values)) * len(values) return values.real diff --git a/SciDataTool/Methods/DataND/transform.py b/SciDataTool/Methods/DataND/transform.py index a5731eee..0db0bae6 100644 --- a/SciDataTool/Methods/DataND/transform.py +++ b/SciDataTool/Methods/DataND/transform.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from SciDataTool.Functions.fft_functions import comp_fft, comp_ifft from SciDataTool.Functions.conversions import rphiz_to_xyz_field, xyz_to_rphiz_field -from numpy import apply_along_axis +from numpy import apply_along_axis, apply_over_axes def transform(self, values, axes_list): """Returns the values of the field transformed or converted. @@ -19,16 +19,16 @@ def transform(self, values, axes_list): values of the transformed field """ - is_fft = True + #is_fft = True + #values = comp_fft(values, axes=[axis_requested.index for axis_requested in axes_list if axis_requested.transform == "fft"]) for axis_requested in axes_list: + # Transform (fft, coordinates, etc) - if axis_requested.transform == "fft" and is_fft: + if axis_requested.transform == "fft": values = apply_along_axis(comp_fft, axis_requested.index, values) - is_fft = False - elif axis_requested.transform == "ifft" and is_fft: + elif axis_requested.transform == "ifft": values = apply_along_axis(comp_ifft, axis_requested.index, values) - is_fft = False - elif axis_requested.transform == "pol2cart": + if axis_requested.transform == "pol2cart": values = apply_along_axis(rphiz_to_xyz_field, axis_requested.index, values, axis_requested.values[:,1]) elif axis_requested.transform == "cart2pol": values = apply_along_axis(xyz_to_rphiz_field, axis_requested.index, values, axis_requested.values[:,1]) diff --git a/setup.py b/setup.py index ea2b91b4..105de4f1 100644 --- a/setup.py +++ b/setup.py @@ -5,14 +5,14 @@ setuptools.setup( name="SciDataTool", - version="1.0.3", + version="1.0.5", author="Helene Toubin", author_email="helene.toubin@eomys.com", description="Scientific Data Tool", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/Eomys/SciDataTool", - download_url="https://github.com/Eomys/SciDataTool/archive/1.0.3.tar.gz", + download_url="https://github.com/Eomys/SciDataTool/archive/1.0.5.tar.gz", packages=setuptools.find_packages(), classifiers=[ "Programming Language :: Python :: 3",