A newer forecast is shorter: updating the next hours while retaining the long horizon

Join two compatible runs by valid time, update the shorter interval and preserve the provenance of the older forecast tail.

Two forecast horizons appear as distinct layers over one landscape.
Two forecast horizons appear as distinct layers over one landscape.

A new forecast run has arrived, but its last point is earlier than the end of the previous run. Replacing the old array with the new one would remove the longer horizon. Appending the old tail and assigning a new creation time to every value would misrepresent where those values came from.

We will examine a third approach: update the new run's interval, retain compatible older points outside it, and preserve each value's original model initialization. We will build an independent Python example with two fictional runs. It downloads no weather and reconstructs no real city's history. All numbers, time boundaries and admission rules were chosen for this exercise.

Bring the runs onto a common time axis

First, separate three quantities: model initialization, forecast lead and the time to which a value applies. For our instantaneous variable, the relationship is:

valid_hour = initialized_hour + lead_hour

The ECMWF explanation of ERA5 terminology likewise distinguishes forecast initialization from the step after it. That reference explains the time concepts; our artificial runs are not ERA5 data and do not reproduce its schedule.

Suppose the older run starts at hour 0 and the newer one at hour 6. An older value at lead 9 and a newer value at lead 3 both describe hour 9. Two values at lead 3, however, describe different hours: 3 and 9. Joining by array position or by lead alone produces the wrong pairs even when both files are perfectly readable.

Time in the example consists of integer hours from a shared arbitrary origin. This makes the arithmetic easy to check by hand. There are no calendar dates, local time zones or daylight-saving transitions. A real adapter must first convert its source's time labels into an agreed time axis.

Do not derive the requested horizon from the new array's length

The first dataset contains an air-temperature forecast at a height of two metres for one fictional point. The second describes the same quantity and point, but starts later and ends earlier on the shared axis.

Property Older long run Newer short run
Name in the exercise old-long new-short
Initialization hour 0 6
Declared leads 0–18 inclusive 0–6 inclusive
Valid times 0–18 inclusive 6–12 inclusive
Number of input points 19 7

The product request is separate: return hours 6 through 18 inclusive. That means 13 hourly positions, with 12 hours between the first and last. The assemble call specifies this window; the new array's final element does not. A shorter input therefore cannot silently reduce the expected answer.

Each run also retains its declared first and last leads. These exist independently of the values that are actually present. If the new run's final record is lost, its boundary remains hour 12. Moving that boundary to 11 and treating the old value for hour 12 as an ordinary tail would conceal a problem within the new coverage.

Check compatibility before choosing numbers

A shared time label does not establish that two values can be combined. In this exercise both runs must have exactly the same Scope: provider, model and model version, product, unit, grid and grid revision, point, normalization version and temporal support type.

This is a conservative contract. Changing degree_Celsius to another unit causes rejection. Changing the grid or point does not authorize choosing something nearby either. Unit conversion, spatial transformation and assessment of their suitability must happen separately. Matching strings in our Scope enforce an agreed contract; they do not establish that an external supplier described its data correctly.

The example accepts only time_kind = instant. ECMWF explains separately that some parameters apply at a specified time while others apply over a processing period. For accumulated precipitation, an identical ending hour can conceal different accumulation starts. Our selector does not solve that problem and rejects interval types.

The structures use dataclass(frozen=True) with tuples of samples. The Python documentation describes field comparison and the restriction on ordinary assignment in a frozen class. Type, boundary and numeric checks are still written explicitly: annotations do not perform those checks by themselves.

Give the new interval a clear responsibility

After admitting the inputs, the selector visits every requested hour. Its central choice is short:

if new.first_valid <= hour <= new.last_valid:
    chosen, role = new, "selected"
elif old is not None and old.first_valid <= hour <= old.last_valid:
    chosen = old
    role = "preserved-prefix" if hour < new.first_valid else "preserved-tail"

