Commit acb0110b authored by Brage.Forland's avatar Brage.Forland

Added bash wrapper to main script. Fix bug which prevented the GBIF_*...

Added bash wrapper to main script. Fix bug which prevented the GBIF_* environmental variabled from being used.
parent 19950b36
......@@ -42,8 +42,8 @@
#' @export
#'
downloadOccupancyData <- function(speciesIDs, outFolder = paste(tempdir(), "occData", sep = "/"),
yearLimits = c(1960, Inf), GBIFUsername = Sys.getenv("GBIFUser", unset = NA),
GBIFPassword = Sys.getenv("GBIFPass", unset = NA), GBIFEmail = Sys.getenv("GBIFEmail", unset = NA),
yearLimits = c(1960, Inf), GBIFUsername = Sys.getenv("GBIF_USER", unset = NA),
GBIFPassword = Sys.getenv("GBIF_PWD", unset = NA), GBIFEmail = Sys.getenv("GBIF_EMAIL", unset = NA),
GBIFAttemptTime = 1800, maxGBIFTime = 14400, templateGrid=NULL) {
### 1.1 ==== Sanity check the function inputs ====
# Set the GBIF projection information
......@@ -126,11 +126,12 @@ downloadOccupancyData <- function(speciesIDs, outFolder = paste(tempdir(), "occD
### 1.2 ==== Create GBIF credentials ====
# Sanity check the GBIF username and password
gbifCredentials <- tryCatch(c(
as.character(GBIFUsername),
as.character(GBIFPassword),
as.character(GBIFEmail)), error = function(err) {
stop(paste("invalid entry for the GBIF credentials:", err, sep = " "))
stop(paste("invalid entry for the GBIF credentials:", err, sep = " "))
})
if(length(gbifCredentials) != 3) {
stop("invalid entry for the GBIF credentials: username, password, and email must have a length of 1")
......
......@@ -38,7 +38,7 @@ writeDistributionModelOutput <- function(fullOutputLoc, speciesInfo, climateData
modelPredictions <- as.data.frame(savedModelOutput$spatialPredictions)
curResponseCurve <- savedModelOutput$responsePredictions
inlaLogMessages <- savedModelOutput$modelObject$logfile
inlaModelSummary <- summary(savedModelOutput$modelObject$logfile)
inlaModelSummary <- summary(savedModelOutput$modelObject)
rm(savedModelOutput)
# Create response curve plots
......@@ -88,10 +88,14 @@ writeDistributionModelOutput <- function(fullOutputLoc, speciesInfo, climateData
modelPredictionsGrob <- ggplot(modelPredictions, aes(x=meanClimatePred, y=meanSpatialPred)) +
geom_point(alpha=0.33, size=0.25) +
geom_rangeframe() +
geom_abline(intercept = INLA::inla.link.logit(0.1), slope =-1, size=0.25, color='#f7fcb9') +
geom_abline(intercept = INLA::inla.link.logit(0.5), slope =-1, size=0.25, color='#addd8e') +
geom_abline(intercept = INLA::inla.link.logit(0.9), slope =-1, size=0.25, color='#31a354') +
theme_tufte()
svg(paste(fullOutputLocSp,"/", "diagnostics_effectdepend", ".svg", sep = ""), width = 5, height = 5)
grid.draw(modelPredictionsGrob)
dev.off()
ggsave(paste( fullOutputLocSp,"/", "diagnostics_effectdepend", ".png", sep = ""),width = 5, height = 5)
# svg(paste(fullOutputLocSp,"/", "diagnostics_effectdepend", ".svg", sep = ""), width = 5, height = 5)
#grid.draw(modelPredictionsGrob)
#dev.off()
sink(paste(fullOutputLocSp, "inla_logfile.txt", sep="/"))
print(inlaLogMessages)
......
#!/bin/sh
ARTSAPP_HOME=/local/home/artsapp
source ${ARTSAPP_HOME}/.gbifpass
Rscript $ARTSAPP_HOME/scripts/artsappsdm.R $*
......@@ -8,8 +8,11 @@ library(readr)
## Configuration
##
ARTSAPP_HOME = "/local/home/artsapp"
if(Sys.getenv("ARTSAPP_HOME")!="") {
ARTSAPP_HOME=Sys.getenv("ARTSAPP_HOME")
} else {
ARTSAPP_HOME=normalizePath(getwd())
}
CACHE_LOC = paste(ARTSAPP_HOME, "data/norge/occurrences.cache", sep="/")
OUTPUT_LOC = paste(ARTSAPP_HOME, "output", sep="/")
......@@ -181,10 +184,6 @@ runDownload <- function() {
speciesOccRaw <- downloadOccupancyData(taxaMissing,
tempDirectory,
yearLimits,
gbifLoginCredentials$username,
gbifLoginCredentials$password,
gbifLoginCredentials$email,
gbifAttemptTime, gbifMaxTime,
templateGrid=extentGrid)
writeOccurrences(speciesOccRaw,CACHE_LOC)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment