FITS: Add Header method to calculate data size #11105
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
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 theBITPIX
, also taking into accountGCOUNT
andPCOUNT
as in_ValidHDU.size
. It might be useful, however, if this were also exposed as a classmethod which takes an arbitraryHeader
object, so that it can be used to compute the data size of a header without having to create the full HDU object.The text was updated successfully, but these errors were encountered: