Add support for FITS formatted orientation files#464
Open
jdbuhler wants to merge 11 commits intocositools:developfrom
Open
Add support for FITS formatted orientation files#464jdbuhler wants to merge 11 commits intocositools:developfrom
jdbuhler wants to merge 11 commits intocositools:developfrom
Conversation
added 3 commits
January 30, 2026 11:16
…s in FITS format, using Astropy QTables. Change all users of .ori files in cosipy to use FITS instead.
…ues; this was done to create the FITS version in the same directory
FITS orientation files with version info present. * Check in FITS files from test_data that should've been in last commit. * Update recent check-in from Hiroki to use FITS orientation files
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
readers internal
* Fix 511keV-Galactic-ImageDeconvolution.ipynb to run correctly from run_tutorials, add missing checksums to notebook, and clean up excess dependency imports
works fine when it runs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Orientation files are currently stored in a MEGALib-derived format, .ori, which is essentially a plain-text table that is read by NumPy. This format is quite slow to read and will also not be acceptable for HEASARC. This patch implements storage of orientation files as an Astropy Table in FITS, which is both faster to read and closer to the eventual form needed for production use.
To support both .ori and FITS inputs, SpacecraftFile now has an open() class method that dispatches to one or the other format's reader depending on the file extension. The old, .ori-specific "parse_from_file()" method has been renamed "_open_ori()" and is only called from open(). The FITS reader and writer rely on Astropy's built-in gzip support to handle compressed FITS files transparently. Per HEASARC, I've added a "VERSION" card to the FITS headers for orientation files, of the form YYYYMMDD.
The actual FITS reading and writing code in SpacecraftFile is only a small part of the patch. The majority of the patch is converting the rest of cosipy, including the test suite and notebooks, to use FITS instead of .ori files. For the large orientation files that we download from wasabi, I've created FITS versions of them in the COSI-SMEX/develop subtree and converted the notebooks to use them. (These files are not highly compressible, so I chose to use .fits instead of .fits.gz for them.)
Note on performance: while Astropy's FITS reader is much faster than the Numpy parser used for .ori format, the limiting factor in reading in an orientation file is now converting the coordinate axes in the file into SkyCoords and constructing the list of Attitudes, not the reading itself.