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

Fix sunpy.io to update header info after scaling applied when data is accessed #7141

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

samaloney
Copy link
Contributor

Initial quick fix _fits.get_header and _fis.read_fits could be refactored to make this a but nicer will do later.

try:
hdu.data # access data to force any scaling BSCALE/BZERO to be applied and keyword will be updated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry about the performance impact and general side-effects of doing this here. 🙈

Copy link
Contributor Author

@samaloney samaloney Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I was too but I don't think it's any different to this line which was and still is being called HDPair(hdu.data, header). Same side effect as far as I can see, hdu.data is being accessed and causes astropy.io to load and scale the data, I'll try to confirm either way. Long term if you want to support lazy loading and dask etc this is an issue for sure.

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to request changes since I'm not quite sure what this is fixing. It should have a test anyway, and I think this would help review the PR.

@github-actions github-actions bot added the Stale The bot will close this PR after 6 months label Mar 21, 2024
@nabobalis nabobalis removed the Stale The bot will close this PR after 6 months label Mar 22, 2024
@nabobalis
Copy link
Contributor

nabobalis commented Mar 22, 2024

I pushed a unit test thinking I understood what the problem is but turns out I did not.

The test passed before and after the code change.

@samaloney, what was the original bug?

EDIT: I MISINTERPRETED THE BUG REPORT - SKILL ISSUE ON MY PART

@nabobalis nabobalis added the io Affects the io submodule label Mar 22, 2024
@sunpy sunpy deleted a comment from github-actions bot Mar 29, 2024
@nabobalis nabobalis force-pushed the bugfix-io-fits-scaling branch 3 times, most recently from 6d1c429 to 0d9e327 Compare March 29, 2024 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Affects the io submodule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants