A convenience wrapper that:
Renames columns to standard names.
Parses the depth column.
Fixes bulk-density units.
Detects and normalises volumetric water content units.
Computes per-profile maximum theta.
Drops rows with missing key variables.
Arguments
- df
A data frame with soil characterization data.
- x_cols
Named character vector mapping standard names to actual column names. Standard names:
"PEDON_ID","sand","silt","clay","soc","bd","matric_head","water_content","depth". Unneeded variables may be omitted.- depth_col
Column name for depth (character string, default
"depth"). If already parsed, set toNULL.- fix_bd
Logical; apply
fix_bd_units()to bulk density (defaultTRUE).- fix_theta
Logical; scale theta to m3/m3 if needed (default
TRUE).
Value
A tibble with standardised columns plus Depth_num,
Depth_label, bd_gcm3, theta_n (normalised WC), and
theta_max_n (per-profile maximum theta).
Examples
if (FALSE) { # \dontrun{
df <- data.frame(
ID = rep("P01", 3),
sand_pct = c(50, 50, 50),
silt = c(30, 30, 30),
clay = c(20, 20, 20),
soc = c(1.2, 1.2, 1.2),
bd_gcc = c(1.3, 1.3, 1.3),
matric_head = c(10, 100, 1000),
theta = c(0.40, 0.30, 0.20),
depth = c("0-30", "0-30", "0-30")
)
df_prep <- prepare_swrc_data(df,
x_cols = c(PEDON_ID = "ID", sand = "sand_pct", bd = "bd_gcc",
water_content = "theta"))
} # }
