R Under development (unstable) (2024-05-04 r86521 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## This is my way of doing this now > require(apsimx) Loading required package: apsimx APSIM(X) not found. If APSIM(X) is installed in an alternative location, set paths manually using 'apsimx_options' or 'apsim_options'. You can still try as the package will look into the registry (under Windows) > apsimx_options(warn.versions = FALSE) > > extd.dir <- system.file("extdata", package = "apsimx") > > run.test.edit.apsimx.batch <- get(".run.local.tests", envir = apsimx.options) > > tmp.dir <- tempdir() > > if(run.test.edit.apsimx.batch){ + + file.copy(paste0(extd.dir, "/", "Wheat.apsimx"), tmp.dir) + + inspect_apsimx("Wheat.apsimx", src.dir = tmp.dir, node = "SurfaceOrganicMatter") + + edit1time <- system.time(edit_apsimx("Wheat.apsimx", src.dir = tmp.dir, + wrt.dir = tmp.dir, + node = "SurfaceOrganicMatter", + parm = "InitialResidueMass", value = 600)) + + inspect_apsimx("Wheat-edited.apsimx", src.dir = tmp.dir, node = "SurfaceOrganicMatter") + + ## Using the 'batch' method + ## Let's say I want to edit 'SurfaceOrganicMatter' + ## InitialResidueMass from 500 to 650 + ## Understanding the structure of JSON files + parms <- list(".Simulations.Simulation.Field.SurfaceOrganicMatter.InitialResidueMass" = 650) + edit2time <- system.time(edit_apsimx_batch("Wheat.apsimx", src.dir = tmp.dir, parms = parms)) + inspect_apsimx("Wheat.apsimx", src.dir = tmp.dir, node = "SurfaceOrganicMatter") + + ## What is the difference in 'elapsed' real time? + edit2time[[3]]/edit1time[[3]] + } > > proc.time() user system elapsed 0.64 0.18 0.76