Description Usage Arguments Value Examples
Fetch or set the substance application rate [g as/ ha], julian day, sprayer volume [L liquid/ha] and fraction of sprayed quantity intercepted on the crop canopy [g as intercepted/ g as sprayed] in an imported MACRO par-file. Calculated from MACRO parameters AMIR, CONCI, IRRDAY and MASSUNITS.
1 2 3 4 5 6 7 8 9 | rmacroliteApplications(x, ...)
## S3 method for class 'macroParFile'
rmacroliteApplications(x, ...)
rmacroliteApplications( x, keep0conc = TRUE, focus_mode = "no", ... ) <- value
## S3 replacement method for class 'macroParFile'
rmacroliteApplications(x, keep0conc = TRUE, focus_mode = "no", ...) <- value
|
x |
A |
... |
Additional parameters passed to specific methods. Currently not used. |
keep0conc |
A single logical value. When equal to |
focus_mode |
A single character string. Currently, possible values are
|
value |
List with 3 or 4 named items: |
A data.frame
with 4 columns (all
numeric-values): g_as_per_ha
,
app_j_day
, f_int
and L_sprayer_per_ha
.
New value of the substance application rate [g as/ ha], the
application Julian day, fraction of the sprayed quantity
intercepted by the crop canopy [g as intercepted/
g as sprayed] and the sprayer volume [L liquid/ha].
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | library( "rmacrolite" )
# # Setup MACRO directory (if needed)
# rmacroliteSetModelVar( "C:/swash/macro" )
# ==========================================================
# Example 1: MACRO In FOCUS simulation with a single annual
# application
# ==========================================================
# Path to an example par-file
par_file_path_1appln <- system.file( "par-files",
"chat_winCer_GW-X_900gHa_d182.par",
package = "rmacrolite" )
# Import the example par-file
par_file_1appln <- rmacroliteImportParFile(
file = par_file_path_1appln )
# Fetch and inspect the current parametrization
out1 <- rmacroliteApplications( x = par_file_1appln )
unique( out1 )
# g_as_per_ha app_j_day L_sprayer_per_ha f_int
# 1 900 182 1000 0
nrow( out1 )
# [1] 26
# Copy the par-file and modify its application parameters
par_file_1appln_b <- par_file_1appln
rmacroliteApplications( x = par_file_1appln_b ) <- list(
"g_as_per_ha" = 999,
"app_j_day" = 183,
"f_int" = 0.01 )
# Check
out1b <- rmacroliteApplications( x = par_file_1appln_b )
unique( out1b )
# g_as_per_ha app_j_day L_sprayer_per_ha f_int
# 1 999 183 1000 0.01
nrow( out1b )
# [1] 26
# Use a method that re-parametrise completely the applications,
# like MACRO In FOCUS, for the same result as above
par_file_1appln_c <- par_file_1appln
rmacroliteApplications( x = par_file_1appln_c,
focus_mode = "gw" ) <- list(
"g_as_per_ha" = 999,
"app_j_day" = 183,
"f_int" = 0.01 )
# Check
out1c <- rmacroliteApplications( x = par_file_1appln_c )
# Internal control
test_1 <- identical(
as.numeric( unlist( unique( out1b ) ) ),
c( 999, 183, 1000, 0.01 ) )
if( !test_1 ){
stop( "Example 1 of rmacroliteApplications()<- failed" ) }
if( !all( all.equal( out1b, out1c, check.attributes = FALSE ) == TRUE ) ){
stop( "rmacroliteApplications() with focus_mode = 'gw' seems to have failed (1 application every year)" )
}
# Clean-up
rm( par_file_path_1appln, par_file_1appln, par_file_1appln_b,
out1, out1b, test_1, par_file_1appln_c, out1c )
# ==========================================================
# Example 2: MACRO In FOCUS simulation with two annual
# applications
# ==========================================================
# Path to the example par-file
par_file_path_2appln <- system.file( "par-files",
"chat_winCer_GW-X_2appln.par",
package = "rmacrolite" )
# Import the example par-file
par_file_2appln <- rmacroliteImportParFile(
file = par_file_path_2appln )
# Fetch and inspect the current parametrization
out2 <- rmacroliteApplications( x = par_file_2appln )
unique( out2 )
# g_as_per_ha app_j_day L_sprayer_per_ha f_int
# 1 900 182 1000 0
# 2 850 189 1000 0
nrow( out2 )
# [1] 52
# Copy the par-file and modify its application parameters
par_file_2appln_b <- par_file_2appln
rmacroliteApplications( x = par_file_2appln_b ) <- list(
"g_as_per_ha" = c( 999, 899 ),
"app_j_day" = c( 183, 190 ),
"f_int" = 0.01 )
# Check
out2b <- rmacroliteApplications( x = par_file_2appln_b )
unique( out2b )
# g_as_per_ha app_j_day L_sprayer_per_ha f_int
# 1 999 183 1000 0.01
# 2 899 190 1000 0.01
nrow( out2b )
# [1] 52
# Use a method that re-parametrise completely the applications,
# like MACRO In FOCUS, for the same result as above
par_file_2appln_c <- par_file_2appln
rmacroliteApplications( x = par_file_2appln_c,
focus_mode = "gw" ) <- list(
"g_as_per_ha" = c( 999, 899 ),
"app_j_day" = c( 183, 190 ),
"f_int" = 0.01 )
# Check
out2c <- rmacroliteApplications( x = par_file_2appln_c )
# Internal control
test_2 <- identical(
as.numeric( unlist( unique( out2b ) ) ),
c( 999, 899, 183, 190, 1000, 1000, 0.01, 0.01 ) )
if( !test_2 ){
stop( "Example 2 of rmacroliteApplications()<- failed" ) }
if( !all( all.equal( out2b, out2c, check.attributes = FALSE ) == TRUE ) ){
stop( "rmacroliteApplications() with focus_mode = 'gw' seems to have failed (2 applications every year)" )
}
# Clean-up
rm( par_file_path_2appln, par_file_2appln, par_file_2appln_b,
out2, out2b, test_2, par_file_2appln_c, out2c )
# ==========================================================
# Example 3: MACRO In FOCUS simulation with a single biennial
# application
# ==========================================================
# Path to the example par-file
par_file_path_biennial <- system.file( "par-files",
"chat_pot_GW-D_1kgHa_d119_biennial.par",
package = "rmacrolite" )
# Import the example par-file
par_file_biennial <- rmacroliteImportParFile(
file = par_file_path_biennial )
# Fetch and inspect the current parametrization
out3 <- rmacroliteApplications( x = par_file_biennial )
unique( out3 )
# g_as_per_ha app_j_day L_sprayer_per_ha f_int
# 1 1000 119 1000 0
# 2 0 1 1000 0
nrow( out3 )
# [1] 46
# Copy the par-file and modify its application parameters
par_file_biennial_c <- par_file_biennial_b <- par_file_biennial
# Variant 1: solute-free irriations are preserved
rmacroliteApplications( x = par_file_biennial_b ) <- list(
"g_as_per_ha" = 999,
"app_j_day" = 183,
"f_int" = 0.01 )
# Check
out3b <- rmacroliteApplications( x = par_file_biennial_b )
unique( out3b )
# g_as_per_ha app_j_day L_sprayer_per_ha f_int
# 1 999 183 1000 0.01
# 2 0 1 1000 0.00
nrow( out3b )
# [1] 46
# Internal control
test_3 <- identical(
as.numeric( unlist( unique( out3b ) ) ),
c( 999, 0, 183, 1, 1000, 1000, 0.01, 0.00 ) )
if( !test_3 ){
stop( "Example 3 of rmacroliteApplications()<- failed" ) }
# Variant 2: solute-free irrigations are not preserved
# like it is the case for MACRO In FOCUS with multiple years
# interval between applications
rmacroliteApplications( x = par_file_biennial_c,
keep0conc = FALSE ) <- list(
"g_as_per_ha" = c( 999, 1 ),
"app_j_day" = c( 183, 2 ),
"f_int" = c( 0.01, 0 ) )
# Check
out3c <- rmacroliteApplications( x = par_file_biennial_c )
unique( out3c )
# g_as_per_ha app_j_day L_sprayer_per_ha f_int
# 1 999 183 1000 0.01
# 2 1 2 1000 0.00
nrow( out3c )
# [1] 46
# Use a method that re-parametrise completely the applications,
# like MACRO In FOCUS, for the same result as above
par_file_biennial_d <- par_file_biennial
rmacroliteApplications( x = par_file_biennial_d,
focus_mode = "gw" ) <- list(
"g_as_per_ha" = 999,
"app_j_day" = 183,
"f_int" = 0,
"years_interval" = 2 )
# Check
out3d <- rmacroliteApplications( x = par_file_biennial_d )
# Re-run case 3b to compare it with 3d, the expected
# result from MACRO In FOCUS
rmacroliteApplications( x = par_file_biennial_b ) <- list(
"g_as_per_ha" = 999,
"app_j_day" = 183,
"f_int" = 0 )
# Check
out3b <- rmacroliteApplications( x = par_file_biennial_b )
# Internal control
test_3c <- identical(
as.numeric( unlist( unique( out3c ) ) ),
c( 999, 1, 183, 2, 1000, 1000, 0.01, 0.00 ) )
if( !test_3c ){
stop( "Example 3c of rmacroliteApplications()<- failed" ) }
if( !all( all.equal( out3b, out3d, check.attributes = FALSE ) == TRUE ) ){
stop( "rmacroliteApplications() with focus_mode = 'gw' seems to have failed (1 application every 2 years)" )
}
# Clean-up
rm( par_file_path_biennial, par_file_biennial, par_file_biennial_b,
out3, out3b, par_file_biennial_c, out3c, test_3, test_3c,
par_file_biennial_d, out3d )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.