View source: R/model_testing.R
| update_stored_model_results | R Documentation |
BioCro models can be tested using test cases, which are sets of known outputs
that correspond to particular inputs. The update_stored_model_results
function stores the model outputs so they can be used for testing.
Note that model tests are distinct from the module tests
described in module_testing.
update_stored_model_results(mtc)
mtc |
A single module test case, which should be created using
|
The update_stored_model_results function is a key part of the BioCro
model testing system. See model_testing for more information.
This function will run the model with the supplied drivers and store the results in an appropriately-named CSV file in the specified directory.
To save space, the values in the result will be rounded using
signif, where the number of digits is specified in the module
test case. Also, only every Nth row will be retained, where N is the value of
row_interval specified in the module test case.
The saved result created by this function will be retrieved by
run_model_test_cases when checking the test case.
This function has no return value.
model_testing
model_test_case
run_model_test_cases
compare_model_output
# Define a test case for the miscanthus model and save the model output to a
# temporary directory
miscanthus_test_case <- model_test_case(
'miscanthus_x_giganteus',
miscanthus_x_giganteus,
get_growing_season_climate(weather$'2005'),
TRUE,
tempdir(),
'soil_evaporation_rate'
)
update_stored_model_results(miscanthus_test_case)
# The output file's name will be based on the test case description
fpath <- file.path(tempdir(), 'miscanthus_x_giganteus_simulation.csv')
# Check that the output file exists and then load it
if (file.exists(fpath)) {
saved_result <- read.csv(fpath)
str(saved_result)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.