Note
Go to the end to download the full example code.
Evapotranspiration from Latent Heat Flux¶
Convert latent heat flux to evapotranspiration rate by accounting for temperature-dependent latent heat.
Latent heat flux (energy) is converted to evapotranspiration (mass) using the temperature-dependent latent heat relationship. This example uses real flux tower data and compares calculated ET with reference values.
Best for: Converting latent heat flux measurements to water flux (ET).
Evapotranspiration from Latent Heat Flux¶
Latent heat flux (W m⁻²) can be converted to evapotranspiration rate (mm h⁻¹) using the temperature-dependent latent heat of vaporization. This example loads real eddy covariance flux tower data and compares calculated ET with EddyPro-derived reference values.
import pandas as pd
import diive as dv
from diive.configs.exampledata import load_exampledata_EDDYPRO_FLUXNET_CSV_30MIN
Load real flux tower data¶
Using example data from a Swiss flux tower (CH-AWS)
df, meta = load_exampledata_EDDYPRO_FLUXNET_CSV_30MIN()
# Extract variables for ET conversion
le = df['LE'].copy() # Latent heat flux (W/m²)
et_eddypro = df['ET'].copy() # Reference ET from EddyPro (mm/h)
ta = df['TA_1_1_1'].copy() # Air temperature (°C)
print("Evapotranspiration from Latent Heat Flux")
print("=" * 50)
print(f"Latent heat flux range: {le.min():.1f} to {le.max():.1f} W/m²")
print(f"Air temperature range: {ta.min():.1f} to {ta.max():.1f}°C")
print(f"Number of records: {len(le)}")
> Reading file
exampledata_EDDYPRO-FLUXNET-CSV-30MIN_CH-AWS_2022.07_FR-20220127-164245_eddypro_
fluxnet_2022-01-28T112538_adv.csv ...
/home/docs/checkouts/diive/checkouts/latest/diive/core/io/filereader.py:677: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`
df[_temp_parsed_index_col] = ''
Evapotranspiration from Latent Heat Flux
==================================================
Latent heat flux range: -275.1 to 929.4 W/m²
Air temperature range: 4.1 to 21.7°C
Number of records: 1488
Convert latent heat to evapotranspiration¶
Apply temperature-dependent conversion
Compare with EddyPro reference¶
Validate calculated ET against EddyPro-derived values
et_valid = et_calculated.dropna()
et_eddypro_valid = et_eddypro[et_valid.index].dropna()
print(f"\nCalculated ET range: {et_valid.min():.4f} to {et_valid.max():.4f} mm/h")
print(f"EddyPro ET range: {et_eddypro_valid.min():.4f} to {et_eddypro_valid.max():.4f} mm/h")
if len(et_eddypro_valid) > 0:
# Calculate agreement metrics
diff = (et_valid - et_eddypro_valid).abs()
mae = diff.mean()
rmse = (((et_valid - et_eddypro_valid) ** 2).mean()) ** 0.5
print(f"\nAgreement metrics:")
print(f" Mean Absolute Error: {mae:.4f} mm/h")
print(f" Root Mean Square Error: {rmse:.4f} mm/h")
print(f" Mean calculated ET: {et_valid.mean():.4f} mm/h")
print(f" Mean EddyPro ET: {et_eddypro_valid.mean():.4f} mm/h")
# Correlation
corr = et_valid.corr(et_eddypro_valid)
print(f" Correlation: {corr:.4f}")
Calculated ET range: -0.4004 to 1.3619 mm/h
EddyPro ET range: -0.4001 to 1.3609 mm/h
Agreement metrics:
Mean Absolute Error: 0.0001 mm/h
Root Mean Square Error: 0.0002 mm/h
Mean calculated ET: 0.1475 mm/h
Mean EddyPro ET: 0.1474 mm/h
Correlation: 1.0000
Visualize ET Comparison using Heatmaps¶
Create heatmaps comparing calculated ET, EddyPro reference, and the difference. Reveals spatial and temporal patterns in ET agreement.
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
fig = plt.figure(facecolor='white', figsize=(18, 6), constrained_layout=True)
gs = gridspec.GridSpec(1, 3, figure=fig, wspace=0.3)
ax1 = fig.add_subplot(gs[0, 0])
ax2 = fig.add_subplot(gs[0, 1])
ax3 = fig.add_subplot(gs[0, 2])
dv.plotting.HeatmapDateTime(series=et_calculated).plot(ax=ax1)
dv.plotting.HeatmapDateTime(series=et_eddypro_valid).plot(ax=ax2)
dv.plotting.HeatmapDateTime(series=(et_valid - et_eddypro_valid)).plot(ax=ax3)
ax1.set_title("ET from Latent Heat Flux (mm/h)", fontsize=12, fontweight='bold')
ax2.set_title("ET from EddyPro Reference (mm/h)", fontsize=12, fontweight='bold')
ax3.set_title("Difference (calculated - reference)", fontsize=12, fontweight='bold')
ax2.tick_params(left=True, labelleft=False)
ax3.tick_params(left=True, labelleft=False)
fig.show()

Output: Calculated Evapotranspiration¶
The main output is the calculated ET time series
print(f"\nCalculated ET time series (mm/h):")
print(f" Shape: {et_calculated.shape}")
print(f" Data type: {et_calculated.dtype}")
print(f" First 10 values:")
print(et_calculated.head(10).to_string())
Calculated ET time series (mm/h):
Shape: (1488,)
Data type: float64
First 10 values:
TIMESTAMP_MIDDLE
2021-07-01 00:15:00 0.009692
2021-07-01 00:45:00 -0.000248
2021-07-01 01:15:00 -0.001500
2021-07-01 01:45:00 -0.000454
2021-07-01 02:15:00 0.002339
2021-07-01 02:45:00 -0.001953
2021-07-01 03:15:00 -0.000524
2021-07-01 03:45:00 0.006094
2021-07-01 04:15:00 0.010135
2021-07-01 04:45:00 0.001860
Freq: 30min
Interpretation¶
The calculated ET closely matches EddyPro values because both use the same formula and temperature-dependent latent heat relationship. Small differences may arise from temperature measurement timing or sensor calibration. This conversion is essential for water cycle analysis and crop water demand estimation in agricultural and ecosystem studies.
The et_calculated series can now be used directly for: - Daily/monthly cumulative water loss - Comparison with precipitation - Crop water requirement analysis - Water balance studies
Total running time of the script: (0 minutes 0.936 seconds)