Title: | A Comprehensive R Interface for the DSSAT Cropping Systems Model |
---|---|
Description: | The purpose of this package is to provide a comprehensive R interface to the Decision Support System for Agrotechnology Transfer Cropping Systems Model (DSSAT-CSM; see <https://dssat.net> for more information). The package provides cross-platform functions to read and write input files, run DSSAT-CSM, and read output files. |
Authors: | Phillip D. Alderman [aut, cre] |
Maintainer: | Phillip D. Alderman <[email protected]> |
License: | GPL (>=3) |
Version: | 0.0.9 |
Built: | 2024-11-15 05:22:20 UTC |
Source: | https://github.com/palderman/dssat |
Adds variable format information to a tibble
add_v_fmt(input_tbl, v_fmt = NULL)
add_v_fmt(input_tbl, v_fmt = NULL)
input_tbl |
a tibble |
v_fmt |
a named vector containing variable format information to be added to 'input_tbl' |
a tibble containing the original tibble with an additional attribute that contains variable format information
# Extract file path for sample ecotype file sample_eco_file <- system.file('extdata','SAMPLE.ECO',package='DSSAT') # Read sample ecotype file eco <- read_eco(sample_eco_file) # Replace formats for TSEN and CDAY parameters eco <- add_v_fmt(eco,v_fmt=c(TSEN='%6.1f',CDAY='%6.1f'))
# Extract file path for sample ecotype file sample_eco_file <- system.file('extdata','SAMPLE.ECO',package='DSSAT') # Read sample ecotype file eco <- read_eco(sample_eco_file) # Replace formats for TSEN and CDAY parameters eco <- add_v_fmt(eco,v_fmt=c(TSEN='%6.1f',CDAY='%6.1f'))
Convert tibble to DSSAT_tbl
as_DSSAT_tbl(tbl_in, v_fmt = NULL, tier_info = NULL)
as_DSSAT_tbl(tbl_in, v_fmt = NULL, tier_info = NULL)
tbl_in |
a tibble |
v_fmt |
a character vector specifying the sprintf() format for each column |
tier_info |
a list of character vectors storing the history of which original table that columns came from for tibbles that are comprised of multiple joined tables |
a tibble of class DSSAT_tbl
Calculate long-term temperature amplitude (AMP)
calc_AMP(wth)
calc_AMP(wth)
wth |
a data frame that contains weather data formatted as would be generated using read_wth, namely including columns DATE, TMAX and TMIN. |
Calculate long-term temperature average (TAV)
calc_TAV(wth)
calc_TAV(wth)
wth |
a data frame that contains weather data formatted as would be generated using read_wth, namely including columns TMAX and TMIN. |
A function to delete DSSAT output files (\*.OUT) and intermediate files (\*.INH, \*.INP and \*.LST) from a directory
clear_output(dir_name = getwd(), file_ext = c("OUT", "LST", "INP", "INH"))
clear_output(dir_name = getwd(), file_ext = c("OUT", "LST", "INP", "INH"))
dir_name |
a length-one character vector indicating the directory in which to delete output files (by default the current working directory) |
file_ext |
a character vector of file extensions to delete |
Convenience function that allows mutating a subset of rows
mutate_cond(.data, condition, ..., envir = parent.frame())
mutate_cond(.data, condition, ..., envir = parent.frame())
.data |
a tibble |
condition |
a logical vector for subsetting rows of '.data' |
... |
Name-value pairs of expressions to be evaluated by 'mutate()' |
envir |
environment within which expressions should be evaluated |
Original code taken from https://stackoverflow.com/questions/34096162/dplyr-mutate-replace-several-columns-on-a-subset-of-rows
a tibble with specified rows modified
Reads parameters from a single DSSAT cultivar parameter file (*.CUL)
read_cul( file_name, col_types = NULL, col_names = NULL, left_justified = c("VAR#", "VARNAME\\.*", "VAR-NAME\\.*", "VRNAME\\.*"), use_std_fmt = TRUE )
read_cul( file_name, col_types = NULL, col_names = NULL, left_justified = c("VAR#", "VARNAME\\.*", "VAR-NAME\\.*", "VRNAME\\.*"), use_std_fmt = TRUE )
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
left_justified |
A character vector of column names that should be left justified |
use_std_fmt |
logical value indicating whether to read FileX using the standard column formats. If FALSE, column formats will be inferred from tier headers |
a tibble containing the data from the raw DSSAT output
# Extract file path for sample cultivar file path sample_cul_file <- system.file('extdata','SAMPLE.CUL',package='DSSAT') # Read sample cultivar file cul <- read_cul(sample_cul_file)
# Extract file path for sample cultivar file path sample_cul_file <- system.file('extdata','SAMPLE.CUL',package='DSSAT') # Read sample cultivar file cul <- read_cul(sample_cul_file)
Reads data from a single DSSAT file
read_dssat( file_name, col_types = NULL, col_names = NULL, na_strings = NULL, left_justified = "EXCODE", guess_max = 10 )
read_dssat( file_name, col_types = NULL, col_names = NULL, na_strings = NULL, left_justified = "EXCODE", guess_max = 10 )
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
na_strings |
A character vector containing strings that should be interpreted as missing values |
left_justified |
A character vector of column names that should be left justified |
guess_max |
An integer indicating the maximum number of lines that should be used to guess the type of a column |
a tibble containing the data from the raw DSSAT output
# Extract file path for sample output file path sample_output <- system.file('extdata','SAMPLE.OUT',package='DSSAT') read_dssat(sample_output)
# Extract file path for sample output file path sample_output <- system.file('extdata','SAMPLE.OUT',package='DSSAT') read_dssat(sample_output)
Reads data from a single DSSAT batch file
read_dssbatch(file_name = "DSSBatch.V47")
read_dssbatch(file_name = "DSSBatch.V47")
file_name |
a character vector of length one that contains the name of a single DSSAT batch file |
a tibble containing the data from the DSSAT batch file
# Create example batch file path batch_file_path <- paste0(tempdir(),'/DSSBatch.V47') # Write example batch file write_dssbatch(x='UFGA0601.BMX',trtno=1:4,file_name = batch_file_path) # Read example batch file dssbatch <- read_dssbatch(batch_file_path)
# Create example batch file path batch_file_path <- paste0(tempdir(),'/DSSBatch.V47') # Write example batch file write_dssbatch(x='UFGA0601.BMX',trtno=1:4,file_name = batch_file_path) # Read example batch file dssbatch <- read_dssbatch(batch_file_path)
Reads parameters from a single DSSAT ecotype parameter file (*.ECO)
read_eco( file_name, col_types = NULL, col_names = NULL, left_justified = c("ECO ", "ECO#", "ECONAME\\.*", "ECO-NAME\\.*") )
read_eco( file_name, col_types = NULL, col_names = NULL, left_justified = c("ECO ", "ECO#", "ECONAME\\.*", "ECO-NAME\\.*") )
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
left_justified |
A character vector of column names that should be left justified |
a tibble containing the data from the raw DSSAT file
# Extract file path for sample ecotype file path sample_eco <- system.file('extdata','SAMPLE.ECO',package='DSSAT') eco <- read_eco(sample_eco)
# Extract file path for sample ecotype file path sample_eco <- system.file('extdata','SAMPLE.ECO',package='DSSAT') eco <- read_eco(sample_eco)
Reads data from a single DSSAT file A
read_filea(file_name, col_types = NULL, col_names = NULL, na_strings = NULL)
read_filea(file_name, col_types = NULL, col_names = NULL, na_strings = NULL)
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
na_strings |
a character vector of string to represent missing values |
a tibble containing the data from the raw DSSAT file
# Extract FileA path for sample file sample_filea <- system.file('extdata','SAMPLE.CRA',package='DSSAT') filea <- read_filea(sample_filea)
# Extract FileA path for sample file sample_filea <- system.file('extdata','SAMPLE.CRA',package='DSSAT') filea <- read_filea(sample_filea)
Reads time series data from a single DSSAT file T
read_filet(file_name, col_types = NULL, col_names = NULL, na_strings = NULL)
read_filet(file_name, col_types = NULL, col_names = NULL, na_strings = NULL)
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
na_strings |
a character vector of string to represent missing values |
a tibble containing the data from the raw DSSAT file
# Extract FileT path for sample file sample_filet <- system.file('extdata','SAMPLE.CRT',package='DSSAT') read_filet(sample_filet)
# Extract FileT path for sample file sample_filet <- system.file('extdata','SAMPLE.CRT',package='DSSAT') read_filet(sample_filet)
Reads input data from a single DSSAT experiment file (*.*X)
read_filex( file_name, col_types = NULL, col_names = NULL, na_strings = NULL, store_v_fmt = FALSE, use_std_fmt = FALSE )
read_filex( file_name, col_types = NULL, col_names = NULL, na_strings = NULL, store_v_fmt = FALSE, use_std_fmt = FALSE )
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
na_strings |
A character vector containing strings that should be interpreted as missing values |
store_v_fmt |
a logical value indicating whether or not to store the format for variables being read |
use_std_fmt |
logical value indicating whether to read FileX using the standard column formats. If FALSE, column formats will be inferred from tier headers |
a tibble containing the data from the raw DSSAT file
Read multiple File X
read_filex_multiple( file_name, col_types = NULL, col_names = NULL, na_strings = NULL, store_v_fmt = FALSE, use_std_fmt = TRUE )
read_filex_multiple( file_name, col_types = NULL, col_names = NULL, na_strings = NULL, store_v_fmt = FALSE, use_std_fmt = TRUE )
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
na_strings |
A character vector containing strings that should be interpreted as missing values |
store_v_fmt |
a logical value indicating whether or not to store the format for variables being read |
use_std_fmt |
logical value indicating whether to read FileX using the standard column formats. If FALSE, column formats will be inferred from tier headers |
Reads data from a single DSSAT output file
read_output( file_name, col_types = NULL, col_names = NULL, left_justified = NULL, read_only = NULL, store_v_fmt = FALSE )
read_output( file_name, col_types = NULL, col_names = NULL, left_justified = NULL, read_only = NULL, store_v_fmt = FALSE )
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
left_justified |
A character vector of column names that should be left justified |
read_only |
NULL or a character vector of column names that should be read in; If non-NULL only the columns listed will be read in. |
store_v_fmt |
a logical value indicating whether or not to store the format for variables being read |
a tibble containing the data from the raw DSSAT output
# Extract file path for sample output file path sample_output <- system.file('extdata','SAMPLE.OUT',package='DSSAT') out <- read_output(sample_output)
# Extract file path for sample output file path sample_output <- system.file('extdata','SAMPLE.OUT',package='DSSAT') out <- read_output(sample_output)
Reads input data from a single DSSAT pest file (*.PST)
read_pest(file_name, col_types = NULL, col_names = NULL)
read_pest(file_name, col_types = NULL, col_names = NULL)
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
a tibble containing the data from the raw DSSAT file
Reads a single DSSAT formatted soil profile from a raw character vector
read_soil_profile( raw_lines, left_justified = NULL, col_types = NULL, col_names = NULL )
read_soil_profile( raw_lines, left_justified = NULL, col_types = NULL, col_names = NULL )
raw_lines |
a character vector that includes the contents of a single tier of data (including headline, but excluding version stamp and other header information) from a DSSAT output file |
left_justified |
A character vector of column names that should be left justified |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
a list containing tibbles for each tier of a DSSAT formatted soil profile
sample_sol <- c( "*IB00000001 IBSNAT SIC 210 DEFAULT - DEEP SILTY CLAY", "@SITE COUNTRY LAT LONG SCS FAMILY", " Generic Generic -99 -99 Generic", "@ SCOM SALB SLU1 SLDR SLRO SLNF SLPF SMHB SMPX SMKE", " -99 0.11 6.0 0.30 85.0 1.00 1.00 IB001 IB001 IB001", "@ SLB SLMH SLLL SDUL SSAT SRGF SSKS SBDM SLOC SLCL SLSI SLCF SLNI SLHW SLHB", " 5 -99 0.228 0.385 0.481 1.000 -99 1.30 1.75 50.0 45.0 0.0 0.170 6.5 -99", " 15 -99 0.228 0.385 0.481 1.000 -99 1.30 1.75 50.0 45.0 0.0 0.170 6.5 -99", " 30 -99 0.249 0.406 0.482 0.638 -99 1.30 1.60 50.0 45.0 0.0 0.170 6.5 -99", " 45 -99 0.249 0.406 0.465 0.472 -99 1.35 1.45 50.0 45.0 0.0 0.140 6.5 -99", " 60 -99 0.249 0.406 0.465 0.350 -99 1.35 1.45 50.0 45.0 0.0 0.140 6.5 -99", " 90 -99 0.308 0.456 0.468 0.223 -99 1.35 1.10 50.0 45.0 0.0 0.110 6.5 -99", " 120 -99 0.207 0.341 0.452 0.122 -99 1.40 0.65 50.0 45.0 0.0 0.060 6.5 -99", " 150 -99 0.243 0.365 0.455 0.067 -99 1.40 0.30 50.0 45.0 0.0 0.030 6.5 -99", " 180 -99 0.259 0.361 0.457 0.037 -99 1.40 0.10 50.0 45.0 0.0 0.010 6.5 -99", " 210 -99 0.259 0.361 0.457 0.020 -99 1.40 0.01 50.0 45.0 0.0 0.000 6.5 -99") read_soil_profile(sample_sol)
sample_sol <- c( "*IB00000001 IBSNAT SIC 210 DEFAULT - DEEP SILTY CLAY", "@SITE COUNTRY LAT LONG SCS FAMILY", " Generic Generic -99 -99 Generic", "@ SCOM SALB SLU1 SLDR SLRO SLNF SLPF SMHB SMPX SMKE", " -99 0.11 6.0 0.30 85.0 1.00 1.00 IB001 IB001 IB001", "@ SLB SLMH SLLL SDUL SSAT SRGF SSKS SBDM SLOC SLCL SLSI SLCF SLNI SLHW SLHB", " 5 -99 0.228 0.385 0.481 1.000 -99 1.30 1.75 50.0 45.0 0.0 0.170 6.5 -99", " 15 -99 0.228 0.385 0.481 1.000 -99 1.30 1.75 50.0 45.0 0.0 0.170 6.5 -99", " 30 -99 0.249 0.406 0.482 0.638 -99 1.30 1.60 50.0 45.0 0.0 0.170 6.5 -99", " 45 -99 0.249 0.406 0.465 0.472 -99 1.35 1.45 50.0 45.0 0.0 0.140 6.5 -99", " 60 -99 0.249 0.406 0.465 0.350 -99 1.35 1.45 50.0 45.0 0.0 0.140 6.5 -99", " 90 -99 0.308 0.456 0.468 0.223 -99 1.35 1.10 50.0 45.0 0.0 0.110 6.5 -99", " 120 -99 0.207 0.341 0.452 0.122 -99 1.40 0.65 50.0 45.0 0.0 0.060 6.5 -99", " 150 -99 0.243 0.365 0.455 0.067 -99 1.40 0.30 50.0 45.0 0.0 0.030 6.5 -99", " 180 -99 0.259 0.361 0.457 0.037 -99 1.40 0.10 50.0 45.0 0.0 0.010 6.5 -99", " 210 -99 0.259 0.361 0.457 0.020 -99 1.40 0.01 50.0 45.0 0.0 0.000 6.5 -99") read_soil_profile(sample_sol)
Reads soil parameters from a single DSSAT soil parameter file (*.SOL)
read_sol( file_name, id_soil = NULL, left_justified = NULL, col_types = NULL, col_names = NULL )
read_sol( file_name, id_soil = NULL, left_justified = NULL, col_types = NULL, col_names = NULL )
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
id_soil |
a length-one character vector containing the soil ID code for a single soil profile |
left_justified |
A character vector of column names that should be left justified |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
a tibble containing the data from the raw DSSAT file
# Extract file path for sample soil file sample_sol <- system.file('extdata','SAMPLE.SOL',package='DSSAT') sol <- read_sol(sample_sol)
# Extract file path for sample soil file sample_sol <- system.file('extdata','SAMPLE.SOL',package='DSSAT') sol <- read_sol(sample_sol)
Reads and combines data and header information from a single tier of a DSSAT output file
read_tier( raw_lines, col_types = NULL, col_names = NULL, na_strings = NULL, left_justified = "EXCODE", guess_max = 1000, store_v_fmt = TRUE, read_only = NULL )
read_tier( raw_lines, col_types = NULL, col_names = NULL, na_strings = NULL, left_justified = "EXCODE", guess_max = 1000, store_v_fmt = TRUE, read_only = NULL )
raw_lines |
a character vector that includes the contents of a single tier of data (including headline, but excluding version stamp and other header information) from a DSSAT output file |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
na_strings |
a character vector of string to represent missing values |
left_justified |
A character vector of column names that should be left justified |
guess_max |
An integer indicating the maximum number of lines that should be used to guess the type of a column |
store_v_fmt |
a logical value indicating whether or not to store the format for variables being read |
read_only |
NULL or a character vector of column names that should be read in; If non-NULL only the columns listed will be read in. |
a tibble containing the data from the raw DSSAT output
sample_data_tier <- c( "*DSSAT Cropping System Model Ver. 4.6.0.030 -forage MAR 27, 2014; 06:11:48", "", "*RUN 1 : 0 KG N/HA PRFRM046 UFGA0601 1 ", "MODEL : PRFRM046 - Tifton 85 bermud ", "EXPERIMENT : UFGA0601 G0 NITROGEN RESPONSE OF TIFTON 85 BERMUDAGRASS REGROW", "DATA PATH : ", " TREATMENT 1 : 0 KG N/HA PRFRM046 ", "", "", "! Soil evaporation (mm/d) by soil depth (cm):", "! 0-5 5-15 15-23 23-32 32-41 41-51 51-61 61-71", "@YEAR DOY DAS SRAA ES1D ES2D ES3D ES4D ES5D ES6D ES7D ES8D", " 2006 001 1 7.40 0.508 0.175 0.060 0.101 0.083 0.110 0.098 0.035", " 2006 002 2 8.40 0.849 0.263 0.064 0.104 0.086 0.113 0.101 0.036", " 2006 003 3 13.10 1.148 0.549 0.091 0.132 0.108 0.144 0.128 0.046") read_tier(sample_data_tier)
sample_data_tier <- c( "*DSSAT Cropping System Model Ver. 4.6.0.030 -forage MAR 27, 2014; 06:11:48", "", "*RUN 1 : 0 KG N/HA PRFRM046 UFGA0601 1 ", "MODEL : PRFRM046 - Tifton 85 bermud ", "EXPERIMENT : UFGA0601 G0 NITROGEN RESPONSE OF TIFTON 85 BERMUDAGRASS REGROW", "DATA PATH : ", " TREATMENT 1 : 0 KG N/HA PRFRM046 ", "", "", "! Soil evaporation (mm/d) by soil depth (cm):", "! 0-5 5-15 15-23 23-32 32-41 41-51 51-61 61-71", "@YEAR DOY DAS SRAA ES1D ES2D ES3D ES4D ES5D ES6D ES7D ES8D", " 2006 001 1 7.40 0.508 0.175 0.060 0.101 0.083 0.110 0.098 0.035", " 2006 002 2 8.40 0.849 0.263 0.064 0.104 0.086 0.113 0.101 0.036", " 2006 003 3 13.10 1.148 0.549 0.091 0.132 0.108 0.144 0.128 0.046") read_tier(sample_data_tier)
Reads weather input data from a single DSSAT weather file (*.WTH)
read_wth(file_name, col_types = NULL, col_names = NULL)
read_wth(file_name, col_types = NULL, col_names = NULL)
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
col_types |
One of NULL, a cols() specification, or a string.
See |
col_names |
A character vector of column names; primarily helpful for cases where there are no white spaces between column names within the header line |
a tibble containing the data from the raw DSSAT file
# Extract file path for sample weather file sample_wth <- system.file('extdata','SAMPLE.WTH',package='DSSAT') read_wth(sample_wth)
# Extract file path for sample weather file sample_wth <- system.file('extdata','SAMPLE.WTH',package='DSSAT') read_wth(sample_wth)
Writes data from a single DSSAT data tier
run_dssat(run_mode = "B", file_name = NULL, suppress_output = FALSE, wd = NULL)
run_dssat(run_mode = "B", file_name = NULL, suppress_output = FALSE, wd = NULL)
run_mode |
a length-one character vector that specifies the run mode that should be used for the DSSAT simulation. One of: A - Run all treatments. User specifies fileX on the command line and the model runs all treatments B - Batch mode. User defines fileX and treatment numbers in Batch file C - Command line mode. Use input from the command line. D - Debug mode. Model skips input module and reads temp file from the command line E - Sensitivity analysis. User defines fileX and treatment number in Batch file F - Farm model. Use Batch file to define experiment G - Gencalc. Use Command line to define experiment and treatment I - Interactive mode. Use model interface for exp. & trtno. L - Gene based model (Locus). Use Batch file to define experiment N - Seasonal analysis. Use Batch file to define experiment and treatments Q - Sequence analysis. Use Batch file to define experiment S - Spatial. Use Batch file to define experiment T - Gencalc. Use Batch file to define experiments and treatment |
file_name |
a length-one character vector that specifies the file name to be used for simulation. Usually the name of a batch file or file X. |
suppress_output |
a logical value indicating whether to suppress DSSAT-CSM output from being printed to the console |
wd |
an optional character string that specifies the working directory within which to run DSSAT-CSM. If left NULL, DSSAT-CSM will be run in the current working directory |
Invisibly returns the console output from running DSSAT-CSM
## Not run: run_dssat() ## End(Not run)
## Not run: run_dssat() ## End(Not run)
Reads parameters from a single DSSAT cultivar parameter file (*.CUL)
write_cul(cul, file_name)
write_cul(cul, file_name)
cul |
a DSSAT_tbl containing the contents of a DSSAT cultivar parameter file |
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
a tibble containing the data from the raw DSSAT output
# Extract file path for sample cultivar file path sample_cul_file <- system.file('extdata','SAMPLE.CUL',package='DSSAT') # Read sample cultivar file cul <- read_cul(sample_cul_file) # Create example cultivar file path sample_cul_file2 <- paste0(tempdir(),'/SAMPLE.CUL') # Write out sample cultivar file write_cul(cul,sample_cul_file2)
# Extract file path for sample cultivar file path sample_cul_file <- system.file('extdata','SAMPLE.CUL',package='DSSAT') # Read sample cultivar file cul <- read_cul(sample_cul_file) # Create example cultivar file path sample_cul_file2 <- paste0(tempdir(),'/SAMPLE.CUL') # Write out sample cultivar file write_cul(cul,sample_cul_file2)
Constructs and writes a DSSAT simulation batch file
write_dssbatch(x, trtno = 1, rp = 1, sq = 0, op = 0, co = 0, file_name = NULL)
write_dssbatch(x, trtno = 1, rp = 1, sq = 0, op = 0, co = 0, file_name = NULL)
x |
a tibble/data frame or character vector; if a tibble, it should contain all required columns of a DSSAT batch file (FILEX, TRTNO, RP, SQ, OP, CO); if a character vector, it should contain FileX file names |
trtno , rp , sq , op , co
|
a numeric vector |
file_name |
an optional character vector of the intended batch file name |
invisibly returns a character vector containing the content of a DSSAT batch file
# Create example batch file path batch_file_path <- paste0(tempdir(),'/DSSBatch.V47') # Write example batch file write_dssbatch(x='UFGA0601.BMX', trtno=1:4, file_name = batch_file_path) # Construct tibble for DSSAT batch file batch_tbl <- data.frame(FILEX='UFGA0601.BMX', TRTNO=1:4, RP=1, SQ=0, OP=0, CO=0) # Write example batch file write_dssbatch(batch_tbl, file_name = batch_file_path)
# Create example batch file path batch_file_path <- paste0(tempdir(),'/DSSBatch.V47') # Write example batch file write_dssbatch(x='UFGA0601.BMX', trtno=1:4, file_name = batch_file_path) # Construct tibble for DSSAT batch file batch_tbl <- data.frame(FILEX='UFGA0601.BMX', TRTNO=1:4, RP=1, SQ=0, OP=0, CO=0) # Write example batch file write_dssbatch(batch_tbl, file_name = batch_file_path)
Reads parameters from a single DSSAT ecotype parameter file (*.ECO)
write_eco(eco, file_name)
write_eco(eco, file_name)
eco |
a DSSAT_tbl containing the contents of a DSSAT ecotype parameter file |
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
a tibble containing the data from the raw DSSAT output
# Extract file path for sample ecotype file path sample_eco_file <- system.file('extdata','SAMPLE.ECO',package='DSSAT') # Read sample ecotype file eco <- read_eco(sample_eco_file) # Create example ecotype file path sample_eco_file2 <- paste0(tempdir(),'/SAMPLE.ECO') # Write out sample ecotype file write_eco(eco,sample_eco_file2)
# Extract file path for sample ecotype file path sample_eco_file <- system.file('extdata','SAMPLE.ECO',package='DSSAT') # Read sample ecotype file eco <- read_eco(sample_eco_file) # Create example ecotype file path sample_eco_file2 <- paste0(tempdir(),'/SAMPLE.ECO') # Write out sample ecotype file write_eco(eco,sample_eco_file2)
Writes data to a single DSSAT file A
write_filea(filea, file_name, drop_duplicate_rows = TRUE)
write_filea(filea, file_name, drop_duplicate_rows = TRUE)
filea |
a tibble containing the data to write to a DSSAT file A |
file_name |
a character vector of length one that contains the name of a single DSSAT file into which 'filea' will be written |
drop_duplicate_rows |
a logical value indicating whether duplicate rows should be dropped from tier_data |
# Extract FileA path for sample file sample_filea <- system.file('extdata','SAMPLE.CRA',package='DSSAT') filea <- read_filea(sample_filea) # Create example FileA file path sample_filea2 <- paste0(tempdir(),'/SAMPLE.CRA') # Write out sample FileA write_filea(filea,sample_filea2)
# Extract FileA path for sample file sample_filea <- system.file('extdata','SAMPLE.CRA',package='DSSAT') filea <- read_filea(sample_filea) # Create example FileA file path sample_filea2 <- paste0(tempdir(),'/SAMPLE.CRA') # Write out sample FileA write_filea(filea,sample_filea2)
Writes data to a single DSSAT file T
write_filet(filet, file_name, drop_duplicate_rows = TRUE)
write_filet(filet, file_name, drop_duplicate_rows = TRUE)
filet |
a tibble containing the data to write to a DSSAT file T |
file_name |
a character vector of length one that contains the name of a single DSSAT file into which 'filet' will be written |
drop_duplicate_rows |
a logical value indicating whether duplicate rows should be dropped from tier_data |
# Extract FileT path for sample file sample_filet <- system.file('extdata','SAMPLE.CRT',package='DSSAT') filet <- read_filet(sample_filet) # Create example FileT file path sample_filet2 <- paste0(tempdir(),'/SAMPLE.CRT') # Write out sample FileA write_filet(filet,sample_filet2)
# Extract FileT path for sample file sample_filet <- system.file('extdata','SAMPLE.CRT',package='DSSAT') filet <- read_filet(sample_filet) # Create example FileT file path sample_filet2 <- paste0(tempdir(),'/SAMPLE.CRT') # Write out sample FileA write_filet(filet,sample_filet2)
Writes data to a single DSSAT FileX
write_filex(filex, file_name, drop_duplicate_rows = TRUE, force_std_fmt = TRUE)
write_filex(filex, file_name, drop_duplicate_rows = TRUE, force_std_fmt = TRUE)
filex |
a list of tibbles containing the data to write to a DSSAT file X |
file_name |
a character vector of length one that contains the name of a single DSSAT file into which 'filet' will be written |
drop_duplicate_rows |
a logical value indicating whether duplicate rows should be dropped from tier_data |
force_std_fmt |
a logical value indicating whether to override the variable format stored within the FileX object with standard DSSAT formatting |
Writes soil parameters to a single DSSAT soil parameter file (*.SOL)
write_sol(sol, file_name, title = NULL, append = TRUE, force_std_fmt = TRUE)
write_sol(sol, file_name, title = NULL, append = TRUE, force_std_fmt = TRUE)
sol |
a tibble of soil profiles that have been read in by read_sol() |
file_name |
a character vector of length one that contains the name of a single DSSAT output file |
title |
a length-one character vector that contains the title of the soil file |
append |
TRUE or FALSE indicating whether soil profile should be appended to file_name. If FALSE, the soil profile will be written to a new file and will overwrite file_name (if it exists). |
force_std_fmt |
a logical value indicating whether to override the variable format stored within the FileX object with standard DSSAT formatting |
Invisibly returns NULL
# Extract file path for sample soil file sample_sol <- system.file('extdata','SAMPLE.SOL',package='DSSAT') # Read sample soil file sol <- read_sol(sample_sol) # Create example soil file path sample_sol2 <- paste0(tempdir(),'/SAMPLE.SOL') # Write example soil file write_sol(sol,sample_sol2)
# Extract file path for sample soil file sample_sol <- system.file('extdata','SAMPLE.SOL',package='DSSAT') # Read sample soil file sol <- read_sol(sample_sol) # Create example soil file path sample_sol2 <- paste0(tempdir(),'/SAMPLE.SOL') # Write example soil file write_sol(sol,sample_sol2)
Writes data from a single DSSAT data tier
write_tier( tier_data, pad_name = NULL, drop_duplicate_rows = FALSE, drop_na_rows = TRUE )
write_tier( tier_data, pad_name = NULL, drop_duplicate_rows = FALSE, drop_na_rows = TRUE )
tier_data |
a tibble containing the data to write out |
pad_name |
a character vector of column names for which to add leading spaces/trailing periods |
drop_duplicate_rows |
a logical value indicating whether duplicate rows should be dropped from tier_data |
drop_na_rows |
a logical value indicating whether rows containing all NA values should be dropped from tier_data |
a character vector
tier_data <- data.frame(TRNO=1:4,HWAM=rnorm(4,2000,250)) tier_data <- add_v_fmt(tier_data,v_fmt=c(TRNO='%6.0f', HWAM='%6.0f')) output <- write_tier(tier_data)
tier_data <- data.frame(TRNO=1:4,HWAM=rnorm(4,2000,250)) tier_data <- add_v_fmt(tier_data,v_fmt=c(TRNO='%6.0f', HWAM='%6.0f')) output <- write_tier(tier_data)
Writes data to a single DSSAT weather file
write_wth( wth, file_name, force_std_fmt = TRUE, location = NULL, comments = NULL, INSI = NULL, LAT = NULL, LONG = NULL, ELEV = NULL, TAV = NULL, AMP = NULL, REFHT = NULL, WNDHT = NULL, CO2 = NULL )
write_wth( wth, file_name, force_std_fmt = TRUE, location = NULL, comments = NULL, INSI = NULL, LAT = NULL, LONG = NULL, ELEV = NULL, TAV = NULL, AMP = NULL, REFHT = NULL, WNDHT = NULL, CO2 = NULL )
wth |
a tibble containing the data to write to a DSSAT weather file |
file_name |
a character vector of length one that contains the name of a single DSSAT file into which 'wth' will be written |
force_std_fmt |
a logical value indicating whether to override the variable format stored within the 'wth' object with standard DSSAT formatting |
location |
a character value that gives the location for the weather file header line |
comments |
a character vector containing any comments to be included in the weather file |
INSI |
Institute and site code (four-digit character code) |
LAT |
Latitude in decimal degrees |
LONG |
Longitude in decimal degrees |
ELEV |
Elevation in meters |
TAV |
Long-term average air temperature at reference height (typically 2 meters) |
AMP |
Long-term monthly air temperature amplitude at reference height (typically 2 meters) |
REFHT |
reference height for air temperature measurements |
WNDHT |
reference height for wind speed measurements |
CO2 |
carbon dioxide concentration in parts per million |