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

find_optimal_celestial_wcs does not accept ImageHDU, PrimaryHDU and CompImageHDU #323

Closed
cylammarco opened this issue Nov 10, 2022 · 1 comment · Fixed by #344
Closed

Comments

@cylammarco
Copy link

@pha12kt found that find_optimal_celestial_wcs does not accept ImageHDU, PrimaryHDU. In the below examples, img is an ImageHDU object.

Failing to accept an ImageHDU object:

>>> find_optimal_celestial_wcs(img)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/reproject/mosaicking/wcs_helpers.py", line 72, in find_optimal_celestial_wcs
    input_shapes = [parse_input_shape(shape) for shape in input_data]
TypeError: 'ImageHDU' object is not iterable

Failing to accept a PrimaryHDU object

>>> find_optimal_celestial_wcs(fits.PrimaryHDU(img.data, img.header))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/reproject/mosaicking/wcs_helpers.py", line 72, in find_optimal_celestial_wcs
    input_shapes = [parse_input_shape(shape) for shape in input_data]
TypeError: 'PrimaryHDU' object is not iterable

But it accepts a list of ImageHDU, or an HDUList

>>> find_optimal_celestial_wcs([img])
(WCS Keywords

Number of WCS axes: 2
CTYPE : 'RA---TAN'  'DEC--TAN'  
CRVAL : 234.05721112817054  39.73269564616722  
CRPIX : 2653.490914560424  2562.2117672994214  
PC1_1 PC1_2  : 1.0  0.0  
PC2_1 PC2_2  : 0.0  1.0  
CDELT : -1.1005555796953587e-05  1.1005555796953587e-05  
NAXIS : 0  0, (5123, 5307))

>>> find_optimal_celestial_wcs(fits.HDUList(img))
(WCS Keywords

Number of WCS axes: 2
CTYPE : 'RA---TAN'  'DEC--TAN'  
CRVAL : 234.05721112817054  39.73269564616722  
CRPIX : 2653.490914560424  2562.2117672994214  
PC1_1 PC1_2  : 1.0  0.0  
PC2_1 PC2_2  : 0.0  1.0  
CDELT : -1.1005555796953587e-05  1.1005555796953587e-05  
NAXIS : 0  0, (5123, 5307))

@cylammarco
Copy link
Author

Suggested Fix: Perform a type check for ImageHDU, PrimaryHDU, and CompImageHDU, and then turn them into a list so that the next line

input_shapes = [parse_input_shape(shape) for shape in input_data]

can continue the work.

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.

1 participant