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

Multiple HDUs? #491

Open
evelyn-is-cool opened this issue Nov 12, 2023 · 1 comment
Open

Multiple HDUs? #491

evelyn-is-cool opened this issue Nov 12, 2023 · 1 comment

Comments

@evelyn-is-cool
Copy link

Here is part of my code:

import aplpy
aplpy.make_rgb_cube(['rings.v3.skycell.1234.089.stk.g.unconv.fits', 'rings.v3.skycell.1234.089.stk.i.unconv.fits',
'rings.v3.skycell.1234.089.stk.y.unconv.fits'], 'rings.v3.skycell.1234.089.stk.fits')

I am getting this error: ValueError: More than one HDU is present, please specify HDU to use with hdu_in= option

How do I resolve this?

@coude
Copy link

coude commented Jan 23, 2024

It's been a while since this issue was posted, but since I just had to deal with this error message I thought I would try to answer. The problem is likely that there are multiple extensions in the fits files you are loading into make_rgb_cube. It looks like the function only accepts fits files with a single extension.

You can check the extensions contained in your fits files with this code:

from astropy.io import fits

Test = fits.open('rings.v3.skycell.1234.089.stk.g.unconv.fits')
Test.info()
Test.close()

This should give a result that looks like this:

Filename: Blue.fits
No. Name Ver Type Cards Dimensions Format
0 STOKES I 1 PrimaryHDU 713 (526, 523) float64

If there are more than 1 extension (unlike the example above), then creating a new fits file with a single PrimaryHDU should solve your issue. Here is a link to the relevant functions: https://docs.astropy.org/en/stable/io/fits/#creating-a-new-image-file.

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

No branches or pull requests

2 participants