Skip to content

Add chain_time_intervals to merge_index_files - #279

Merged
adperezm merged 1 commit into
ExtremeFLOW:mainfrom
nick-morse:fix/stats-time-interval-merge
Oct 14, 2026
Merged

adperezm merged 1 commit into
ExtremeFLOW:mainfrom
nick-morse:fix/stats-time-interval-merge

Conversation

@nick-morse

Copy link
Copy Markdown
Contributor

Another Claude-generated version of a fix I needed during postprocessing. I'm not sure if this is the best way to address the issue, or if there's another intended workflow, so let me know. In particular, this kinda assumes that you write out at time intervals coinciding with restarts, and you haven't accidentally lost a batch of statistics.

Ideally, Neko would write out the start/stop times or interval, but I guess the fld file format prohibits this...

Backstory:

I usually store my statistics batches in different folders to avoid accidentally overwriting them (perhaps not necessary, but suggested in the Neko user docs). Therefore, each index file is written on its own, so its first entry's time_previous_output is the start time that index file was given. Merging index files from each folder into one time series leaves every index's first entry measured from a start time rather than from the entry before it, so the recorded time_interval grows and overlaps previous batches.

This PR:

This PR adds chain_time_intervals, which measures each interval from the preceding entry in time. The idea is to chain together statistics that were recorded continuously in time for the same run. Only entries that disagree with their predecessor are changed, so intervals that are already consistent are left alone. It is off by default, because merged indices are not always one series, e.g. for an ensemble. It requires sort_by_time, since the intervals are chained along the sorted sequence.

Each index is written on its own, so its first entry's `time_previous_output`
is the start time that index was given. Merging several indices into one time
series leaves every index's first entry measured from a start time rather than
from the entry before it, so the intervals overlap and grow.
`average_field_files` weights every file by `time_interval`, so the late files
then dominate the average.

Add `chain_time_intervals`, which measures each interval from the preceding
entry in time. Only entries that disagree with their predecessor are changed,
so intervals that are already consistent are left alone.

It is off by default, because merged indices are not always one series: for an
ensemble each member is measured from its own start and chaining across members
would be meaningless. When it is off and the inconsistency is present, log a
warning, so a merged time series does not go unnoticed. It requires
`sort_by_time`, since the intervals are chained along the sorted sequence.

Also preserve `statistics_start_time` through the merge, which is what the
first entry's interval is measured from, and make the sort stable so entries
with the same time keep their indexed order.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@adperezm
adperezm merged commit 7f7e647 into ExtremeFLOW:main Oct 14, 2026
36 of 40 checks passed
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