diff --git a/scripts/output/comparison/supplycurves.R b/scripts/output/comparison/supplycurves.R index 236f5e45feb4881189f670b953a6711b42ae31c5..0ca570400a8ca4a4fe0799291122ae4dd6d59b84 100644 --- a/scripts/output/comparison/supplycurves.R +++ b/scripts/output/comparison/supplycurves.R @@ -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) diff --git a/scripts/output/single/rds_report.R b/scripts/output/single/rds_report.R index 1d02912fa00baf80f7bb637dd67a3b5f053364ec..f602fd1267c452665cae4ae285f106a8e44b6036 100644 --- a/scripts/output/single/rds_report.R +++ b/scripts/output/single/rds_report.R @@ -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) }