if (FALSE) {
##
# setup parallel backend
library(doParallel)
ncores <- detectCores() - 2
registerDoParallel(cores = ncores)
# run search function using default search grid - takes a while
res <- winsrch_grid(tidobjmean)
# view the error surface
library(ggplot2)
ggplot(res, aes(x = factor(mos), y = factor(yrs), fill = err)) +
geom_tile() +
facet_wrap(~ flo) +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0,0)) +
scale_fill_gradientn(colours = gradcols())
# optimal combo
res[which.min(res$err), ]
##
# create a custom search grid, e.g. years only
grid_in <- createsrch(mos = 1, yrs = seq(1, 10), flo = 1)
res <- winsrch_grid(tidobjmean, grid_in)
}
Run the code above in your browser using DataLab