Note
Go to the end to download the full example code.
Yearly Cumulative Summaries¶
Annual cumulative sum visualization with reference band and highlighted years. Compare individual years against climatological mean and variability.
Best for: Annual budget analysis, comparing specific years to baseline, trend detection
import diive as dv
Load and prepare data¶
df_orig = dv.load_exampledata_parquet()
# Convert units: umol CO2 m-2 s-1 --> g C m-2 30min-1
conversion_factor = 0.02161926
series_units = r'($\mathrm{gC\ m^{-2}}$)'
series = df_orig['NEE_CUT_REF_f'].copy()
series = series.multiply(conversion_factor)
print(f"Loaded {len(df_orig)} records")
print(f"Unit conversion factor: {conversion_factor}")
> Loaded .parquet file
/home/docs/checkouts/diive/checkouts/latest/diive/configs/exampledata/exampledat
a_PARQUET_CH-DAV_FP2022.5_2013-2022_ID20230206154316_30MIN.parquet (0.050
seconds).
Loaded 175296 records
Unit conversion factor: 0.02161926
Yearly cumulative with reference band¶
Plot annual cumulative sums with mean and standard deviation from reference period. Gray band shows climatological range, helping identify anomalous years.
dv.plotting.CumulativeYear(
series=series,
series_units=series_units,
yearly_end_date=None,
start_year=2015,
end_year=2019,
show_reference=True,
excl_years_from_reference=None,
).plot(format_style=style, highlight_year_color='#F44336')
print("\nPlotted yearly cumulative sums with reference band (2015-2017 baseline)")

Plotted yearly cumulative sums with reference band (2015-2017 baseline)
Highlight specific year for comparison¶
Emphasize a single year for detailed comparison against reference period.
The same style is reused, so both figures share identical chrome.
dv.plotting.CumulativeYear(
series=series,
series_units=series_units,
yearly_end_date=None,
start_year=2015,
end_year=2019,
show_reference=True,
excl_years_from_reference=None,
highlight_year=2017,
).plot(format_style=style, highlight_year_color='#F44336')
print("Plotted yearly cumulative sums with year 2017 highlighted")
print("Highlighting enables easy identification of outlier years and trends")

Plotted yearly cumulative sums with year 2017 highlighted
Highlighting enables easy identification of outlier years and trends
Total running time of the script: (0 minutes 0.616 seconds)