The overall goal of SurEau Climate is to generate hourly forcings from daily climatic variables
Input: climate_df (DataFrame with daily records),
date string (DD/MM/YYYY)
│
▼
┌────────────────────────────────────────────┐
│ new_climate_day(climate_df, date) │
│ │
│ 1. Parse date string → DOY, year │
│ (dateutil.parser handles any format) │
│ │
│ 2. Slice row where DATE == date │
│ │
│ 3. Assign met fields: │
│ T_mean, T_min, T_max │
│ RH_mean, RH_min, RH_max │
│ PPT, RG, WS_mean │
│ │
│ 4. VPD = f(RH_mean, T_mean) │
│ │
│ │
│ 5. Look up prev/next row by integer pos │
│ → T_min_prev, T_max_prev, T_min_next │
│ (needed for diurnal T model) │
└────────────────────────────────────────────┘
│
▼
SurEauClimate object
┌────────────────────────────────────────────┐
│ compute_Rn_and_ETP(clim, params, opts) │
│ │
│ Branch: opts.Rn_formulation │
│ ───────────────────────────── │
│ "Linacre": │
│ nN = 0.25 if PPT > 0 else 0.75 │
│ (cloud proxy: rainy=cloudy, dry=clear) │
│ │
│ SW_abs = (1 − 0.17) × RG × 10⁶ │
│ LW_loss = 1927.987 × (1+4·nN) │
│ × (100 − T_mean) │
│ │
│ Rn = max(0, SW_abs − LW_loss ) × 10⁻⁶ │
│ │
│ ETP_formulation │
│ ───────────────────────────── │
│ "PT": Priestley-Taylor │
│ ETP = α × Δ·Rn / [λ(Δ+γ)] │
│ via pyet.priestley_taylor() │
│ (α = params.PT_coeff ≈ 1.14) │
│ │
│ "PM": Penman-Monteith │
│ es = pyet.calc_es(T) │
│ ea = es − VPD │
│ ETP = pyet.pm(T, WS, Rn, ea, elev) │
└────────────────────────────────────────────┘
│
▼
clim.net_radiation, clim.ETP set
┌────────────────────────────────────────────┐
│ new_climate_hourly(clim, opts, veg_params) │
│ │
│ 1. Daylength & solar geometry │
│ sunrise_h, sunset_h, daylen_h │
│ = daylength(opts.latitude, clim.DOY) │
│ Polar edge cases clamped to [0, 24] │
│ │
│ 2. Radiation disaggregation │
│ time_rel = hour × 3600 − sunrise_s │
│ io = π/daylen × sin(π·t_rel/daylen) │
│ io = 0 outside [sunrise, sunset] │
│ RG_h = RG × io × 3600 [MJ m⁻² h⁻¹] │
│ Rn_h = Rn × io × 3600 │
│ │
│ 3. PAR │
│ PAR_h = PPFD(Watt(RG_h)) │
│ pot_PAR_h = potential_PAR(h, lat, DOY) │
│ │
│ 4. Temperature disaggregation │
│ Parton & Logan model per hour: │
│ • Daytime: sine ramp Tmin → Tmax │
│ • Evening: exp decay → T_min_next │
│ Uses T_min_prev, T_max_prev, │
│ T_min_next from adjacent days │
│ │
│ 5. Relative humidity disaggregation │
│ Dewpoint ≈ Tmin (RH_max at sunrise) │
│ ea = RH_max/100 × es(Tmin) │
│ RH_h = ea / es(T_h) × 100 │
│ Clipped to [0.5, 100] % │
│ │
│ 6. Wind speed │
│ WS_h = WS_mean (constant across hours) │
│ │
│ 7. VPD_h = f(RH_h, T_h) per hour │
│ │
│ 8. ETP disaggregation │
│ "PT": pyet.priestley_taylor( │
│ T_h, Rn_h, α, elev) │
│ "PM": pyet.pm(T_h, WS_h, Rn_h, │
│ ea_h, elev) │
│ │
│ 9. Time-step duration n_h │
│ n_h[0] = ts[0] + (24 − ts[-1]) │
│ n_h[i>0] = ts[i] − ts[i-1] │
│ │
│ 10. Subset to opts.time_steps │
│ (full 24 h or custom sub-hourly idx) │
│ │
│ 11. PPT assigned to first time step only │
└────────────────────────────────────────────┘
│
▼
SurEauClimateHourly
object (ch)
│
┌─────────┴──────────┐
│ Two parallel uses: │
▼ ▼
┌───────────────┐ ┌──────────────────────────────────────┐
│ get_hourly_ │ │ interpolate_climate_hourly( │
│ snapshot( │ │ ch1_arrays, ch2_arrays, p=0.5) │
│ ch, idx) │ │ │
│ │ │ Linear blend between two snapshots: │
│ Extracts one │ │ field = (1−p)·ch1[f] + p·ch2[f] │
│ timestep as │ │ │
│ a plain dict │ │ Interpolated fields: │
│ for passing │ │ T_air_mean, RG, WS, VPD, │
│ into the │ │ RH_air_mean, ETP, ETP_veg* │
│ hydraulic │ │ (*if present in both snapshots) │
│ solver │ │ │
│ │ │ Non-interpolated fields copied │
│ Keys: │ │ verbatim from ch1 │
│ T, RG, WS, │ │ │
│ VPD, RH, │ │ Used to refine forcing between │
│ ETP, PAR, │ │ two stored hourly time steps │
│ pot_PAR, │ └──────────────────────────────────────┘
│ n_hours, │
│ time │
└───────────────┘
│
▼
Returns:
• new_climate_day() → SurEauClimate object
• compute_Rn_and_ETP() → SurEauClimate object (Rn + ETP added)
• new_climate_hourly() → SurEauClimateHourly object
(RG, Rn, PAR, T, RH, WS, VPD, ETP,
time, n_hours, PPT arrays)
• get_hourly_snapshot() → dict (single timestep)
• interpolate_climate_hourly() → dict (blended between two snapshots)
source
new_climate_day
def new_climate_day(
climate_df:pandas.core.frame.DataFrame, date:int
)-> plant_hydraulics.parameter_classes.SurEauClimate:
Extract daily climate from each row of a DataFrame
The column names in the data frame MUST be named as the following:
DATE: Date with format DD/MM/YYYY
Tair_mean: Air temperature mean (degress C)
Tair_max: Maximum air temperature (degress C)
Tair_min: Minimum air temperature (degress C)
RHair_mean: Mean relative humidity of the day (%)
RHair_max: Maximum relative humidity of the day (%)
RHair_min: Minimum relative humidity of the day (%)
PPT_sum: Precipitation (mm)
RG_sum: Global radiation (MJ/m2)
WS_mean: Mean wind speed of the day (m/s)
source
compute_Rn_and_ETP
def compute_Rn_and_ETP(
clim:plant_hydraulics.parameter_classes.SurEauClimate,
params:plant_hydraulics.parameter_classes.SurEauVegetationParams,
opts:plant_hydraulics.parameter_classes.SurEauModelOptions
)-> plant_hydraulics.parameter_classes.SurEauClimate:
Compute daily net radiation and PET.
Given today’s solar radiation, precipitation, and temperature — how much energy is available at the surface, and how much water could potentially evaporate?”
Both outputs are stored back into clim and returned for use in the rest of the model.
Physics notes:
-Rn: Linacre (1968) formulation: shortwave absorbed = (1 - 0.17) × RG longwave loss = 1927.987 × (1 + 4·nN) × (100 - T_mean) nN = 0.25 if PPT > 0 else 0.75
-ETP: Priestley-Taylor: ETP = α × Δ·Rn / λ(Δ+γ)
source
new_climate_hourly
def new_climate_hourly(
clim:plant_hydraulics.parameter_classes.SurEauClimate,
opts:plant_hydraulics.parameter_classes.SurEauModelOptions,
veg_params:plant_hydraulics.parameter_classes.SurEauVegetationParams
)-> plant_hydraulics.parameter_classes.SurEauClimateHourly:
Disaggregate daily climate to sub-daily time steps.
source
interpolate_climate_hourly
def interpolate_climate_hourly(
ch1_arrays:dict , ch2_arrays:dict , p:float = 0.5
)-> dict :
Linearly interpolate between two hourly climate snapshots.
source
get_hourly_snapshot
def get_hourly_snapshot(
ch:plant_hydraulics.parameter_classes.SurEauClimateHourly, idx:int
)-> dict :
Extract a single timestep from ClimateHourly as a dict.
Example: Generate hourly forcings using daily values for SurEau
# List available example files
list_example_data()
climat_data_for_sureau_medlyn.csv
climat_example.csv
sureau_medlyn_daily_climate.csv
['climat_data_for_sureau_medlyn.csv',
'climat_example.csv',
'sureau_medlyn_daily_climate.csv']
from itables import to_html_datatable
from IPython.display import HTML, display
# Load example data
climate_df = load_example_data("climat_example.csv" , sep= ";" )
climate_df["DATE" ] = pd.to_datetime(climate_df["DATE" ], format = " %d /%m/%Y" ).dt.strftime("%Y-%m- %d " )
html_str = to_html_datatable(climate_df)
display(HTML(html_str))
Loading ITables v2.8.1 from the internet...
(need help ?)
# Convert numeric columns (all except DATE)
for each_col in climate_df.columns:
if each_col != "DATE" :
climate_df[each_col] = pd.to_numeric(climate_df[each_col], errors= "coerce" )
Compute Rn and ETP with compute_Rn_and_ETP()
clim = compute_Rn_and_ETP(clim, veg_params, opts)
print (f" \n Net radiation (Rn) : { clim. net_radiation:.4f} MJ m⁻² day⁻¹" )
print (f" PET (ETP) : { clim. ETP:.4f} mm day⁻¹" )
Net radiation (Rn) : 0.8222 MJ m⁻² day⁻¹
PET (ETP) : 0.1300 mm day⁻¹
Disaggregate to hourly with new_climate_hourly()
hourly_ch = new_climate_hourly(clim, opts, veg_params)
print (f" \n Output arrays (24 h each):" )
print (
f" ch.T_air_mean [°C] : { hourly_ch. T_air_mean. min ():.1f} – { hourly_ch. T_air_mean. max ():.1f} "
)
print (
f" ch.RH_air_mean [%] : { hourly_ch. RH_air_mean. min ():.1f} – { hourly_ch. RH_air_mean. max ():.1f} "
)
print (
f" ch.RG [MJ m⁻² h⁻¹]: { hourly_ch. RG. min ():.3f} – { hourly_ch. RG. max ():.3f} "
)
print (
f" ch.Rn [MJ m⁻² h⁻¹]: { hourly_ch. Rn. min ():.3f} – { hourly_ch. Rn. max ():.3f} "
)
print (
f" ch.VPD [kPa] : { hourly_ch. VPD. min ():.3f} – { hourly_ch. VPD. max ():.3f} "
)
print (
f" ch.ETP [mm h⁻¹] : { hourly_ch. ETP. min ():.4f} – { hourly_ch. ETP. max ():.4f} "
)
print (
f" ch.PAR [µmol m⁻² s⁻¹]: { hourly_ch. PAR. min ():.0f} – { hourly_ch. PAR. max ():.0f} "
)
Output arrays (24 h each):
ch.T_air_mean [°C] : -4.4 – -2.1
ch.RH_air_mean [%] : 96.9 – 96.9
ch.RG [MJ m⁻² h⁻¹]: 0.000 – 0.333
ch.Rn [MJ m⁻² h⁻¹]: 0.000 – 0.141
ch.VPD [kPa] : 0.014 – 0.016
ch.ETP [mm h⁻¹] : 0.0000 – 0.0230
ch.PAR [µmol m⁻² s⁻¹]: 0 – 213
Inspect a single timestep with get_hourly_snapshot()
# solar noon
hour = 12
snap = get_hourly_snapshot(hourly_ch, hour)
print (f" \n Snapshot at hour { hour} :00" )
for each_param, each_value in snap.items():
print (f" { each_param:<18} : { each_value:.4f} " )
Snapshot at hour 12:00
T_air_mean : -2.4368
RG : 0.3334
WS : 0.3000
VPD : 0.0158
RH_air_mean : 96.9151
ETP : 0.0230
PAR : 212.9775
potential_PAR : 669.6074
n_hours : 1.0000
time : 12.0000
Loop over multiple days
week_dates = climate_df["DATE" ].iloc[:7 ].tolist()
daily_summary = []
for date in week_dates:
c = new_climate_day(climate_df, date)
c = compute_Rn_and_ETP(c, veg_params, opts)
h = new_climate_hourly(c, opts, veg_params)
daily_summary.append(
{
"date" : date,
"Rn" : c.net_radiation,
"ETP" : c.ETP,
"T_mean" : c.T_air_mean,
"VPD" : c.VPD,
"ETP_sum_hourly" : float (np.nansum(h.ETP)),
}
)
print (
f" \n { 'Date' :<12} { 'Rn' :>8} { 'ETP_day' :>9} { 'ETP_Σh' :>8} { 'T_mean' :>8} { 'VPD' :>8} "
)
print (f" { '' :12} { 'MJ/m²' :>8} { 'mm/d' :>9} { 'mm/d' :>8} { '°C' :>8} { 'kPa' :>8} " )
print (" " + "-" * 57 )
for each_row in daily_summary:
print (
f" { each_row['date' ]:<12} { each_row['Rn' ]:8.3f} { each_row['ETP' ]:9.4f} "
f" { each_row['ETP_sum_hourly' ]:8.4f} { each_row['T_mean' ]:8.2f} { each_row['VPD' ]:8.4f} "
)
Date Rn ETP_day ETP_Σh T_mean VPD
MJ/m² mm/d mm/d °C kPa
---------------------------------------------------------
1990-01-01 0.822 0.1300 0.1333 -3.25 0.0148
1990-01-02 1.886 0.3155 0.3276 -1.95 0.0163
1990-01-03 0.078 0.0138 0.0141 -0.70 0.0179
1990-01-04 0.157 0.0272 0.0277 -1.20 0.0173
1990-01-05 0.565 0.1066 0.1100 1.05 0.0228
1990-01-06 0.420 0.0829 0.0847 2.25 0.0222
1990-01-07 0.375 0.0680 0.0691 0.05 0.0189