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

FFT to work on complex data vs [RE,IM] final shape of data #38

Open
walkloud opened this issue Mar 19, 2021 · 2 comments · May be fixed by #39
Open

FFT to work on complex data vs [RE,IM] final shape of data #38

walkloud opened this issue Mar 19, 2021 · 2 comments · May be fixed by #39
Assignees

Comments

@walkloud
Copy link
Member

Chroma sometimes writes complex data structures to H5 format with

[<array_structure>, re, im]

and sometimes as

[<array_structure>, complex]

So - we want either FFT to detect or a flag for the user to switch which data structure to act on

@asmeyer2012
Copy link

asmeyer2012 commented Mar 19, 2021

It's a bit more complicated than just adding support for complex. The data we have is a structural array of complex

>>> np.dtype(( np.dtype(('complex128',(4,4))), (3,3)))
dtype((('<c16', (4, 4)), (3, 3)))

This gets expanded by fft_file and its dimensions are appended to the spatial dimensions. When get_fft is called, it only uses the last 3 dimensions,

out = get_fft(arr, cuda=cuda, axes=(-1, -2, -3))

which are now dimensions in the structural array rather than spatial indices.

The max_momentum option also assumes the spatial indices are last, so it will cut in the wrong dimension and possibly get an out of bounds error:

for axis, key in enumerate(["x", "y", "z"]):
    axis = -1 * (axis + 1)
    LOGGER.debug(
        "\t\t Axis %d: %s -> %s[%s]", axis, key, key, slice_index
    )
    out = np.take(out, slice_index, axis=axis)

@asmeyer2012 asmeyer2012 linked a pull request Mar 19, 2021 that will close this issue
@ckoerber
Copy link
Member

Thanks @asmeyer2012 for the PR!

I have not looked at it in detail yet but I was wondering if this addition should be more general (@walkloud, do we expect other files to also require this dynamic shape/complex reshuffling). E.g., should this reshuffling be incorporated into the dset reader and kept outside of the FFT?

E.g., conceptually the reader converts hdf5 data types to python types and here the python type should obviously be complex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants