# NOT RUN {
## may create files
demo(radioactivePlumes_addProperties)
# number of not detected plumes for given set of 10 sensors,
# weighted by total dose of plumes
sensors = sample.int(nLocations(radioactivePlumes), 10)
nondetection = function(x, threshold = 1e-7, nout = 1){
all(x[,2] < threshold)
}
sumWeighted = function(x, weight, nout = 1){
sum(x * weight$totalDose)
}
weightedSumUndetectedAtSensors = simulationsApply(
simulations = radioactivePlumes,
locations = sensors,
fun_p = nondetection,
fun_Rp = sumWeighted
)
# map of average time until detection of plumes
# if a plume never reaches a location it is counted as being there after a week
meanDetectionTime = function(x, nout = 1){
y = x
y[is.na(x)] = 7 * 86400
z = mean(y, na.rm = TRUE)
}
mapMeanDetectionTime = simulationsApply(
simulations = radioactivePlumes,
kinds = 3,
fun_l = meanDetectionTime
)
radioactivePlumes@locations@data$meanDetectionTime =
mapMeanDetectionTime[["result_locations"]]
spplot(radioactivePlumes@locations, zcol = "meanDetectionTime")
# general ratio and difference of 'maxdose' and 'finaldose'
ratioMaxFinal = function(x, nout = 2){
ratio = x[2]/x[1]
diff = x[2] - x[1]
ratio[!is.finite(ratio)] = NA
out = c(ratio, diff)
}
valuesRatio = simulationsApply(
simulations = radioactivePlumes,
fun_pl = ratioMaxFinal,
fun_Rpl_cellStats = "mean",
nameSave = "ratio"
)
hist(valuesRatio[["result_locationsplumes"]], 1,
xlim = c(0,1), breaks = c(seq(0, 1, 0.01), 10000))
hist(valuesRatio[["result_locationsplumes"]], 2,
xlim = c(-0.001, 0.001), breaks = c(-1000, seq(-0.001, 0.001, 0.0001), 1000))
# }
# NOT RUN {
# }
# NOT RUN {
<!-- %# linear model -->
# }
# NOT RUN {
<!-- %# early detection -->
# }
# NOT RUN {
<!-- %## chunks / no chunks -->
# }
Run the code above in your browser using DataLab