View source: R/calibrate_sim.R
calibrate_sim | R Documentation |
Starts a calibration run with multiple iterations using a GLM-AED2 setup. At the end a output csv.-file of all iterations and a diagnostic plot are created.
calibrate_sim(
var = "temp",
path,
field_file,
nml_file = "glm3.nml",
glm_file = "glm3.nml",
calib_setup = NULL,
glmcmd = NULL,
first.attempt = TRUE,
period = NULL,
scaling = TRUE,
verbose = TRUE,
method = "CMA-ES",
metric = "RMSE",
target.fit = 1.5,
target.iter = 100,
plotting = TRUE,
output,
conversion.factor = 1
)
var |
Character vector of valid variable names (see |
path |
String with the path to the GLM setup |
field_file |
CSV or TSV field data (see resample_to_fieldfor format) |
nml_file |
String of the namelist file that will be calibrated, default is 'glm3.nml' |
glm_file |
String of the glm-namelist file, default is 'glm3.nml' |
calib_setup |
Data frame containing information regarding the calibration (see get_calib_setup) |
glmcmd |
String containing the desired glm run command, default is GLM3r |
first.attempt |
Boolean, if TRUE a nml-template will be created, set it to FALSE after your first calibration run; default is TRUE |
period |
List that provides a start and a stop date for the simulation |
scaling |
Boolean, if TRUE variable values will be scaled on the space (0,10), recommended for CMA-ES, default is TRUE |
verbose |
should operations and output of GLM be shown. Default is TRUE. |
method |
String of the optimization method, default is 'CMA-ES' (Hansen 2009), alternatively you can also use 'Nelder-Mead' |
metric |
String of the calibration fit metric, default is RMSE |
target.fit |
Double of your preferred fit, calibration will stop after reaching that; default is 1.5 |
target.iter |
Double of maximum amount of iterations, default is 150 |
plotting |
Boolean, if TRUE plots all results as heat maps |
output |
Character array of the output folder path |
conversion.factor |
Double of the conversion factor between simulated and observed data, default is 1 for temp. |
Robert Ladwig, Tadhg Moore
get_calib_setup
, get_calib_periods
, get_calib_init_validation
calib_setup <- get_calib_setup()
print(calib_setup)
#Example calibration
#Copy files into temporary directory
sim_folder <- tempdir() #simulation path
glmtools_folder = system.file('extdata', package = 'glmtools')
file.copy(list.files(glmtools_folder,full.names = TRUE), sim_folder, overwrite = TRUE)
field_file <- file.path(sim_folder, 'LakeMendota_field_data_hours.csv')
nml_file <- file.path(sim_folder, 'glm3.nml')
driver_file <- file.path(sim_folder, 'LakeMendota_NLDAS.csv')
period = get_calib_periods(nml_file = nml_file, ratio = 1)
output = file.path(sim_folder, 'output/output.nc')
var = 'temp' # variable to apply the calibration procedure
## Not run:
calibrate_sim(var = var, path = sim_folder, field_file = field_file,
nml_file = nml_file, calib_setup = calib_setup,
glmcmd = NULL,
first.attempt = TRUE, period = period, method = 'CMA-ES',
scaling = TRUE, #scaling should be TRUE for CMA-ES
verbose = FALSE,
metric = 'RMSE',plotting = FALSE,
target.fit = 1.5,
target.iter = 50, output = output)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.