An hour outside both intervals produces a missing result with reason no-coverage. Its value is neither extrapolated along a straight line, copied from the last known hour nor replaced by zero. The baseline must also have an earlier initialization and a different identifier; the order of the function arguments does not automatically establish those properties.

Inside the new declared interval, a separate strict rule applies: a missing new point remains missing even if the old run has a value for that hour. This is a deliberate exercise policy, not a universal requirement for weather products. A product may permit that fallback, but it must describe, label and test it explicitly. Silent mixing removes the ability to distinguish an incomplete new run from a complete one.

What the program returned

The main execution takes place at synthetic hour 6. The maximum admitted source age is 12 hours. All 13 requested positions have values in this scenario: seven come from the newer run and six from the retained older tail.

Valid hour Temperature, °C Run Its initialization Lead
6 9.5 Newer 6 0
9 12.5 Newer 6 3
12 15.5 Newer 6 6
13 17 Older 0 13
18 22 Older 0 18

The table shows five of the thirteen returned points. The complete result also includes the source revision identifier, each point's role, its age and a reason for absence where applicable. The result does not receive one shared initialization of “6”: that would be wrong for the tail.

The change from 15.5 at hour 12 to 17 at hour 13 does not establish a real temperature jump. These are fictional numbers from two runs. The selector neither smooths the boundary nor evaluates forecast skill. Any smoothing would create a newly computed value requiring its own provenance.

Assembly time does not make the source younger

Reassembling at hour 9 retains the same values and model initializations. The newer run's age becomes 3 hours and the older one's becomes 9. assembled_hour changes, but each point's initialized_hour remains its original value. Downloading, caching or rendering a page does not create a new model run.

A boundary test makes the consequence visible. At hour 12, the older run still satisfies our inclusive age limit. At hour 13, it is 13 hours old, so all six tail positions become unavailable with reason source-too-old. The newer points are 7 hours old and remain available. This does not recommend a 12-hour service policy: the threshold is an explicit parameter of this small experiment.

Here the age policy applies equally to every requested point, including elapsed ones. Another product can define different rules, but those rules must not be inferred from the current time. Requesting hours 4 and 5 with the old run available returns its retained forecasts. Without that run, the result is missing. A past value does not become an observation merely because its hour has ended.

A gap must remain visible in the validation result

In an additional scenario, we remove the newer point at lead 3. That is hour 9, for which the old run contains the number 13. The result has one selected-gap, with no hidden fallback. A separate test removes the new interval's final point and confirms the same boundary behaviour.

An empty set of new values does not cancel its declared interval either: seven positions remain empty while the six old tail points survive. Without the old run, the main scenario contains six gaps. Outside both intervals, a value cannot appear without additional data or a new computational model.

The complete flag checks that every expected position has a value. A zero temperature is an ordinary number; None denotes absence. Completeness is neither a forecast-accuracy assessment nor permission to publish. The function returns only an in-memory candidate. The next product layer decides whether an incomplete window may be displayed.

Scope of the local check

The local check used the Python standard library.

The actual local execution on Python 3.12.14 completed 33 test methods successfully. Expected hours, values, run identifiers, initializations, leads and ages are written in a separate literal fixture. They are not generated by the function under test.

The tests also change every compatibility dimension and check duplicate leads, NaN, infinity, booleans, future initialization, empty data and preservation of inputs after rejection. The exercise is limited to two runs, one instantaneous product and a window of at most 49 positions. It contains no network calls, provider archive, restart recovery or active-forecast write.

With these distinctions in place, the longer horizon has understandable provenance. For every hour, we can identify the run that supplied the number, why that value is admitted and why a gap appears beside it. The newer segment updates its part of the window, while the retained tail remains clearly identified as an older forecast.

  1. Weather The process finished, but was the whole forecast updated?
  2. Weather The provider is late: when can a forecast remain on display?
  3. Weather Degrees, wind and precipitation: normalize units without losing meaning
  4. Weather Forecasts and observations: what weather data does the user see?

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article