title: 'Ecosystem models review' output: html_document: default


knitr::opts_chunk$set(collapse = TRUE)
devtools::load_all()

required_pkg <- c(
  "RCurl", "XML", "plyr"
)

pkg_to_install <- required_pkg[!(required_pkg %in%
  installed.packages()[, "Package"])]
if (length(pkg_to_install)) install.packages(pkg_to_install, repos = "http://cran.us.r-project.org")

invisible(lapply(required_pkg, library, character.only = TRUE))

1. Ecopath with Ecosim (EwE) models

# To get a list of available EwE models and to get the input and output values for selected models
# The source code is from the EcoBase (a database of Ecopath with Ecosim models) website: http://ecobase.ecopath.org/#docs

# To get a list of available EwE models -----------------------------------

call_back_function <- basicTextGatherer()
invisible(curlPerform(url = "http://sirs.agrocampus-ouest.fr/EcoBase/php/webser/soap-client_3.php", writefunction = call_back_function$update))

data <- xmlTreeParse(call_back_function$value(), useInternalNodes = TRUE)
model_list <- ldply(xmlToList(data), data.frame)
model_info <- data.frame(matrix(unlist(model_list), ncol=length(model_list), byrow=FALSE))
names(model_info) <- names(model_list)

# Model information -------------------------------------------------------
# names(model_info)
# model_info$model.model_name
# 
# sort(unique(model_info$model.country)) # "United States", "united States of America", "United States of America"
# 
# unique(model_info$model.ecosim) # "false", "true",  NA
# 
# unique(model_info$model.fisheries) # "false", "true",  NA

# model numbers: U.S. models, use EcoSim, model fisheries
model_id <- (model_info$model.country %in% c("United States", "united States of America", "United States of America")) &
  (model_info$model.ecosim %in% c("true", NA)) &
  (model_info$model.fisheries %in% c("true", NA))

us_model <- model_info[model_id, ]

model_number <- as.numeric(us_model$model.model_number)

# General ecosystem information table
col_names <- c("model.model_number", "model.model_name", "model.country", "model.ecosystem_type", "model.num_group", "model.model_year", "model.model_period")
knitr::kable(us_model[, col_names], caption = "Table 1. Ecosystem information of available EwE models.", row.names = FALSE)

# General model information table
col_names <- c("model.model_number", "model.model_name", "model.ecosim", "model.ecospace", "model.whole_food_web", "model.fisheries", "model.aquaculture", "model.environment_variability", "model.ecosyst_functioning", "model.pollution", "model.dissemination_allow", "model.is_fitted", "model.other_impact_assessment")
knitr::kable(us_model[, col_names], caption = "Table 2. Model information of available EwE models.", row.names = FALSE)

# General contact information table
col_names <- c("model.model_number", "model.model_name", "model.author", "model.contact", "model.reference", "model.url", "model.doi")
knitr::kable(us_model[, col_names], caption = "Table 3. Conatact information of available EwE models.", row.names = FALSE)

# us_model$model.model_name
# To get input and output values for selected models ---------------------------------
# model_io <- list()
# 
# for (i in seq_along(model_number)){
#   call_back_function <- basicTextGatherer()
# 
#   curlPerform(url = paste("http://sirs.agrocampus-ouest.fr/EcoBase/php/webser/soap-client.php?no_model=", model_number[i], sep = ""), writefunction = call_back_function$update, verbose = TRUE)
# 
#   model_data <- xmlTreeParse(call_back_function$value(), useInternalNodes = TRUE)
# 
#   model_io[[i]] <- list(
#     input = xpathSApply(model_data, "//group", function(x) xmlToList(x)),
#     output = xpathSApply(model_data,'//group',function(x) xmlToList(x))
#   )
# }

2. Atlantis models



Bai-Li-NOAA/IFA4EBFM documentation built on April 21, 2024, 7:58 p.m.