Skip to content

Faster TimeSelector and SpacecraftHistory#543

Merged
israelmcmc merged 8 commits intocositools:developfrom
israelmcmc:faster_sc_history_and_time_selection
Apr 14, 2026
Merged

Faster TimeSelector and SpacecraftHistory#543
israelmcmc merged 8 commits intocositools:developfrom
israelmcmc:faster_sc_history_and_time_selection

Conversation

@israelmcmc
Copy link
Copy Markdown
Collaborator

TimeSelector:

  • Faster, using only 64bit precision
  • Add unit tests
  • Be consistent about tstart inclusive, stop exclusive.

I'll work on a similar trick (64bit precision) for SpacecraftHistory (I'll abandon histpy.TimeAxis in favor of a regular Axis since COSI doesn't need <1us precision).

- Faster, using only 64bit precision
- Add unit tests
- Be consistent about tstart inclusive, stop exclusive.

Signed-off-by: Israel Martinez <imc@umd.edu>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.80%. Comparing base (6ef0230) to head (c73702e).
⚠️ Report is 91 commits behind head on develop.

Files with missing lines Patch % Lines
cosipy/spacecraftfile/spacecraft_file.py 73.33% 8 Missing ⚠️
Files with missing lines Coverage Δ
cosipy/event_selection/time_selection.py 100.00% <100.00%> (+100.00%) ⬆️
cosipy/spacecraftfile/spacecraft_file.py 90.00% <73.33%> (+5.76%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Still need to fix some unit tests

Signed-off-by: Israel Martinez <imc@umd.edu>
Signed-off-by: Israel Martinez <imc@umd.edu>
Signed-off-by: Israel Martinez <imc@umd.edu>
Signed-off-by: Israel Martinez <imc@umd.edu>
Signed-off-by: Israel Martinez <imc@umd.edu>
Signed-off-by: Israel Martinez <imc@umd.edu>
@israelmcmc israelmcmc marked this pull request as ready for review April 13, 2026 15:38
Signed-off-by: Israel Martinez <imc@umd.edu>
@jdbuhler jdbuhler self-requested a review April 13, 2026 17:18
Copy link
Copy Markdown
Contributor

@jdbuhler jdbuhler left a comment

Choose a reason for hiding this comment

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

I don't have a good sense of how expensive the conversions between Time and Julian date are, but I assume they are way less painful than the TimeAxis operations. I'll have to benchmark the SpacecraftHistory after the changes to see what the overhead of select_interval() is.

I see that intervals_duration() now returns a value in days. Are there other places where we were used to using seconds as the typical time unit of orientation history but are now going to have to change?

@israelmcmc
Copy link
Copy Markdown
Collaborator Author

@jdbuhler Thanks for checking. I used Julian days because that's what the underlying Time objects use. It just needs to sum jd1+jd2. Hopefully this sum is not much of an overhead, and it will allows us to still use Time for the inputs/outputs.

I see that intervals_duration() now returns a value in days. Are there other places where we were used to using seconds as the typical time unit of orientation history but are now going to have to change?

No code should assume units of intervals_duration(). The function only "promises" to return Quantity. If we find such instance using .value, we should change them to to_value(u.s) (if really needed in seconds). I also used days here to avoid the extra conversion from the underlaying jd

@jdbuhler jdbuhler self-requested a review April 14, 2026 06:25
Copy link
Copy Markdown
Contributor

@jdbuhler jdbuhler left a comment

Choose a reason for hiding this comment

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

OK, approving review

@israelmcmc israelmcmc merged commit 57f2c6a into cositools:develop Apr 14, 2026
8 checks passed
@israelmcmc
Copy link
Copy Markdown
Collaborator Author

Thanks @jdbuhler !

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.

2 participants