Exploring Patterns · Lesson 3 of 5
Time-Series Patterns
~16 min
The Concept
You plot five years of nitrate at well GW-14 as a time series. Immediately, three things are visible that no summary statistic could show: values peak every spring (fertiliser application), drop in summer (crop uptake), and have been drifting gradually upward across the whole five years. One event stands out, a sharp spike in March 2022, during a heavy rainfall week.
These are three completely different patterns, seasonal, trend, and event, layered on top of each other. Treating them as one undifferentiated 'variability' would be like trying to explain the total in one number.
A time series (any set of measurements recorded one after another over time) is any measurement recorded sequentially over time. Almost all environmental data is a time series. Decomposing a time series (splitting it apart into its separate ingredients) means separating it into its components: the long-term trend (is nitrate rising over years?), the seasonal cycle (does it peak every spring?), and the residuals (what's left over after removing trend and season, random variation, individual events).
Each component needs different tools and different interpretations. The trend answers 'is there a long-term change?', the question the research station was set up to answer. The seasonal component answers 'when in the year does this happen?', important for monitoring design. The residuals may contain the most scientifically interesting events.
The Analogy
Think of a kid's height measured every month on a doorframe. There is a steady upward trend as they grow. There might be a tiny seasonal wobble, taller after a growth spurt in summer. And there is noise, since standing up a little straighter one day can nudge the mark up a few millimeters. Separating those three things tells you what is really going on instead of one confusing wiggly line.
Try It
Toggle the trend, seasonal, and residual layers on the Bluewater Basin nitrate time series to see what each component contributes.
The teal line is the raw signal — everything combined. Toggle each layer to see what it contributes. The trend is the slow drift; the seasonal pattern repeats every 12 months; the residualis what's left over — noise and events.
Code (optional)
import pandas as pd
from statsmodels.tsa.seasonal import seasonal_decompose
df = pd.read_csv("GW14_nitrate_monthly.csv", parse_dates=["month"])
df = df.set_index("month")
# Decompose into trend, seasonal, and residual components
result = seasonal_decompose(df["nitrate_mgL"], model="additive", period=12)
print("Trend range (min to max):")
print(f" {result.trend.dropna().min():.2f} → {result.trend.dropna().max():.2f} mg/L")
print(f"Seasonal peak-to-trough swing: {result.seasonal.max() - result.seasonal.min():.2f} mg/L")
print(f"Largest residual: {result.resid.dropna().abs().max():.2f} mg/L")Line by line
- seasonal_decompose separates the time series into three components using a moving average for the trend.
- period=12 tells the function the seasonal cycle repeats every 12 months.
- model='additive' assumes trend, season, and residual add together, appropriate when the seasonal swing doesn't grow as the overall level increases.
- Printing ranges for each component quantifies how much of the total variability each one explains.
Why Real Researchers Care
Time-series decomposition is used by government environment agencies worldwide to separate long-term trends (what the public and policymakers care about) from seasonal cycles (which mask trends if not removed) and random variation. The UK Environment Agency uses this approach for reporting on long-term trends in river water quality under the Water Framework Directive.
Quick Check
Q1. Bluewater Basin's nitrate shows a consistent spring peak every year. After removing the seasonal component, nitrate still trends upward over five years. What can you conclude?
Your Goal
From the time-series simulation above, identify: (1) the approximate month of the annual nitrate peak; (2) whether the long-term trend over five years is upward, downward, or flat; (3) the single highest residual event and its approximate date.
Hint: Use the toggle controls to isolate each component so you can read each one cleanly.
Teach It Back
Explain what time-series decomposition reveals that a simple scatter plot or histogram of the same data would not.