Difference between revisions of "Metal concentrations in lake sediments"

From Testiwiki
Jump to: navigation, search
(Answer)
m
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:Minera]]
 
[[Category:Minera]]
 +
[[Category:Code under inspection]]
 
{{variable|moderator=Jouni|stub=Yes}}
 
{{variable|moderator=Jouni|stub=Yes}}
  
Line 7: Line 8:
  
 
== Answer ==
 
== Answer ==
 +
 +
==== 1) Calculate the metal concentration based on the mean value of the surrounding lakes (spherical area specified by radius)====
  
 
{{resultlink}}
 
{{resultlink}}
  
 
<rcode graphics="1" include="page:OpasnetBaseUtils|name:generic|page:Recommended_R_functions|name:tailoredfunctions" variables="
 
<rcode graphics="1" include="page:OpasnetBaseUtils|name:generic|page:Recommended_R_functions|name:tailoredfunctions" variables="
name:metalli|description:Valitse näytettävä metalli|type:selection|options:'Co';Co;'Cr';Cr;'Cu';Cu;'Fe';Fe;'Mn';Mn;'Ni';Ni;'Pb';Pb;'S';S;'V';V;'Zn';Zn|default:Co">
+
name:metalli|description:Select metal|type:selection|options:'Co';Co;'Cr';Cr;'Cu';Cu;'Fe';Fe;'Mn';Mn;'Ni';Ni;'Pb';Pb;'S';S;'V';V;'Zn';Zn|default:Co">
 
library(OpasnetBaseUtils)
 
library(OpasnetBaseUtils)
 
library(xtable)
 
library(xtable)
Line 17: Line 20:
  
 
data <- tidy(op_baseGetData("opasnet_base", "Op_en5462"))
 
data <- tidy(op_baseGetData("opasnet_base", "Op_en5462"))
#print(xtable(data), type = 'html')
 
 
out <- data[data$Observation %in% metalli, ]
 
out <- data[data$Observation %in% metalli, ]
 
colnames(out) <- c("DateTime", "TagName", "Value")
 
colnames(out) <- c("DateTime", "TagName", "Value")
Line 24: Line 26:
 
cat(paste("Metalli: ", metalli, "\n", sep=""))
 
cat(paste("Metalli: ", metalli, "\n", sep=""))
 
plot(out$Value)
 
plot(out$Value)
#multivarplot(out)
 
  
 
</rcode>
 
</rcode>
Line 32: Line 33:
 
name:northing|description:Northing|default:6995650|
 
name:northing|description:Northing|default:6995650|
 
name:easting|description:Easting|default:3653220|
 
name:easting|description:Easting|default:3653220|
name:säde|description:Valitse ympyrän säde(km; järvet ko. alueelta huomioidaan)|default:100|
+
name:säde|description:Give radius (km; lakes inside that area are taken into account)|default:100|
name:metalli|description:Valitse metallit|type:checkbox|options:'Co';Co;'Cr';Cr;'Cu';Cu;'Fe';Fe;'Mn';Mn;'Ni';Ni;'Pb';Pb;'S';S;'V';V;'Zn';Zn|default:'Co'">
+
name:metalli|description:Select metals|type:selection|options:'Co';Co;'Cr';Cr;'Cu';Cu;'Fe';Fe;'Mn';Mn;'Ni';Ni;'Pb';Pb;'S';S;'V';V;'Zn';Zn|default:'Co'">
  
 
library(OpasnetBaseUtils)
 
library(OpasnetBaseUtils)
 
library(xtable)
 
library(xtable)
 
library(ggplot2)
 
library(ggplot2)
 +
library(reshape)
  
 
data <- (op_baseGetData("opasnet_base", "Op_en5462"))
 
data <- (op_baseGetData("opasnet_base", "Op_en5462"))
 
data <- tidy(data)
 
data <- tidy(data)
#print(xtable(data), type = 'html')
 
out <- data[data$Observation %in% metalli, ]
 
colnames(out) <- c("DateTime", "TagName", "Value")
 
out$Value <- as.numeric(out$Value)
 
out$DateTime <- as.numeric(out$DateTime)
 
cat("Metalli: ", metalli, "\n")
 
 
  
 +
data$Result <- as.numeric(data$Result) # This replaces all as.numeric rows below.
 
data <- reshape(data, timevar = "Observation", idvar = "ID", direction = "wide")
 
data <- reshape(data, timevar = "Observation", idvar = "ID", direction = "wide")
 
colnames(data) <- gsub("Result.", "", colnames(data))
 
colnames(data) <- gsub("Result.", "", colnames(data))
  
class(data$Easting)
+
data$distance <- sqrt((as.numeric(data$Easting) - easting)^2 + (as.numeric(data$Northing) - northing)^2)
class(data$Northing)
 
class(easting)
 
