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

FITS: Add Header method to calculate data size #11105

Closed
embray opened this issue Nov 30, 2020 · 4 comments · Fixed by #12110
Closed

FITS: Add Header method to calculate data size #11105

embray opened this issue Nov 30, 2020 · 4 comments · Fixed by #12110
Labels
API change PRs and issues that change an existing API, possibly requiring a deprecation period Effort-low Feature Request io.fits Package-intermediate Refactoring

Comments

@embray
Copy link
Member

embray commented Nov 30, 2020

Description

Per same discussion with @hickst from #11100, it would be useful for Header objects to have a method to calculate the size (in bytes) of the data portion following that header (e.g. in the context of seeking through a stream containing FITS data).

Currently the individual HDU classes have different internal methods for determining the size of the data array when loading it, but this isn't exposed in any consistent, easily usable manner. When loading HDUs from a file their match_header classmethods are used to determine the appropriate HDU class to represent the HDU of that header.

HDUs could similarly have a classmethod responsible for returning the size of the data given a specific header. In most cases this is just a matter of multiplying together the NAXISn keywords with the BITPIX, also taking into account GCOUNT and PCOUNT as in _ValidHDU.size. It might be useful, however, if this were also exposed as a classmethod which takes an arbitrary Header object, so that it can be used to compute the data size of a header without having to create the full HDU object.

@embray embray added Feature Request io.fits Priority-Low Effort-low Package-intermediate Refactoring API change PRs and issues that change an existing API, possibly requiring a deprecation period labels Nov 30, 2020
@aaryapatil
Copy link
Member

Is anyone working on this? Seems straightforward to expose the internal data-size calculation using a method in Header and a classmethod in HDU.

P.S. It has been a while since I touched the io.fits code, but I would like to get involved with it again. (I surprisingly enjoy working with this sub-package even if it always seems too difficult 🤯)

@hickst
Copy link

hickst commented Apr 18, 2021

@aaryapatil See the thread on AstroPy SLACK for related information and pointers to various code projects nibbling around the edges of this idea: https://app.slack.com/client/T067V5AR2/C83KTJ2EM/thread/C83KTJ2EM-1617575712.017400

@Cadair
Copy link
Member

Cadair commented Apr 18, 2021

This would be super useful. Happy to help test it if someone wants to open a PR!

@aaryapatil
Copy link
Member

Thanks @hickst and @Cadair! I’ll work on it and open a PR soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change PRs and issues that change an existing API, possibly requiring a deprecation period Effort-low Feature Request io.fits Package-intermediate Refactoring
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants