knitr::opts_chunk$set(fig.width=12, fig.height=8, fig.path='images/', echo=FALSE, warning=FALSE, message=FALSE, eval=TRUE)
load("data/flood_metadata.RData") load("data/flood_data.RData") source("global.R") library(plot3D) julian_normalized <- flood_metadata$median_julian / max(flood_metadata$median_julian, na.rm = TRUE) flood_metadata$area_total[24] <- NA # Getting rid of station n24 which has a much bigger catchment than the others area_normalized <- flood_metadata$area_total / max(flood_metadata$area_total, na.rm = TRUE) initial_index <- seq(along = julian_normalized) to_cluster <- na.omit(data.frame(julian_day = julian_normalized, area = area_normalized, index = initial_index)) set.seed(20) stationsCluster <- kmeans(to_cluster[1:2], 3, nstart = 20) st_selection_1 <- c() st_selection_2 <- c() st_selection_3 <- c() for (i in seq(along = to_cluster$index)) { if (stationsCluster$cluster[[i]] == 1) {st_selection_1[i] <- to_cluster$index[i]} if (stationsCluster$cluster[[i]] == 2) {st_selection_2[i] <- to_cluster$index[i]} if (stationsCluster$cluster[[i]] == 3) {st_selection_3[i] <- to_cluster$index[i]} } # st_selection_1 <- c(24,24) # HACK as this station is alone in its cluster st_selection_1 <- as.vector(na.omit(st_selection_1)) st_selection_2 <- as.vector(na.omit(st_selection_2)) st_selection_3 <- as.vector(na.omit(st_selection_3)) print("st_selection_1") st_selection_1 print("st_selection_2") st_selection_2 print("st_selection_3") st_selection_3 ## TO plot the clusters in 2D plot(to_cluster[1:2], xlab("julian_day"), ylab("size"), col = stationsCluster$cluster, pch = 20, cex = 3)
gof_type <- "QS" returnPeriod <- 2 plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_1) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_2) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_3)
returnPeriod <- 10 plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_1) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_2) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_3)
returnPeriod <- 30 plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_1) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_2) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_3)
gof_type <- "BS" returnPeriod <- 2 plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_1) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_2) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_3)
returnPeriod <- 10 plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_1) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_2) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_3)
returnPeriod <- 30 plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_1) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_2) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_3)
gof_type <- "r.levels" returnPeriod <- 10 plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_1) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_2) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_3)
returnPeriod <- 100 plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_1) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_2) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_3)
returnPeriod <- 200 plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_1) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_2) plot4server_rlevels_coeffvar_ave(gof_type, returnPeriod,30,150, st_selection_3)
gof_type <- "KS" plot4server_gof_averaged(gof_type, 30,150, st_selection_1) plot4server_gof_averaged(gof_type, 30,150, st_selection_2) plot4server_gof_averaged(gof_type, 30,150, st_selection_3)
gof_type <- "AD" plot4server_gof_averaged(gof_type, 30,150, st_selection_1) plot4server_gof_averaged(gof_type, 30,150, st_selection_2) plot4server_gof_averaged(gof_type, 30,150, st_selection_3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.