class(northing)
 
  
data$distance <- sqrt((as.numeric(data$Easting) - easting)^2 + (as.numeric(data$Northing) - northing)^2) <= säde*1000
+
data <- melt(data, measure.vars = c("Co", "Cr", "Cu", "Fe", "Mn", "Ni", "Pb", "S", "V", "Zn"))
  
head(data)
+
out <- data
 +
out$distance <- data$distance <= säde*1000
 +
out <- as.data.frame(as.table(tapply(out$value, out[c("variable", "distance")], mean)))
 +
colnames(out) <- gsub("variable", "metalli", colnames(out))
 +
colnames(out) <- gsub("Freq", "pitoisuus", colnames(out))
 +
cat("Metallipitoisuuden keskiarvo ", säde, " km säteellä pisteestä ", easting, "E, ", northing, " N.\n")
 +
print(xtable(out[out$distance == TRUE, ]), type = 'html')
  
data$Co <- as.numeric(data$Co)
+
cat("Pitoisuudet metallille", metalli, ".\n")
data$Cr <- as.numeric(data$Cr)
+
concentration <- data[data$distance <= säde*1000 & data$variable == metalli, "value"]
data$Cu <- as.numeric(data$Cu)
+
plot(concentration) # simple plot about concentrations.
data$Fe <- as.numeric(data$Fe)
+
qplot(Easting, Northing, data = data[data$variable == metalli, ], size = value) # Concentrations on a "map".
data$Mn <- as.numeric(data$Mn)
+
</rcode>
data$Ni <- as.numeric(data$Ni)
 
data$Pb <- as.numeric(data$Pb)
 
data$S <- as.numeric(data$S)
 
data$V <- as.numeric(data$V)
 
data$Zn <- as.numeric(data$Zn)
 
 
 
as.data.frame(as.table(tapply(data$Co, data$distance, mean)))
 
as.data.frame(as.table(tapply(data$Cr, data$distance, mean)))
 
as.data.frame(as.table(tapply(data$Cu, data$distance, mean)))
 
 
 
plot(out$Value)
 
#multivarplot(out)
 
  
 +
==== 2) Calculate metal concentration based on the concentration of a big lake ====
  
 +
<rcode graphics="1" include="page:OpasnetBaseUtils|name:generic|page:Object-oriented_programming_in_Opasnet|name:answer"
 +
variables="
 +
name:metalli|description:Select the metals|type:checkbox|options:'Co';Co;'Cr';Cr;'Cu';Cu;'Fe';Fe;'Mn';Mn;'Ni';Ni;'Pb';Pb;'S';S;'V';V;'Zn';Zn|
 +
name:name|description:Name of the big lake|type:text|
 +
name:coeff.pH|description:Coefficient for pH|default:1|
 +
name:coeff.landuse|description:Coefficient for land use|default:1
 +
">
 +
library(OpasnetBaseUtils)
 +
n <- 1
 +
data <- tidy(op_baseGetData("opasnet_base", "Op_en5462"))
 +
temp <- data[data$Observation == "Järvi", ]
 +
temp <- temp[temp$Result == name, "ID"]
 +
data <- data[data$ID == temp & data$Observation %in% metalli, ]
 +
conc <- make.ovariable(data)
 +
conc <- conc * coeff.pH * coeff.landuse
 +
conc@sample
 +
library(xtable)
 +
print(xtable(conc@sample), type = 'html')
 
</rcode>
 
</rcode>
  
 
== Rationale ==
 
== Rationale ==
  
Based on data from [http://en.gtk.fi GTK], Finland.
+
Based on data from [http://en.gtk.fi GTK], Finland. Data structure (not content) was updated based on this code: [http://fi.opasnet.org/fi_wiki/index.php?title=J%C3%A4rvisedimenttien_metallipitoisuudet&oldid=16253#Update_data_structure]. Old code does not work any more until it is simplified.
  
 
=== Dependencies ===
 
=== Dependencies ===

Latest revision as of 11:00, 26 August 2013



Question

What are metal concentrations in lake sediments? The focus is on Finland.

Answer

1) Calculate the metal concentration based on the mean value of the surrounding lakes (spherical area specified by radius)

Show results


Select metal:

+ Show code

Northing:

Easting:

Give radius (km; lakes inside that area are taken into account):

Select metals:

+ Show code

2) Calculate metal concentration based on the concentration of a big lake

Select the metals:
Co
Cr
Cu
Fe
Mn
Ni
Pb
S
V
Zn

Name of the big lake:

Coefficient for pH:

Coefficient for land use:

+ Show code

Rationale

Based on data from GTK, Finland. Data structure (not content) was updated based on this code: [1]. Old code does not work any more until it is simplified.

Dependencies

Formula

See also

Keywords

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>

Metal concentrations in lake sediments. Opasnet . [2]. Accessed 02 Jun 2024.