Skip to content
Snippets Groups Projects
Unverified Commit 998771da authored by Lavinia Baumstark's avatar Lavinia Baumstark Committed by GitHub
Browse files

Merge pull request #143 from dklein-pik/develop

Little fixes to output scripts
parents 40bcec59 d5b2043f
No related branches found
No related tags found
No related merge requests found
......@@ -14,22 +14,23 @@ x <- readSupplycurveBio(outputdirs)
years <- getYears(x$supplycurve)
years <- years[years>="y2005" & years<="y2100"]
years <- "y2080"
#years <- "y2080"
regions <- sort(getRegions(x$supplycurve))
out<-swopen(template="david")
title <- paste0(years)
dat <- gginput(x$supplycurve[regions,years,],scatter="type")
for (year in years) {
title <- paste0(year)
dat <- gginput(x$supplycurve[regions,year,],scatter="type")
dat$year<-factor(dat$year)
p <- ggplot(dat, aes(x=.value.x,y=.value.y)) +
geom_line(aes(colour=scenario, linetype=curve)) + #geom_line(size=0.5) +
geom_point(data=gginput(x$rem_point[regions,years,],scatter = "variable"),aes(x=.value.x,y=.value.y,colour=scenario)) +
geom_point(data=gginput(x$mag_point[regions,years,],scatter = "variable"),aes(x=.value.x,y=.value.y,colour=scenario),shape=5) +
geom_point(data=gginput(x$rem_point[regions,year,],scatter = "variable"),aes(x=.value.x,y=.value.y,colour=scenario)) +
geom_point(data=gginput(x$mag_point[regions,year,],scatter = "variable"),aes(x=.value.x,y=.value.y,colour=scenario),shape=5) +
facet_wrap(~region) +
ggtitle(title) + ylab("$/GJ") + xlab("EJ") + coord_cartesian(xlim=c(0,80),ylim=c(0,30))
swfigure(out,print,p,sw_option="height=9,width=12")
}
swclose(out,outfile=paste0("supplycurves.pdf"),clean_output=TRUE,save_stream=FALSE)
......@@ -41,11 +41,21 @@ saveRDS(q,file=rds)
if(file.exists(runstatistics) & dir.exists(resultsarchive)) {
stats <- list()
load(runstatistics)
if(!is.null(stats$id)) {
saveRDS(q,file=paste0(resultsarchive,"/",stats$id,".rds"))
cwd <- getwd()
setwd(resultsarchive)
system("ls 1*.rds > files")
setwd(cwd)
if(is.null(stats$id)) {
# create an id if it does not exist (which means that statistics have not
# been saved to the archive before) and save statistics to the archive
message("No id found in runstatistics.rda. Calling lucode::runstatistics() to create one.")
stats <- lucode::runstatistics(file = runstatistics, submit = cfg$runstatistics)
message("Created the id ",stats$id)
# save stats locally (including id) otherwise it would generate a new id (and
# resubmit the results and the statistics) next time rds_report is executed
save(stats, file=runstatistics, compress="xz")
}
# Save report to results archive
saveRDS(q,file=paste0(resultsarchive,"/",stats$id,".rds"))
cwd <- getwd()
setwd(resultsarchive)
system("ls 1*.rds > files")
setwd(cwd)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment