Damage vector for life-cycle analysis: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(→‎Formula: rewritten. Uses ovaMatrixProduct from OpasnetUtils/Drafts)
(→‎Formula: old code removed)
Line 56: Line 56:


library(OpasnetUtils)
library(OpasnetUtils)
library(xtable)
library(ggplot2)
library(ggplot2)
library(reshape2)
library(reshape2)
Line 62: Line 61:
objects.latest("Op_en6007", code_name = "answer") # [[OpasnetUtils/Drafts]]. We need ovaMatrixProduct.
objects.latest("Op_en6007", code_name = "answer") # [[OpasnetUtils/Drafts]]. We need ovaMatrixProduct.


limit <- 0.001
show_bins <- 10 # How many different direct inputs to show?
show_bins <- 10 # How many different direct inputs to show?


Line 81: Line 79:


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


# 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.
Line 100: Line 98:
normalisation$Obs <- NULL
normalisation$Obs <- NULL


head(normalisation)
oprint(head(normalisation))


normalisation <- Ovariable("normalisation", data = normalisation)
normalisation <- Ovariable("normalisation", data = normalisation)
Line 110: Line 108:
activity        <- EvalOutput(activity, N = 1)
activity        <- EvalOutput(activity, N = 1)
normalisation    <- EvalOutput(normalisation, N = 1)
normalisation    <- EvalOutput(normalisation, N = 1)
#damagesPerImpact2 <- damagesPerImpact@output
#impactsPerDollar2 <- impactsPerDollar@output
#activity2        <- activity@output
#normalisation2    <- normalisation@output


#############################33
#############################33
#damagesPerImpact2 <- reshape( # Reshape it into the wide format.
# damagesPerImpact2[ , colnames(damagesPerImpact2) != "Obs"], # Data to be reshaped
# times = "Result", # Column(s) to be reshaped
# timevar = "Unique_categories", # Column identifiers
# idvar = "Damage_categories", # Row identifiers
# direction = "wide" # Reshape from long to wide format
#)
#colnames(damagesPerImpact2) <- gsub("Result.", "", colnames(damagesPerImpact2)) # Remove extra "Result." from colnames.
#rownames(damagesPerImpact2) <- damagesPerImpact2[[1]] # Make the first column the rownames.
#damagesPerImpact2[1] <- NULL # Remove the first column.
#damagesPerImpact2[1:5, 1:5]
#damagesPerImpact2 <- t(as.matrix(damagesPerImpact2)) # Turn the data.frame into a matrix and transpose it.
#impactsPerDollar2 <- reshape(
# impactsPerDollar2,
# times = "Result",
# timevar = "Unique_categories",
# idvar = "Purchasing_sector",
# direction = "wide"
#)
#colnames(impactsPerDollar2) <- gsub("Result.", "", colnames(impactsPerDollar2))
#rownames(impactsPerDollar2) <- impactsPerDollar2[[1]]
#impactsPerDollar2[1] <- NULL
#impactsPerDollar2[1:5, 1:5]
#impactsPerDollar2 <- as.matrix(impactsPerDollar2)
#activity2 <- merge(data.frame(directRequirements2 = rownames(impactsPerDollar2)), activity2, all.x = TRUE)
#activity2$Result[is.na(activity2$Result)] <- 0


impactsPerDollar2 <- impactsPerDollar * activity # Multiply data matrix with activities.
impactsPerDollar2 <- impactsPerDollar * activity # Multiply data matrix with activities.


head(impactsPerDollar@output)
oprint(head(impactsPerDollar@output))
head(damagesPerImpact@output)
oprint(head(damagesPerImpact@output))


out <- ovaMatrixProduct(
out <- ovaMatrixProduct(
Line 164: Line 123:
) # Do a matrix multiplication
) # Do a matrix multiplication


# After matrix operations, turn out into a data.frame for graphics.
out <- out / normalisation * 365 # Normalise and scale to daily values.
 
#out <- as.data.frame(out)
 
#out$Purchasing_sector <- rownames(out)
#out <- melt(out, idvars = "Purchasing_sector", variable_name = "damages") # Reshape into long format
 
 


# Merge all but show_bins largest bins to 'Other'.
# Merge all but show_bins largest bins to 'Other'.
Line 185: Line 137:
"Other"
"Other"
)
)
#out <- dropall(out)
# Rename the columns to reflect actual things.
#colnames(out)[colnames(out) == "value"] <- "Result"
#damages <- EvalOutput(new("ovariable", name = "damages", data = out)) # Make an ovariable
damageFractions <- out / normalisation * 365 # Normalise and scale to daily values.


# Plot results on a bar graph.
# Plot results on a bar graph.
Line 201: Line 142:
cat("Effects smaller than or equal to ", limit / sum(sums$Freq) * 100, " % of the total effect are not shown.\n")
cat("Effects smaller than or equal to ", limit / sum(sums$Freq) * 100, " % of the total effect are not shown.\n")


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

Revision as of 17:16, 27 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

Coffee cup inputs(Euro)
ObsPurchasing_sectorResult
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>