Title: | Read and Modify 'STICS' Input/Output Files |
---|---|
Description: | Manipulating input and output files of the 'STICS' crop model. Files are either 'JavaSTICS' XML files or text files used by the model 'fortran' executable. Most basic functionalities are reading or writing parameter names and values in both XML or text input files, and getting data from output files. Advanced functionalities include XML files generation from XML templates and/or spreadsheets, or text files generation from XML files by using 'xslt' transformation. |
Authors: | Patrice Lecharpentier [aut, cre] , Remi Vezy [aut] , Samuel Buis [aut] , Michel Giner [aut] , Timothee Flutre [ctb], Thomas Robine [ctb], Amine Barkaoui [ctb], Patrick Chabrier [ctb], Julie Constantin [rev], Dominique Ripoche [rev], Marie Launay [rev], Alain Mollier [rev], Christine Le Bas [rev], Joel Leonard [rev] |
Maintainer: | Patrice Lecharpentier <[email protected]> |
License: | LGPL (>= 3) |
Version: | 1.5.0 |
Built: | 2024-11-13 13:24:25 UTC |
Source: | https://github.com/sticsrpacks/sticsrfiles |
[
method for cropr_simulation
This method ensure keeping the cropr_simulation
attribute when subsetting a
cropr_simulation
list.
## S3 method for class 'cropr_simulation' x[...]
## S3 method for class 'cropr_simulation' x[...]
x |
A |
... |
An index |
A subset of a cropr_simulation
, keeping its attribute
path <- file.path(get_examples_path("sti"), "workspace1") sim <- SticsRFiles::get_sim(workspace = path) # sim returns a `cropr_simulation` list
path <- file.path(get_examples_path("sti"), "workspace1") sim <- SticsRFiles::get_sim(workspace = path) # sim returns a `cropr_simulation` list
Computes the date corresponding to a given day number (or vector of) with reference to a start year. Typically, the start year should be the year of a STICS simulation start, but not necessarily.
compute_date_from_day(day, start_year)
compute_date_from_day(day, start_year)
day |
day number(s) to be converted |
start_year |
year to be used as time reference (simulation start year). |
Date vector
Timothee Flutre
compute_date_from_day(day = 290, start_year = 1994) compute_date_from_day(day = 700, start_year = 1994)
compute_date_from_day(day = 290, start_year = 1994) compute_date_from_day(day = 700, start_year = 1994)
Computes the day number corresponding to a given date (or vector of) from the first day of a start year. Typically, the start year should be the year of a STICS simulation start. Leap years are properly handled.
compute_day_from_date( date, start_year = NULL, start_date = lifecycle::deprecated() )
compute_day_from_date( date, start_year = NULL, start_date = lifecycle::deprecated() )
date |
date(s) vector to be converted,
in the character format ("YYYY-MM-DD") or |
start_year |
year to be used as time reference (simulation start year). Optional. |
start_date |
numeric vector
Timothee Flutre
date <- as.Date("2015-02-10") compute_day_from_date(date = date) compute_day_from_date(date = "2015-02-10", start_year = 2014) date <- as.Date("2009-02-10") compute_day_from_date(date = date, start_year = 2008 ) dates <- c(as.Date("2008-02-10"), as.Date("2009-02-10")) compute_day_from_date(date = dates, start_year = 2008 )
date <- as.Date("2015-02-10") compute_day_from_date(date = date) compute_day_from_date(date = "2015-02-10", start_year = 2014) date <- as.Date("2009-02-10") compute_day_from_date(date = date, start_year = 2008 ) dates <- c(as.Date("2008-02-10"), as.Date("2009-02-10")) compute_day_from_date(date = dates, start_year = 2008 )
The input file according to his type (ini,plant,tec,station,soil,par) is converted to a text file readable by the STICS model (ficini.txt, ficplt1.txt,...)
convert_xml2txt( file, plant_id = 1, out_dir = NULL, save_as = NULL, stics_version = "latest", xml_file = lifecycle::deprecated(), plt_num = lifecycle::deprecated(), out_file = lifecycle::deprecated() )
convert_xml2txt( file, plant_id = 1, out_dir = NULL, save_as = NULL, stics_version = "latest", xml_file = lifecycle::deprecated(), plt_num = lifecycle::deprecated(), out_file = lifecycle::deprecated() )
file |
Path (including name) of the xml file to convert |
plant_id |
The plant identifier (main crop: 1 ; associated crop: 2) |
out_dir |
Path of the directory where to generate the file. Optional, set to the path of the input xml file by default |
save_as |
Name of the output file (optional, default: fixed name for STICS) |
stics_version |
the STICS files version to use (optional, default to latest). |
xml_file |
|
plt_num |
|
out_file |
None
## Not run: xml_path <- "/path/to/corn_plt.xml" javastics_path <- "/path/to/JavaSTICS/folder" convert_xml2txt(file = xml_path, javastics = javastics_path) ## End(Not run)
## Not run: xml_path <- "/path/to/corn_plt.xml" javastics_path <- "/path/to/JavaSTICS/folder" convert_xml2txt(file = xml_path, javastics = javastics_path) ## End(Not run)
Download locally the example data from the data repository in the SticsRPacks organisation.
download_data( out_dir = tempdir(), example_dirs = NULL, stics_version = "latest", dir = lifecycle::deprecated(), version_name = lifecycle::deprecated() )
download_data( out_dir = tempdir(), example_dirs = NULL, stics_version = "latest", dir = lifecycle::deprecated(), version_name = lifecycle::deprecated() )
out_dir |
Path of the directory where to download the data |
example_dirs |
List of use case directories names (optional) |
stics_version |
Name of the STICS version. Optional, by default the latest version returned by get_stics_versions_compat() is used. |
dir |
|
version_name |
The path to the folder where data have been downloaded
# Getting data for a given example : study_case_1 and a given STICS version download_data(example_dirs = "study_case_1", stics_version = "V9.0")
# Getting data for a given example : study_case_1 and a given STICS version download_data(example_dirs = "study_case_1", stics_version = "V9.0")
The file is an example that can be used for generating JavaSTICS
usms.xml input file from parameters values stored in a CSV file using
the function gen_usms_xml
download_usm_csv( file = NULL, out_dir = tempdir(), stics_version = "latest", overwrite = FALSE, verbose = FALSE, csv_name = lifecycle::deprecated(), version_name = lifecycle::deprecated(), dest_dir = lifecycle::deprecated() )
download_usm_csv( file = NULL, out_dir = tempdir(), stics_version = "latest", overwrite = FALSE, verbose = FALSE, csv_name = lifecycle::deprecated(), version_name = lifecycle::deprecated(), dest_dir = lifecycle::deprecated() )
A vector of copied files path.
download_usm_csv()
download_usm_csv()
The file is an example that can be used for generating
JavaSTICS input files from parameters values stored in Excel spreadsheet
format (USMs, Ini, Soils, Tec, Station, ...). Each sheet contains parameters
values to insert into XML files, with the help of these functions:
gen_usms_xml
, gen_sols_xml
,
gen_tec_xml
, gen_sta_xml
,
gen_usms_xml
, gen_ini_xml
download_usm_xl( file = NULL, out_dir = tempdir(), stics_version = "latest", overwrite = FALSE, verbose = FALSE, xl_name = lifecycle::deprecated(), version_name = lifecycle::deprecated(), dest_dir = lifecycle::deprecated(), ... )
download_usm_xl( file = NULL, out_dir = tempdir(), stics_version = "latest", overwrite = FALSE, verbose = FALSE, xl_name = lifecycle::deprecated(), version_name = lifecycle::deprecated(), dest_dir = lifecycle::deprecated(), ... )
A vector of copied files path.
download_usm_xl()
download_usm_xl()
Generates a param.sti file and sets code optim in
new_travail.usm to force parameters values in STICS simulations
(this function is typically called before SticsOnR::run_stics()
)
force_param_values( workspace, values, javastics, param_values = lifecycle::deprecated() )
force_param_values( workspace, values, javastics, param_values = lifecycle::deprecated() )
workspace |
Path of the workspace containing the STICS (txt) input files. |
values |
named vector of parameter values to force. See Details for more information. |
javastics |
Path of JavaSTICS |
param_values |
This function operates on STICS text input files.
Do not use it before calling gen_usms_xml2txt()
, otherwise
param.sti and new_travail.usm files will be overwritten.
This function has been created to be called before
SticsOnR::run_stics()
. It can not work with SticsOnR::run_javastics()
,
that will overwrite param.sti and new_travail.usm files.
values
can contain NA. In this case, the corresponding parameter(s)
will not be forced (default value(s), i.e. read in STICS input files,
will be used). If values==NA or values==NULL,
not any parameter will be forced (all default values used).
A logical status TRUE if successful, FALSE otherwise
SticsOnR::run_stics()
## Not run: example_txt_dir <- get_examples_path(file_type = "txt") force_param_values(example_txt_dir, setNames(object = c(220, 330), c("stlevamf", "stamflax")), javastics = "/path/to/javastics" ) ## End(Not run)
## Not run: example_txt_dir <- get_examples_path(file_type = "txt") force_param_values(example_txt_dir, setNames(object = c(220, 330), c("stlevamf", "stamflax")), javastics = "/path/to/javastics" ) ## End(Not run)
Generate STICS general parameters xml file(s) from a template file according to a STICS version
gen_general_param_xml(out_dir, stics_version = "latest", overwrite = FALSE)
gen_general_param_xml(out_dir, stics_version = "latest", overwrite = FALSE)
out_dir |
Path of the directory where to generate the file(s). |
stics_version |
Name of the STICS version. Optional, the latest one is used as default |
overwrite |
Optional logical, TRUE for overwriting files, FALSE otherwise (default) |
Please see get_stics_versions_compat()
for the full list of
STICS versions that can be used for the argument stics_version
.
None
gen_general_param_xml(out_dir = tempdir()) gen_general_param_xml(out_dir = tempdir(), stics_version = "V10.0", overwrite = TRUE)
gen_general_param_xml(out_dir = tempdir()) gen_general_param_xml(out_dir = tempdir(), stics_version = "V10.0", overwrite = TRUE)
Generate STICS ini xml file(s) from a template or an input file
gen_ini_xml( param_df, file = NULL, out_dir, crop_tag = "Crop", stics_version = "latest", ini_in_file = lifecycle::deprecated(), param_table = lifecycle::deprecated(), out_path = lifecycle::deprecated() )
gen_ini_xml( param_df, file = NULL, out_dir, crop_tag = "Crop", stics_version = "latest", ini_in_file = lifecycle::deprecated(), param_table = lifecycle::deprecated(), out_path = lifecycle::deprecated() )
param_df |
A table (df, tibble) containing the values of the parameters to use (see details) |
file |
Path of an ini xml file to be used as a template. Optional,
if not provided, the function will use a standard template depending on
the STICS version (see |
out_dir |
Path of the directory where to generate the file(s). |
crop_tag |
identifier for the crop parameters names related to the main crop, or the associated crop if any (example: Crop is used in the param_table example in the details section below) |
stics_version |
Name of the STICS version.
Optional, used if the |
ini_in_file |
|
param_table |
|
out_path |
Please see get_stics_versions_compat()
for the full list of
STICS versions that can be used for the
argument stics_version
.
param_df
is a data.frame
with the following format:
Ini_name | nbplantes | stade0_Crop1 | lai0_Crop1 | masec0_Crop1 |
USM_2017_T1_ini.xml | 1 | snu | 0 | 0 |
Vill09_ini.xml | 1 | snu | 0 | 0 |
Vill10_ini.xml | 1 | snu | 0 | 0 |
Vill11_ini.xml | 1 | snu | 0 | 0 |
Vill12_ini.xml | 1 | snu | 0 | 0 |
Vill13_ini.xml | 1 | snu | 0 | 0 |
Vill14_ini.xml | 1 | snu | 0 | 0 |
Standard_ini.xml | 1 | snu | 0 | 0 |
The first column gives the ini file name (to be generated), all following columns give the parameter value to put in the file, and each line denotes a separate ini file (for e.g. several USMs).
The first column name must contain the keyword ini or Ini or INI as a prefix to be detected (as shown in the table extract above).
If not given (the default, NULL
), the function returns the template as is.
None
library(readxl) xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") ini_param_df <- read_excel(xl_path, sheet = "Ini") gen_ini_xml( out_dir = tempdir(), param_df = ini_param_df[1:2,] )
library(readxl) xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") ini_param_df <- read_excel(xl_path, sheet = "Ini") gen_ini_xml( out_dir = tempdir(), param_df = ini_param_df[1:2,] )
Generating observation data files from a data.frame
gen_obs( df, out_dir, usms_list = NULL, obs_table = lifecycle::deprecated(), out_path = lifecycle::deprecated() )
gen_obs( df, out_dir, usms_list = NULL, obs_table = lifecycle::deprecated(), out_path = lifecycle::deprecated() )
df |
A data frame containing the values of the observations to use (see Details). |
out_dir |
Path of the directory where to generate the file(s). |
usms_list |
An optional list of usms names to be used for selecting which files to generate from the obs_table |
obs_table |
|
out_path |
df
is a data.frame
with the following format:
usm_name | ian | mo | jo | jul | densite | lai(n) | masec(n) | azomes |
USM_2017_T1_CI | 2017 | 9 | 6 | 249 | NA | NA | 0.31 | 27.07395 |
USM_2017_T1_CI | 2017 | 9 | 20 | 263 | NA | NA | 0.60 | 27.90000 |
USM_2018_T1 | 2017 | 10 | 20 | 293 | NA | 0.1 | NA | NA |
USM_2018_T1 | 2018 | 5 | 15 | 482 | NA | 1.2 | NA | NA |
usm_name
column contains usms names which are used as output .obs
files names
ian
, mo
, jo
and jul
are mandatory
(year, month, day and julian date)
Other columns one per variable contain observations values or NA
@seealso get_var_info
for getting variable right syntax or
searching a variable name.
A return logical status indicating if any error when writing files (FALSE), TRUE when no errors.
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") obs_df <- read_params_table(file = xl_path, sheet_name = "Obs") gen_obs(df = obs_df, out_dir = "/path/to/dest/dir")
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") obs_df <- read_params_table(file = xl_path, sheet_name = "Obs") gen_obs(df = obs_df, out_dir = "/path/to/dest/dir")
Generate STICS sols xml file from a template or an input file
gen_sols_xml( file, param_df, template = NULL, stics_version = "latest", sols_in_file = lifecycle::deprecated(), sols_param = lifecycle::deprecated(), sols_out_file = lifecycle::deprecated(), sols_nb = lifecycle::deprecated() )
gen_sols_xml( file, param_df, template = NULL, stics_version = "latest", sols_in_file = lifecycle::deprecated(), sols_param = lifecycle::deprecated(), sols_out_file = lifecycle::deprecated(), sols_nb = lifecycle::deprecated() )
Please see get_stics_versions_compat()
for the full list of
STICS versions that can be used for the argument stics_version
.
param_df
is a data.frame
with the following format:
Soil_name | argi | norg | calc | pH | albedo | q0 | epc_1 |
USM_T1 | 20.35000 | 0.100 | 0.52 | 8.23 | 0.22 | 9.630 | 30 |
LF1 | 17.00000 | 1.900 | 0.00 | 6.70 | 0.22 | 9.360 | 30 |
LF2 | 17.00000 | 1.800 | 0.00 | 6.70 | 0.22 | 9.360 | 30 |
LAP | 22.00000 | 2.000 | 0.00 | 6.50 | 0.22 | 9.760 | 25 |
LAS | 24.05000 | 2.500 | 30.00 | 8.00 | 0.22 | 9.928 | 30 |
LA0 | 30.00675 | 2.300 | 0.50 | 7.50 | 0.22 | 10.400 | 30 |
LC0 | 22.38750 | 2.000 | 10.00 | 7.90 | 0.22 | 9.792 | 25 |
Vill09 | 25.00000 | 0.101 | 0.40 | 7.90 | 0.22 | 10.000 | 30 |
Vill10 | 14.30000 | 0.099 | 1.50 | 8.20 | 0.22 | 9.144 | 30 |
Vill11 | 11.80000 | 0.100 | 0.00 | 7.30 | 0.22 | 8.944 | 30 |
Vill12 | 14.30000 | 0.091 | 0.60 | 8.30 | 0.22 | 9.144 | 30 |
Vill13 | 16.80000 | 0.088 | 0.20 | 7.80 | 0.22 | 9.344 | 30 |
Vill14 | 15.10000 | 0.095 | 1.30 | 7.90 | 0.22 | 9.208 | 30 |
The first column gives the soil name, all following columns give the parameter values to put in the sols.xml file for each soil row.
The first column name must contain the keyword Soil or soil or SOIL as a prefix to be detected (as shown in the table extract above).
If not given (the default, NULL
), the function returns the template as is.
None
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") sols_param_df <- read_params_table(file = xl_path, sheet_name = "Soils") gen_sols_xml(file = file.path(tempdir(), "sols.xml"), param_df = sols_param_df)
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") sols_param_df <- read_params_table(file = xl_path, sheet_name = "Soils") gen_sols_xml(file = file.path(tempdir(), "sols.xml"), param_df = sols_param_df)
Generate STICS sta xml file(s) from a template or an input file
gen_sta_xml( param_df, file = NULL, out_dir, stics_version = "latest", param_table = lifecycle::deprecated(), sta_in_file = lifecycle::deprecated(), out_path = lifecycle::deprecated() )
gen_sta_xml( param_df, file = NULL, out_dir, stics_version = "latest", param_table = lifecycle::deprecated(), sta_in_file = lifecycle::deprecated(), out_path = lifecycle::deprecated() )
param_df |
A table (df, tibble) containing the values of the parameters to use (see details) |
file |
Path of a sta xml file to be used as a template. Optional, if not provided, the function will use a standard template depending on the STICS version. |
out_dir |
Path of the directory where to generate the file(s). |
stics_version |
Name of the STICS version. Optional, used if
the |
param_table |
|
sta_in_file |
|
out_path |
Please see get_stics_versions_compat()
for the full list of
STICS versions that can be used for the argument stics_version
.
param_df
is a data.frame
with the following format:
Sta_name | zr | NH3ref | latitude | patm | aclim |
climatex_sta.xml | 2.5 | 0 | 49 | 1000 | 20 |
climatex2_sta.xml | 2.8 | 0 | 49 | 1000 | 20 |
climatex3_sta.xml | 2.2 | 0 | 49 | 1000 | 20 |
The first column gives the sta file name (to be generated), all following columns give the parameter value to put in the file, and each line denotes a separate sta file (for e.g. several USMs).
The first column name must contain the keyword sta or Sta or STA as a prefix to be detected (as shown in the table extract above).
If not given (the default, NULL
), the function returns the template as is.
None
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") sta_param_df <- read_params_table(file = xl_path, sheet_name = "Station") gen_sta_xml(out_dir = tempdir(), param_df = sta_param_df)
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") sta_param_df <- read_params_table(file = xl_path, sheet_name = "Station") gen_sta_xml(out_dir = tempdir(), param_df = sta_param_df)
Generate STICS tec xml file(s) from a template or an input file
gen_tec_xml( param_df = NULL, file = NULL, out_dir, stics_version = "latest", na_values = NA, param_table = lifecycle::deprecated(), tec_in_file = lifecycle::deprecated(), out_path = lifecycle::deprecated() )
gen_tec_xml( param_df = NULL, file = NULL, out_dir, stics_version = "latest", na_values = NA, param_table = lifecycle::deprecated(), tec_in_file = lifecycle::deprecated(), out_path = lifecycle::deprecated() )
param_df |
A table (df, tibble) containing the values of the parameters to use (see details) |
file |
Path of a tec xml file to be used as a template. Optional, if not provided, the function will use a standard template depending on the STICS version. |
out_dir |
Path of the directory where to generate the file(s). |
stics_version |
Name of the STICS version. Optional, used if
the |
na_values |
value to use as missing value in param_table (optional, default : NA) |
param_table |
|
tec_in_file |
|
out_path |
Please see get_stics_versions_compat()
for the full list of
STICS versions that can be used for the
argument stics_version
.
param_df
is a data.frame
with the following format:
Tec_name | julres_1 | coderes_1 |
USM_2017_T1_CI_tec.xml | NA | 1 |
BIN_CANPC_05_SEC_220-0-0_34K_CANPC05T3_Q_tec.xml | 110 | 1 |
BIN_AGT_04_IRR_220-0-0_33K_AGT04T2_Q_tec.xml | 73 | 1 |
AGA_ARB_13_IRR_220-0-0_37K_ARB13_C_tec.xml | 82 | 1 |
AGA_ARB_13_SEC_220-0-0_37K_ARB13_C_tec.xml | 82 | 1 |
FRA_ARB_11_SEC_220-0-0_38K_E_tec.xml | 70 | 1 |
MAG_ARB_09_SEC_220-0-0_38K_E_tec.xml | 81 | 1 |
MAG_ARV_12_IRR_220-0-0_36K_ARV12_C_tec.xml | 100 | 1 |
MAG_ARV_12_SEC_220-0-0_36K_ARV12_C_tec.xml | 100 | 1 |
FRA_ARB_12_SEC_220-0-0_31K_ARB12_C_tec.xml | 92 | 1 |
FRA_ARB_13_SEC_220-0-0_37K_ARB13_C_tec.xml | 82 | 1 |
The first column gives the tec file name (to be generated), all following columns give the parameter value to put in the file, and each line denotes a separate tec file (for e.g. several USMs).
The first column name must contain the keyword tec or Tec or TEC as a prefix to be detected (as shown in the table extract above).
If not given (the default, NULL
), the function returns the template as is.
None
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") tec_param_df <- read_params_table(file = xl_path, sheet_name = "Tec") gen_tec_xml(out_dir = tempdir(), param_df = tec_param_df[1:2, ])
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") tec_param_df <- read_params_table(file = xl_path, sheet_name = "Tec") gen_tec_xml(out_dir = tempdir(), param_df = tec_param_df[1:2, ])
Generate STICS usms xml file from a template or an input file
gen_usms_xml( file, param_df = NULL, template = NULL, stics_version = "latest", usms_out_file = lifecycle::deprecated(), usms_nb = lifecycle::deprecated(), usms_param = lifecycle::deprecated(), usms_in_file = lifecycle::deprecated() )
gen_usms_xml( file, param_df = NULL, template = NULL, stics_version = "latest", usms_out_file = lifecycle::deprecated(), usms_nb = lifecycle::deprecated(), usms_param = lifecycle::deprecated(), usms_in_file = lifecycle::deprecated() )
file |
Path (including name) of the usms file to generate. |
param_df |
A table (df, tibble) containing the values of the parameters to use (see details) |
template |
Path of an USM xml file to be used as a template. Optional, if not provided, the function will use a standard template depending on the STICS version. |
stics_version |
Name of the STICS version. Optional,
used if the |
usms_out_file |
|
usms_nb |
|
usms_param |
|
usms_in_file |
Please see get_stics_versions_compat()
for the full list of
STICS versions that can be used for the argument stics_version
.
param_df
is a data.frame
with the following format:
usm_name | datedebut | datefin | nomsol |
USM_2017_T1_CI | 199 | 263 | USM_T1 |
USM_2018_T1 | 264 | 570 | USM_T1 |
BIN_CANPC_05_SEC_220-0-0_34K_CANPC05T3_Q | 199 | 263 | LF1 |
BIN_AGT_04_IRR_220-0-0_33K_AGT04T2_Q | 264 | 570 | LF1 |
AGA_ARB_13_IRR_220-0-0_37K_ARB13_C | 199 | 263 | F1 |
AGA_ARB_13_SEC_220-0-0_37K_ARB13_C | 264 | 570 | LF1 |
FRA_ARB_11_SEC_220-0-0_38K_E | 199 | 263 | LF1 |
MAG_ARB_09_SEC_220-0-0_38K_E | 264 | 570 | LF1 |
MAG_ARV_12_IRR_220-0-0_36K_ARV12_C | 199 | 263 | LF1 |
MAG_ARV_12_SEC_220-0-0_36K_ARV12_C | 264 | 570 | LF1 |
FRA_ARB_12_SEC_220-0-0_31K_ARB12_C | 199 | 263 | LF1 |
FRA_ARB_13_SEC_220-0-0_37K_ARB13_C | 264 | 570 | LF1 |
The first column gives the usm name, all following columns give the parameter values to put in the usms.xml file for each usm row.
The first column name must contain the keyword Usm or usm or USM as a prefix to be detected (as shown in the table extract above).
If not given (the default, NULL
), the function returns the template as is.
an invisible xml_document object
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") usms_param_df <- read_params_table(file = xl_path, sheet_name = "USMs") gen_usms_xml(file = file.path(tempdir(), "usms.xml"), param_df = usms_param_df)
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx") usms_param_df <- read_params_table(file = xl_path, sheet_name = "USMs") gen_usms_xml(file = file.path(tempdir(), "usms.xml"), param_df = usms_param_df)
The function creates sets of input files for one or multiple
usms from usms data stored in a JavaSTICS workspace. For multiple usms,
sets will be generated into individual folders named with usm names.
Observations files will be also copied if they are named [usm_name].obs
For one usm, files will be generated either in the workspace directory
or in a subdirectory.
gen_usms_xml2txt( javastics = NULL, workspace = NULL, out_dir = NULL, usm = c(), stics_version = "latest", verbose = TRUE, dir_per_usm_flag = TRUE, java_cmd = "java", java_converter = FALSE, javastics_path = lifecycle::deprecated(), workspace_path = lifecycle::deprecated(), target_path = lifecycle::deprecated(), usms_list = lifecycle::deprecated() )
gen_usms_xml2txt( javastics = NULL, workspace = NULL, out_dir = NULL, usm = c(), stics_version = "latest", verbose = TRUE, dir_per_usm_flag = TRUE, java_cmd = "java", java_converter = FALSE, javastics_path = lifecycle::deprecated(), workspace_path = lifecycle::deprecated(), target_path = lifecycle::deprecated(), usms_list = lifecycle::deprecated() )
A list with named elements: usms_path : created directories paths (for storing STICS input files), files : generated files list (in JavaSTICS workspace origin), copy_status : logical value vector, indicating if all files have been generated for each usm obs_copy_status : logical value vector, indicating if observation files have been successfully copied in usms directories
## Not run: javastics <- "/path/to/JavaSTICS/folder" workspace <- "/path/to/workspace" # For all usms gen_usms_xml2txt(javastics, workspace) # For an usms list usm <- c("usm1", "usm2") gen_usms_xml2txt(javastics, workspace, usm) ## End(Not run)
## Not run: javastics <- "/path/to/JavaSTICS/folder" workspace <- "/path/to/workspace" # For all usms gen_usms_xml2txt(javastics, workspace) # For an usms list usm <- c("usm1", "usm2") gen_usms_xml2txt(javastics, workspace, usm) ## End(Not run)
Generating a daily variable list file from variables names
gen_varmod( workspace, var, append = FALSE, file_name = "var.mod", stics_version = "latest", force = FALSE, var_names = lifecycle::deprecated(), version = lifecycle::deprecated() )
gen_varmod( workspace, var, append = FALSE, file_name = "var.mod", stics_version = "latest", force = FALSE, var_names = lifecycle::deprecated(), version = lifecycle::deprecated() )
workspace |
Path of the directory containing the STICS var.mod file to modify |
var |
vector of variables names (see details) |
append |
if TRUE, |
file_name |
file name to generate (without path, default value: "var.mod") |
stics_version |
Name of the STICS version (used to check variable names) |
force |
Force variables writing even if they are not a STICS variable (default: FALSE). |
var_names |
|
version |
Variable names can be found using get_var_info()
. They are
checked before writing. If any variable name does not exist,
it will not be written by default, but the function will still write
the variables that exist. force= TRUE
may however be used to write
variables that do not exist.
None
gen_varmod(tempdir(), c("lai(n)", "hauteur")) # Add a variable to the others: gen_varmod(tempdir(), "masec(n)", append = TRUE) # NB: var.mod will have "lai(n)","hauteur" and "masec(n)"
gen_varmod(tempdir(), c("lai(n)", "hauteur")) # Add a variable to the others: gen_varmod(tempdir(), "masec(n)", append = TRUE) # NB: var.mod will have "lai(n)","hauteur" and "masec(n)"
Read the meteorology input for STICS ("climat.txt")
get_climate_txt( workspace, file_name = "climat.txt", preserve = TRUE, dirpath = lifecycle::deprecated(), filename = lifecycle::deprecated() )
get_climate_txt( workspace, file_name = "climat.txt", preserve = TRUE, dirpath = lifecycle::deprecated(), filename = lifecycle::deprecated() )
workspace |
Path of the workspace containing the STICS climate file to read |
file_name |
The meteorology file name (default to |
preserve |
Logical, |
dirpath |
|
filename |
A data.frame of the input meteorological variables used as input for the STICS model.
The time-related variables are summarised into one POSIXct column named
date
.
path <- get_examples_path(file_type = "txt") Meteo <- get_climate_txt(path)
path <- get_examples_path(file_type = "txt") Meteo <- get_climate_txt(path)
Extracts the cultivar names from a plant file
get_cultivars_list(file)
get_cultivars_list(file)
file |
The path of a plant file. |
A vector of cultivar names
path <- get_examples_path(file_type = "xml") # Read from a plant file (all cultivars available in a plant file) cv_list <- get_cultivars_list(file = file.path(path, "file_plt.xml"))
path <- get_examples_path(file_type = "xml") # Read from a plant file (all cultivars available in a plant file) cv_list <- get_cultivars_list(file = file.path(path, "file_plt.xml"))
Extracts the values of cultivar-specific parameters from a plant file
get_cultivars_param(file)
get_cultivars_param(file)
file |
The path of a plant file. |
A data.frame with one row per cultivar and one column per parameter
path <- get_examples_path(file_type = "xml") # Read from a plant file (all cultivars available in a plant file) cv_param_df <- get_cultivars_param(file = file.path(path, "file_plt.xml"))
path <- get_examples_path(file_type = "xml") # Read from a plant file (all cultivars available in a plant file) cv_param_df <- get_cultivars_param(file = file.path(path, "file_plt.xml"))
Getting examples files path attached to a STICS version for a given file type
get_examples_path( file_type, stics_version = "latest", overwrite = FALSE, version_name = lifecycle::deprecated() )
get_examples_path( file_type, stics_version = "latest", overwrite = FALSE, version_name = lifecycle::deprecated() )
A directory path for examples files for given file type and STICS version or a vector of (for unknown file types "" is returned as path)
get_examples_path(file_type = "csv") get_examples_path(file_type = c("csv", "sti")) get_examples_path(file_type = "csv", stics_version = "V8.5")
get_examples_path(file_type = "csv") get_examples_path(file_type = c("csv", "sti")) get_examples_path(file_type = "csv", stics_version = "V8.5")
Is LAI forced for usms in usms.xml
get_lai_forcing(usm_file_path, usms_list = c())
get_lai_forcing(usm_file_path, usms_list = c())
usm_file_path |
Path to usms.xml file |
usms_list |
Usm(s) name(s) (optional, see details) |
Use get_usms_list()
to get the list of the usm names for an
usms.xml file.
A named numeric vector with a Boolean value (TRUE = forced
)
for each usm
# Xml case xml_usms <- file.path(get_examples_path(file_type = "xml"), "usms.xml") get_lai_forcing(xml_usms) get_lai_forcing(xml_usms, "wheat") get_lai_forcing(xml_usms, c("wheat", "intercrop_pea_barley"))
# Xml case xml_usms <- file.path(get_examples_path(file_type = "xml"), "usms.xml") get_lai_forcing(xml_usms) get_lai_forcing(xml_usms, "wheat") get_lai_forcing(xml_usms, c("wheat", "intercrop_pea_barley"))
Read STICS observation files from a JavaSTICS workspace and store data into a list per usm
get_obs( workspace, usm = NULL, var = NULL, dates = NULL, usms_file = NULL, javastics = NULL, verbose = TRUE, usm_name = lifecycle::deprecated(), var_list = lifecycle::deprecated(), dates_list = lifecycle::deprecated(), usms_filepath = lifecycle::deprecated(), javastics_path = lifecycle::deprecated() )
get_obs( workspace, usm = NULL, var = NULL, dates = NULL, usms_file = NULL, javastics = NULL, verbose = TRUE, usm_name = lifecycle::deprecated(), var_list = lifecycle::deprecated(), dates_list = lifecycle::deprecated(), usms_filepath = lifecycle::deprecated(), javastics_path = lifecycle::deprecated() )
The .obs
files names must match USMs names, e.g. for a usm
called "banana", the .obs
file should be named banana.obs
.
For intercrops, the name should be suffixed by "p" for the principal
and "a" for the associated plant.
If usm
is not specified (or equal to NULL
), the
function reads the files from all usms in the workspace
(s).
If usms_file
is provided and if the associated plant file is found,
the plant names in the "Plant" column of the generated data.frame
are either the plant code (as specified in the plant file) or
the name of the plant file, if the plant file is not found.
If usms_file
is not specified, the plants are named "plant_1"
by default (+ "plant_2" for intercrops).
A list, where each element is a data.frame
of observations
for the given usm. The list is named after the USM name.
Intercrops are returned in a single data.frame
, and are identified
using either the "Plant" or "Dominance" columns.
See Details section for more information about the "Plant" column.
path <- file.path(get_examples_path(file_type = "obs"), "mixed") # Get observations for all usms, but only banana has observations: Meas <- get_obs(path) # Get observations only for banana: Meas_banana <- get_obs(path, "banana") ## Not run: # Get observations with real plant names when plant # folder is not in the workspace: get_obs(path, "banana", javastics = "/path/to/JavaSTICS/folder") ## End(Not run)
path <- file.path(get_examples_path(file_type = "obs"), "mixed") # Get observations for all usms, but only banana has observations: Meas <- get_obs(path) # Get observations only for banana: Meas_banana <- get_obs(path, "banana") ## Not run: # Get observations with real plant names when plant # folder is not in the workspace: get_obs(path, "banana", javastics = "/path/to/JavaSTICS/folder") ## End(Not run)
Helper function that returns names and descriptions of STICS input parameters from a partial name and/or descriptive keywords.
get_param_info(param = NULL, keyword = NULL, stics_version = "latest")
get_param_info(param = NULL, keyword = NULL, stics_version = "latest")
param |
Vector of parameter names (or partial names). Optional, if not provided, the function returns information for all parameters |
keyword |
Optional, strings or a vector of to be used for searching in parameters names and definition |
stics_version |
Name of the STICS version. Optional, can be used
to search parameters information relative to a specific STICS version.
By default the latest version returned by |
The function understand regex
as input.
A data.frame with information about parameter(s) with columns
name
,file
,min
,max
, definition
# Find by parameter name (fuzzy search): SticsRFiles::get_param_info("alb") SticsRFiles::get_param_info("alb[e]?") # Find by keyword (fuzzy search in parameter name and description): SticsRFiles::get_param_info(keyword = "bdil") # Find for a particular version: SticsRFiles::get_param_info("alb", stics_version = "V9.0")
# Find by parameter name (fuzzy search): SticsRFiles::get_param_info("alb") SticsRFiles::get_param_info("alb[e]?") # Find by keyword (fuzzy search in parameter name and description): SticsRFiles::get_param_info(keyword = "bdil") # Find for a particular version: SticsRFiles::get_param_info("alb", stics_version = "V9.0")
Read STICS model input parameters from a usm in text format
(STICS input)
Generally used after calling building a usm with JavaSTICS
.
Read a specific STICS model input parameter file.
Users would generally use the wrapper get_param_txt()
instead.
get_param_txt( workspace, param = NULL, plant_id = NULL, variety = NULL, value_id = NULL, exact = FALSE, stics_version = "latest", dirpath = lifecycle::deprecated(), ... ) get_ini_txt( file = "ficini.txt", stics_version, filepath = lifecycle::deprecated() ) get_general_txt(file = "tempopar.sti", filepath = lifecycle::deprecated()) get_tmp_txt(file = "tempoparv6.sti", filepath = lifecycle::deprecated()) get_plant_txt( file = "ficplt1.txt", variety = NULL, filepath = lifecycle::deprecated() ) get_tec_txt( file = "fictec1.txt", stics_version = "latest", several_fert = NULL, several_thin = NULL, is_pasture = NULL, filepath = lifecycle::deprecated(), ... ) get_soil_txt( file = "param.sol", stics_version, filepath = lifecycle::deprecated() ) get_station_txt(file = "station.txt", filepath = lifecycle::deprecated()) get_usm_txt( file = "new_travail.usm", plant_id = NULL, filepath = lifecycle::deprecated() )
get_param_txt( workspace, param = NULL, plant_id = NULL, variety = NULL, value_id = NULL, exact = FALSE, stics_version = "latest", dirpath = lifecycle::deprecated(), ... ) get_ini_txt( file = "ficini.txt", stics_version, filepath = lifecycle::deprecated() ) get_general_txt(file = "tempopar.sti", filepath = lifecycle::deprecated()) get_tmp_txt(file = "tempoparv6.sti", filepath = lifecycle::deprecated()) get_plant_txt( file = "ficplt1.txt", variety = NULL, filepath = lifecycle::deprecated() ) get_tec_txt( file = "fictec1.txt", stics_version = "latest", several_fert = NULL, several_thin = NULL, is_pasture = NULL, filepath = lifecycle::deprecated(), ... ) get_soil_txt( file = "param.sol", stics_version, filepath = lifecycle::deprecated() ) get_station_txt(file = "station.txt", filepath = lifecycle::deprecated()) get_usm_txt( file = "new_travail.usm", plant_id = NULL, filepath = lifecycle::deprecated() )
workspace |
Path of the workspace containing the STICS (txt) input files. |
param |
Vector of parameter names. Optional, if not provided, the function returns an object with all parameters. |
plant_id |
plant index (1, 2), default(NULL) calculated from from plant number in STICS initialization file |
variety |
Integer. The plant variety to get the parameter from. |
value_id |
index of technical interventions to be used to retrieve parameter values, or layer index for soil parameters |
exact |
Boolean indicating if the function must return results only for exact match. |
stics_version |
An optional version name as listed in get_stics_versions_compat() return |
dirpath |
|
... |
Further arguments to pass (for future-proofing only) |
file |
File path |
filepath |
|
several_fert |
Is there several fertilization in the USM ? See details. |
several_thin |
Is there several thinning in the USM ? See details. |
is_pasture |
Is the plant a pasture ? See details. |
If the variety
is not given and a param
is asked,
the function will return the values for the variety that is simulated in
the USM by checking the variete
parameter in the technical file.
If param
is not provided by the user, the values from all varieties
will be returned unless the user ask for a given variety
.
several_fert
, several_thin
and is_pasture
are read from
the tmp file (tempoparv6.sti
). get_param_txt()
does it automatically.
If you absolutely need to use directly get_tec_txt
, please see example.
A list of parameters value(s),
or if param = NULL
a list of all parameters:
ini |
Initialization parameters |
general |
General parameters |
tec |
Technical parameters |
plant |
Plant parameters |
soil |
Soil parameters |
station |
Station parameters |
A list of parameters, depending on the file/function:
ini |
Initialization parameters |
general |
General parameters |
tec |
Technical parameters |
plant |
Plant parameters |
soil |
Soil parameters |
station |
Station parameters |
tmp |
Temporary parameters |
Users would generally use get_param_txt
to identify parameters
names and values and pass them to other functions.
The functions are compatible with intercrops. Users generally only use
get_param_txt()
, which is a wrapper for all these functions.
gen_varmod()
,
get_param_txt()
.
path <- get_examples_path(file_type = "txt") # Getting the interrow distance parameter value get_param_txt(path, param = "interrang") # Getting varietal parameters values # Get the leaf lifespan of the variety used in the usm: get_param_txt(workspace = path, param = "durvieF") # Get the leaf lifespan of another variety available in the plant file: get_param_txt(workspace = path, param = "durvieF", variety = "Furio") # To get the values for several (or all) varieties, either put all varieties: varieties <- c("Pactol", "Cherif", "Furio", "Dunia", "Volga", "Cecilia") get_param_txt(workspace = path, param = "durvieF", variety = varieties) # Or get it from the output of the function returning all parameters: get_param_txt(workspace = path)$plant$plant1$durvieF # Get parameters for a specific plant get_param_txt(workspace = path, plant_id = 1) get_param_txt(workspace = path, param = "durvieF", plant_id = 1) get_param_txt(workspace = path, param = "durvieF", plant_id = 1, variety = varieties) # Get parameters for specific interventions or soil layers get_param_txt(workspace = path, param = "amount", value_id = c(1,3)) get_param_txt(workspace = path, param = "Hinitf", value_id = c(1,3)) get_param_txt(workspace = path, param = "epc", value_id = c(1,3)) ## Not run: # Read the initialisation file (ficini.txt): library(SticsRFiles) path <- file.path(get_examples_path(file_type = "txt"), "ficini.txt") get_ini_txt(path) # Read the tec file directly: # First, get the parameters from the tmp file: tmp <- get_tmp_txt(file = file.path(get_examples_path(file_type = "txt"), "tempoparv6.sti")) several_fert <- ifelse(tmp$option_engrais_multiple == 1, TRUE, FALSE) several_thin <- ifelse(tmp$option_thinning == 1, TRUE, FALSE) is_pasture <- ifelse(tmp$option_pature == 1, TRUE, FALSE) # Then, get the technical parameters: get_tec_txt( file = file.path(get_examples_path(file_type = "txt"), "fictec1.txt"), several_fert = several_fert, several_thin = several_thin, is_pasture = is_pasture ) ## End(Not run)
path <- get_examples_path(file_type = "txt") # Getting the interrow distance parameter value get_param_txt(path, param = "interrang") # Getting varietal parameters values # Get the leaf lifespan of the variety used in the usm: get_param_txt(workspace = path, param = "durvieF") # Get the leaf lifespan of another variety available in the plant file: get_param_txt(workspace = path, param = "durvieF", variety = "Furio") # To get the values for several (or all) varieties, either put all varieties: varieties <- c("Pactol", "Cherif", "Furio", "Dunia", "Volga", "Cecilia") get_param_txt(workspace = path, param = "durvieF", variety = varieties) # Or get it from the output of the function returning all parameters: get_param_txt(workspace = path)$plant$plant1$durvieF # Get parameters for a specific plant get_param_txt(workspace = path, plant_id = 1) get_param_txt(workspace = path, param = "durvieF", plant_id = 1) get_param_txt(workspace = path, param = "durvieF", plant_id = 1, variety = varieties) # Get parameters for specific interventions or soil layers get_param_txt(workspace = path, param = "amount", value_id = c(1,3)) get_param_txt(workspace = path, param = "Hinitf", value_id = c(1,3)) get_param_txt(workspace = path, param = "epc", value_id = c(1,3)) ## Not run: # Read the initialisation file (ficini.txt): library(SticsRFiles) path <- file.path(get_examples_path(file_type = "txt"), "ficini.txt") get_ini_txt(path) # Read the tec file directly: # First, get the parameters from the tmp file: tmp <- get_tmp_txt(file = file.path(get_examples_path(file_type = "txt"), "tempoparv6.sti")) several_fert <- ifelse(tmp$option_engrais_multiple == 1, TRUE, FALSE) several_thin <- ifelse(tmp$option_thinning == 1, TRUE, FALSE) is_pasture <- ifelse(tmp$option_pature == 1, TRUE, FALSE) # Then, get the technical parameters: get_tec_txt( file = file.path(get_examples_path(file_type = "txt"), "fictec1.txt"), several_fert = several_fert, several_thin = several_thin, is_pasture = is_pasture ) ## End(Not run)
Extracting parameter values for a list of xml files and parameters
get_param_xml( file, param = NULL, select = NULL, select_value = NULL, value_id = NULL, xml_file = lifecycle::deprecated(), param_name = lifecycle::deprecated(), value = lifecycle::deprecated(), ... )
get_param_xml( file, param = NULL, select = NULL, select_value = NULL, value_id = NULL, xml_file = lifecycle::deprecated(), param_name = lifecycle::deprecated(), value = lifecycle::deprecated(), ... )
file |
Vector of the xml file paths from which parameters values must be extracted |
param |
Vector of parameter names. Optional, if not provided, the function returns information for all parameters. |
select |
node name or attribute name to use for selection (optional, default to no selection) |
select_value |
Vector of values used for select (see examples). Optional, should be provided only if select is provided. |
value_id |
Vector of ids of the parameters values to be retrieved from the parameter values vector |
xml_file |
|
param_name |
|
value |
|
... |
Pass further arguments to |
A list of parameter values for each xml_file (a list of list)
# Soil file file <- file.path(get_examples_path(file_type = "xml"), "sols.xml") # For all soils get_param_xml(file) get_param_xml(file, c("argi", "norg")) # With soil selection # scalar parameters per soil get_param_xml(file, c("argi", "norg"), select = "sol", select_value = c("solcanne", "solbanane") ) # Crop management file file <- file.path(get_examples_path(file_type = "xml"), "file_tec.xml") # Getting parameters for irrigation (date and quantity) get_param_xml(file, c("julapI_or_sum_upvt", "amount"))
# Soil file file <- file.path(get_examples_path(file_type = "xml"), "sols.xml") # For all soils get_param_xml(file) get_param_xml(file, c("argi", "norg")) # With soil selection # scalar parameters per soil get_param_xml(file, c("argi", "norg"), select = "sol", select_value = c("solcanne", "solbanane") ) # Crop management file file <- file.path(get_examples_path(file_type = "xml"), "file_tec.xml") # Getting parameters for irrigation (date and quantity) get_param_xml(file, c("julapI_or_sum_upvt", "amount"))
Extracting plant number from usms.xml or new_travail.usm file data
get_plants_nb( usms_file, usms_list = c(), usm_file_path = lifecycle::deprecated() )
get_plants_nb( usms_file, usms_list = c(), usm_file_path = lifecycle::deprecated() )
Use get_usms_list()
to get the list of the usm names for
an usms.xml file.
A named numeric vector of plants number per usm
# Xml case xml_usms <- file.path(get_examples_path(file_type = "xml"), "usms.xml") get_plants_nb(xml_usms) get_plants_nb(xml_usms, "wheat") get_plants_nb(xml_usms, c("wheat", "intercrop_pea_barley")) # Txt case txt_usm <- file.path(get_examples_path(file_type = "txt"), "new_travail.usm") get_plants_nb(txt_usm)
# Xml case xml_usms <- file.path(get_examples_path(file_type = "xml"), "usms.xml") get_plants_nb(xml_usms) get_plants_nb(xml_usms, "wheat") get_plants_nb(xml_usms, c("wheat", "intercrop_pea_barley")) # Txt case txt_usm <- file.path(get_examples_path(file_type = "txt"), "new_travail.usm") get_plants_nb(txt_usm)
Extracting data from the STICS report file
get_report_results( workspace, file_name = "mod_rapport.sti", usm = NULL, var_list = NULL, usm_name = lifecycle::deprecated() )
get_report_results( workspace, file_name = "mod_rapport.sti", usm = NULL, var_list = NULL, usm_name = lifecycle::deprecated() )
workspace |
Path of the directory containing the STICS report file to read. |
file_name |
A report file name among "mod_rapport.sti" (default), "mod_rapportA.sti", "mod_rapportP.sti" |
usm |
Vector of USM names. Optional, if not provided, the function returns the results for all USMs. |
var_list |
vector of output variables names to filter
(optional, see |
usm_name |
The data may be filtered using usm_name
vector of usm names and
and/or var_list
vector of variables names. In the returned data.frame,
variables names respect the same syntax as in the get_sim output.
A data.frame
path <- get_examples_path(file_type = "sti") get_report_results(workspace = path) get_report_results(workspace = path, usm = c("DurumWheat", "grass")) get_report_results(workspace = path, var_list = c("masec(n)", "QNplante")) get_report_results(workspace = path, usm = c("DurumWheat", "grass")) get_report_results(workspace = path) get_report_results(workspace = path, file_name = "mod_rapportA.sti")
path <- get_examples_path(file_type = "sti") get_report_results(workspace = path) get_report_results(workspace = path, usm = c("DurumWheat", "grass")) get_report_results(workspace = path, var_list = c("masec(n)", "QNplante")) get_report_results(workspace = path, usm = c("DurumWheat", "grass")) get_report_results(workspace = path) get_report_results(workspace = path, file_name = "mod_rapportA.sti")
Reads and format daily output file(s) (mod_s*.sti) for usm(s) with possible selection on variable names, cumulative DOY and dates
get_sim( workspace, usm = NULL, var = NULL, dates = NULL, usms_file = NULL, javastics = NULL, verbose = TRUE, usm_name = lifecycle::deprecated(), var_list = lifecycle::deprecated(), dates_list = lifecycle::deprecated(), usms_filepath = lifecycle::deprecated(), javastics_path = lifecycle::deprecated() )
get_sim( workspace, usm = NULL, var = NULL, dates = NULL, usms_file = NULL, javastics = NULL, verbose = TRUE, usm_name = lifecycle::deprecated(), var_list = lifecycle::deprecated(), dates_list = lifecycle::deprecated(), usms_filepath = lifecycle::deprecated(), javastics_path = lifecycle::deprecated() )
If usm
is not specified (or equal to NULL
), the
function reads the files from all usms in the workspace
(s).
If usms_file
is provided and if the associated plant file is found,
the plant names in the "Plant" column of the generated data.frame
are either the plant code (as specified in the plant file) or
the name of the plant file, if the plant file is not found.
If usms_file
is not specified, the plants are named "plant_1" by default
(+ "plant_2" for intercrops).
A list, where each element is a data.frame
of simulation results
for the given usm. The list is named after the USM name.
Intercrops are returned in a single data.frame
, and are identified
using either the "Plant" or "Dominance" columns.
See Details section for more information about the "Plant" column.
path <- get_examples_path(file_type = "sti") sim_data <- get_sim(path, "banana")
path <- get_examples_path(file_type = "sti") sim_data <- get_sim(path, "banana")
Extracts the soil names from a "usms.xml" file, or from a soil file
get_soils_list( file, soil = NULL, file_path = lifecycle::deprecated(), name = lifecycle::deprecated() )
get_soils_list( file, soil = NULL, file_path = lifecycle::deprecated(), name = lifecycle::deprecated() )
file |
Either the path of an usm file or of a soil file. |
soil |
Vector of soil names (or partial names). Optional, if not provided, the function returns the names of all the soils included in the given file. |
file_path |
|
name |
The file given as the file_path
is either a "usms" file type
to get all the soils used in a particular USM, or a soil file type ("sols")
to get all soil types available in a soil file.
A vector of soil names
path <- get_examples_path(file_type = "xml") # Read from a usms file (soils used in a USM): soil_list <- get_soils_list(file = file.path(path, "usms.xml")) # Read from a soil file (all soil types available in a soil file) soil_list <- get_soils_list(file = file.path(path, "sols.xml")) soil_list <- get_soils_list(file = file.path(path, "usms.xml"), soil = c("solcanne", "sole"))
path <- get_examples_path(file_type = "xml") # Read from a usms file (soils used in a USM): soil_list <- get_soils_list(file = file.path(path, "usms.xml")) # Read from a soil file (all soil types available in a soil file) soil_list <- get_soils_list(file = file.path(path, "sols.xml")) soil_list <- get_soils_list(file = file.path(path, "usms.xml"), soil = c("solcanne", "sole"))
Get the versions of STICS that are fully compatible with this package.
get_stics_versions_compat(version_index = NULL)
get_stics_versions_compat(version_index = NULL)
version_index |
Absolute positive index, or negative relative index from latest version |
A named list with the STICS versions compatible with this package ($versions_list), and the latest version in use ($latest_version) or an existing version selected using version_index.
# Getting the complete versions list get_stics_versions_compat() # Getting the first version get_stics_versions_compat(1) # Getting the previous version of the latest one get_stics_versions_compat(-1)
# Getting the complete versions list get_stics_versions_compat() # Getting the first version get_stics_versions_compat(1) # Getting the previous version of the latest one get_stics_versions_compat(-1)
Getting existing xml files path list per usm from an usms.xml file
get_usms_files( workspace, usms_list = NULL, usms_file = "usms.xml", file_type = NULL, javastics = NULL, df_output = FALSE, workspace_path = lifecycle::deprecated(), file_name = lifecycle::deprecated(), javastics_path = lifecycle::deprecated() )
get_usms_files( workspace, usms_list = NULL, usms_file = "usms.xml", file_type = NULL, javastics = NULL, df_output = FALSE, workspace_path = lifecycle::deprecated(), file_name = lifecycle::deprecated(), javastics_path = lifecycle::deprecated() )
The possible values for file_type are: "fplt", "finit", "fclim1", "fclim2", "fstation", "ftec", "sols", "pargen" and "parnew"
A named list with existing files path in each usm element
See get_soils_list()
to get all soils in a usm file,
and get_usms_list()
to get the list of usms.
## Not run: get_usms_files( workspace = "/path/to/workspace", javastics = "/path/to/JavaSTICS/folder" ) get_usms_files( workspace = "/path/to/workspace", javastics = "/path/to/JavaSTICS/folder", usm_list = c("usm1", "usm3") ) get_usms_files( workspace = "/path/to/workspace", file_type = c("finit", "ftec") ) ## End(Not run)
## Not run: get_usms_files( workspace = "/path/to/workspace", javastics = "/path/to/JavaSTICS/folder" ) get_usms_files( workspace = "/path/to/workspace", javastics = "/path/to/JavaSTICS/folder", usm_list = c("usm1", "usm3") ) get_usms_files( workspace = "/path/to/workspace", file_type = c("finit", "ftec") ) ## End(Not run)
Extracting a usm names list from an usms.xml file
get_usms_list( file, usm = NULL, usm_path = lifecycle::deprecated(), name = lifecycle::deprecated() )
get_usms_list( file, usm = NULL, usm_path = lifecycle::deprecated(), name = lifecycle::deprecated() )
file |
Path (including name) of the USM xml file |
usm |
Vector of USM names (or partial names). Optional, if not provided, the function returns the names of all the USMs included in the given file. |
usm_path |
|
name |
A vector of usm names
path <- get_examples_path(file_type = "xml") usms_list <- get_usms_list(file = file.path(path, "usms.xml")) usms_list <- get_usms_list(file = file.path(path, "usms.xml"), usm = c("usm1", "usm2"))
path <- get_examples_path(file_type = "xml") usms_list <- get_usms_list(file = file.path(path, "usms.xml")) usms_list <- get_usms_list(file = file.path(path, "usms.xml"), usm = c("usm1", "usm2"))
Helper function that returns names and descriptions of STICS output variables from a partial name and/or descriptive keywords.
get_var_info(var = NULL, keyword = NULL, stics_version = "latest")
get_var_info(var = NULL, keyword = NULL, stics_version = "latest")
var |
Vector of variable names (or partial names). Optional, if not provided, the function returns information for all variables. |
keyword |
Search by keyword instead of variable name (search in the name and description field) |
stics_version |
Name of the STICS version. Optional, can be used
to search parameters information relative to a specific STICS version.
By default the latest version returned by |
The function understand regex
as input.
A data.frame with information about variable(s) with columns
name
, definition
, unit
, type
# Find by variable name (fuzzy search): SticsRFiles::get_var_info("lai") # Find by keyword (fuzzy search in variable name and description): SticsRFiles::get_var_info(keyword = "lai") # Find for a particular version: SticsRFiles::get_var_info("lai", stics_version = "V9.0")
# Find by variable name (fuzzy search): SticsRFiles::get_var_info("lai") # Find by keyword (fuzzy search in variable name and description): SticsRFiles::get_var_info(keyword = "lai") # Find for a particular version: SticsRFiles::get_var_info("lai", stics_version = "V9.0")
Get the STICS output variables (from var.mod file)
get_varmod(workspace, file_name = "var.mod")
get_varmod(workspace, file_name = "var.mod")
workspace |
Path of the directory containing the STICS var.mod file |
file_name |
file name to read (without path, default value: "var.mod") |
The variables that will be returned by STICS
gen_varmod
get_varmod(get_examples_path(file_type = "txt"))
get_varmod(get_examples_path(file_type = "txt"))
Evaluating if the OS is a Mac OS type
is_mac()
is_mac()
TRUE/FALSE
is_mac()
is_mac()
Tells if one or more parameter names are valid STICS input parameters.
is_stics_param(param, stics_version = "latest")
is_stics_param(param, stics_version = "latest")
param |
A vector of parameter names |
stics_version |
Name of the STICS version. Optional, can be used
to search parameters information relative to a specific STICS version.
By default the latest version returned by |
A boolean vector: TRUE
if the parameter exist, FALSE
otherwise
get_param_info()
for interactive use.
is_stics_param(c("adil", "adilmax", "unknown"))
is_stics_param(c("adil", "adilmax", "unknown"))
Tells if one or more variable names are valid STICS output variables.
is_stics_var(var, stics_version = "latest")
is_stics_var(var, stics_version = "latest")
var |
A vector of variable names |
stics_version |
Name of the STICS version. Optional, can be used
to search parameters information relative to a specific STICS version.
By default the latest version returned by |
A boolean vector: TRUE
if the variable exist, FALSE
otherwise
get_var_info()
for interactive use.
is_stics_var(c("lai(n)", "masec(n)", "unknown"))
is_stics_var(c("lai(n)", "masec(n)", "unknown"))
Evaluating if the OS is a unix like type
is_unix()
is_unix()
TRUE/FALSE
is_unix()
is_unix()
Evaluating if the OS is a windows type
is_windows()
is_windows()
TRUE/FALSE
is_windows()
is_windows()
Getting parameters data from tables files (Excel sheet, csv)
read_params_table( file, sheet_name = NULL, num_na = "NA", char_na = "NA", file_path = lifecycle::deprecated() )
read_params_table( file, sheet_name = NULL, num_na = "NA", char_na = "NA", file_path = lifecycle::deprecated() )
file |
Excel or csv file path (including name of the file) |
sheet_name |
Name of an Excel sheet (useless for csv files) |
num_na |
Replacement value for numerical NA values (default: NA) |
char_na |
Replacement value for character NA values (default: "") |
file_path |
After data are loaded, numerical and string NA values are replaced respectively with num_na or char_na
A tibble of parameters
usm_xl_file <- download_usm_xl( file = "inputs_stics_example.xlsx", verbose = FALSE ) read_params_table(usm_xl_file, sheet = "USMs") usm_csv_file <- download_usm_csv( file = "inputs_stics_example_USMs.csv", verbose = FALSE, stics_version = "V9.2" ) read_params_table(file = usm_csv_file)
usm_xl_file <- download_usm_xl( file = "inputs_stics_example.xlsx", verbose = FALSE ) read_params_table(usm_xl_file, sheet = "USMs") usm_csv_file <- download_usm_csv( file = "inputs_stics_example_USMs.csv", verbose = FALSE, stics_version = "V9.2" ) read_params_table(file = usm_csv_file)
Replace or set an input parameter from a pre-existing STICS input file.
set_param_txt( workspace, param, value, append = FALSE, plant_id = 1, variety = NULL, value_id = NULL, stics_version = "latest", dirpath = lifecycle::deprecated(), add = lifecycle::deprecated(), plant = lifecycle::deprecated(), layer = 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, value_id = NULL, filepath = lifecycle::deprecated(), add = lifecycle::deprecated() ) set_soil_txt( file = "param.sol", param, value, layer = NULL, stics_version = "latest", filepath = lifecycle::deprecated() )
set_param_txt( workspace, param, value, append = FALSE, plant_id = 1, variety = NULL, value_id = NULL, stics_version = "latest", dirpath = lifecycle::deprecated(), add = lifecycle::deprecated(), plant = lifecycle::deprecated(), layer = 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, value_id = NULL, filepath = lifecycle::deprecated(), add = lifecycle::deprecated() ) set_soil_txt( file = "param.sol", param, value, layer = NULL, stics_version = "latest", filepath = lifecycle::deprecated() )
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 (default = 1). |
variety |
The plant variety to set the parameter value,
either the variety name ( |
value_id |
The soil layers id or technical interventions id |
stics_version |
An optional version name as listed in get_stics_versions_compat() return |
dirpath |
|
add |
|
plant |
|
layer |
|
file |
Path (including name) of the file to modify |
filepath |
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.
None
gen_varmod
is not used by set_param_txt
.
To replace the output variables required from STICS,
please directly call gen_varmod
.
# 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) # Change the value of durvieF for another variety: set_param_txt(workspace = path, param = "durvieF", variety = "Nefer", value = 178) # Change the value of soil parameter "cailloux" for all layers # or a specific one set_param_txt(workspace = path, param = "cailloux", value = 1) set_param_txt(workspace = path, param = "cailloux", value_id = 2, value = 2) # Change the value of parameter "amount" for all water supply interventions # or a specific one set_param_txt(workspace = path, param = "amount", value = 50) set_param_txt(workspace = path, param = "amount", value_id = 2, value = 40)
# 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) # Change the value of durvieF for another variety: set_param_txt(workspace = path, param = "durvieF", variety = "Nefer", value = 178) # Change the value of soil parameter "cailloux" for all layers # or a specific one set_param_txt(workspace = path, param = "cailloux", value = 1) set_param_txt(workspace = path, param = "cailloux", value_id = 2, value = 2) # Change the value of parameter "amount" for all water supply interventions # or a specific one set_param_txt(workspace = path, param = "amount", value = 50) set_param_txt(workspace = path, param = "amount", value_id = 2, value = 40)
Setting parameter values for a parameter or a vector of and with a parameters values vector
set_param_xml( file, param, values, save_as = NULL, select = NULL, select_value = NULL, value_id = NULL, overwrite = FALSE, xml_file = lifecycle::deprecated(), out_path = lifecycle::deprecated(), param_name = lifecycle::deprecated(), param_value = lifecycle::deprecated(), value = lifecycle::deprecated(), ... )
set_param_xml( file, param, values, save_as = NULL, select = NULL, select_value = NULL, value_id = NULL, overwrite = FALSE, xml_file = lifecycle::deprecated(), out_path = lifecycle::deprecated(), param_name = lifecycle::deprecated(), param_value = lifecycle::deprecated(), value = lifecycle::deprecated(), ... )
file |
Path (including name) of the xml file to modify |
param |
Vector of parameter names. |
values |
A vector or a list of parameter(s) values (see details). |
save_as |
Path (including name) of the xml file to generate.
Optional, if NULL |
select |
node name or attribute name to use for selection (optional, default to no selection) |
select_value |
Vector of values used for select (see examples). Optional, should be provided only if select is provided. |
value_id |
Vector of ids of the parameters values to be retrieved from the parameter values vector |
overwrite |
Logical TRUE for overwriting the output file, FALSE otherwise (default) |
xml_file |
|
out_path |
|
param_name |
|
param_value |
|
value |
|
... |
Pass further arguments to |
It is possible to give several values for a parameter by passing a vector of values. For example, for two parameters with two values each: value= list(c(1,2), c(2.3,4.5))
A logical value TRUE for operation success, FALSE otherwise
ex_path <- get_examples_path(file_type = "xml") # Soil file sol_path <- file.path(ex_path, "sols.xml") # For scalar parameters per soil # Setting all soils "argi" values to 50 set_param_xml(sol_path, "argi", 50, overwrite = TRUE) # Getting changed values # get_param_xml(sol_path, "argi") # Setting a specific value to "argi" for "solcanne" soil set_param_xml(file = sol_path, param = "argi", values = 56, select = "sol", select_value = "solcanne", overwrite = TRUE ) # Getting changed values # get_param_xml(sol_path, "argi", # select = "sol", select_value = "solcanne" #) # Setting a specific values to 2 parameters "argi" and # "norg" for "solcanne" soil set_param_xml(sol_path, c("argi", "norg"), list(100, 150), select = "sol", select_value = "solcanne", overwrite = TRUE ) # Getting changed values # get_param_xml(sol_path, c("argi", "norg"), # select = "sol", select_value = "solcanne" #) # For vector parameters per soil (5 values, one per soil layer) set_param_xml(sol_path, c("epc", "HCCF"), select = "sol", select_value = c("solcanne", "solbanane"), values = list(c(20:24, 10:14), c(50:54, 40:44)), overwrite = TRUE ) # Getting changed values # get_param_xml(sol_path, c("epc", "HCCF"), # select = "sol", # select_value = c("solcanne", "solbanane") # ) # For specific values of vector parameters set_param_xml(sol_path, "HCCF", select = "sol", select_value = "solcanne", values = c(46.8, 48.5, 50.1), value_id = c(1,3,5), overwrite = TRUE ) # Getting changed values # get_param_xml(sol_path, "HCCF", # select = "sol", # select_value = "solcanne", # value_id = c(1,3,5) # ) # Crop management file tec_path <- file.path(ex_path, "file_tec.xml") # Modifying irrigations parameters set_param_xml(tec_path, c("julapI_or_sum_upvt", "amount"), values = list(200:215, 20:35), overwrite = TRUE ) # Getting changed values # get_param_xml(tec_path, c("julapI_or_sum_upvt", "amount"))
ex_path <- get_examples_path(file_type = "xml") # Soil file sol_path <- file.path(ex_path, "sols.xml") # For scalar parameters per soil # Setting all soils "argi" values to 50 set_param_xml(sol_path, "argi", 50, overwrite = TRUE) # Getting changed values # get_param_xml(sol_path, "argi") # Setting a specific value to "argi" for "solcanne" soil set_param_xml(file = sol_path, param = "argi", values = 56, select = "sol", select_value = "solcanne", overwrite = TRUE ) # Getting changed values # get_param_xml(sol_path, "argi", # select = "sol", select_value = "solcanne" #) # Setting a specific values to 2 parameters "argi" and # "norg" for "solcanne" soil set_param_xml(sol_path, c("argi", "norg"), list(100, 150), select = "sol", select_value = "solcanne", overwrite = TRUE ) # Getting changed values # get_param_xml(sol_path, c("argi", "norg"), # select = "sol", select_value = "solcanne" #) # For vector parameters per soil (5 values, one per soil layer) set_param_xml(sol_path, c("epc", "HCCF"), select = "sol", select_value = c("solcanne", "solbanane"), values = list(c(20:24, 10:14), c(50:54, 40:44)), overwrite = TRUE ) # Getting changed values # get_param_xml(sol_path, c("epc", "HCCF"), # select = "sol", # select_value = c("solcanne", "solbanane") # ) # For specific values of vector parameters set_param_xml(sol_path, "HCCF", select = "sol", select_value = "solcanne", values = c(46.8, 48.5, 50.1), value_id = c(1,3,5), overwrite = TRUE ) # Getting changed values # get_param_xml(sol_path, "HCCF", # select = "sol", # select_value = "solcanne", # value_id = c(1,3,5) # ) # Crop management file tec_path <- file.path(ex_path, "file_tec.xml") # Modifying irrigations parameters set_param_xml(tec_path, c("julapI_or_sum_upvt", "amount"), values = list(200:215, 20:35), overwrite = TRUE ) # Getting changed values # get_param_xml(tec_path, c("julapI_or_sum_upvt", "amount"))
Upgrading _ini.xml file(s) to a newer version
upgrade_ini_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
upgrade_ini_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
file |
Path of an initialisation (*_ini.xml) file or a vector of |
out_dir |
Output directory path of the generated files |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
... |
Additional input arguments |
See SticsRFiles::get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_ini_xml( file = file.path(dir_path,"file_ini.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_ini_xml( file = file.path(dir_path,"file_ini.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading a param_gen.xml file to a newer version
upgrade_param_gen_xml( file, out_dir, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
upgrade_param_gen_xml( file, out_dir, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
file |
Path of a param_gen.xml file |
out_dir |
Output directory path of the generated file |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
See get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_param_gen_xml( file = file.path(dir_path, "param_gen.xml"), out_dir = tempdir() )
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_param_gen_xml( file = file.path(dir_path, "param_gen.xml"), out_dir = tempdir() )
Upgrading a param_newform.xml file to a newer version
upgrade_param_newform_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
upgrade_param_newform_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
file |
Path of a param_newform.xml file |
out_dir |
Output directory path of the generated file |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
See SticsRFiles::get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_param_newform_xml( file = file.path(dir_path,"param_newform.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_param_newform_xml( file = file.path(dir_path,"param_newform.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading _plt.xml file(s) to a newer version
upgrade_plt_xml( file, out_dir, param_newform_file, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
upgrade_plt_xml( file, out_dir, param_newform_file, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
file |
Path of an plant (*_plt.xml) file or a vector of |
out_dir |
Output directory path of the generated files |
param_newform_file |
Path of the param_newform.xml file corresponding to the file version |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency between |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
... |
Additional input arguments |
See get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_plt_xml( file = file.path(dir_path,"file_plt.xml"), out_dir = tempdir(), param_newform_file = file.path(dir_path, "param_newform.xml"), param_gen_file = file.path(dir_path, "param_gen.xml") )
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_plt_xml( file = file.path(dir_path,"file_plt.xml"), out_dir = tempdir(), param_newform_file = file.path(dir_path, "param_newform.xml"), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading a sols.xml file to a newer version
upgrade_sols_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
upgrade_sols_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
file |
Path of a sols.xml file |
out_dir |
Output directory path of the generated file |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
See SticsRFiles::get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_sols_xml( file = file.path(dir_path,"sols.xml" ), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_sols_xml( file = file.path(dir_path,"sols.xml" ), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading _sta.xml file(s) to a newer version
upgrade_sta_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
upgrade_sta_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
file |
Path of a station (*_sta.xml) file or a vector of |
out_dir |
Output directory path of the generated files |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
... |
Additional input arguments |
See SticsRFiles::get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_sta_xml( file = file.path(dir_path,"file_sta.xml" ), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_sta_xml( file = file.path(dir_path,"file_sta.xml" ), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading _tec.xml file(s) to a newer version
upgrade_tec_xml( file, out_dir, param_newform_file, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
upgrade_tec_xml( file, out_dir, param_newform_file, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
file |
Path of a crop management (*_tec.xml) file or a vector of |
out_dir |
Output directory path of the generated files |
param_newform_file |
Path of the param_newform.xml file corresponding to the file version |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
... |
Additional input arguments |
See get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_tec_xml( file = file.path(dir_path,"file_tec.xml"), out_dir = tempdir(), param_newform_file = file.path(dir_path, "param_newform.xml"), param_gen_file = file.path(dir_path, "param_gen.xml") )
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_tec_xml( file = file.path(dir_path,"file_tec.xml"), out_dir = tempdir(), param_newform_file = file.path(dir_path, "param_newform.xml"), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading a usms.xml file to a newer version
upgrade_usms_xml( file, out_dir, param_gen_file, obs_dir = NULL, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
upgrade_usms_xml( file, out_dir, param_gen_file, obs_dir = NULL, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
file |
Path of a usms.xml file |
out_dir |
Output directory path of the generated file |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
obs_dir |
Directory path of the observation data files |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
See get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_usms_xml( file = file.path(dir_path,"usms.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_usms_xml( file = file.path(dir_path,"usms.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading XML files of a JavaSTICS workspace directory to a newer STICS version format
upgrade_workspace_xml( workspace, javastics, out_dir, stics_version = "V9.2", target_version = "V10.0", plant = FALSE, overwrite = FALSE, ... )
upgrade_workspace_xml( workspace, javastics, out_dir, stics_version = "V9.2", target_version = "V10.0", plant = FALSE, overwrite = FALSE, ... )
workspace |
Path of a JavaSTICS workspace |
javastics |
Path of JavaSTICS containing the STICS version corresponding to the version of the files to be converted |
out_dir |
Output directory of the generated files |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
plant |
logical (optional), TRUE for upgrading plant files if a "plant" sub-directory of workspace exists, FALSE otherwise |
overwrite |
logical (optional), TRUE for overwriting files if they exist, FALSE otherwise |
... |
Additional input arguments |
See SticsRFiles::get_stics_versions_compat() for listing versions
If general parameters files exist in workspace
, they are also upgraded.
In that case, residues parameters values are kept and might not be adapted
to the target model version.
Weather data and observations files are fully copied to out_dir
None
## Not run: upgrade_workspace_xml( workspace = "/path/to/JavaSTICS/workspace", javastics = "/path/to/JavaSTICS/folder", out_dir = "/path/to/an/output/directory" ) ## End(Not run)
## Not run: upgrade_workspace_xml( workspace = "/path/to/JavaSTICS/workspace", javastics = "/path/to/JavaSTICS/folder", out_dir = "/path/to/an/output/directory" ) ## End(Not run)