Skip to content

Place window-averaged samples at their window centers - #478

Merged
xkykai merged 10 commits into
mainfrom
xk/monthly-sample-window
Aug 13, 2026
Merged

xkykai merged 10 commits into
mainfrom
xk/monthly-sample-window

Conversation

@xkykai

@xkykai xkykai commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #477.

ECCO4Monthly and EN4Monthly files hold a calendar-month mean and carry that window's center in their own time variable, while all_dates names them by the first of the month. native_times used the naming date as the FieldTimeSeries node time, so an EN4 series asked for 1 July returned July's mean, 3 K too warm at 40°N 60°W where the files' own dates give 296.79 K.

  • sample_window(metadatum) — the (start, stop) dates of the window a value represents, and the only thing a dataset declares. Zero-width by default, so instantaneous products are unchanged. window_center, time_window_offset, sample_window_span and uncovered_time_gaps derive from it, and native_times places each node at its window center.
  • Declared for every monthly-mean product (ECCO2/ECCO4, both ECCO-Darwin, EN4, AVISO, GLORYS, WOA, ERA5 monthly single-level and pressure-level), and for ERA5's hourly accumulations and mean rates, which cover the hour ending at the stamp.
  • A cyclical series repeats over the span its windows tile: 365 days for twelve monthly means, against the 364.5 inferred from node spacing.
  • Nodes sit half a window inside the span the data covers, so FieldTimeSeries warns under Cyclical — which fills the ends by wrapping — and throws under Linear, which extrapolates without bound past the last node. Clamp, instantaneous products and single samples are untouched.

all_dates still returns the first of the month: it is the file key, and the centers are not a Month(1) range (16 June 00:00 to 16 July 12:00 is 30.5 days).

Not covered here: the coupled atmosphere applies one time interpolator, built from u.times, to the precipitation fluxes as well, so ERA5's shifted rain nodes have no effect there (radiation interpolates on its own axis and does pick them up); and the daily products (ECCO2Daily, AVISODaily, GLORYSDaily) need their time_bnds checked before a window is declared.

#424 adds the same functions for MODIS composites; whichever lands first, the other drops its copy.

ECCO4Monthly and EN4Monthly files hold a calendar-month mean and carry that
window's center in their own `time` variable, while `all_dates` names them by
the first of the month. `native_times` used the naming date as the
FieldTimeSeries node time, so every sample interpolated about 15 days before
the time it describes.

Add `sample_window` and `time_window_offset`, applied by `native_times`, and
declare a one-month window for both datasets. The default window is zero-width,
so instantaneous products are unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Comment thread src/DataWrangling/ECCO/ECCO.jl Outdated
Comment thread src/DataWrangling/EN4/EN4.jl Outdated
xkykai and others added 4 commits July 29, 2026 09:24
Co-authored-by: Simone Silvestri <silvestri.simone0@gmail.com>
Co-authored-by: Simone Silvestri <silvestri.simone0@gmail.com>
`sample_window` becomes the single dataset hook: `window_center`,
`time_window_offset`, `sample_window_span` and `uncovered_time_gaps` derive from
it. It is declared for every monthly-mean product and for ERA5's hourly
accumulations and mean rates, which cover the hour ending at the stamp.

A cyclical series now repeats over the span its windows tile rather than the node
spacing, and `FieldTimeSeries` warns under `Cyclical` and throws under `Linear`
when the ends of the series can only be extrapolated.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@xkykai xkykai changed the title Place monthly-mean samples at their averaging-window centers Place window-averaged samples at their window centers Aug 7, 2026
xkykai added 3 commits August 6, 2026 17:49
Renamed 'Linear' to 'LinearTimeIndexing' to avoid shadowing.
Updated the wording for clarity in the documentation regarding time indexing operations.
@xkykai
xkykai marked this pull request as ready for review August 10, 2026 09:37
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.

ECCO4Monthly and EN4Monthly dates sit 15 days before the files' own time coordinate

2 participants