edit_apsim_replace_soil_profile: Edit APSIM 'Classic' file with a replaced soil profile

View source: R/edit_apsim_replace_soil_profile.R

edit_apsim_replace_soil_profileR Documentation

Edit APSIM ‘Classic’ file with a replaced soil profile

Description

Edits an APSIM Classic simulation by replacing the soil profile

Usage

edit_apsim_replace_soil_profile(
  file = "",
  src.dir = ".",
  wrt.dir = NULL,
  soil.profile = NULL,
  swim = NULL,
  soilwat = NULL,
  initialwater = NULL,
  edit.tag = "-edited",
  overwrite = FALSE,
  verbose = TRUE,
  root
)

Arguments

file

name of the .apsim file to be edited

src.dir

source directory

wrt.dir

writing directory

soil.profile

a soil profile object with class ‘soil_profile’

swim

list with SWIM specific parameters

soilwat

list with SoilWat specific parameters

initialwater

list with InitialWater specific parameters

edit.tag

default edit tag ‘-edited’

overwrite

default FALSE

verbose

default TRUE. Will print messages indicating what was done.

root

supply the node postion in the case of multiple simulations such as factorials.

Details

This function is designed to batch replace the whole soil in an APSIM simulation.

Value

writes an APSIM file to disk with the supplied soil profile

Note

There is no such thing as a default soil, carefully build the profile for each simulation. This function replaces values and it can grow an XML node, but it cannot edit a property which is not present in the original file.

Examples


sp <- apsimx_soil_profile(nlayers = 20,
                          crops = c("Barley", "Chickpea", "Lucerne", 
                          "Maize", "Perennial Grass", "Sorghum", 
                          "Wheat", "Millet"))

extd.dir <- system.file("extdata", package = "apsimx")

## Writing to a temp directory
tmp.dir <- tempdir()
edit_apsim_replace_soil_profile("Millet.apsim", soil.profile = sp, 
                                edit.tag = "-newsoil",
                                src.dir = extd.dir, 
                                wrt.dir = tmp.dir)
                                
inspect_apsim("Millet-newsoil.apsim", src.dir = tmp.dir,
              node = "Soil", soil.child = "Water")
 


apsimx documentation built on Sept. 11, 2024, 5:42 p.m.