stanfill / apsimr Goto Github PK
View Code? Open in Web Editor NEWRunning APSIM from R
Running APSIM from R
Hi Bryan Stanfill:
Please give my best regards to you.Recently, I am doing the sensitivity analysis of APSIM model parameters, but there is a problem, I hope to get your advice. Now I have the sample file of model parameters. I need to bring these parameters into the model to get the output result, but I don't know how to implement it in code. Thank you in advance!
Hi, I have installed the APSIM 710 in my computer and when I run the examples of package apsimr in RStudio, an error accured(as the title). the information and code in follows:
library(apsimr)
apsimExe <-"C:/Program Files (x86)/Apsim710-r4203/Model/Apsim.exe"
apsimWd <- "~/APSIM"
toRun <- c("Centro.apsim", "Continuous Wheat.apsim")
results <- apsim(exe = apsimExe, wd = apsimWd, files = toRun)
Error in setwd(wd) : cannot change working directory
but if I change the work directory, and ignore the parameter of "wd",everything is fine
apsimExe <-"C:/Program Files (x86)/Apsim710-r4203/Model/Apsim.exe"
toRun <- c("Centro.apsim", "Continuous Wheat.apsim")
apsimWd<-setwd("C:/Program Files (x86)/APSIM710-r4203/Examples")
results <- apsim(exe = apsimExe, files =toRun)
#output
results
$Centro
Date year day DaysAfterSowing biomass green_biomass stover_wt yield lai esw_layr.. root_depth
2 1989-03-20 1989 79 179 9212.5 5675.2 829.84 914.1 0 43.787 1499.976
3 1990-03-18 1990 77 177 11626.4 7463.2 1046.64 1160.0 0 11.990 1499.991
$Continuous Wheat
Date biomass yield grain_protein grain_size esw
2 1942-10-11 9545.8 3583.2 16.417 0.041 326.700
3 1943-10-29 13445.1 5040.1 16.448 0.033 266.912
4 1945-10-22 12805.3 4887.7 16.078 0.041 286.493
5 1947-10-24 14758.1 5800.6 13.786 0.041 323.269
6 1948-10-29 13575.9 4329.3 10.896 0.029 294.760
7 1949-10-26 13677.3 4662.1 11.348 0.032 393.612
8 1950-10-12 5477.1 2037.9 16.443 0.041 537.431
the error accured again:
meanYield<-function(x){
return(mean(x$lai_cowpea))
}
n <- 75
parValues <- data.frame(SoilCN = runif(n, 5, 25),
DiffusConst = runif(n, 20, 50), CNCov = runif(n, 0, 1))
apsimExe <-"C:/Program Files (x86)/Apsim75-r3008/Model/Apsim.exe"
apsimWd <- "~/APSIM"
apsimVars <- c("SoilOrganicMatter/SoilCN", "SoilWater/DiffusConst", "SoilWater/CNCov")
apsimWd<-setwd("C:/Program Files (x86)/APSIM710-r4203/Examples")
apsimFile <- "Canopy.apsim"
emulRes <- apsim_emul_sa(model = apsim_vector, X = parValues, method = "singleGAM",
exe = apsimExe, wd=apsimWd, vars = apsimVars, to.run = apsimFile,
g = meanYield, overwrite = TRUE)
Error in apsim(exe = exe, wd = wd, files = to.run) :
An error occured when trying to run APSIM. Please check your arguments again, especially the path to APSIM.exe.
any idear about this? thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.