Lyalpha / spalipy

Detection-based astronomical image registration.
GNU General Public License v3.0
10 stars 2 forks source link

The source_fits isn't passed in as HDUList #7

Closed kendallackley closed 4 years ago

kendallackley commented 4 years ago

This is for older versions of astropy. For astropy<=3, we have the code and error:

>>> from spalipy import spalipy
>>> s= spalipy.Spalipy("r0204859_UT4-median.cat", "r0204805_UT4-median.cat", "r0204859_UT4-median.fits", output_filename='r0204859_UT4-median-aligned.fits')
>>> s.main()
Matched 8429 detections within 5 pixels with affine transformation
Affine alignment pixel residuals [median (stddev)]: x = 0.047 (0.402), y = -0.035 (0.461)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/spalipy/spalipy.py", line 180, in main
    self.align()
  File "/usr/local/lib/python3.5/dist-packages/spalipy/spalipy.py", line 394, in align
    self.source_fits.writeto(output_filename,
AttributeError: 'list' object has no attribute 'writeto'

where r0204859_UT4-median.fits should be read in as an HDUList but is read in instead as a "regular" list.

I think a simple fix would be to add the lines

if type(self.source_fits) is list:
            self.source_fits = fits.HDUList(self.source_fits)

at 393 prior to

self.source_fits.writeto(output_filename,
                                     overwrite=overwrite)
Lyalpha commented 4 years ago

Bug in astropy < 3.1.0 related to HDUList.copy().

Updated requirements rather than trying to catch bugs in outdated external packages.