Skip to content

Index space weather records by UTC day - #176

Merged
ssmichael1 merged 1 commit into
ssmichael1:mainfrom
scottshambaugh:spaceweather-utc-day
Sep 12, 2026
Merged

Index space weather records by UTC day#176
ssmichael1 merged 1 commit into
ssmichael1:mainfrom
scottshambaugh:spaceweather-utc-day

Conversation

@scottshambaugh

@scottshambaugh scottshambaugh commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

This fixes a timing bug in space weather data, which was indexed by TAI rather than UTC. This meant the last 37 seconds of each UTC day read the next day's record. This changes results very slightly as a result (though this doesn't get picked up by the unit tests - you may want tighter bounds on the golden value checks).

@ssmichael1

Copy link
Copy Markdown
Owner

This is subtle. Good find. I'll merge over the weekend. Thank you.

@ssmichael1

Copy link
Copy Markdown
Owner

recommended alternative, pure integer math:

instant.rs:

/// UTC calendar day as an integer Modified Julian Day number.
/// Same leap-second convention as `as_mjd_utc`, but integer arithmetic only.
pub(crate) fn utc_day_number(&self) -> i64 {
    (self.raw - Self::MJD_EPOCH.raw - microleapseconds(self.raw)).div_euclid(86_400_000_000)
}

spaceweather.rs:

let day = tm.utc_day_number();
let first_day = first.date.utc_day_number();
if day >= first_day {
    let idx = (day - first_day) as usize;
    if idx < sw.len() && sw[idx].date.utc_day_number() == day {
        return Ok(sw[idx].clone());
    }
}

Let me know your thoughts.

@scottshambaugh

Copy link
Copy Markdown
Contributor Author

I like that, amended and force pushed

@ssmichael1
ssmichael1 merged commit c77b218 into ssmichael1:main Sep 12, 2026
8 checks passed
@ssmichael1 ssmichael1 mentioned this pull request Sep 12, 2026
ssmichael1 added a commit that referenced this pull request Sep 12, 2026
Version bump in Cargo.toml, python/Cargo.toml, pyproject.toml; changelog
rolled (Unreleased -> 0.22.0 - 2026-09-12; entries added for #176 and the
#178 references; 0.20.3 pruned to keep five releases). Docs index links the
new starting-step / warm-start section of the integrators guide.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017VHexyxYasfatXebfxtphw
ssmichael1 added a commit that referenced this pull request Sep 12, 2026
* Release 0.22.0

Version bump in Cargo.toml, python/Cargo.toml, pyproject.toml; changelog
rolled (Unreleased -> 0.22.0 - 2026-09-12; entries added for #176 and the
#178 references; 0.20.3 pruned to keep five releases). Docs index links the
new starting-step / warm-start section of the integrators guide.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017VHexyxYasfatXebfxtphw

* docs: release steps in CONTRIBUTING (cargo update, version sync, tag)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017VHexyxYasfatXebfxtphw

* build: compile the extension with --locked against the committed Cargo.lock

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017VHexyxYasfatXebfxtphw

* Cargo.lock: record 0.22.0 for the workspace crates

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017VHexyxYasfatXebfxtphw

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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