rmacroliteInfo-methods: Fetch or set the INFORMATION section at the end of an...

Description Usage Arguments Value Examples

Description

Fetch or set the INFORMATION section at the end of an imported MACRO par-file. Only relevant for par-files produced by MACRO In FOCUS.

Usage

1
2
3
4
5
6
7
8
9
rmacroliteInfo(x, ...)

## S3 method for class 'macroParFile'
rmacroliteInfo(x, ...)

rmacroliteInfo( x, warn = TRUE, ... ) <- value

## S3 replacement method for class 'macroParFile'
rmacroliteInfo(x, warn = TRUE, ...) <- value

Arguments

x

A macroParFile, as imported with rmacroliteImportParFile-methods, and preferably produced by MACRO In FOCUS.

...

Additional parameters passed to specific methods. Currently not used.

warn

Single logical value. If TRUE, a warning is raised whenever x does not contain an information section. If FALSE, the function proceeds silently. Only relevant when setting new information.

value

A named list of character strings or integer. It should contain the items "output_file", "type" and "compound" (each of these being a single character string), and optionally "years_interval" (a single integer). Name and path of the output file, type of simulation ("parent"; "parent, intermediate", "metabolite" or "metabolite, intermediate"), name of the compound parametrised in the par-file, and number of years in between application-years (1 for application(s) every year, 2 for application(s) every other year and 3 for application(s) every thord year), respectively.

Value

Vector of character strings named "output_file", "type" and "compound". Name and path of the output file, type of simulation ("parent"; "parent, intermediate", "metabolite" or "metabolite, intermediate") and name of the compound parametrised in the par-file, respectively

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
library( "rmacrolite" ) 

# # Setup MACRO directory (if needed)
# rmacroliteSetModelVar( "C:/swash/macro" )



#   Path to an example par-file
par_file_path <- system.file( "par-files", 
    "chat_winCer_GW-X_900gHa_d182.par", 
    package = "rmacrolite" ) 

#   Import the example par-file
par_file <- rmacroliteImportParFile( 
    file = par_file_path ) 



#   Fetch the current information
#   Note: will only work on MACRO In FOCUS par-files
rmacroliteInfo( x = par_file ) 

                         # output_file 
    # "C:\\swash\\macro\\macro001.bin" 
                                # type 
                            # "parent" 
                            # compound 
                              # "GW-X"

#   Modify the parameter
par_file2 <- par_file

new_info <- list( 
    "output_file" = "C:/path/to/macro002.bin", 
    "type"        = "metabolite", 
    "compound"    = "GW-Z" )

rmacroliteInfo( x = par_file2 ) <- new_info 

#   NOTE: Only the meta-information are changed, not the 
#         actual parameters, so the example above is 
#         pointless.

#   Check the result
info <- rmacroliteInfo( x = par_file2 )
info 

if( !identical( unlist( new_info ), info ) ){
    stop( "Test of rmacroliteInfo() failed" ) }

#   Clean-up
rm( par_file_path, par_file, par_file2, info, new_info  )

julienmoeys/rmacrolite documentation built on May 22, 2019, 6:31 p.m.