--- title: "Modify a HYPE Parameter File" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Modify a HYPE Parameter File} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = FALSE, fig.width = 7.1, fig.height = 6 ) ``` ## Setup Load HYPEtools Package and Import Files ```{r setup, message=FALSE} # Load Package library(HYPEtools) # Get Path to HYPEtools Model Example Files model_path <- system.file("demo_model", package = "HYPEtools") # Import HYPE Model Files gd <- ReadGeoData(file.path(model_path, "GeoData.txt")) gcl <- ReadGeoClass(file.path(model_path, "GeoClass.txt")) prf <- ReadPar(file.path(model_path, "par.txt"), encoding = "latin1") ``` ## Import Checks ```{r checks} # Exaimine parameter structure str(prf) # Display without the comment items prf[sapply(prf, function(x) is.numeric(x) & length(x) > 0)] # Show values for a parameter "rrcs1" - Note it has 2 values, i.e. it is soil-dependent prf$rrcs1 ``` ## Update Model Parameters by a Constant Fraction Here we increase the "cmlt" parameter by 50% (i.e. multiply the original value by 1.5) ```{r updatepar} # Fraction by which the original value will by multiplied mult <- 1.5 # Display the current values (3, i.e. landuse-dependent) prf$cmlt # Create a new paramater list prf.150 <- prf # Multiply by a specified fraction and display again prf.150$cmlt <- prf$cmlt * mult prf.150$cmlt ``` ## Update Model Parameters by a Constant Fraction for a Selected Land Use Group Here we increase the "cmlt" parameter by 50%, but only for SLCs with "Forest" as a land use. ```{r updateparlu} # Forest is Land Use Class 2 comment(gcl) # Specify multiplication factors mult <- c(1, 1.5, 1) # Create a new parameter list prf.150.for <- prf # Multiply values for the selected landuse by a specified fraction and display again prf.150.for$cmlt <- prf$cmlt * mult prf.150.for$cmlt # See a ratio of the new vs. the original parameters prf.150.for$cmlt / prf$cmlt ```