Skip to content

Commit

Permalink
Merge pull request #3456 from jzuhone/fix_join_fits_images
Browse files Browse the repository at this point in the history
fix combining FITS images
  • Loading branch information
neutrinoceros authored Jul 28, 2021
2 parents f580385 + 45b2e63 commit cb1aecc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions yt/visualization/fits_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,12 +735,12 @@ def from_images(cls, image_list):
w = first_image.wcs
img_shape = first_image.shape
data = []
for is_first, _is_last, fid in mark_ends(image_list):
for fid in image_list:
assert_same_wcs(w, fid.wcs)
if img_shape != fid.shape:
raise RuntimeError("Images do not have the same shape!")
for hdu in fid.hdulist:
if is_first:
if len(data) == 0:
data.append(_astropy.pyfits.PrimaryHDU(hdu.data, header=hdu.header))
else:
data.append(_astropy.pyfits.ImageHDU(hdu.data, header=hdu.header))
Expand Down
7 changes: 7 additions & 0 deletions yt/visualization/tests/test_fits_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ def test_fits_image():
assert_equal(combined_fid.magnetic_unit, dens_img.magnetic_unit)
assert_equal(combined_fid.current_time, dens_img.current_time)

# Make sure that we can combine FITSImageData instances with more
# than one image each
combined_fid2 = FITSImageData.from_images([combined_fid, combined_fid])
# Writing the FITS file ensures that we have assembled the images
# together correctly
combined_fid2.writeto("combined.fits", overwrite=True)

cut = ds.cutting([0.1, 0.2, -0.9], [0.5, 0.42, 0.6])
cut_frb = cut.to_frb((0.5, "unitary"), 128)

Expand Down

0 comments on commit cb1aecc

Please sign in to comment.