Note
Go to the end to download the full example code.
Daytime NEE Partitioning ONEFlux (RECO/GPP)¶
Partition net ecosystem exchange (NEE) into gross primary production (GPP) and
ecosystem respiration (RECO) with the daytime method of Lasslop et al. (2010),
here as a faithful Python port of ONEFlux’s flux_part_gl2010 (the FLUXNET2015
daytime partitioning).
The daytime method fits a rectangular-hyperbola light-response curve (LRC) to
daytime NEE in short windows - GPP saturating with light, modulated by VPD - and
holds the temperature sensitivity E0 fixed from a prior nighttime estimate.
RECO and GPP are then predicted for every record. Output columns carry the
_DT_OF token (daytime, ONEFlux), so this port lives side by side with the
daytime REddyProc port (_DT_RP) and the nighttime ports (_NT_OF /
_NT_RP) in one dataframe.
Best for: matching an ONEFlux / FLUXNET2015 daytime partitioning, or comparing the ONEFlux and REddyProc daytime implementations.
dv.flux.PartitioningNEE(method='daytime', mode='oneflux') runs the same
port. It selects any of the four partitioning ports with these two arguments.
Inputs and reference columns¶
ONEFlux’s daytime method uses BOTH the measured (gappy) and the gap-filled
drivers: measured Rg/TA classify records (day if Rg > 4) and feed the
internal NEE-uncertainty look-up that weights the fits, while the gap-filled
drivers feed the fits and the flux prediction. Unlike the nighttime method, it
does NOT use solar geometry or latitude - the day/night split is the measured
radiation threshold.
The gap-filled NEE (nee_f) is optional. ONEFlux reads it only for windows
without any measured nighttime NEE, for example at high latitudes in summer
or in long gaps. Without it such windows are not fitted and a warning lists
them.
The bundled CH-DAV dataset ships REddyProc daytime reference columns
(Reco_DT_CUT_REF / GPP_DT_CUT_REF). They come from a different
algorithm and provenance (measured NEE uncertainty, bootstrap, full record), so
the ONEFlux port tracks GPP closely and RECO with a stable bias - a provenance
artifact, not an algorithmic difference (on identical inputs, every fit is
bitwise identical to a native ONEFlux run under NumPy 1, and RECO/GPP differ
by at most 6e-6 umol m-2 s-1, float32 rounding).
import matplotlib.pyplot as plt
import numpy as np
import diive as dv
df = dv.load_exampledata_parquet()
# One growing season (April-September 2017). The light-response curve is fitted in
# short windows, so this span carries the full seasonal range the fit needs - spring
# onset, peak season, autumn senescence - while the run stays quick.
df = df.loc[(df.index.year == 2017) & (df.index.month.isin([4, 5, 6, 7, 8, 9]))].copy()
print("Partitioning method: DAYTIME (Lasslop et al. 2010, ONEFlux port) -> *_DT_OF")
print(f"Period: {df.index.min().date()} to {df.index.max().date()} ({len(df)} records)")
> 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.049
seconds).
Partitioning method: DAYTIME (Lasslop et al. 2010, ONEFlux port) -> *_DT_OF
Period: 2017-04-01 to 2017-09-30 (8784 records)
Run the partitioning¶
part = dv.flux.DaytimePartitioningOneFlux(
nee=df['NEE_CUT_REF_orig'], # measured NEE (NaN where not measured)
ta=df['Tair_orig'], # measured air temperature
sw_in=df['Rg_orig'], # measured incoming shortwave radiation
ta_f=df['Tair_f'], # gap-filled air temperature
sw_in_f=df['Rg_f'], # gap-filled incoming shortwave radiation
vpd=df['VPD_f'], # gap-filled VPD, in hPa in this dataset
vpd_in_kpa=False, # the default expects kPa
)
part.run()
results = part.results
print("\nResult columns:", list(results.columns))
print(results[['RECO_DT_OF', 'GPP_DT_OF']].describe())
> Daytime partitioning ONEFlux (Lasslop et al. 2010) starting for 1 year(s).
──────── Daytime NEE Partitioning ONEFlux (Lasslop et al. 2010) Report ─────────
Reference: Pastorello et al. (2020), https://doi.org/10.1038/s41597-020-0534-3
RECO GPP
Year Records filled filled RECO mean GPP mean E0
2017 8,784 8,784 8,784 3.01 4.34 189.25
(100%) (100%)
GPP standard error mean 0.93
Fluxes in umol m-2 s-1.
v Daytime partitioning (ONEFlux) finished.
Result columns: ['RECO_DT_OF', 'GPP_DT_OF', 'SE_GPP_DT_OF', 'ALPHA_DT_OF', 'BETA_DT_OF', 'K_DT_OF', 'RREF_DT_OF', 'E0_DT_OF']
RECO_DT_OF GPP_DT_OF
count 8784.000000 8784.000000
mean 3.007158 4.342658
std 1.124100 4.988300
min 0.767210 0.000000
25% 2.425755 0.000000
50% 2.810199 1.735606
75% 3.209718 8.988725
max 9.559732 21.464735
Compare to the bundled reference¶
GPP should track the reference column closely; daytime RECO is more sensitive and carries a bias (the reference is REddyProc-derived, see above).
reco_ref = df['Reco_DT_CUT_REF']
gpp_ref = df['GPP_DT_CUT_REF']
m_reco = results['RECO_DT_OF'].notna() & reco_ref.notna()
m_gpp = results['GPP_DT_OF'].notna() & gpp_ref.notna()
print(f"RECO correlation, diive (ONEFlux method) vs reference: "
f"{np.corrcoef(results['RECO_DT_OF'][m_reco], reco_ref[m_reco])[0, 1]:.4f}")
print(f"GPP correlation, diive (ONEFlux method) vs reference: "
f"{np.corrcoef(results['GPP_DT_OF'][m_gpp], gpp_ref[m_gpp])[0, 1]:.4f}")
print(f"\nMeans (umol m-2 s-1):")
print(f" RECO diive (ONEFlux method): {results['RECO_DT_OF'].mean():.3f} "
f"reference: {reco_ref.mean():.3f}")
print(f" GPP diive (ONEFlux method): {results['GPP_DT_OF'].mean():.3f} "
f"reference: {gpp_ref.mean():.3f}")
RECO correlation, diive (ONEFlux method) vs reference: 0.3695
GPP correlation, diive (ONEFlux method) vs reference: 0.8850
Means (umol m-2 s-1):
RECO diive (ONEFlux method): 3.007 reference: 3.547
GPP diive (ONEFlux method): 4.343 reference: 5.457
Visual comparison¶
Scatter the partitioned RECO and GPP against the reference columns, with the 1:1 line for orientation.
fig, axes = plt.subplots(1, 2, figsize=(11, 5.2))
fig.subplots_adjust(left=0.08, right=0.97, top=0.88, bottom=0.12, wspace=0.27)
for ax, dcol, ref, name, color in [
(axes[0], 'RECO_DT_OF', reco_ref, 'RECO', '#F44336'), # red
(axes[1], 'GPP_DT_OF', gpp_ref, 'GPP', '#2196F3'), # blue
]:
m = results[dcol].notna() & ref.notna()
x, y = ref[m], results[dcol][m]
ax.scatter(x, y, s=4, alpha=0.15, color=color, edgecolors='none')
lim = [float(min(x.min(), y.min())), float(max(x.max(), y.max()))]
ax.plot(lim, lim, color='#455A64', lw=1.0, ls='--', label='1:1')
ax.set_xlim(lim)
ax.set_ylim(lim)
ax.set_xlabel(f'reference {name} (umol m-2 s-1)')
ax.set_ylabel(f'diive (ONEFlux method) {name} (umol m-2 s-1)')
ax.set_title(f'{name} r = {np.corrcoef(x, y)[0, 1]:.3f}')
ax.legend(loc='upper left', frameon=False)
fig.suptitle('diive (ONEFlux method) vs reference - daytime (CH-DAV 2017)')
plt.show()

