Updated stored result for a BioCro model test case
update_stored_model_results.Rd
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
.
Arguments
- mtc
A single module test case, which should be created using
model_test_case
.
Details
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.
Examples
# 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)
}
#> 'data.frame': 179 obs. of 72 variables:
#> $ Grain : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ GrossAssim : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ GrossAssim_CO2 : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ Leaf : num 0.0007 0.0471 0.0992 0.1539 0.21 ...
#> $ LeafLitter : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ LeafWS : num 1 0.925 0.867 0.794 0.708 ...
#> $ Rhizome : num 7 6.87 6.74 6.61 6.48 ...
#> $ RhizomeLitter : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Root : num 0.007 0.0492 0.0972 0.1487 0.2031 ...
#> $ RootLitter : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Shell : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Sp : num 1.7 1.7 1.7 1.7 1.7 1.7 1.7 1.7 1.7 1.7 ...
#> $ Stem : num 0.007 0.0591 0.1187 0.1828 0.2509 ...
#> $ StemLitter : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ StomataWS : num 1 0.979 0.962 0.939 0.91 ...
#> $ TTc : num 0 7.42 18.75 33.16 50.71 ...
#> $ absorbed_longwave : num 326 347 357 367 401 ...
#> $ alpha : num 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 ...
#> $ canopy_assimilation_rate : num -2.03e-07 -1.76e-05 -4.37e-05 -7.78e-05 -1.66e-04 ...
#> $ canopy_assimilation_rate_CO2 : num -0.000187 -0.016324 -0.04044 -0.072003 -0.15349 ...
#> $ canopy_conductance : num 9.52e-05 6.28e-03 1.30e-02 1.97e-02 2.60e-02 ...
#> $ canopy_height : num 0.000895 0.060225 0.12684 0.19676 0.26847 ...
#> $ canopy_photorespiration_rate : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ canopy_photorespiration_rate_CO2: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ canopy_transpiration_rate : num 0.000089 0.016389 0.040782 0.063025 0.12527 ...
#> $ cosine_zenith_angle : num -0.562 -0.558 -0.554 -0.55 -0.546 ...
#> $ cws1 : num 0.32 0.31 0.302 0.291 0.277 ...
#> $ cws2 : num 0.32 0.32 0.32 0.32 0.32 0.32 0.32 0.32 0.32 0.32 ...
#> $ doy : int 123 124 125 126 127 128 129 130 131 132 ...
#> $ fractional_doy : int 123 124 125 126 127 128 129 130 131 132 ...
#> $ gbw_canopy : num 0.005 0.005 0.0133 0.0162 0.0266 ...
#> $ gmst : num 20.7 20.8 20.9 20.9 21 ...
#> $ hour : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ julian_date : int 2453500 2453500 2453500 2453500 2453500 2453500 2453500 2453500 2453500 2453500 ...
#> $ kGrain : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ kLeaf : num 0.33 0.33 0.33 0.33 0.33 0.33 0.33 0.33 0.33 0.33 ...
#> $ kRhizome : num -8e-04 -8e-04 -8e-04 -8e-04 -8e-04 -8e-04 -8e-04 -8e-04 -8e-04 -8e-04 ...
#> $ kRoot : num 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 ...
#> $ kStem : num 0.37 0.37 0.37 0.37 0.37 0.37 0.37 0.37 0.37 0.37 ...
#> $ lai : num 0.00119 0.0801 0.1687 0.26169 0.35707 ...
#> $ leaf_senescence_index : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ lha : num 183 183 183 183 183 ...
#> $ lmst : num 14.9 14.9 15 15.1 15.1 ...
#> $ ncalls : int 4296 4296 4296 4296 4296 4296 4296 4296 4296 4296 ...
#> $ net_assimilation_rate_grain : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ net_assimilation_rate_leaf : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ net_assimilation_rate_rhizome : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ net_assimilation_rate_root : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ net_assimilation_rate_stem : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ precip : num 0 0 0 0 0 0 0 0 0 0.0106 ...
#> $ rh : num 0.68 0.34 0.44 0.51 0.54 0.59 0.62 0.84 0.7 0.94 ...
#> $ rhizome_senescence_index : int 0 24 48 72 96 120 144 168 192 216 ...
#> $ root_senescence_index : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ soil_evaporation_rate : num 7.1 6.45 9.86 10.32 14.84 ...
#> $ soil_water_content : num 0.32 0.318 0.315 0.313 0.309 ...
#> $ solar : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ solar_L : num 41.2 42.2 43.2 44.2 45.2 ...
#> $ solar_azimuth_angle : num 363 363 363 363 363 ...
#> $ solar_dec : num 15.7 16 16.3 16.6 16.9 ...
#> $ solar_ell : num 42.9 43.9 44.9 45.8 46.8 ...
#> $ solar_ep : num 23.4 23.4 23.4 23.4 23.4 ...
#> $ solar_g : num 118 119 120 121 122 ...
#> $ solar_ra : num 40.5 41.4 42.4 43.4 44.3 ...
#> $ solar_zenith_angle : num 124 124 124 123 123 ...
#> $ stem_senescence_index : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ temp : num 2.12 6.52 8.53 10.4 16.8 16.8 18.1 16.7 20.5 10.7 ...
#> $ time : int 2928 2952 2976 3000 3024 3048 3072 3096 3120 3144 ...
#> $ time_zone_offset : int -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 ...
#> $ vmax : int 39 39 39 39 39 39 39 39 39 39 ...
#> $ windspeed : num 3.22 1.84 4.06 4.33 6.48 3.69 4.98 4.84 4.58 9.68 ...
#> $ year : int 2005 2005 2005 2005 2005 2005 2005 2005 2005 2005 ...
#> $ nrow : int 4296 4296 4296 4296 4296 4296 4296 4296 4296 4296 ...