apsiminitiative / apsimwheatphenology Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Hi! I've been studying APSIM model for one year! But i don't know how to establish the relationship between R language and APSIM model. librarying the Rapsim package with R which is enough.how to prepare those simFiles, simFolders, simSuffix and osbfile ? where are the tutorials? and the code as follow is for Comparing simulated and measured values? Please take time out of your busy schedule to answer my questions. Have a nice day !!!
install.packages("devtools")
devtools::install_github("byzheng/rapsim")
force = TRUE
library(rapsim)
RApsim <- function(
para = NULL,
obsFile = NULL,
simFiles = NULL,
simFolders = NULL,
simSuffix = "outputfile_daily",
xvar = "DaysAfterSowing", ... )
{
para <- setpara( p = para, ... )
if ( !is.null( para$outputPrefix ) && ( right( para$outputPrefix ) == "/" | right( para$outputPrefix ) == "\" ) )
{
dir.create( para$outputPrefix, showWarnings = FALSE )
}
sim <- readsim( simFiles, simFolders, simSuffix )
obs <- readobs( obsFile )
sim.obs <- combineObsSim( obs, sim,
para$variables,
para$identifiers,
para$isOutputObsData )
all.plots <- NULL
all.plots[[length( all.plots ) + 1]] <-
plotObsSimCompare( sim.obs, para$identifiers, para$variables )
com.plots <- NULL
if ( !is.null( sim.obs[[xvar]] ) & xvar %in% para$identifiers$sim )
{
xlab <- "Days After Sowing (d)"
com.plots <- plotGraphCombinations( sim.obs,
graph.combinations = para$graph.combinations,
identifiers = para$identifiers,
variables = para$variables,
xvar = xvar,
isOutputObsData = para$isOutputObsData )
plots.num <- length( all.plots )
for ( i in 1:length( com.plots ) )
{
plots.num <- plots.num + 1
all.plots[[plots.num]] <- com.plots[[i]]
}
}
filename <- NULL
if ( para$outputPrefix == "" )
{
filename <- paste( "graph.simul-observed", ".", para$outputFormat, sep = "" )
}
else
{
filename <- paste( para$outputPrefix, ".", "graph.simul-observed", ".", para$outputFormat, sep = "" )
}
if ( para$outputFormat == "pdf" )
{
pdf( filename, paper = "a4", width = 8, height = 11, onefile = TRUE )
for ( i in 1:length( all.plots ) )
{
print( all.plots[[i]] )
}
dev.off()
}
}
library(APSIMWheatPhenology)
met <- system.file("extdata/weather.met", package = "APSIMWheatPhenology")
sim <- system.file("extdata/example.sim", package = "APSIMWheatPhenology")
df <- wheatPhenology(sim, stages = 6, stageNames = 'flow', model = 'APSIM',
met = met, daily = FALSE)
#> Error: 'wcal' is not an exported object from 'namespace:weaana'
Created on 2022-02-20 by the reprex package (v2.0.1)
sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Latin America.1252
[2] LC_CTYPE=Spanish_Latin America.1252
[3] LC_MONETARY=Spanish_Latin America.1252
[4] LC_NUMERIC=C
[5] LC_TIME=Spanish_Latin America.1252
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
Hi Teacher Zheng
When I ran the apsimx example , I encountered the following problem(About the path):
library(ApsimOnR)
library(CroptimizR)
library(dplyr)
library(nloptr)
library(DiceDesign)
start_time <- Sys.time()
simulation_name <- "GattonRowSpacingRowSpace25cm"
variable_names=c("Wheat.Leaf.LAI")
apsimx_path="/usr/local/bin/Models" (In this here,I need to fill in the APSIM next generation installation path)
apsimx_path <- 'D:\Program Files\APSIMNG\Bin\Apsimx.exe' This is my Apsim NG installation path,but it's wrong
Error in system(cmd, wait = TRUE, intern = TRUE) : 'D:\Program' not found
Thank you in advance
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.