Skip to contents

Data preparation

Standardise raw soil data for modelling

prepare_swrc_data()
Prepare a soil data frame for SWRC modelling

Model fitting

Train the CNN1D-PINN and swrc_fit S3 methods

fit_swrc()
Fit a physics-informed CNN1D SWRC model
build_swrc_model()
Build the CNN1D monotone-integral SWRC model
norouzi_lambdas()
Return default Norouzi et al. (2025) loss weights (lambdas)
build_residual_sets()
Build physics residual point sets (S1 – S4)
print(<swrc_fit>)
Print method for swrc_fit
summary(<swrc_fit>)
Summary method for swrc_fit

Prediction

Predict water content at specific or dense pF grids

predict_swrc()
Predict water content at specific pF or matric-head values
predict_swrc_dense()
Predict dense SWRC curves for a set of soil profiles
predict_theta_s()
Extract saturated water content (theta_s) from covariates
predict(<swrc_fit>)
Predict method for swrc_fit

Evaluation & metrics

Performance metrics and evaluation

evaluate_swrc()
Compute metrics from a swrc_fit on new data
swrc_metrics()
Compute regression metrics for SWRC predictions
swrc_metrics_by_group()
Compute regression metrics by group

Visualisation

Publication-quality plots

plot_swrc()
Plot soil water retention curves (SWRC)
plot_pred_obs()
Plot predicted vs. observed water content
plot_swrc_metrics()
Plot model performance metric comparison
plot_training_history()
Plot training loss history

Texture

USDA texture classification and triangle

classify_texture()
Classify soil texture according to the USDA system
add_texture()
Add texture classification column to a data frame
texture_triangle()
Plot a USDA soil texture triangle (ternary diagram)

Save / Load

Persist and reload trained models

save_swrc_model()
Save a fitted SWRC model to disk
load_swrc_model()
Load a previously saved SWRC model from disk
swrc_model_exists()
Check whether a model directory contains a valid saved model

Internal helpers

Scaling, physics, utilities

fit_minmax()
Fit a min-max scaler from a training data frame
apply_minmax()
Apply a fitted min-max scaler to a data frame
invert_minmax()
Invert a min-max scaling transformation
pf_from_head()
Convert matric head (cm) to pF
head_from_pf()
Convert pF to matric head (cm)
pf_normalize()
Normalise pF values to [0, 1]
head_normalize()
Normalise matric head (cm) to the pF domain
parse_depth()
Parse a soil depth string into midpoint and label
parse_depth_column()
Parse depth column in a data frame
fix_bd_units()
Detect and correct bulk-density units
theta_unit_factor()
Detect theta unit scale factor
compute_physics_loss()
Compute the physics-informed residual loss (Norouzi et al. 2025)
residual_to_tensors()
Convert residual point sets to TensorFlow tensors
make_obs_matrices()
Build observation matrices for the CNN1D model
make_profile_array()
Build a sequence array for one or more soil profiles
make_train_step()
Create an eager-mode train step function
safe_grad()
Safely compute a TensorFlow gradient
data_prep
Data preparation for CNN1D SWRC modelling
io
Save and load fitted SWRC models
metrics
Performance metrics for SWRC models
model
CNN1D monotone-integral model architecture
physics
Physics-informed constraints for SWRC modelling
plots
Publication-quality plots for SWRC analysis
predict
Prediction from fitted SWRC models
scale
Min-max feature scaling
texture
USDA soil texture classification
train
Training the CNN1D SWRC model
utils
Utility functions for soilFlux

Data

Example datasets

swrc_example
Example soil water retention dataset