# \donttest{
# Load example watershed data
data("example_watershed")
# Set crop factor
example_watershed$crop_factor <- NA
example_watershed$crop_factor[example_watershed$land_cover_type=="agriculture"] <- 0.75
# Set request for daily model results in cells number 3, 6 (outlet) and 9
example_watershed$result_cell <- FALSE
example_watershed$result_cell[c(3,6,9)] <- TRUE
# Get bounding box to determine limits
b <- sf::st_bbox(example_watershed)
b
# Define a raster topology, using terra package,
# with the same CRS as the watershed. In this example cells have 100 m side.
# Coordinates in the 'sf' object are assumed to be cell centers
r <-terra::rast(xmin = 401380, ymin = 4671820, xmax = 402880, ymax = 4672620,
nrow = 8, ncol = 15, crs = "epsg:32631")
# Load example meteo data frame from package meteoland
data("examplemeteo")
# Load default medfate parameters
data("SpParamsMED")
# Set simulation period
dates <- seq(as.Date("2001-01-01"), as.Date("2001-03-31"), by="day")
# Watershed control parameters (TETIS model; Frances et al. 2007)
ws_control <- default_watershed_control("tetis")
# Launch simulations
res <- spwb_land(r, example_watershed, SpParamsMED, examplemeteo,
dates = dates, summary_frequency = "month",
watershed_control = ws_control)
# Print a summary of water balance components
summary(res)
# Option 'reduce_to_dominant = TRUE' in initialization, may be useful to speed up calculations
example_simplified <- initialize_landscape(example_watershed, SpParams = SpParamsMED,
local_control = defaultControl(soilDomains = "single"),
reduce_to_dominant = TRUE)
# Launch simulations over simplified landscape (should be considerably faster)
res_simplified <- spwb_land(r, example_simplified, SpParamsMED, examplemeteo,
dates = dates, summary_frequency = "month",
watershed_control = ws_control)
# }
Run the code above in your browser using DataLab