Skip to contents

Replace ptps column with ptps derived using rain snow line code (lapse rate + MAT)

Usage

rsnwelev(forcing, pars, ae_tbl)

Arguments

forcing

named list of per-zone forcing data frames (each with a mat_degc column). The list names are matched against the parameter zone column.

pars

parameter data frame that supplies one value per forcing zone for each of elev (reference elevation, m), talr (temperature lapse rate, degC per 100 m) and pxtemp (rain/snow threshold temperature, degC). A zone column is used to align values with forcing when present.

ae_tbl

data.frame with col1 containing quantile info and subsequent col with elev for each zone

Value

The forcing list with each zone's ptps column replaced by the value derived from the rsnwelev model.

Examples

# area_elev_curve is bundled for SFLN2 (2 zones); pair it with SFLN2 data.
data(sfln2_forcing)
data(sfln2_pars)
data(area_elev_curve)
# rsnwelev only needs the zones that match the area-elevation table,
# so drop the SFLN2-CU consumptive-use zone before calling.
forcing_zones <- sfln2_forcing[c("SFLN2-1", "SFLN2-2")]
# rsnwelev needs elev plus a temperature lapse rate (talr, degC/100m) and a
# rain/snow threshold (pxtemp, degC) per zone. The bundled calibration only
# carries elev, so add representative talr/pxtemp rows for the two zones.
zones <- c("SFLN2-1", "SFLN2-2")
rs_pars <- rbind(
  sfln2_pars[sfln2_pars$name == "elev" & sfln2_pars$zone %in% zones, ],
  data.frame(
    p_name = paste0(rep(c("talr_", "pxtemp_"), each = 2), zones),
    name = rep(c("talr", "pxtemp"), each = 2),
    type = "rsnwelev",
    zone = rep(zones, 2),
    value = c(0.5, 0.5, 1.0, 1.0)
  )
)
forcing_adj <- rsnwelev(forcing_zones, rs_pars, area_elev_curve)