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

Example of reading data/header with io.fits.read is broken #4181

Closed
wtbarnes opened this issue May 18, 2020 · 0 comments · Fixed by #4183
Closed

Example of reading data/header with io.fits.read is broken #4181

wtbarnes opened this issue May 18, 2020 · 0 comments · Fixed by #4183
Labels
Bug Probably a bug Documentation Affects the documentation io Affects the io submodule

Comments

@wtbarnes
Copy link
Member

In the docs, we have the following example of how to read the data and header directly from a file using sunpy.io.fits.read,

[data,header] = sunpy.io.fits.read(filename)

There are a few problems here.

  1. If you have 2 HDUs, this returns the first to data and the second to header, obviously not the intended behavior.
  2. You can use the hdus kwarg to select only a specific HDU but it turns out this is broken because the rest of the function expects an HDUList and after we slice it, we don't cast it back to an HDUList so everything after this explodes in fun and unexpected ways.
  3. Even accounting for the first two problems, this function returns a list of data,header pairs, not a list of data and headers so you get a ValueError when trying to return this to a tuple as above. Fixing items 1 and 2, this example could be amended to,
data, header = sunpy.io.fits.read(filename)[0]
@wtbarnes wtbarnes added Bug Probably a bug Documentation Affects the documentation io Affects the io submodule labels May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Probably a bug Documentation Affects the documentation io Affects the io submodule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant