Skip to content

Zonal Mean Time Coarsener Bug#864

Open
Arcomano1234 wants to merge 9 commits intomainfrom
fix/zonal-mean-shape-bug
Open

Zonal Mean Time Coarsener Bug#864
Arcomano1234 wants to merge 9 commits intomainfrom
fix/zonal-mean-shape-bug

Conversation

@Arcomano1234
Copy link
Contributor

@Arcomano1234 Arcomano1234 commented Feb 21, 2026

Some of the underlying assumptions (to significantly decrease the logic needed for the buffers) made in the coarsening of zonal mean plots lead to an edge case where if the coarsening factor and windowing (e.g., number of forward steps in memory) were specific values we ended up having a size mismatch. To fix this more concrete logic is added to the buffer mechanism and added regression test to make more robust checks (if a batch needed to be skipped and put entirely into the buffer as well as the values that were found in #860)
Changes:

  • refactor the buffer mechanism in zonal mean time coarsener to allow for more robust logic including the potential for full batches to be put into the buffer

  • Tests added

Resolves #860

@Arcomano1234 Arcomano1234 marked this pull request as ready for review February 27, 2026 00:14


def test_zonal_mean_time_coarsening_25_steps_per_window():
"""Regression: forward_steps_in_memory=25 with factor=2 causes 13 vs 12
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Regression: forward_steps_in_memory=25 with factor=2 causes 13 vs 12
"""
Regression: forward_steps_in_memory=25 with factor=2 causes 13 vs 12

# if we have a buffer that means we didnt record the last batch
if self._buffer_gen:
start_idx = self.last_step
buffer_size = (
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't confidently review this file, the code is hard for me to understand. The for-if statements are nested up to 4 levels, and there's communication I don't understand happening between the first outer loop (for target_data) and the second outer loop (for gen_data). I also don't really know what "buffer" means in this context.

We chatted on Slack about potentially refactoring this to a helper function and cleaning it up before merging this, since this isn't a bug that usually affects us.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the buffer is some residual that gets patched on to the start of the next coarsen? If so, a model like

def coarsen(data: T1, prefix_data: T2 | None) -> tuple[T1, T2 | None]:

for some suitable types T1 and T2 would be a good pattern to use

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.

Config-dependent zonal mean shape error

2 participants