pyFFTW | A pythonic python wrapper around FFTW

 by   pyFFTW Python Version: Current License: Non-SPDX

kandi X-RAY | pyFFTW Summary

kandi X-RAY | pyFFTW Summary

null

A pythonic python wrapper around FFTW
Support
    Quality
      Security
        License
          Reuse

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pyFFTW
            Get all kandi verified functions for this library.

            pyFFTW Key Features

            No Key Features are available at this moment for pyFFTW.

            pyFFTW Examples and Code Snippets

            No Code Snippets are available at this moment for pyFFTW.

            Community Discussions

            QUESTION

            Matplotlib speed up saving plots to disk
            Asked 2021-Feb-10 at 10:06

            I want to create an animation from roughly 250 individual frames, showing data plotted as 2D images in a figure with 4 x 11 subpanels. The data represent power spectra of velocity as a function of temporal frequency and latitude. However, each frame takes about 4 seconds to create and save, including run-time computation of the data. In the non-interactive plotting mode, I use 'agg' as the backend to avoid time spent for interactivity plotting features.

            The speed bottleneck here is not the computation of the data to plot, but saving the plots to disk. Example run-times for random data (see code below) and only 5 frames without saving the plots are sth. like 5 seconds, with saving the plots 17-19 seconds. For the actual data I use, there are some more plot artists to be drawn (text on panels, an additional line plot etc.), but the script execution time is quite similar. For the about 250 frames in total, this indicates roughly 900 seconds, thus 15 minutes to compute the data and then save the plots. However, since I likely want to generate similar frames several times or with slightly different data, it would be good to decrease this script execution time.

            A (hopefully) reproducible code, using random data, but with data sizes equal to the actual data I use, is given below. An example frame (the first one generated by the code) can also be found below. In the code, the function create_fig() generates a figure with subpanels containing dummy data and in the for-loop over the different frames, only the data in the subpanels is replaced.

            Is there a way to speed-up saving the plots into the png files? Any help is much appreciated!

            ...

            ANSWER

            Answered 2021-Feb-09 at 16:57

            I will give you some tips, but can be not a solution:

            • You are doing the rigth thing to run over the matrix, but check if can maximize the cache transposing your matrix (when you have a very tall and narrow case)

            • Have your heard about of sparse-matrix or matrix compressing techniques?

            • do the stuff that you need to do when i<1 outside of the for loop - you will save 1 comparison if you take out that

            • can you use parallel computation? like Omp for python?

            Source https://stackoverflow.com/questions/66123211

            QUESTION

            Why do the R and Python FFT give different results?
            Asked 2020-Dec-03 at 10:13

            I was running a simple experiment when I noticed a difference between R's and Python's FFT.

            First, Python:

            ...

            ANSWER

            Answered 2020-Dec-03 at 10:13

            Following the suggestion in the comments, I did the following:

            Source https://stackoverflow.com/questions/65113748

            QUESTION

            Phase discontinuity happens during ifft operation using pyfftw and scipy.fft
            Asked 2020-Jun-11 at 14:18

            When doing ifft of a 2D ndarray using pyfftw, I found the resultant phase is discontinuous in many positions. My code is as follows:

            ...

            ANSWER

            Answered 2020-Jun-11 at 09:30

            A phase is best shown as an angle on a unit circle. And a circle does not have a begin and an end. Going around the circle does not create a discontinuity. Adding exactly 2*pi (one trip around the circle) does not change the phase, so +pi and -pi are the same phase. The absolute difference of those two phases is thus not 2*pi, but zero. If you take in account tiny rounding errors, it is almost zero.

            My suggestion is to use a "cyclic" color scheme (don't know a better term), where approaching +pi on one end and -pi on the other end colors the graph with the same color.

            Source https://stackoverflow.com/questions/62320258

            QUESTION

            Import Error with pyFFTW (scipy.fftpack) in Python 3.8
            Asked 2020-Feb-24 at 12:19

            I have a numerical simulation program that works fine at the institute I'm in, there I have a Win10 box where I installed Python 3.7.3 64-bit. I am trying to run the same program in my laptop with Manjaro and Python 3.8.1 (It was also 3.7.3 at the time I installed it, but rolling release ¬¬). The problem is that in my laptop I am getting the following error when trying to import pyFFTW

            ...

            ANSWER

            Answered 2020-Feb-24 at 12:19

            This is fixed in master. A release should be made shortly. You can either wait for that or pull from github.

            Edit: Release made that fixes this on Feb 3 2020.

            Source https://stackoverflow.com/questions/59959319

            QUESTION

            Efficiently using 1-D pyfftw on small slices of a 3-D numpy array
            Asked 2019-Aug-30 at 18:35

            I have a 3D data cube of values of size on the order of 10,000x512x512. I want to parse a window of vectors (say 6) along dim[0] repeatedly and generate the fourier transforms efficiently. I think I'm doing an array copy into the pyfftw package and it's giving me massive overhead. I'm going over the documentation now since I think there is an option I need to set, but I could use some extra help on the syntax.

            This code was originally written by another person with numpy.fft.rfft and accelerated with numba. But the implementation wasn't working on my workstation so I re-wrote everything and opted to go for pyfftw instead.

            ...

            ANSWER

            Answered 2019-Aug-30 at 18:35

            The FFTW advanced plans can be automatically built by pyfftw. The code could be modified in the following way:

            • Real to complex transforms can be used instead of complex to complex transform. Using pyfftw, it typically writes:

            Source https://stackoverflow.com/questions/57716884

            QUESTION

            What is wrong with this Fourier transform? (in python)
            Asked 2019-Jul-03 at 09:45

            As people who have read my previous posts on this site could tell, I have been trying to implement a PDE solver that uses FFT in Python. The programming part is mostly worked out, but the program produces an (very suitable for this site) overflow error (basically it grows very much until it becomes a NaN).

            After ruling out all other possibilities, I pinned down the problem to the FFT and the way I am trying to do the derivatives, so I decided to test two different FFT's (numpy's fft module and the pyFFTW package) with the following code:

            ...

            ANSWER

            Answered 2019-Jul-03 at 09:45

            The mistake here is that your assumptions about your function are not correct. e^x sin(y) might seem harmonic, but you only calculated it for -1 < x,y < 1. The fft will implicitly continue it periodically, i.e. you get discontinuities at all the edges of your function. If the function is not continuous, it's not harmonic and especially you get divergences in the Fourier transfom. This is what makes your FFT diverge at the edges. Besides that, "far away" from the edges, the results look as expected.

            Source https://stackoverflow.com/questions/56858722

            QUESTION

            Calculation of Laplacian in real pyFFTW
            Asked 2019-Jun-28 at 19:15

            For the forward (multidimensional) FFTW algorithm you can specify that the input numpy.ndarray is real, and the output should be complex. This is done when creating the byte-aligned arrays that go in the arguments of the fft_object:

            ...

            ANSWER

            Answered 2019-Jun-28 at 19:15

            I'm not familiar with pyfftw, but with the numpy.fft module it would work just fine (assuming you use rfftfreq as mentioned in the comments).

            To recap: for a real array, a, the fourier transform, b, has a Hermtian-like property: b(-kx,-ky) is the complex conjugate of b(kx,ky). The real version of the forward fft discards (most of) the redundant information by omitting the negative kys. The real version of the backward fft assumes that the values at the missing frequencies can be found by complex conjugating the appropriate elements.

            If you had used the complex fft and kept all frequencies, -k2 * b would still have the Hermitian-like property. So the assumption made by the real backward fft still holds and would give the correct answer.

            I guess with pyfftw it will work just fine provided that you specify a float64 array of the correct size for the output for the direction=FFT_BACKWARD case.

            Source https://stackoverflow.com/questions/56810488

            QUESTION

            How to use numpy for large sets of data
            Asked 2019-Jun-17 at 21:47

            I have a really big set of datapoints (1 million at least). I am using pyFFTW to do the FFT. To get the x axis values, I am using x = np.linespace(0.0, 1.0 / (2.0 * T), len(fft_data))

            I need to return all the FFT values as list of lists (e.g: [[x1, y1], [x2, y2]]).

            I am using this code:

            ...

            ANSWER

            Answered 2019-Jun-17 at 20:19

            QUESTION

            Attempting to use pyfftw - "The output array and input array dtypes do not correspond to a valid fftw scheme."
            Asked 2019-May-31 at 15:12

            I am using pyfftw for a simple fft. I am unsure how to use pyfftw because I am getting the error:

            ...

            ANSWER

            Answered 2019-May-31 at 15:12

            You may want to use complex128 as the output type, since the DFT of a real-valued signal is complex-valued in general (unless the real-valued signal is symmetric).

            See https://hgomersall.github.io/pyFFTW/pyfftw/pyfftw.html#scheme-table

            Source https://stackoverflow.com/questions/56397265

            QUESTION

            When using the drop-in fft replacements for scipy_fftpack, is the wisdom stored globally?
            Asked 2019-Apr-27 at 19:50

            When using the drop in FFTW replacement for scipy_fftpack, does it compute the wisdom once per FFT size and then never again?

            I have a loop which repeated calls

            ...

            ANSWER

            Answered 2019-Apr-27 at 19:50

            Yes, the previously computed wisdom is used on subsequent iterations of the loop, but is forgotten once the process ends (unless explicitly stored and reloaded). The interfaces API also has the facility to cache the FFTW object and reuse it should that be possible and desired. I suggest looking the docs for that.

            Source https://stackoverflow.com/questions/55875445

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pyFFTW

            No Installation instructions are available at this moment for pyFFTW.Refer to component home page for details.

            Support

            For feature suggestions, bugs create an issue on GitHub
            If you have any questions vist the community on GitHub, Stack Overflow.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • sshUrl

            git@github.com:pyFFTW/pyFFTW.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link