source('~/WorkFolder/RCoding/MetricsPaperCode/FullSensitivityESD.R')
source('~/WorkFolder/RCoding/MetricsPaperCode/FullSensitivityESD.R')
source('~/WorkFolder/RCoding/MetricsPaperCode/FullSensitivityESD.R')
head sensitivityframe
head(sensitivityframe)
source('~/WorkFolder/RCoding/MetricsPaperCode/CentralParameters.R')
source('~/WorkFolder/RCoding/MetricsPaperCode/CentralParameters.R')
source('~/WorkFolder/RCoding/MetricsPaperCode/CentralParameters.R')
source('~/WorkFolder/RCoding/MetricsPaperCode/nonCO2ESD.R', encoding = 'UTF-8')
source('~/WorkFolder/RCoding/MetricsPaperCode/nonCO2ESD.R', encoding = 'UTF-8')
source('~/WorkFolder/RCoding/MetricsPaperCode/GWPtimescalecalc.R')
ggplot(GWPplusone)+geom_line(aes(x=discount,y=GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
coord_cartesian(ylim=c(0,200))
ggplot(GWPplusone)+geom_line(aes(x=discount,y=GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+coord_flip(ylim=c(0,200))
ggplot(GWPplusone)+geom_line(aes(x=discount,y=GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
coord_cartesian(ylim=c(0,200))
source('~/WorkFolder/RCoding/MetricsPaperCode/FullSensitivityESD.R')
ggplot(GWPplusone)+geom_line(aes(x=discount,y=GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
coord_cartesian(ylim=c(0,200))
GWProotvector <- vector()
ratiovector <- vector()
tempvar <- 1
#solve for GWP year lengths equal to the breakpoints for the secondary axis:
breaklist <- c(200,100,60,40,30,20)
for (iter in breaklist)
{
ratiovector[tempvar] <- calcGWP(iter, co2emission, ch4emission, constantco2, constantch4, constantn2o)
GWProotvector[tempvar] <- iter
tempvar <- tempvar + 1
}
#fifth order polynomial fit yields exact values for 6 breakpoints.
fit4 <- lm(GWProotvector~poly(ratiovector,5,raw=TRUE))
GWPfit <- function(ratioinput)
{
coefs <- coef(fit4)
result <- coefs[1]+(coefs[2]*ratioinput)+
(coefs[3]*ratioinput^2)+(coefs[4]*ratioinput^3)+
(coefs[5]*ratioinput^4)+(coefs[6]*ratioinput^5)
return(result)
}
#change data format for use in ggplot:
#resultmelt <- melt(resultframe, id ="discountvector")
ytitle <- expression(CH[4]~to~CO[2]~ratio)
myplot <- ggplot(GWPplusone)+geom_line(aes(x=discountvector, y = GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
labs(title=titlename,x="Discount Rate", y=ytitle)+
theme(legend.title=element_blank(), legend.justification=c(0,1), legend.position=c(0,1))+
scale_colour_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
scale_shape_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
coord_cartesian(ylim=c(0,200))
#used to be 5,95: maybe because we can't do 0?
#need to use a GWPfit because the program can't handle using calcGWProot directly.
secaxisplot[[length(secaxisplot)+1]] <- myplot +
scale_y_continuous(breaks=c(10,30,50,70,90), sec.axis =
sec_axis(~GWPfit(.),name="equivalent GWP year length",breaks=breaklist))
#ggsave(secaxisplot, file = args[2], width = 4, height = 4)
myplot <- ggplot(GWPplusone)+geom_line(aes(x=discountvector, y = GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
labs(title="GWP and damage ratio",x="Discount Rate", y=ytitle)+
theme(legend.title=element_blank(), legend.justification=c(0,1), legend.position=c(0,1))+
scale_colour_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
scale_shape_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
coord_cartesian(ylim=c(0,200))
myplot
myplot <- ggplot(GWPplusone)+geom_line(aes(x=discountvector, y = GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
labs(title="GWP and damage ratio",x="Discount Rate", y=ytitle)+
theme(legend.title=element_blank(), legend.justification=c(0,1), legend.position=c(0,1))+
scale_colour_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
scale_shape_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
coord_cartesian(ylim=c(5,95))
myplot
myplot <- ggplot(GWPplusone)+geom_line(aes(x=discount, y = GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
labs(title="GWP and damage ratio",x="Discount Rate", y=ytitle)+
theme(legend.title=element_blank(), legend.justification=c(0,1), legend.position=c(0,1))+
scale_colour_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
scale_shape_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
coord_cartesian(ylim=c(5,95))
myplot
myplot <- ggplot(GWPplusone)+geom_line(aes(x=discount, y = GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
labs(title="GWP and damage ratio",x="Discount Rate", y=ytitle)+
theme(legend.title=element_blank(), legend.justification=c(0,1), legend.position=c(0,1))+
scale_colour_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
scale_shape_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
coord_cartesian(ylim=c(0,200))
myplot
secaxisplot[[length(secaxisplot)+1]] <- myplot +
scale_y_continuous(breaks=c(10,30,50,70,90), sec.axis =
sec_axis(~GWPfit(.),name="equivalent GWP year length",breaks=breaklist))
secaxisplot <- myplot +  scale_y_continuous(breaks=c(10,30,50,70,90), sec.axis =
sec_axis(~GWPfit(.),name="equivalent GWP year length",breaks=breaklist))
secaxisplot
myplot <- ggplot(GWPplusone)+geom_line(aes(x=discount, y = GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
labs(title="GWP and damage ratio",x="Discount Rate", y=ytitle)+
theme(legend.title=element_blank(), legend.justification=c(0,1), legend.position=c(0,1))+
scale_colour_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
scale_shape_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
coord_cartesian(ylim=c(0,95))
#used to be 5,95: maybe because we can't do 0?
#need to use a GWPfit because the program can't handle using calcGWProot directly.
secaxisplot <- myplot +  scale_y_continuous(breaks=c(10,30,50,70,90), sec.axis =
sec_axis(~GWPfit(.),name="equivalent GWP year length",breaks=breaklist))
secaxisplot
ggplot(GWPplusone)+geom_line(aes(x=discount,y=GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
coord_cartesian(ylim=c(0,200))+labs(title="equivalent GWP by discount rate",x="Discount Rate", y="equivalent GWP year length")
#flipping axes:
ratioplusone <- as.data.frame(cbind(discountquant, discountlist))
ytitle <- expression(CH[4]~to~CO[2]~ratio)
myplot <- ggplot(ratioplusone)+geom_line(aes(x=discount, y = GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
labs(title="GWP and damage ratio",x="Discount Rate", y=ytitle)+
theme(legend.title=element_blank(), legend.justification=c(0,1), legend.position=c(0,1))+
scale_colour_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
scale_shape_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
coord_cartesian(ylim=c(0,95))
#used to be 5,95: maybe because we can't do 0?
#need to use a GWPfit because the program can't handle using calcGWProot directly.
secaxisplot <- myplot +  scale_y_continuous(breaks=c(10,30,50,70,90), sec.axis =
sec_axis(~GWPfit(.),name="equivalent GWP year length",breaks=breaklist))
secaxisplot
ratioplusone <- as.data.frame(cbind(discountquant, discountlist))
colnames(ratioplusone) <- c("GWPmin", "GWP10", "GWP25", "GWPmed", "GWP75", "GWP90", "GWPmax","discount")
ytitle <- expression(CH[4]~to~CO[2]~ratio)
myplot <- ggplot(ratioplusone)+geom_line(aes(x=discount, y = GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
labs(title="GWP and damage ratio",x="Discount Rate", y=ytitle)+
theme(legend.title=element_blank(), legend.justification=c(0,1), legend.position=c(0,1))+
scale_colour_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
scale_shape_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
coord_cartesian(ylim=c(0,95))
#used to be 5,95: maybe because we can't do 0?
#need to use a GWPfit because the program can't handle using calcGWProot directly.
secaxisplot <- myplot +  scale_y_continuous(breaks=c(10,30,50,70,90), sec.axis =
sec_axis(~GWPfit(.),name="equivalent GWP year length",breaks=breaklist))
secaxisplot
ggsave("results/doubleaxis.pdf", plot = secaxisplot, device = cairo_pdf, width = 6.4, height = 6.4, units = "cm", dpi = 600)
fig2 <- ggplot(GWPplusone)+geom_line(aes(x=discount,y=GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
coord_cartesian(ylim=c(0,200))+labs(title="equivalent GWP by discount rate",x="Discount Rate", y="equivalent GWP year length")
ggsave("results/fig2dummy.pdf", plot = fig2, device = cairo_pdf, width = 6.4, height = 6.4, units = "cm", dpi = 600)
#flipping axes:
fig2
ggplot(GWPplusone)+geom_line(aes(x=discount,y=GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+coord_flip(ylim=c(0,200))
ggplot(GWPplusone)+geom_line(aes(x=discount,y=GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+coord_flip(ylim=c(0,200))+
labs(title="discount rate by GWP",y="Discount Rate", x="equivalent GWP year length")
ggplot(GWPplusone)+geom_line(aes(x=discount,y=GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+coord_flip(ylim=c(0,200))+
labs(title="discount rate by GWP",x="equivalent GWP year length",y="Discount Rate")
ggplot(GWPplusone)+geom_line(aes(x=discount,y=GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+coord_flip(ylim=c(0,200))+
labs(title="discount rate by GWP",y="equivalent GWP year length",x="Discount Rate")
secaxisplot
myplot <- ggplot(ratioplusone)+geom_line(aes(x=discount, y = GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
labs(title="GWP and damage ratio",x="Discount Rate", y=ytitle)+
theme(legend.title=element_blank(), legend.justification=c(0,1), legend.position=c(0,1))+
scale_colour_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
scale_shape_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
coord_cartesian(ylim=c(0,100))
secaxisplot <- myplot +  scale_y_continuous(breaks=c(10,30,50,70,90), sec.axis =
sec_axis(~GWPfit(.),name="equivalent GWP year length",breaks=breaklist))
secaxisplot
myplot <- ggplot(ratioplusone)+geom_line(aes(x=discount, y = GWP25))+geom_line(aes(x=discount,y=GWPmed))+
geom_line(aes(x=discount,y=GWP75))+geom_line(aes(x=discount,y=GWP10))+geom_line(aes(x=discount,y=GWP90))+
labs(title="GWP and damage ratio",x="Discount Rate", y=ytitle)+
theme(legend.title=element_blank(), legend.justification=c(0,1), legend.position=c(0,1))+
scale_colour_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
scale_shape_discrete(labels=c("integrated radiative forcing","integrated temperature","tempsquare"))+
coord_cartesian(ylim=c(5,95))
#need to use a GWPfit because the program can't handle using calcGWProot directly.
secaxisplot <- myplot +  scale_y_continuous(breaks=c(10,30,50,70,90), sec.axis =
sec_axis(~GWPfit(.),name="equivalent GWP year length",breaks=breaklist))
secaxisplot
ggsave("results/doubleaxis.pdf", plot = secaxisplot, device = cairo_pdf, width = 6.4, height = 6.4, units = "cm", dpi = 600)
source('~/WorkFolder/RCoding/MetricsPaperCode/CentralParameters.R')
source('~/WorkFolder/RCoding/MetricsPaperCode/CentralParameters.R')
source('~/WorkFolder/RCoding/MetricsPaperCode/CentralParameters.R')
source('~/WorkFolder/RCoding/MetricsPaperCode/CentralParameters.R')
source('~/WorkFolder/RCoding/MetricsPaperCode/CentralParameters.R')
source('~/WorkFolder/RCoding/MetricsPaperCode/nonCO2ESD.R')
source('~/WorkFolder/RCoding/MetricsPaperCode/GWPtimescalecalc.R')
