# NOT RUN {
# The examples provided here are illustration of how to generate diagnostics plots
# from optimization runs of the model. Optimization runs are very time consuming so
# the examples only involve a bare minimum of model runs and are not realistic.
# Alternatively, data in the package StrathE2E2examples can be used to generate
# example plots.
# --------------------------------------------------------------------------
# }
# NOT RUN {
# Load the 1970-1999 version of the North Sea model supplied with the package and generate
# a quick test data object with only 8 itereations and running the model for 3 years.
# More realistic would be at least 500 iterations and running for 50 years.
# Even so this example will take a few minutes to run:
model<-e2e_read(model.name="North_Sea",
model.variant="1970-1999",
model.ident="test")
# This model is already optimized to the observed ecosystem data supplied with the package
# Perturb the temperature driving to knock the model away from its maximum likelihood
# state relative to the target data to illustrate the performance:
# add 3 degC to upper layer offshore temperatures:
model$data$physics.drivers$so_temp <- model$data$physics.drivers$so_temp+3
# add 3 degC to inshore temperatures:
model$data$physics.drivers$si_temp <- model$data$physics.drivers$si_temp+3
# add 3 degC to lower layer offshore temperatures:
model$data$physics.drivers$d_temp <- model$data$physics.drivers$d_temp+3
test_run <- e2e_optimize_eco(model, nyears=3, n_iter=8, start_temperature=0.4,
csv.output=FALSE)
plot_data <- e2e_plot_opt_diagnostics(model,selection="ECO",results=test_run)
# Red bars shows the final accepted values of each parameters, boxes and whiskers
# show the dirtribution of paramater values explored, relative to the starting values
str(plot_data,max.level=1) # show the structure of the list object plot_data
# }
# NOT RUN {
# --------------------------------------------------------------------------
# Or... plot example date supplied with the package showing some data generated during
# the process of optimizing the North Sea model:
# This example requires the Strathe2E2examples supplementary data package.
if(require(StrathE2E2examples)){
model <- e2e_read(model.name="North_Sea", model.variant="1970-1999")
plot_data <- e2e_plot_opt_diagnostics(model,selection="ECO",use.example=TRUE)
# Red bars shows the final accepted values of each parameters, boxes and whiskers
# show the dirtribution of paramater values explored, relative to the starting values
# Example data are only available for the 1970-1999 variant of the North Sea model
}
# --------------------------------------------------------------------------
# }
# NOT RUN {
# Same for harvest ratio optimization...
model<-e2e_read(model.name="North_Sea",
model.variant="2003-2013",
model.ident="test")
# This model is already optimized to the observed ecosystem data supplied with the package
# Perturb the temperature driving to knock the model away from its maximum likelihood
# state relative to the target data to illustrate the performance o fthe process:
# add 3 degC to upper layer offshore temperatures:
model$data$physics.drivers$so_temp <- model$data$physics.drivers$so_temp+3
# add 3 degC to inshore temperatures:
model$data$physics.drivers$si_temp <- model$data$physics.drivers$si_temp+3
# add 3 degC to lower layer offshore temperatures:
model$data$physics.drivers$d_temp <- model$data$physics.drivers$d_temp+3
test_run <- e2e_optimize_hr(model, nyears=3, n_iter=8, start_temperature=0.4,
csv.output=FALSE)
plot_data <- e2e_plot_opt_diagnostics(model,selection="HR",results=test_run)
# Red bars shows the final accepted values of each parameters, boxes and whiskers
# show the dirtribution of paramater values explored, relative to the starting values
str(plot_data,max.level=1) # show the structure of the list object plot_data
# }
# NOT RUN {
# --------------------------------------------------------------------------
# Or... plot example date supplied with the package showing some data generated
# during the process of optimizing the North Sea model:
# This example requires the Strathe2E2examples supplementary data package.
if(require(StrathE2E2examples)){
model <- e2e_read(model.name="North_Sea", model.variant="2003-2013")
plot_data <- e2e_plot_opt_diagnostics(model,selection="HR",use.example=TRUE)
# Red bars shows the final accepted values of each parameters, boxes and whiskers
# show the dirtribution of paramater values explored, relative to the starting values
# Example data are only available for the 2003-2013 variant of the North Sea model
}
# --------------------------------------------------------------------------
# }
# NOT RUN {
# For activity rate optimization relative to ecosystem data:
model<-e2e_read(model.name="North_Sea",
model.variant="1970-1999",
model.ident="test")
# This model is already optimized to the observed ecosystem data supplied with the package,
# but not by optimizing gear activity rates
# The e2e_optimize_eco() function was used in this case.
# Perturb the temperature driving to knock the model away from its maximum likelihood
# state relative to the target data:
# add 3 degC to upper layer offshore temperatures:
model$data$physics.drivers$so_temp <- model$data$physics.drivers$so_temp+3
# add 3 degC to inshore temperatures:
model$data$physics.drivers$si_temp <- model$data$physics.drivers$si_temp+3
# add 3 degC to lower layer offshore temperatures:
model$data$physics.drivers$d_temp <- model$data$physics.drivers$d_temp+3
test_run <- e2e_optimize_act(model, selection="ECO", n_iter=8, start_temperature=0.4,
cooling=0.975, csv.output=FALSE, nyears=3)
plot_data <- e2e_plot_opt_diagnostics(model,selection="ACT",
fitted.to="ECO",results=test_run)
# Red bars shows the final accepted values of each parameters, boxes and whiskers
# show the dirtribution of paramater values explored, relative to the starting values
str(plot_data,max.level=1) # show the structure of the list object plot_data
# There are no example data available in the package for this function
# }
# NOT RUN {
# --------------------------------------------------------------------------
# }
# NOT RUN {
# For activity rate optimization relative to zonal harvest ratios:
model<-e2e_read(model.name="North_Sea",
model.variant="1970-1999",
model.ident="test")
# Activity rates in this model are already optimized to the target harvest ratios supplied with
# the package but we woud not expect to recover these values in this short demonstration run
test_run <- e2e_optimize_act(model, selection="HR", n_iter=30, start_temperature=1.0,
cooling=0.985, csv.output=FALSE, n_traj=5 )
plot_data <- e2e_plot_opt_diagnostics(model,selection="ACT",fitted.to="HR",
results=test_run)
# Red bars shows the final accepted values of each parameters, boxes and whiskers
# show the dirtribution of paramater values explored, relative to the starting values
str(plot_data,max.level=1) # show the structure of the list object plot_data
# }
# NOT RUN {
# --------------------------------------------------------------------------
# Or... plot example date supplied with the package showing some data generated during
# the process of optimizing the North Sea model:
# This example requires the Strathe2E2examples supplementary data package.
if(require(StrathE2E2examples)){
model <- e2e_read(model.name="North_Sea", model.variant="1970-1999")
plot_data <- e2e_plot_opt_diagnostics(model,selection="ACT",fitted.to="HR",
use.example=TRUE)
# Red bars shows the final accepted values of each parameters, boxes and whiskers
# show the dirtribution of paramater values explored, relative to the starting values
# Example data are only available for the 1970-1999 variant of the North Sea model
}
# --------------------------------------------------------------------------
# }
Run the code above in your browser using DataLab