Updated stored result for a BioCro model test case
update_stored_model_results.RdBioCro 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 83 variables:
#> $ Grain : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Grain_gr_rate : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Leaf : num 0.0007 0.0472 0.0996 0.1543 0.2102 ...
#> $ LeafLitter : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ LeafWS : num 1 0.925 0.867 0.794 0.708 ...
#> $ Leaf_WS_loss_rate : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Leaf_gr_rate : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Rhizome : num 7 6.87 6.74 6.61 6.48 ...
#> $ RhizomeLitter : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Rhizome_gr_rate : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Root : num 0.007 0.0493 0.0976 0.149 0.2033 ...
#> $ RootLitter : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Root_gr_rate : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Shell : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ Shell_gr_rate : 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.0592 0.1191 0.1833 0.2512 ...
#> $ StemLitter : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ Stem_gr_rate : int 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_molar_flux : num -0.000188 -0.01624 -0.040484 -0.071886 -0.15204 ...
#> $ canopy_assimilation_rate : num -2.03e-07 -1.76e-05 -4.38e-05 -7.77e-05 -1.64e-04 ...
#> $ canopy_conductance : num 9.52e-05 6.29e-03 1.30e-02 1.97e-02 2.60e-02 ...
#> $ canopy_gross_assimilation_molar_flux : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ canopy_gross_assimilation_rate : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ canopy_height : num 0.000895 0.060319 0.12729 0.19718 0.26864 ...
#> $ canopy_non_photorespiratory_CO2_release_molar_flux: num 0.000188 0.01624 0.040484 0.071886 0.15204 ...
#> $ canopy_non_photorespiratory_CO2_release_rate : num 2.03e-07 1.76e-05 4.38e-05 7.77e-05 1.64e-04 ...
#> $ canopy_photorespiration_molar_flux : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ canopy_photorespiration_rate : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ canopy_transpiration_rate : num 8.86e-05 1.58e-02 3.99e-02 6.14e-02 1.21e-01 ...
#> $ 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.0267 ...
#> $ 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.08023 0.1693 0.26225 0.35729 ...
#> $ 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 : num -6.71e-08 -5.79e-06 -1.44e-05 -2.56e-05 -5.42e-05 ...
#> $ net_assimilation_rate_rhizome : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ net_assimilation_rate_root : num -6.10e-08 -5.27e-06 -1.31e-05 -2.33e-05 -4.93e-05 ...
#> $ net_assimilation_rate_shell : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ net_assimilation_rate_stem : num -7.53e-08 -6.50e-06 -1.62e-05 -2.88e-05 -6.08e-05 ...
#> $ 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 ...
#> $ whole_plant_growth_respiration_molar_flux : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ whole_plant_growth_respiration_rate : int 0 0 0 0 0 0 0 0 0 0 ...
#> $ 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 ...