feat(cycle): align_observations and analysis_time_in_window for irregular observation streams
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start with packages/pipekit-cycle/src/pipekit_cycle/da.py and cycle.py to understand SmootherCycle and WindowedCycle, then inspect the package exports and pipekit_array.batching.batch for the padding behavior to match. Implement the public helper in the specified windows.py path and update AnalysisStep documentation; done means the listed boundary, padding, overflow, and analysis-index cases pass, with the documented default behavior preserved.
Written by the indexing model from the issue text.
Description
Problem / Request
Add a helper that groups an irregular observation stream into fixed-shape analysis windows, and let SmootherCycle place the analysis inside its window.
User Story
As a DA practitioner with irregular satellite times, I want observations grouped into same-sized windows with a validity mask, so that a JAX consumer can run the whole cycle under one
lax.scan.
Motivation
WindowedCycle and SmootherCycle assume that each window's observations arrive already grouped.
Any real observation stream needs this grouping, and padding each window to one count is what keeps a downstream cycle's shapes stable.
The analysis is also always taken after the last step, whereas smoothers commonly place it mid-window.
This comes from the survey of DataAssimBench in #44.
Proposed API
# Shapes: N_y observation times; W windows; M the padded per-window count
# proposed (this issue)
class WindowIndices(NamedTuple):
indices: tuple[int, ...] # length M: positions in obs_times
valid: tuple[bool, ...] # length M: True marks a real observation
t_start: float
t_end: float
def align_observations(
obs_times: Sequence[float],
*,
t0: float,
window: float,
stride: float | None = None, # defaults to window
n_windows: int | None = None,
max_obs: int | None = None, # defaults to the largest window's count
) -> list[WindowIndices]: ...
# usage
windows = align_observations(times, t0=0.0, window=6.0) # W entries of length M
- A window covers
[t_start, t_end), so that an observation on a boundary belongs to exactly one window whenstride == window. - Padding repeats the window's last real index with
valid=False, the rule thatpipekit_array.batch(pad="last")already uses. - An empty window has all
valid=Falseand indices of 0. - A window with more than
max_obsobservations raisesValueError; it never silently drops data. - The helper is pure Python, because pipekit-cycle's base install has no array dependency.
# proposed (this issue)
class SmootherCycle(StatefulOperator):
def __init__(self, ..., analysis_time_in_window: float | None = None): ...
analysis_time_in_window is a fraction in [0, 1]. None keeps today's behaviour, and otherwise analysis_step also receives analysis_index=round(f * (window - 1)).
Design Snapshot
SmootherCycle._apply today, from packages/pipekit-cycle/src/pipekit_cycle/da.py @ 7c446f1, steps window times and calls analysis_step(forecasts, observations, obs_op=..., obs_err_cov=...) once.
It can't see the window's start state.
That is a separate gap, recorded in geostack report 10, and it stays out of this issue.
References & Existing Code
dabench/dacycler/_utils.pyandanalysis_time_in_windowin DataAssimBench (https://github.com/StevePny/DataAssimBench).WindowedCycleincycle.pyandSmootherCycleinda.py@7c446f1.pipekit_array.batching.batch@7c446f1for the padding rule.
Implementation Steps
- Add
WindowIndicesandalign_observationsinpackages/pipekit-cycle/src/pipekit_cycle/windows.py, and re-export them. - Add
analysis_time_in_windowtoSmootherCycle, validating the range, and add it toget_config. - Document the extra keyword for
AnalysisStepimplementers.
Definition of Done
- Code lands at the intended path.
- Tests pass:
make test. - Lint + typecheck pass:
make lint && make typecheck. - Docstrings (Google-style) on all public symbols.
Testing
- Every observation inside the covered range appears in exactly one window when
stride == window, including one exactly on a boundary. - Every window has length
max_obs, and padded positions repeat the last real index withvalid=False. - An empty window is all invalid, and
max_obssmaller than a window's count raisesValueError. - With
analysis_time_in_window=None,SmootherCycleresults are identical to today's. -
analysis_time_in_window=0.5on a window of 5 passesanalysis_index=2.
Documentation
-
SmootherCycledocstring, with an irregular-times example.
Relationships
- Parent (theme epic): #149
- Related: #44, #163
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 3h 50m
- Merged PRs (30d)
- 143
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jejjohnson/pipekit
-
area:code layer:0-primitives priority:p2 type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jejjohnson/pipekit#296 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 57/100
jejjohnson/pipekit#411 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 4/5 3-5 days Newbie friendliness 48/100
jejjohnson/pipekit#410 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 5/5 Over a week Newbie friendliness 38/100
jejjohnson/pipekit#409 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 75/100
jejjohnson/pipekit#408 ·
Maintainers usually reply within 1 day
All issues in jejjohnson/pipekit
Similar issues
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
freelawproject/litigant-portal#1307 ·
Maintainers usually reply within 2 days
-
type/bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
h2oai/h2o-llmstudio#1163 ·
Maintainers usually reply within 1 day