Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Code for reading PRESTO's *.fft files is wrong. #13

Open
astrogewgaw opened this issue Jan 5, 2024 · 0 comments · May be fixed by #16 or #17
Open

🐛 Code for reading PRESTO's *.fft files is wrong. #13

astrogewgaw opened this issue Jan 5, 2024 · 0 comments · May be fixed by #16 or #17
Assignees
Labels
bug Something isn't working

Comments

@astrogewgaw
Copy link
Owner

As can be seen from the FAQ here, the way I am reading PRESTO's *.fft files in priwo is just plain wrong. Quoting from the FAQ:

PRESTO's *.dat files are straight 32-bit floats (i.e. numpy.float32, or typecode "f"), and the *.fft files are straight 2x32-bit floats treated as complex numbers (i.e. numpy.complex64, or typecode "F"). This means that you can easily read them using numpy.fromfile:

import numpy as np
dat = np.fromfile("myfile.dat", dtype=np.float32)
fft = np.fromfile("myfile.fft", dtype=np.complex64)

For the FFT data, the zeroth frequency bin (i.e. fft[0]) has the real-valued DC component in the real portion, and the real-valued Nyquist frequency stored as the imaginary portion! That is a common trick for packing FFT results so that the number of complex data points is N/2, where N was the length of the input time series, rather than N/2+1. The FFT amplitudes are also completely unnormalized (equivalent to using the "raw" normalization mode with explorefft.

@astrogewgaw astrogewgaw added the bug Something isn't working label Jan 5, 2024
@astrogewgaw astrogewgaw self-assigned this Jan 5, 2024
@astrogewgaw astrogewgaw linked a pull request Mar 26, 2024 that will close this issue
@astrogewgaw astrogewgaw linked a pull request Sep 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant