Skip to content

Commit

Permalink
update test script for previous results
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Schmidt-Walter committed Sep 6, 2024
1 parent d1f05de commit 9abcb12
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
Binary file modified tests_compare_actual_vs_previous/simresults.rds
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
# Manual test comparing the simulation results of the actual version vs a previous reference,
# to check if some unwanted changes have been made
# it will work savely only, if actual and previous results were created on the same machine.
# machine: oflks593
# ref-version: v0.5.3

library(LWFBrook90R)
library(data.table)

# Set up the input data
data("slb1_soil")
data("slb1_meteo")
res_previous <- readRDS("tests_compare_actual_vs_previous/simresults.rds")
meteo <- readRDS("tests_compare_actual_vs_previous/meteo.rds")
input <- res_previous$model_input
setDT(meteo)

# create model input
opts <- set_optionsLWFB90(startdate = as.Date("2002-01-01"), enddate = as.Date("2003-12-31"))
parms <- set_paramLWFB90()
soil <- cbind(slb1_soil, hydpar_wessolek_tab(texture = slb1_soil$texture))
setDT(slb1_meteo)
meteo <- slb1_meteo[which(dates >= opts$startdate
& dates <= opts$enddate),]
input$param_b90$water_table_depth <- -9999 # new input-parameters
input$param_b90$snowlqini <- 0
input$param_b90$snowccini <- 0

res_actual <- run_LWFB90(options_b90 = opts, param_b90 = parms, climate = meteo, soil =soil)
res_actual <- run_LWFB90(options_b90 = input$options_b90,
param_b90 = input$param_b90,
climate = meteo)

meteo <- readRDS("tests_compare_actual_vs_previous/meteo.rds")
res_previous <- readRDS("tests_compare_actual_vs_previous/simresults.rds")
res_previous$layer_output <- res_previous$layer_output[order(nl, yr, doy)]

test_that("sim-outputs of actual are equal to previous", {
expect_equal(res_actual$output, res_previous$output)
expect_equal(res_actual$layer_output, res_previous$layer_output)
expect_equal(res_actual$output[,-which(names(res_actual$output) %in% c("snowlq", "cc")), with = F], res_previous$output)
expect_equal(res_actual$layer_output[,-which(names(res_actual$layer_output) %in% c("relawati")), with = F], res_previous$layer_output)
})


test_that("sim-inputs of actual are equal to previous", {
expect_equal(res_actual$model_input$param_b90, res_previous$model_input$param_b90)
expect_equal(res_actual$model_input$standprop_daily, res_previous$model_input$standprop_daily)
Expand Down

0 comments on commit 9abcb12

Please sign in to comment.