Repository navigation
fix(parsing): apply the UTC offset of trajectory timestamps - #70
Merged
Merged
Conversation
neats_json_to_flights parsed each trajectory `ts` with
strptime("%Y-%m-%dT%H:%M:%S%z") and wrote it back with strftime, which
dropped the UTC offset without applying it: "12:02:00+02:00" became
12:02 UTC instead of 10:02 UTC. Schema-valid RFC 3339 forms such as
fractional seconds or a lowercase "z" raised ValueError and aborted the
whole batch.
The new helper _ts_to_utc_string applies the offset, accepts a lowercase
"t"/"z" and a space separator, truncates fractional seconds, and reads a
ts without offset as UTC. Invalid values raise ValueError naming the
flight and the trajectory point. The output contract is unchanged: a
naive UTC string "%Y-%m-%d %H:%M:%S".
All existing data uses "+0000", "Z" or "+00:00". On 148 NEATS JSON files
(85,128 flights, 10,995,586 points) the output is identical to before.
Fixes units audit item D2; the audit report records the status.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 20, 2026
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.
Summary
Fixes units audit item D2.
neats_json_to_flightsdropped the UTC offset of eachtrajectory
tswithout applying it (12:02:00+02:00became 12:02 UTC instead of 10:02),and schema-valid RFC 3339 forms (fractional seconds, lowercase
z) raisedValueError,aborting the whole batch.
New helper
_ts_to_utc_stringinneats_io.py:t/zand a space separator;tswithout offset as UTC (maintainer decision);ValueErrornaming the flight and trajectory point for invalid values.Output contract unchanged: naive UTC string
"%Y-%m-%d %H:%M:%S".The audit report gets a follow-up status table and a status note under D2.
Not in this PR: an invalid
tsstill stops the whole batch (separate PR).Evidence that nothing breaks
(85,128 flights, 10,995,586 points; every
tsis+0000,Zor+00:00) comparedexactly before/after (values, dtypes, column order, attrs): 0 differences.
(baseline 231/4/23 + 36 new tests).
timestamp forms against the old code and two reference parsers (0 disagreements with
the references; no UTC input changes); all callers checked incl. Dataiku recipes;
new tests fail on the old code (19/23). Edge cases they raised are fixed.
ruff,ruff format, projectmypyclean.Note on the pre-commit mypy hook
The
mirrors-mypyhook fails for every commit, independently of this change: itsisolated env installs numpy 2.5.4, whose stubs use Python 3.12 syntax while mypy targets
3.11. This commit was made with
SKIP=mypy; project mypy (uv run mypy src/pyneats/)passes. A separate PR will fix the hook.