Introduction

This vignette demonstrates the main functionality of the sacsmaR package. We first begin with introducing the input files required for the functions. Next, we introduce each different module included (PET, SNOW17, SAC-SMA, Lohmann routing). Finally, we'll show the usage of the hydrologigical simulation function, which is a wrapper for the individual modules.

#Rmarkdown setup
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

#Required packages
library(sacsmaR)
library(dplyr)
library(lubridate)
library(ggplot2)

Input-data

We'll use the St. Croix Watershed data, which is included in this package r data(stcroix)

Simulation period & Grid-info file

watershed <- "stcroix" 

# starting date of the simulation
str_date <- as.Date("1970/01/1") 

# ending date of the simulation
end_date <- as.Date("1980/12/31")  

# Grid info file, consists of essential information for each grid cell:
# latitude (Deg), longitude (Deg), area, elevation (meters),  
# flowlegth  Each row belongs to a different HRU

hru_info <- stcroix$hru.info    
as_tibble(grid_info)

Model parameters

Calibration parameters for the hydrology, pet, snow, and routing modules. Each row belongs to a different HRU

hru_par  <- stcroix$hru.par
as_tibble(hru_par)

Climate inputs

#time-series of precipitation and temperature for each HRU.
hru_prcp  <- stcroix$prcp.grid
hru_tavg  <- stcroix$tavg.grid

Illustration of modules

PET module

Simulate daily potential evapotranspiration for a single HRU based on Hamon equation. The pet equation takes four inputs: par (pet parameter), tavg (time-series of average temperature), latitude information, and jday (day of the year from 1 to 365)

pet <- hamon(par  = par_petHamon[1], 
             tavg = hru_tavg[[1]],
             lat  = hru_lat[[1]], 
             jday = jday)

df <- data_frame(date = seq_date, pet = pet)
ggplot(df, aes(date, pet)) + geom_line() + labs(x = "", y = "PET (mm/day)")

SNOW module

Simulates snow based on the SNOW17 model

snowMelt <- snow17(par = par_snow17[1,],
                   prcp = hru_prcp[[1]],
                   tavg = hru_tavg[[1]],
                   elev = hru_elev[[1]],
                   jday = jday)

Runoff module

Simulates runoff at each grid cell

simflow <- sacsma(par = par_sacsma[1,],
                  prcp = hru_prcp[[1]],
                  pet = pet, lat = hru_lat[1], elev = hru_elev[1])

Routing module

Simulates routing along the river using the lohmann model

flow <- lohmann(par = par_routLah[1,], flength = hru_flowlen[1])

Hydrology simulation

Complete hydrological simulation using the Hydrosim() function, which is a wrapper for the PET, SAC-SMA, SNOW17, and Lohmann modules

hru_par <- hru_par %>% as.matrix()

par_sacsma   = hru_par[,1:16] 
par_petHamon = hru_par[,17]  
par_snow17   = hru_par[,18:27] 
par_routLah  = hru_par[,28:31] 

flowR <- hydroSim(
  par.hamon    = hru_par[,17],
  par.snow17   = hru_par[,18:27],
  par.sacsma   = hru_par[,1:16],
  par.lohmann  = hru_par[,28:31],
  tavg.grid    = hru_tavg,
  prcp.grid    = hru_prcp,
  lat.grid     = hru_lat,
  elev.grid    = hru_elev,
  area.grid    = hru_area, 
  flength.grid = hru_flowlen,
  jday = jday)

df <- data_frame(date = seq_date, flowR = flowR)
ggplot(df, aes(date, flowR)) + geom_line() + labs(x = "", y = "flow (mm/day)")


tanerumit/SACSMA-R documentation built on May 29, 2019, 9:52 a.m.