Skip to content

Commit

Permalink
fix further errors in impose climate change function
Browse files Browse the repository at this point in the history
  • Loading branch information
tanerumit committed Feb 1, 2024
1 parent 0fd9bb1 commit b0fa5ac
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions R/imposeClimateChanges.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,18 @@ imposeClimateChanges <- function(
# Transient changes (gradual)
if(isTRUE(transient.precip.change)) {

# Set constraint on maximum change (i.e., maximum = 99%)
min_precipf = 0.01

precip_mean_deltaf <- (change.factor.precip.mean - 1) * 2 + 1
precip_meanf <- sapply(1:12,
function(m) seq(1, change.factor.precip.mean[m] * 2, length.out = max(year_ind)))
function(m) seq(1, precip_mean_deltaf[m], length.out = max(year_ind)))
precip_meanf[precip_meanf < min_precipf] <- min_precipf

precip_var_deltaf <- (change.factor.precip.variance - 1) * 2 + 1
precip_varf <- sapply(1:12,
function(m) seq(1, change.factor.precip.variance[m] * 2, length.out = max(year_ind)))
function(m) seq(1, precip_var_deltaf[m], length.out = max(year_ind)))
precip_varf[precip_varf < min_precipf] <- min_precipf

# Step changes
} else {
Expand Down

0 comments on commit b0fa5ac

Please sign in to comment.