One day, one year
Sessions 3 to 8 took the model apart. This session puts it back together. Pick any day between October 1986 and September 1999 and follow its water through every step, with every variable and every formula filled in with that day's numbers. Then zoom out to a full year, check that no water is lost, and confirm that the model in your browser is the real one.
You will be able to
- trace one day through all of dCREST's steps and read every intermediate variable;
- explain how the states carry information from one day to the next;
- read a year of the model's stores and fluxes;
- check mass conservation, and explain why a model needs a spin-up period.
The daily loop
All of dCREST fits in a few lines of pseudo-code. The five states start from fixed initial values, and each day updates them in order:
SWE, W, SM, G, Fs = 0, 0, 0.5·wm, 0.3·hmaxaq, 0 # initial states
for each day t:
L, SWE = snow(P[t], T[t], SWE) # Session 3
L, d, W = canopy(L, PET[t], W) # Session 4: water and demand left
if L > d: Qint, Qov, SM' = wet_soil(L, d, SM) # Session 5, 6
else: Qint, Qov, SM', G = dry_soil(L, d, SM, G) # Session 6
SM, G, Qb, Qsp = aquifer(SM', G) # Session 7
Qr, Fs = fast_reservoir(Qov, Fs) # Session 8
r[t] = (Qr + Qint + Qb + Qsp) · (1 − lf)
Q = convolve(r, unit_hydrograph(nshape, kmult, area)) # Session 8, after the loop
The states carry the model's memory. Everything the model "knows" about the past, such as a wet winter, a dry summer or last week's storm, is held in those five numbers at the end of each day, plus the runoff of the last 29 days that the unit hydrograph is still delivering.
Step through a day
- 16 February 1990: the soil is almost full, the infiltration curve saturates, and nearly all of the 116 mm that reached the soil becomes overland flow.
- The next day: little rain, but the unit hydrograph delivers its largest share (35%) of the previous day's runoff, so the river peaks.
- 15 August 1993: a dry day. The canopy is empty, the soil and the aquifer supply the evaporation, and the river runs on baseflow alone.
- 2–7 February 1996: snow accumulates and then melts in one day.
A year of the model
Read the year from the stores. The soil fills through autumn and winter while evaporation is low, reaches near-capacity in late winter, when each storm then produces large runoff, and dries through summer. The aquifer follows the soil with a lag of weeks. The canopy is refilled by every rain and emptied by the next sunny days. Evaporation switches from canopy to soil to aquifer as the dry spells lengthen.
No water is lost
Over any period, everything that came in must have left or still be stored. For the whole test decade, using the run in your browser:
| Term (1 Oct 1989 – 30 Sep 1999) | mm |
|---|
The residual is the size of rounding errors in computer arithmetic. (The rows are rounded to 0.1 mm, so adding them by hand can be off by a few tenths; the residual is computed from the unrounded values.) The package's test suite checks the same balance on synthetic catchments every time it runs and fails if the residual exceeds 10−12 of the precipitation.
Spin-up: forgetting the start
The model has to start from some initial state: half-full soil, an aquifer at 30% of capacity, no snow. Those guesses are wrong, but the model forgets them, because each day's state depends more on recent weather than on the distant past. To be safe, every run starts three years before the period that is scored, a spin-up. The widget below starts the model from very different initial soil and aquifer states and shows how quickly the runs converge.
Is this the real model?
Checking…
In Python
The same loop as the pseudo-code above, with the step functions from the earlier sessions (imported from the course module). It runs the test period and compares the result with a stored run of the PyTorch package.
Check your understanding
On 17 February 1990 only about 3 mm of rain fell, yet the model's river flow peaked. Where did the water come from?
From the previous day's storm: the fast reservoir released most of the 112 mm of overland flow it received on the 16th, and the unit hydrograph delivered it to the gauge over the next days.
Which five numbers carry all of the model's memory from one day to the next?
The states: snowpack SWE, canopy W, soil SM, aquifer G and fast reservoir Fs. (The unit hydrograph also spreads past runoff forward, but it holds no water of its own beyond what is still in transit.)
Why is the water-balance residual not exactly zero?
Computers store numbers with about 16 significant digits, so each of the tens of thousands of additions rounds slightly. The residual is the accumulated rounding, far below any physical meaning.
Why are the first three years of each run not scored?
The initial states are guesses. Three years of spin-up let the model forget them, so the scored period reflects the forcing and the parameters, not the starting point.
What to remember
- One day = snow → canopy → soil (wet or dry) → aquifer → fast reservoir → losses; routing follows after the loop.
- Five states carry all memory; spin-up makes the initial guesses irrelevant.
- Mass is conserved to rounding error.
- The browser model reproduces the PyTorch package to about \(10^{-14}\) mm/day.