Replace or set an input parameter from a pre-existing STICS input file.

set_param_txt(
  workspace,
  param,
  value,
  append = FALSE,
  plant_id = NULL,
  variety = NULL,
  layer = NULL,
  stics_version = "latest",
  dirpath = lifecycle::deprecated(),
  add = lifecycle::deprecated(),
  plant = lifecycle::deprecated()
)

set_usm_txt(
  file = "new_travail.usm",
  param,
  value,
  append = FALSE,
  filepath = lifecycle::deprecated(),
  add = lifecycle::deprecated()
)

set_station_txt(
  file = "station.txt",
  param,
  value,
  append = FALSE,
  filepath = lifecycle::deprecated(),
  add = lifecycle::deprecated()
)

set_ini_txt(
  file = "ficini.txt",
  param,
  value,
  append = FALSE,
  plant_id = 1,
  layer = NULL,
  stics_version = "latest",
  filepath = lifecycle::deprecated(),
  add = lifecycle::deprecated()
)

set_general_txt(
  file = "tempopar.sti",
  param,
  value,
  append = FALSE,
  filepath = lifecycle::deprecated(),
  add = lifecycle::deprecated()
)

set_tmp_txt(
  file = "tempoparv6.sti",
  param,
  value,
  append = FALSE,
  filepath = lifecycle::deprecated(),
  add = lifecycle::deprecated()
)

set_plant_txt(
  file = "ficplt1.txt",
  param,
  value,
  append = FALSE,
  variety = NULL,
  filepath = lifecycle::deprecated(),
  add = lifecycle::deprecated()
)

set_tec_txt(
  file = "fictec1.txt",
  param,
  value,
  append = FALSE,
  filepath = lifecycle::deprecated(),
  add = lifecycle::deprecated()
)

set_soil_txt(
  file = "param.sol",
  param,
  value,
  layer = NULL,
  stics_version = "latest",
  filepath = lifecycle::deprecated()
)

Arguments

workspace

Path of the workspace containing the STICS (txt) input files.

param

Vector of parameter names.

value

New parameter value

append

Boolean. Append input to existing file

plant_id

The plant identifier (main crop: 1 ; associated crop: 2). Only used for plant, technical or initialisation parameters.

variety

The plant variety to set the parameter value, either the variety name (codevar in the plant file) or the index (variete in the technical file).

layer

The soil layer if any (only concerns soil-related parameters)

stics_version

An optional version name as listed in get_stics_versions_compat() return

dirpath

[Deprecated] dirpath is no longer supported, use workspace instead.

add

[Deprecated] add is no longer supported, use append instead.

plant

[Deprecated] plant is no longer supported, use plant_id instead.

file

Path (including name) of the file to modify

filepath

[Deprecated] filepath is no longer supported, use file instead.

Value

None

Details

The plant parameter can be either equal to 1, 2 for the associated plant in the case of intercrop, or c(1,2) for both Principal and associated plants. get_var_info is a helper function that returns all possible output variables. If the variety is not given and if param is a varietal parameter, the function will modify the value of param for the simulated variety, as given in the technical file.

Note

gen_varmod is not used by set_param_txt. To replace the output variables required from STICS, please directly call gen_varmod.

Examples

# Getting example data path
path <- get_examples_path(file_type = "txt")


# Change the value of durvieF for the current variety:
set_param_txt(workspace = path, param = "durvieF", value = 245)
#> [[1]]
#> NULL
#> 

# Change the value of durvieF for another variety:
set_param_txt(workspace = path, param = "durvieF",
              variety = "Nefer", value = 178)
#>  Variety not found in plantfile. Possible varieties are: "DK250", "Pactol", "Cherif", "Furio", "Dunia", "Volga", "Cecilia", "DK604", "Nobilis-DE", "DK300", "Anjou285", "DK312", "DK240", "banguy", "magrite", and "clarica"
#> [[1]]
#> NULL
#> 

# If the parameter is found in several files, use the set_*
# functions directly, e.g. cailloux is found in the general file
# ("codecailloux") and the soil file. If we want to change its value
# in the soil file, we use set_soil_txt():
set_soil_txt(file = file.path(path, "param.sol"),
             param = "cailloux", layer = 2, value = 1)