R/physical_constraints.R
apply_physical_constraints.RdEnforces physically realistic bounds and relationships across simulated climate variables.
apply_physical_constraints(climate_data, verbose = TRUE, tolerance = 0)A dataframe generated from
simulate_climate() or related simulation functions.
Logical. If TRUE, prints correction summaries. Default is TRUE.
Numeric tolerance used when comparing floating-point values. Default is 0.
A corrected climate dataframe with physically realistic values enforced.
This function is designed as a quality-control layer for synthetic climate simulations and ensures that impossible atmospheric or hydrological states are removed.
The function automatically checks and corrects:
Tmin <= Tmax
Avg.Temp lies between Tmin and Tmax
Relative humidity remains within 0–100%
Dew point does not exceed air temperature
Rainfall and rain days remain non-negative
Wind speed remains non-negative
Solar radiation remains non-negative
Evapotranspiration remains non-negative
Vapor pressure deficit remains non-negative
Sunshine fraction remains within 0–1
Cloud factor remains within 0–1
stations <- create_stations(n = 3)
#> Generating synthetic station network...
#> Generated 3 synthetic stations within bounding box.
#> Deriving climate-aware station attributes...
time_index <- generate_time_index(
start_date = "2010-01-01",
end_date = "2012-12-31"
)
#> Generated 1096 time steps at daily resolution.
climate <- simulate_climate(
stations = stations,
time_index = time_index
)
#> Temperature simulation complete for 3 stations.
#> Rainfall simulation complete for 3 stations.
#> Relative humidity simulation complete for 3 stations.
#> Dew point simulation complete for 3 stations.
#> Wind speed simulation complete for 3 stations.
#> Wind direction simulation complete for 3 stations.
#> Solar radiation simulation complete for 3 stations.
#> Evapotranspiration simulation complete for 3 stations.
#> Integrated climate simulation complete for 3 stations.
climate <- apply_physical_constraints(climate)
#> Physical constraints applied. 0 corrections made.