The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
R package to interact with the modeling framework Simplace
This package provides methods to interact with the modelling
framework Simplace -
Scientific
Impact assessment and
Modelling
PLatform for
Advanced
Crop and
Ecosystem management.
See www.simplace.net for more
information on Simplace. Simplace is written in Java (and some parts in
Scala) so one can access it from R
via rJava
.
The purpose of this package is to simplify the interaction between R and
Simplace, by providing functions to:
For installing Simplace, please consult the webpage www.simplace.net.
A brief guide to install Simplace:
simplace
package in R:install.packages('simplace')
The most recent development version can be installed from github:
::install_github("gk-crop/simplace_rpkg") devtools
If you encounter errors, make sure to install the packages
devtools
and rJava
.
The usage of Simplace in R follows roughly this scheme:
data.frame
,
list
etc.)rJava
should be installed automatically with
simplace
. If not, install it manually:install.packages('rJava')
simplace_core
,
simplace_modules
and optionally simplace_run
are in a common directory and set the installation dir to this
directory.library(simplace)
<- findSimplaceInstallations()
SimplaceInstallationDir
<- paste(SimplaceInstallationDir,
Solution "simplace_run/simulation/gk/solution/complete/Complete.sol.xml",sep="")
<- initSimplace(SimplaceInstallationDir)
simplace
openProject(simplace, Solution)
<- list()
parameter $enddate <- "31-12-1992"
parameter
<- createSimulation(simplace,parameter)
sid runSimulations(simplace)
<- getResult(simplace,"DIAGRAM_OUT", sid);
result
closeProject(simplace)
After specifying the directories and the solution, the framework is initialized and the project opened. The end date of the simulation is (re)set and the simulation is run. After the run the result is retrieved.
<- resultToDataframe(result)
resf
<- 300:730
dates <- resf[dates,
weights c("TOP_LINE_Roots","TOP_LINE_Leaves","TOP_LINE_Stems","TOP_LINE_StorageOrgans")]
matplot(dates,weights,type="l",xlab="Days",ylab="Weight [g/m2]",main="Simulated Biomass")
legend(300,800,legend=c("Roots","Leaves","Stems","Storage Organs"),lty=1:4,col=1:4)
The result is converted to a dataframe. Interesting variables are extracted and then plotted.
<- resultToList(result,expand=TRUE)
resultlistexp <- resultlistexp$BOTTOM_ARRAY_VolumetricWaterContent
water <- do.call(rbind,water)
wmat <- wmat[dates,]
wmatpart <- dim(wmatpart)[2]
layers filled.contour(dates,-(layers:1),wmatpart[,layers:1],
xlab="Day", ylab="Layer", main="Water content in soil",
color.palette = function(n){rgb((n:1)/n,(n:1)/n,1)})
As the result contains an array which holds the water content for 40 layers, it is transformed to a list and the array is expanded.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.