
Apply a fitted ERA5 met bias correction to a full record
Source:R/apply_met_bias_correction.R
apply_met_bias_correction.RdTakes the object from fit_met_bias_correction() and applies it to any
ERA5 met frame from extract_era5_hourly_met() /
extract_era5_lake_met() - typically the full record, not just the
training window. Each corrected variable is clamped back to physical
bounds. Optionally the corrected primaries are expanded so the
dependent variables (dew point, vapour pressure, cloud cover, longwave,
u/v wind, station pressure) are regenerated consistently with
expand_met().
Usage
apply_met_bias_correction(
era5,
bc,
vars = NULL,
clamp = TRUE,
swr_ceiling = 1361,
expand = FALSE,
lat = NULL,
lon = NULL,
elev = NULL,
tz = NULL,
verbose = TRUE
)Arguments
- era5
data frame with
Date+MET_*columns.- bc
a
met_biascorrobject fromfit_met_bias_correction().- vars
subset of
names(bc$models)to apply; default all.- clamp
clamp to physical bounds after correcting (default
TRUE):MET_pprain/MET_ppsnow/MET_radswd/MET_radlwd/MET_wndspd>= 0,MET_humrelwithin 0 to 100,MET_radswd<=swr_ceiling.- swr_ceiling
hard upper bound for corrected
MET_radswd(W/m2). Default 1361 (solar constant); pass a clear-sky series (same length asera5) for a tighter, time-varying cap.- expand
if
TRUE, keepDate+ corrected primaries and callexpand_met()to rebuild the full set. Needslat/lon/elev(taken fromattr(era5, "lat")/"lon"whenNULL).- lat, lon, elev
lake position for
expand.- tz
timezone for the solar geometry in
expand_met(); defaults to thetzattribute ofera5, else"UTC".- verbose
report which variables were corrected.
Value
era5 with corrected columns (same class/attributes), plus
attr(., "biascorr") recording the training window and methods. When
expand = TRUE, the expand_met() output frame.