Skip to content

Add support for FITS formatted orientation files#464

Open
jdbuhler wants to merge 11 commits intocositools:developfrom
McKelvey-Engineering-CSE:sf_fits_clean
Open

Add support for FITS formatted orientation files#464
jdbuhler wants to merge 11 commits intocositools:developfrom
McKelvey-Engineering-CSE:sf_fits_clean

Conversation

@jdbuhler
Copy link
Contributor

@jdbuhler jdbuhler commented Jan 30, 2026

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.

Jeremy Buhler 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
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 93.24324% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.87%. Comparing base (a4f1924) to head (b6de516).
⚠️ Report is 7 commits behind head on develop.

Files with missing lines Patch % Lines
cosipy/spacecraftfile/SpacecraftFile.py 92.85% 5 Missing ⚠️
Files with missing lines Coverage Δ
cosipy/data_io/UnBinnedData.py 92.85% <100.00%> (ø)
cosipy/event_selection/good_time_interval.py 92.23% <100.00%> (ø)
cosipy/spacecraftfile/SpacecraftFile.py 93.05% <92.85%> (-0.23%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant