Spaces:
Running
Running
Download session-01.html from hydros-ou/dcrest-course: direct link, hf CLI and curl.
- Browser
- Download file 21.2 kB
-
https://huggingface.co/spaces/hydros-ou/dcrest-course/resolve/main/session-01.html
- Command line
-
hf download hf://spaces/hydros-ou/dcrest-course/session-01.html
-
curl -L -o session-01.html https://huggingface.co/spaces/hydros-ou/dcrest-course/resolve/main/session-01.html
21.2 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>Session 1 · A river basin as a water budget — dCREST, step by step</title> | |
| <meta name="description" content="What a catchment and a stream gauge are, how river flow becomes a depth in mm per day, and the long-term water balance of the Leaf River."> | |
| <link rel="preconnect" href="https://fonts.googleapis.com"> | |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | |
| <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,600;1,6..72,400&family=Source+Sans+3:wght@400;600;700&display=swap"> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css"> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uplot@1.6.31/dist/uPlot.min.css"> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.16/codemirror.min.css"> | |
| <link rel="stylesheet" href="assets/course.css"> | |
| <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js"></script> | |
| <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js"></script> | |
| <script defer src="https://cdn.jsdelivr.net/npm/uplot@1.6.31/dist/uPlot.iife.min.js"></script> | |
| <script defer src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.16/codemirror.min.js"></script> | |
| <script defer src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.16/mode/python/python.min.js"></script> | |
| <script defer src="assets/dcrest.js"></script> | |
| <script defer src="assets/course.js"></script> | |
| </head> | |
| <body> | |
| <main> | |
| <div class="kicker">Session 1 · Foundations</div> | |
| <h1>A river basin as a water budget</h1> | |
| <p class="lede">Before building any model, look at the river. This session introduces the four numbers a rainfall–runoff model works with, shows how river flow is turned into the same units as rain, and uses thirty-four years of Leaf River data to write the basin's water budget.</p> | |
| <div class="meta"><span><b>Time</b> about 25 minutes</span><span><b>Needs</b> nothing</span></div> | |
| <figure class="video"><video controls preload="none" playsinline poster="video/s01.jpg"><source src="video/s01.mp4" type="video/mp4"></video> | |
| <figcaption>Watch this session first: a 7-minute narrated video with English subtitles. The page below goes further and lets you try each step yourself.</figcaption></figure> | |
| <div class="goals"><h4>You will be able to</h4><ul> | |
| <li>say what a catchment and a stream gauge are;</li> | |
| <li>convert river flow from cubic metres per second to millimetres per day, and back;</li> | |
| <li>read the four daily series a model needs: precipitation, temperature, potential evaporation and flow;</li> | |
| <li>write the water balance of a basin and use it to estimate how much water evaporates;</li> | |
| <li>explain why the Leaf River runs high in winter and low in summer although it rains all year.</li> | |
| </ul></div> | |
| <h2>The catchment and its gauge</h2> | |
| <p>Rain that falls on land runs downhill. Every point on a river therefore collects water from a definite area: all the land from which water flows to that point. That area is the point's <strong>catchment</strong> (also called a watershed, drainage basin or river basin). Its boundary is the line of high ground, the divide, where rain on one side drains towards the point and rain on the other side drains elsewhere.</p> | |
| <p>The point itself is usually a <strong>stream gauge</strong>, a station where the water level is recorded continuously and converted to <strong>discharge</strong>, the volume of water passing per second. The U.S. Geological Survey (USGS) runs thousands of them. Our gauge, USGS 02472000, sits on the Leaf River near the town of Collins in southern Mississippi. Its catchment covers 1924 km², about the size of a square 44 km on a side: low hills (mean elevation 123 m), 67% forest, and loamy soils.</p> | |
| <div class="callout case"><span class="label">Why this river</span> | |
| <p>The Leaf River is a classic test case for rainfall–runoff models. Sorooshian, Duan and Gupta (1993) used its historical record to show that the SCE-UA search algorithm can reliably find the best settings of the Sacramento model, a conceptual model of the same family as CREST. Many studies of model calibration have used it since. Its record is complete: not a single day of flow is missing in water years 1981–2014.</p> | |
| </div> | |
| <h2>Four numbers per day</h2> | |
| <p>A daily rainfall–runoff model sees the world as four numbers per day, each one an average over the whole catchment.</p> | |
| <div class="tablewrap"><table> | |
| <thead><tr><th>Symbol</th><th>Name</th><th>Units</th><th>Where it comes from here</th></tr></thead> | |
| <tbody> | |
| <tr><td class="sym"><var data-v="P">P</var></td><td>precipitation (rain and snow)</td><td>mm/day</td><td>Daymet, a gridded daily dataset built from weather stations, averaged over the catchment</td></tr> | |
| <tr><td class="sym"><var data-v="T">T</var></td><td>air temperature, daily mean</td><td>°C</td><td>Daymet, as above</td></tr> | |
| <tr><td class="sym"><var data-v="PET">PET</var></td><td>potential evapotranspiration</td><td>mm/day</td><td>computed from temperature and the sunlight reaching the top of the atmosphere at that latitude and date (the Oudin et al., 2005, formula)</td></tr> | |
| <tr><td class="sym"><var data-v="Q">Q</var></td><td>discharge (river flow)</td><td>mm/day</td><td>USGS gauge record, converted to a depth (next section)</td></tr> | |
| </tbody></table></div> | |
| <p>The first three are the model's <strong>forcing</strong>: they drive it. The fourth is what the model must predict. <var data-v="PET">PET</var> needs a word of explanation. It is not a measurement of evaporation. It is an estimate of how much water the air <em>could</em> take up from a surface that never runs dry: a thirst, set by sunshine and warmth. How much is actually evaporated depends on how much water the land can supply, and that is one of the things the model has to work out.</p> | |
| <div class="callout idea"><span class="label">Key idea</span> | |
| <p>The basin-averaged daily series are a simplification. Rain varies within the catchment and within the day. A daily, catchment-averaged ("lumped") model accepts this loss of detail in exchange for being simple and fast. dCREST is such a model.</p> | |
| </div> | |
| <h2>River flow as a depth</h2> | |
| <p>Rain is measured as a depth: 10 mm of rain means that a layer of water 10 mm thick fell everywhere. River flow is measured as a volume per second, for example 50 m³/s. To compare the two, spread the river's daily volume evenly over the catchment and ask how thick a layer it makes:</p> | |
| <div class="eq">\[ | |
| Q\;[\text{mm/day}] \;=\; \frac{Q\;[\text{m}^3/\text{s}] \times 86\,400\ \text{s/day}}{A\;[\text{km}^2] \times 10^6\ \text{m}^2/\text{km}^2} \times 1000\ \text{mm/m} \;=\; \frac{86.4\; Q\;[\text{m}^3/\text{s}]}{A\;[\text{km}^2]} | |
| \]</div> | |
| <p>For the Leaf River, \(A = 1924\) km², so 1 m³/s is 0.0449 mm/day, and 1 mm/day of flow is 22.3 m³/s. From here on, all water amounts in this course (rain, evaporation, storage, flow) are depths in millimetres, so they can be added and subtracted directly.</p> | |
| <div class="widget" id="conv"> | |
| <div class="whead"><span class="wtag">Try it</span><span class="wtitle">Convert river flow for the Leaf River</span></div> | |
| <div class="controls"> | |
| <label class="ctl"><span class="top"><span>flow in m³/s</span></span><input type="number" id="cv_m3s" value="50" min="0" step="1"></label> | |
| <label class="ctl"><span class="top"><span>flow in mm/day</span></span><input type="number" id="cv_mm" step="0.01"></label> | |
| <label class="ctl"><span class="top"><span>catchment area in km²</span></span><input type="number" id="cv_area" value="1924" min="1" step="1"></label> | |
| </div> | |
| <p class="note">Type in either box. A flood of 1 000 m³/s at the Leaf River gauge is a layer of about 45 mm over the whole basin in one day.</p> | |
| </div> | |
| <h2>Thirty-four years of the Leaf River</h2> | |
| <p>The chart shows one water year at a time. Hydrologists count years from 1 October to 30 September, so that each winter sits in a single year; water year 1990 runs from October 1989 to September 1990. Rain hangs down from the top as blue bars, and the river's flow rises from the bottom as a dark line. Drag across the chart to zoom, double-click to zoom out.</p> | |
| <div class="widget wide" id="rec"> | |
| <div class="whead"><span class="wtag">Try it</span><span class="wtitle">The record, one water year at a time</span></div> | |
| <div class="controls"><label class="ctl"><span class="top"><span>water year</span><output id="rec_wyv"></output></span><input type="range" id="rec_wy" min="1981" max="2014" step="1" value="1990"></label> | |
| <div class="ctl"><span class="top"><span>this year</span></span><div class="stats" id="rec_stats"></div></div></div> | |
| <div class="chart" id="rec_chart"></div> | |
| <div class="chart" id="rec_chart2"></div> | |
| <p class="note">Top: precipitation (bars, right axis, pointing down) and river flow (line, left axis), both in mm/day. Bottom: daily mean air temperature and potential evapotranspiration.</p> | |
| </div> | |
| <p>Three things are worth noticing in almost every year. First, flow responds to rain within a day or two, then recedes over weeks. Second, the same amount of rain produces far more flow in winter than in summer. Third, the river never stops: even after weeks without rain, some water still arrives from storage underground. A model has to reproduce all three.</p> | |
| <h2>The water budget</h2> | |
| <p>Water is never created or destroyed. Over any period, the water that arrives as precipitation either leaves again, as evaporation or as river flow, or stays in the catchment as stored water (in snow, soil and groundwater):</p> | |
| <div class="eq">\[ P \;=\; ET \;+\; Q \;+\; \Delta S \]</div> | |
| <p class="eqnote">\(ET\) is actual evapotranspiration, the water that really went back to the air; \(\Delta S\) is the change in storage over the period.</p> | |
| <p>Over a single month \(\Delta S\) can be large, but over many years storage cannot keep growing or shrinking, so \(\Delta S \approx 0\) and the budget gives a way to estimate the hard-to-measure evaporation: \(ET \approx P - Q\). For the Leaf River in water years 1981–2014:</p> | |
| <div class="tablewrap"><table> | |
| <thead><tr><th>Average over water years 1981–2014</th><th class="n">mm/yr</th><th>share of precipitation</th></tr></thead> | |
| <tbody> | |
| <tr><td>Precipitation <var data-v="P">P</var></td><td class="n">1515</td><td>100%</td></tr> | |
| <tr><td>River flow <var data-v="Q">Q</var></td><td class="n">478</td><td>32% (the <em>runoff ratio</em>)</td></tr> | |
| <tr><td>Evapotranspiration, \(ET \approx P - Q\)</td><td class="n">1037</td><td>68%</td></tr> | |
| <tr><td>Potential evapotranspiration <var data-v="PET">PET</var></td><td class="n">1126</td><td>for comparison</td></tr> | |
| </tbody></table></div> | |
| <p>Two thirds of the rain goes back to the air. Actual evaporation reaches 92% of the potential: in this humid basin the land can usually meet most of the atmosphere's demand. In a drier basin, the land would run out of water and actual evaporation would fall far below its potential.</p> | |
| <div class="widget wide" id="ann"> | |
| <div class="whead"><span class="wtag">Data</span><span class="wtitle">Precipitation and river flow, every water year</span></div> | |
| <div class="chart" id="ann_chart"></div> | |
| <p class="note">Light bars: precipitation. Dark bars: river flow. The gap between them is, give or take a change in storage, the water that evaporated. Dry years lose a larger share of their rain to evaporation.</p> | |
| </div> | |
| <h2>Why the river runs high in winter</h2> | |
| <p>Rain at the Leaf River is spread fairly evenly over the year, between 3.1 mm/day in October and 5.3 mm/day in February. River flow is not: it averages 3.2 mm/day in February and only 0.39 mm/day in August. The difference comes from the atmosphere's thirst. Potential evapotranspiration climbs from 1.0 mm/day in January to 5.3 mm/day in July.</p> | |
| <div class="widget" id="mon"> | |
| <div class="whead"><span class="wtag">Data</span><span class="wtitle">The average year</span></div> | |
| <div class="chart" id="mon_chart"></div> | |
| <p class="note">Monthly means over water years 1981–2014, mm/day.</p> | |
| </div> | |
| <p>In summer the air takes back almost all the rain, the soil dries out, and new rain is used to wet the soil again instead of reaching the river. In winter evaporation is small, the soil stays wet, and rain runs off. The same rain gives very different flow depending on <em>how wet the catchment already is</em>. That wetness is a hidden quantity: it is not in the four numbers above. Tracking it is the main job of a hydrological model, and the subject of the next session.</p> | |
| <h2>In Python</h2> | |
| <p>The cell below loads the Leaf River data (the same file the widgets use) and computes the water budget. Edit it and press Run. For example, change the years, or compute the runoff ratio of the wettest year only.</p> | |
| <div class="pycell" data-title="The Leaf River water budget"> | |
| <textarea> | |
| from dcrest_course import * | |
| case = load_case() # Leaf River near Collins, MS | |
| print(case.name, "-", case.area_km2.__round__(), "km2") | |
| print("days in the record:", len(case.dates), "from", case.dates[0], "to", case.dates[-1]) | |
| # water years: Oct-Sep, named after the year they end in | |
| year = case.dates.astype("datetime64[Y]").astype(int) + 1970 | |
| month = case.dates.astype("datetime64[M]").astype(int) % 12 + 1 | |
| wy = year + (month >= 10) | |
| rows = [] | |
| for y in range(1981, 2015): | |
| m = wy == y | |
| P, Q, PET = case.P[m].sum(), case.Qobs[m].sum(), case.PET[m].sum() | |
| rows.append(dict(wy=y, P=P, Q=Q, ET=P - Q, PET=PET, ratio=Q / P)) | |
| table(rows[:8], ["wy", "P", "Q", "ET", "PET", "ratio"], fmt="{:9.2f}") | |
| print("...") | |
| P = np.mean([r["P"] for r in rows]); Q = np.mean([r["Q"] for r in rows]) | |
| print(f"\nmean P {P:.0f} mm/yr, Q {Q:.0f} mm/yr, runoff ratio {Q/P:.2f}, ET = P - Q = {P-Q:.0f} mm/yr") | |
| months = np.arange(1, 13) | |
| plot(months, [case.P[month == k].mean() for k in months], [case.PET[month == k].mean() for k in months], | |
| [case.Qobs[month == k].mean() for k in months], labels=["P", "PET", "Q"], | |
| title="Monthly means (mm/day)", xlabel="month") | |
| </textarea> | |
| </div> | |
| <h2>Check your understanding</h2> | |
| <div class="quiz"> | |
| <details><summary>A gauge records 200 m³/s. How many mm/day is that for the Leaf River?</summary><div class="ans"><p>\(86.4 \times 200 / 1924 = 0.0449 \times 200 \approx 9.0\) mm/day.</p></div></details> | |
| <details><summary>Over 34 years the basin received 1515 mm/yr and the river carried 478 mm/yr. Where did the rest go, and what assumption did we make?</summary><div class="ans"><p>It evaporated (evapotranspiration, about 1037 mm/yr). We assumed that the change in stored water over 34 years is negligible compared with the totals, and that no water leaves the basin underground past the gauge.</p></div></details> | |
| <details><summary>Why is potential evapotranspiration larger than actual evapotranspiration?</summary><div class="ans"><p>PET is what the air could evaporate if water were always available. When the soil is dry, the land cannot supply that much, so actual evaporation is lower.</p></div></details> | |
| <details><summary>February gets about a third more rain than August, yet its river flow is about eight times larger. Why so much more?</summary><div class="ans"><p>The extra rain explains only a small part. In August the atmosphere's demand is about three times larger than in February, so most rain is evaporated and dry soil soaks up the rest. In February the soil is already wet and little evaporates, so much more of the rain becomes flow. The catchment's wetness, a stored quantity, controls the response.</p></div></details> | |
| </div> | |
| <div class="remember"><h4>What to remember</h4><ul> | |
| <li>A catchment is all the land that drains to one point; the gauge measures what leaves it.</li> | |
| <li>Flow in mm/day is \(86.4\,Q[\text{m}^3/\text{s}] / A[\text{km}^2]\), the same units as rain.</li> | |
| <li>\(P = ET + Q + \Delta S\). At the Leaf River about two thirds of the rain evaporates.</li> | |
| <li>How much rain becomes flow depends on how wet the catchment already is. Models track that wetness as stored water.</li> | |
| </ul></div> | |
| </main> | |
| <script> | |
| window.pageInit = async function () { | |
| // flow converter | |
| const m3 = document.getElementById("cv_m3s"), mm = document.getElementById("cv_mm"), ar = document.getElementById("cv_area"); | |
| const fromM3 = () => { mm.value = (86.4 * (+m3.value) / (+ar.value)).toFixed(3); }; | |
| const fromMm = () => { m3.value = ((+mm.value) * (+ar.value) / 86.4).toFixed(1); }; | |
| m3.addEventListener("input", fromM3); ar.addEventListener("input", fromM3); mm.addEventListener("input", fromMm); fromM3(); | |
| const c = await Course.data(); | |
| const css = Course.css; | |
| // record explorer: hydrograph with inverted hyetograph, plus temperature and PET | |
| const wyIn = document.getElementById("rec_wy"), wyOut = document.getElementById("rec_wyv"); | |
| let u1 = null, u2 = null; | |
| const sync = uPlot.sync("rec"); | |
| function draw() { | |
| const wy = +wyIn.value; wyOut.textContent = wy; | |
| const i0 = c.idx(`${wy - 1}-10-01`), i1 = c.idx(`${wy}-09-30`) + 1; | |
| const t = c.time.subarray(i0, i1), P = c.P.subarray(i0, i1), Q = c.Qobs.subarray(i0, i1); | |
| const T = c.T.subarray(i0, i1), E = c.PET.subarray(i0, i1); | |
| const sum = (a) => a.reduce((x, y) => x + y, 0); | |
| document.getElementById("rec_stats").innerHTML = | |
| `<span class="s"><span class="k">P</span><span class="v2">${sum(P).toFixed(0)} mm</span></span>` + | |
| `<span class="s"><span class="k">Q</span><span class="v2">${sum(Q).toFixed(0)} mm</span></span>` + | |
| `<span class="s"><span class="k">Q / P</span><span class="v2">${(sum(Q) / sum(P)).toFixed(2)}</span></span>`; | |
| const ax = { stroke: css("--muted"), grid: { stroke: css("--rule") }, ticks: { stroke: css("--rule") } }; | |
| const w = Math.max(document.getElementById("rec_chart").clientWidth, 300); | |
| const pmax = Math.max(...P) * 2.2, qmax = Math.max(...Q) * 1.15; | |
| const o1 = { width: w, height: 300, cursor: { sync: { key: sync.key }, drag: { x: true, y: false } }, | |
| scales: { x: { time: true }, y: { range: [0, qmax] }, p: { range: [0, pmax], dir: -1 } }, | |
| series: [{}, { label: "flow Q", stroke: css("--obs"), width: 1.4, scale: "y" , points: { show: false } }, | |
| { label: "precipitation P", stroke: css("--snow"), fill: css("--snow"), width: 0, scale: "p", paths: uPlot.paths.bars({ size: [0.9, 100] }) }], | |
| axes: [{ ...ax }, { ...ax, label: "flow (mm/day)", labelSize: 18, size: 54 }, { ...ax, scale: "p", side: 1, label: "precipitation (mm/day)", labelSize: 18, size: 54, grid: { show: false } }] }; | |
| const o2 = { width: w, height: 170, cursor: { sync: { key: sync.key } }, scales: { x: { time: true } }, | |
| series: [{}, { label: "temperature T (°C)", stroke: css("--fast"), width: 1.1 , points: { show: false } }, { label: "PET (mm/day)", stroke: css("--et"), width: 1.4 , points: { show: false } }], | |
| axes: [{ ...ax }, { ...ax, size: 54 }] }; | |
| if (u1) u1.destroy(); if (u2) u2.destroy(); | |
| u1 = new uPlot(o1, [t, Q, P], document.getElementById("rec_chart")); | |
| u2 = new uPlot(o2, [t, T, E], document.getElementById("rec_chart2")); | |
| } | |
| wyIn.addEventListener("input", draw); draw(); | |
| new ResizeObserver(() => { const w = Math.max(document.getElementById("rec_chart").clientWidth, 300); u1 && u1.setSize({ width: w, height: 300 }); u2 && u2.setSize({ width: w, height: 170 }); }).observe(document.getElementById("rec")); | |
| // annual bars | |
| const yrs = [], Pa = [], Qa = []; | |
| for (let wy = 1981; wy <= 2014; wy++) { | |
| const i0 = c.idx(`${wy - 1}-10-01`), i1 = c.idx(`${wy}-09-30`) + 1; | |
| let p = 0, q = 0; for (let i = i0; i < i1; i++) { p += c.P[i]; q += c.Qobs[i]; } | |
| yrs.push(wy); Pa.push(p); Qa.push(q); | |
| } | |
| Course.xyChart(document.getElementById("ann_chart"), { x: Float64Array.from(yrs), height: 260, xlabel: "water year", ylabel: "mm per year", xint: true, | |
| series: [{ label: "precipitation", values: Float64Array.from(Pa), color: "rgba(61,143,203,0.32)", bars: true }, | |
| { label: "river flow", values: Float64Array.from(Qa), color: css("--accent"), bars: true }] }); | |
| // monthly climatology | |
| const mP = new Array(12).fill(0), mE = new Array(12).fill(0), mQ = new Array(12).fill(0), mn = new Array(12).fill(0); | |
| const i0 = c.idx("1980-10-01"), i1 = c.idx("2014-09-30") + 1; | |
| for (let i = i0; i < i1; i++) { const m = new Date(c.time[i] * 1000).getUTCMonth(); mP[m] += c.P[i]; mE[m] += c.PET[i]; mQ[m] += c.Qobs[i]; mn[m]++; } | |
| const x = Float64Array.from({ length: 12 }, (_, i) => i + 1); | |
| Course.xyChart(document.getElementById("mon_chart"), { x, height: 250, xlabel: "month", ylabel: "mm/day", xrange: [0.5, 12.5], | |
| series: [{ label: "precipitation P", values: Float64Array.from(mP, (v, i) => v / mn[i]), color: css("--snow"), width: 2 }, | |
| { label: "potential evapotranspiration PET", values: Float64Array.from(mE, (v, i) => v / mn[i]), color: css("--et"), width: 2 }, | |
| { label: "river flow Q", values: Float64Array.from(mQ, (v, i) => v / mn[i]), color: css("--obs"), width: 2.2 }] }); | |
| }; | |
| </script> | |
| </body> | |
| </html> | |