-
Notifications
You must be signed in to change notification settings - Fork 14
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
DM-46581: Speed up TimeConverter #1090
Conversation
This change almost halves the time of |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1090 +/- ##
==========================================
- Coverage 89.69% 89.69% -0.01%
==========================================
Files 361 361
Lines 47278 47306 +28
Branches 9716 9720 +4
==========================================
+ Hits 42407 42429 +22
- Misses 3495 3498 +3
- Partials 1376 1379 +3 ☔ View full report in Codecov by Sentry. |
Include the jd1 and jd2 to ensure that we can recreate the time accurately enough from the repr() form.
Constructing the TimeDelta is slow. Calculating the JD components and explicitly adding them to the epoch JD values is much faster than constructing a TimeDelta and adding that to a Time.
This format is only ever use by TimeConverter so we can trust that the values passed are always OK and skip usual checks.
We would like to get microseconds in our ISO output form.
We only use it in a couple of places explicitly but it is used.
# For JD times we want to use jd1 and jd2 to maintain precision. | ||
if isinstance(t, astropy.time.Time): | ||
if t.format == "jd": | ||
return f"astropy.time.Time({t.jd1}, {t.jd2}, scale='{t.scale}', format='{t.format}')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't trigger with the new code because for Timespan we always convert the Time to nsec internally and then convert back to Time on request and so return a format=unix_tai_fast variant for repr. If we ever decide to simply keep the Timespan we were given then this would trigger again.
We have decided that returning it in tai unix fast format is going to be confusing since these times are visible to people via Timespan. Therefore switch the format to "jd" and accept a small overhead going from 8us to 10us in construction.
Checklist
doc/changes
configs/old_dimensions