Damage vector for life-cycle analysis: Difference between revisions

From Opasnet
Jump to navigation Jump to search
mNo edit summary
(→‎Formula: small adjustments)
Line 53: Line 53:
===Formula===
===Formula===


<rcode graphics="1" variables="
<rcode graphics=1>
name:limit|description:What is the smallest fraction of the total effect you want to see?|default:0.001
">


library(OpasnetUtils)
library(OpasnetUtils)
library(xtable)
library(xtable)
library(ggplot2)
library(ggplot2)
library(reshape)
library(reshape2)
 
show_bins <- 10 # How many different direct inputs to show?


# Take the damage factor table from this page.
# Take the damage factor table from this page.
Line 75: Line 75:
colnames(damagesPerImpact) <- gsub("Result.", "", colnames(damagesPerImpact)) # Remove extra "Result." from colnames.
colnames(damagesPerImpact) <- gsub("Result.", "", colnames(damagesPerImpact)) # Remove extra "Result." from colnames.
rownames(damagesPerImpact) <- damagesPerImpact[[1]] # Make the first column the rownames.
rownames(damagesPerImpact) <- damagesPerImpact[[1]] # Make the first column the rownames.
damagesPerImpact <- damagesPerImpact[ , 2:ncol(damagesPerImpact)] # Remove the first column.
damagesPerImpact[1] <- NULL # Remove the first column.
 
oprint(damagesPerImpact)
 
damagesPerImpact <- t(as.matrix(damagesPerImpact)) # Turn the data.frame into a matrix and transpose it.
damagesPerImpact <- t(as.matrix(damagesPerImpact)) # Turn the data.frame into a matrix and transpose it.


Line 90: Line 93:
colnames(impactsPerDollar) <- gsub("Result.", "", colnames(impactsPerDollar))
colnames(impactsPerDollar) <- gsub("Result.", "", colnames(impactsPerDollar))
rownames(impactsPerDollar) <- impactsPerDollar[[1]]
rownames(impactsPerDollar) <- impactsPerDollar[[1]]
impactsPerDollar <- impactsPerDollar[ , 2:ncol(impactsPerDollar)]
impactsPerDollar[1] <- NULL
 
#oprint(impactsPerDollar)
 
impactsPerDollar <- as.matrix(impactsPerDollar)
impactsPerDollar <- as.matrix(impactsPerDollar)


Line 96: Line 102:


coffee <- opbase.data("Op_en5902.coffeecupinputs") # Download the data from Opasnet Base.
coffee <- opbase.data("Op_en5902.coffeecupinputs") # Download the data from Opasnet Base.
coffee <- coffee[ , colnames(coffee) != "Obs"] # Remove the redundant Obs column.
coffee$Obs <- NULL # Remove the redundant Obs column.


cat("Primary prosesses related to a cup of coffee (in Euro)\n")
cat("Primary prosesses related to a cup of coffee (in Euro)\n")


print(xtable(coffee), type = 'html')
oprint(coffee)
 
# Combine the direct requirements of a coffee cup with a full vector of requirements and fill empty cells with 0.
# Combine the direct requirements of a coffee cup with a full vector of requirements and fill empty cells with 0.


coffee <- merge(data.frame(directRequirements = rownames(impactsPerDollar)), coffee, all.x = TRUE)
coffee <- merge(data.frame(directRequirements = rownames(impactsPerDollar)), coffee, all.x = TRUE)
coffee$Result <- ifelse(is.na(coffee$Result), 0, coffee$Result)
coffee$Result[is.na(coffee$Result)] <- 0


# Get the normalisation data for different damages and make an ovariable out of it.
# Get the normalisation data for different damages and make an ovariable out of it.


temp <- tidy(opbase.data("Op_en5904"), objname="normalisation")
# temp <- tidy(opbase.data("Op_en5904"), objname="normalisation")
temp <- temp[ , colnames(temp) != "Obs"]
temp <- opbase.data("Op_en5904")
temp$Obs <- NULL


normalisation <- EvalOutput(new("ovariable",  
normalisation <- EvalOutput(new("ovariable",  
Line 116: Line 122:
data = temp
data = temp
))
))
oprint(normalisation@data)


impactsPerDollar <- impactsPerDollar * coffee$Result # Multiply data matrix with activities.
impactsPerDollar <- impactsPerDollar * coffee$Result # Multiply data matrix with activities.
Line 127: Line 135:
out$directRequirements <- rownames(out)
out$directRequirements <- rownames(out)
out <- melt(out, idvars = "directRequirements", variable_name = "damages") # Reshape into long format
out <- melt(out, idvars = "directRequirements", variable_name = "damages") # Reshape into long format
out <- out[out$value >= sum(out$value) * limit , ] # Remove all rows with smaller values than the limit.
 
sums <- as.data.frame(as.table(tapply(out$value, out["directRequirements"], sum)))
limit <- sort(sums$Freq, decreasing = TRUE)[show_bins]
keeps <- sums[sums$Freq > limit , "directRequirements"]
 
out$directRequirements <- as.factor(ifelse(out$directRequirements %in% keeps, out$directRequirements, "Other"))
 
#out <- out[out$value >= sum(out$value) * limit , ] # Remove all rows with smaller values than the limit.
out <- dropall(out)  
out <- dropall(out)  
# Alternative approach: very small values of B are merged to "Other" category in A: temp$A  as.factor(ifelse(temp$B <= 6, "Other", temp$A))


# Rename the columns to reflect actual things.
# Rename the columns to reflect actual things.
Line 142: Line 158:
cat("Effects smaller than", limit*100, "% of the total effect are not shown.\n")
cat("Effects smaller than", limit*100, "% of the total effect are not shown.\n")


ggplot(damageFractions@output, aes(x = damages, weight = Result, fill = directRequirements)) + geom_bar() +
#oprint(damageFractions)
 
ggplot(damageFractions@output, aes(x = Damage, weight = Result, fill = directRequirements)) + geom_bar() +
theme_grey(base_size = 24) +
theme_grey(base_size = 24) +
theme(axis.text.x = element_text(angle = 45)) +
theme(axis.text.x = element_text(angle = 45)) +

Revision as of 21:19, 23 December 2013



Question

What are the damages per unit purchased commodity using a life-cycle assessment?

Answer

Rationale

Dependencies

Data

damagefactors(-)
ObsUnique_categoriesHuman healthEcosystem qualityClimate changeResourcesWater consumption
1Carcinogens0.00000280000
2Non-carcinogens0.00000280000
3Respiratory inorganics0.00070000
4Ionizing radiation0.000000000210000
5Ozone layer depletion0.001050000
6Respiratory organics0.000002130000
7Aquatic ecotoxicity00.0000502000
8Terrestrial ecotoxicity00.00791000
9Terrestrial acidification/nutrification01.04000
10Land occupation01.09000
11Aquatic acidification00000
12Aquatic eutrophication00000
13Global warming00100
14Non-renewable energy00010
15Mineral extraction00010
16Water withdrawal00000
17Water consumption00001

Example of coffee cup

coffeecupinputs(Euro)
ObsdirectRequirementsResult
131131A - Sugar cane mills and refining0.1
2112120 - Dairy cattle and milk production0.2
3311820 - Cookie, cracker, and pasta manufacturing0.5
4311920 - Coffee and tea manufacturing0.2
5221100 - Electric power generation, transmission, and distribution0.1
6322299 - All other converted paper product manufacturing0.04
7335210 - Small electrical appliance manufacturing0
8335221 - Household cooking appliance manufacturing0.01

Formula

+ Show code

See also

Keywords

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>