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
Flip jp2 data vertically before saving #7486
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to fix the relevant unit test (
sunpy/sunpy/io/tests/test_jp2.py
Lines 44 to 46 in f79e5d9
# Sanity check that reading back the jp2 returns coherent data | |
jp2_readback = _jp2.read(outfile) | |
assert header['DATE'] == jp2_readback[0].header['DATE'] |
sunpy/io/_jp2.py
Outdated
@@ -176,7 +176,7 @@ def write(fname, data, header, **kwargs): | |||
|
|||
tmpname = fname + "tmp.jp2" | |||
jp2_data = np.uint8(data) | |||
jp2 = Jp2k(tmpname, jp2_data, **kwargs) | |||
jp2 = Jp2k(tmpname, np.flip(jp2_data, 0), **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment that explains that we have to flip the array back here because we flip it upon reading (due to the difference in the origin of the data)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does it get flipped when its read in?
Oh it's the [::-1]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment here, and updated the test to verify the data array after reading it back.
How would you recommend doing that? edit:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just needs a changelog, but other than that looks good to me.
Co-authored-by: Will Barnes <will.t.barnes@gmail.com>
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
…6-on-5.1 Backport PR #7486 on branch 5.1 (Flip jp2 data vertically before saving)
Flip jp2 data vertically before saving (cherry picked from commit 76c3ced)
PR Description
Fixes #7485
Flipping the data array when saving as jp2 fixes this problem.