sunpy
sunpy copied to clipboard
Saving with the ".jp2" extension results in a vertically flipped image
Describe the bug
Images get flipped when saving as jp2 files. This was my fault when I added this feature 🎉
To Reproduce
from sunpy.map import Map
m = Map("https://helioviewer.org/jp2/AIA/2024/03/08/304/2024_03_08__00_00_05_123__SDO_AIA_AIA_304.jp2")
m.peek()
m.save("test.jp2")
flipped = Map("test.jp2")
flipped.peek()
See screenshots below
Screenshots
m.peek()
flipped.peek()
System Details
import sunpy sunpy.util.system_info() ============================== sunpy Installation Information ==============================
General ####### OS: Mac OS 14.3.1 Arch: 64bit, (arm) sunpy: 4.0.dev2573+gf79e5d92d Installation path: sunpy.egg-info
Required Dependencies ##################### astropy: 6.0.0 numpy: 1.26.4 packaging: 23.2 parfive: 2.0.2 pyerfa: 2.0.1.1 requests: 2.31.0
Optional Dependencies ##################### sunpy: 4.0.dev2573+gf79e5d92d
Installation method
git checkout
Notes for posterity:
- Saving JPEG2000 images was implemented in #6153, and that PR really ought to have had the unit test verify the written output (cf. https://github.com/sunpy/sunpy/pull/6153/files#r873841948). That's an unforced error on our part.
- JPEG2000 images were flipped on reading way back in 2014 (#768).