Skip to content
ken edited this page May 24, 2017 · 7 revisions

Welcome to GRAPLEr!

GRAPLEr brings the power of distributing computing to the fingertips of lake ecology modelers. It is a Web Service that allows you to submit batches of GLM (General Lake Model) simulations to a distributed computing system, directly from your R/Rstudio environment.

GRAPLEr has been developed as a collaboration between researchers in PRAGMA and GLEON, with support from a supplement the the PRAGMA award (NSF OCI-1234983). For additional information, contact Renato Figueiredo (renato at acis.ufl.edu), Cayelan Carey (cayelan at vt.edu) or Paul Hanson (pchanson at wisc.edu)

You can use the following commands to get started using GRAPLEr in your R environment; these are an excerpt from a project EDDIE module used in a workshop at GLEON17

Install glmtools:

install.packages('glmtools', repos=c('http://cran.rstudio.com', 'http://owi.usgs.gov/R'))
library(glmtools)
library(GLMr)

Install GRAPLEr:

install.packages("devtools")
library("devtools")
devtools::install_github("GRAPLE/GRAPLEr") 
library(httr)
library(RCurl)
library(jsonlite)
library("GrapleR")

Copy a template file that comes with glmtools to a simulation directory:

nml_template_path() 
# this should give you a path that tells you where the example GLM nml file is. E.g.:
# "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/GLMr/extdata/glm2.nml"
# copy glm2.nml, met_hourly.csv to another folder, e.g. "/Users/yourname/Desktop/GRAPLEr"

Connect to the GRAPLEr Web service:

graple <- new("Graple")
cat(graple@StatusMsg)
graple <- GrapleListPostProcessFilters(graple)
cat(graple@StatusMsg)
graple <- GrapleChkVersionCompatibility(graple)
cat(graple@StatusMsg)
# Each "cat" instruction prints the status of the preceding call.

Configure a test batch of 100 simulations to send to GRAPLEr (replace the sim_folder path to your computer's path)

grapleExp1 <- new("Graple", ExpRootDir = "GRAPLE/ExpRoot/Exp1", ResultsDir = "GRAPLE/Results/Exp1", TempDir = tempdir())
grapleExp1 <- setExpName(grapleExp1, "BatchExperiment1")

Start the simulations:

grapleExp1 <- GrapleRunExperiment(grapleExp1);
cat(grapleExp1@StatusMsg)

Check their status; repeat until the command returns a message that they are completed:

grapleExp1 <- GrapleCheckExperimentCompletion(grapleExp1)
while (grapleExp1@StatusMsg != '100.0% complete') {
  Sys.sleep(5);
  grapleExp1 <- GrapleCheckExperimentCompletion(grapleExp1) 
  cat(grapleExp1@StatusMsg);
}

Once complete, download results:

grapleExp1 <- GrapleGetExperimentResults(grapleExp1);
cat(grapleExp1@StatusMsg);

Plot two sample outputs:

sim_folder_1<-paste(sim_folder,sep='/','Sims','Sim1','Results')
sim_folder_101<-paste(sim_folder,sep='/','Sims','Sim100','Results')
nc_file_1 <- file.path(sim_folder_1, 'output.nc')
nc_file_101 <- file.path(sim_folder_101, 'output.nc')
plot_temp(file=nc_file_1, fig_path=FALSE)
plot_temp(file=nc_file_101, fig_path=FALSE)