Skip to content

Commit

Permalink
Update 'dailyNRCS_Maestas2016_ResilienceResistance'
Browse files Browse the repository at this point in the history
- reflect that resilience and resistance are combined into one RR
variable — unlike Chambers et al. 2014
- update test projects


Former-commit-id: 17989a1cbc43e290b5eaac7d707fb411ed676964 [formerly 859c3f8a2320e5d92c5a56f0e1b4f5d8a69984b3]
Former-commit-id: 623fc3e
  • Loading branch information
dschlaep committed Oct 4, 2016
1 parent 43f827b commit 04cb829
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 49 deletions.
30 changes: 19 additions & 11 deletions R/2_SWSF_p2of5_CreateDB_Tables_v51.R
Original file line number Diff line number Diff line change
Expand Up @@ -818,17 +818,25 @@ if(any(simulation_timescales=="daily") && aon$dailyNRCS_SoilMoistureTemperatureR
c("Anhydrous", "Aridic", "Udic", "Ustic", "Xeric")))))
}
#35b
if(any(simulation_timescales=="daily") && aon$dailyNRCS_Chambers2014_ResilienceResistance && aon$dailyNRCS_SoilMoistureTemperatureRegimes){
cats <- c("Low", "ModeratelyLow", "Moderate", "ModeratelyHigh", "High")
temp <- c(temp, paste0("NRCS_Sagebrush", rep(c("Resilience", "Resistance"), each=length(cats)), "_", cats))
rm(cats)
}
#35c
if(any(simulation_timescales=="daily") && aon$dailyNRCS_Maestas2016_ResilienceResistance && aon$dailyNRCS_SoilMoistureTemperatureRegimes){
cats <- c("Low", "Moderate","High")
temp <- c(temp, paste0("NRCS_Sagebrush", rep(c("Resilience", "Resistance"), each=length(cats)), "_", cats))
rm(cats)
}
if (any(simulation_timescales == "daily") &&
aon$dailyNRCS_Chambers2014_ResilienceResistance &&
aon$dailyNRCS_SoilMoistureTemperatureRegimes) {

cats <- c("Low", "ModeratelyLow", "Moderate", "ModeratelyHigh", "High")
temp <- c(temp, paste0("NRCS_Chambers2014_Sagebrush",
rep(c("Resilience", "Resistance"), each = length(cats)),
"_", cats))
rm(cats)
}

#35c
if (any(simulation_timescales == "daily") &&
aon$dailyNRCS_Maestas2016_ResilienceResistance &&
aon$dailyNRCS_SoilMoistureTemperatureRegimes) {

temp <- c(temp, paste0("NRCS_Maestas2016_SagebrushRR_", c("Low", "Moderate", "High")))
}

#35.2
if(any(simulation_timescales=="daily") & aon$dailyWetDegreeDays){
temp <- c(temp, paste("WetDegreeDays.SWPcrit", rep(fieldtag_SWPcrit_MPa, each=3), rep(c(".topLayers", ".bottomLayers", ".anyLayer"), times=length(SWPcrit_MPa)), "_Cdays_mean", sep=""))
Expand Down
70 changes: 32 additions & 38 deletions R/2_SWSF_p4of5_Code_v51.R
Original file line number Diff line number Diff line change
Expand Up @@ -4097,49 +4097,43 @@ do_OneSite <- function(i_sim, i_labels, i_SWRunInformation, i_sw_input_soillayer
resMeans[nv:(nv+2*length(cats)-1)] <- c(resilience, resistance)
nv <- nv + 2*length(cats)

rm(cats, resilience, resistance) # Tregime, Sregime)
rm(cats, resilience, resistance)

}

#35c
if(any(simulation_timescales=="daily") && aon$dailyNRCS_Maestas2016_ResilienceResistance && aon$dailyNRCS_SoilMoistureTemperatureRegimes){ #Requires "dailyNRCS_SoilMoistureTemperatureRegimes"
#Based on Table 1 in Chambers, J. C., D. A. Pyke, J. D. Maestas, M. Pellant, C. S. Boyd, S. B. Campbell, S. Espinosa, D. W. Havlina, K. E. Mayer, and A. Wuenschel. 2014. Using Resistance and Resilience Concepts to Reduce Impacts of Invasive Annual Grasses and Altered Fire Regimes on the Sagebrush Ecosystem and Greater Sage-Grouse: A Strategic Multi-Scale Approach. Gen. Tech. Rep. RMRS-GTR-326. U.S. Department of Agriculture, Forest Service, Rocky Mountain Research Station, Fort Collins, CO.
if(print.debug) print("Aggregation of dailyNRCS_Maestas2016_ResilienceResistance")
# if(!exists("prcp.yr")) prcp.yr <- get_PPT_yr(sc, runData, simTime)

#Result containers
cats <- c("Low", "Moderate","High")
resilience <- resistance <- rep(0, times=length(cats))
names(resilience) <- names(resistance) <- cats

if(regimes_done){
#---Table 1 in Chambers et al. 2014
rows_resistance <- rows_resilience <- c("High","High","Moderate","Moderate","Moderate","Low","Low")
#Ecological type
Table1_EcologicalType <- matrix(c("Cryic", "Xeric", "Frigid", "Xeric","Cryic","Aridic", "Mesic", "Xeric", "Frigid", "Aridic", "Mesic", "Aridic"), ncol=2, byrow=TRUE)
Type <- as.logical(Tregime[Table1_EcologicalType[, 1]]) & as.logical(Sregime[Table1_EcologicalType[, 2]])

#Resilience and Resistance
RR <- which(Type)
for(ir in RR){
resilience[rows_resilience[ir]] <- 1
resistance[rows_resistance[ir]] <- 1
}

rm(rows_resilience, rows_resistance, Table1_EcologicalType, Type,
MAP, Table1_Characteristics_mm, Characteristics, RR)
} else {
resilience <- resistance <- rep(NA, times=length(cats))
#Based on Maestas, J.D., Campbell, S.B., Chambers, J.C., Pellant, M. & Miller, R.F. (2016). Tapping Soil Survey Information for Rapid Assessment of Sagebrush Ecosystem Resilience and Resistance. Rangelands, 38, 120-128.
if (print.debug)
print("Aggregation of dailyNRCS_Maestas2016_ResilienceResistance")

RR <- c(Low = 0, Moderate = 0, High = 0)

if (regimes_done) {
#---Table 1 in Maestas et al. 2016
Table1 <- matrix(c(
"Cryic", "Xeric", "High",
"Frigid", "Xeric", "High",
"Cryic", "Aridic", "Moderate",
"Frigid", "Aridic", "Moderate",
"Mesic", "Xeric", "Moderate",
"Mesic", "Aridic", "Low"),
ncol = 3, byrow = TRUE)

temp <- Table1[as.logical(Tregime[Table1[, 1]]) & as.logical(Sregime[Table1[, 2]]), 3]
RR[temp] <- 1

rm(Table1)
}
resMeans[nv:(nv+2*length(cats)-1)] <- c(resilience, resistance)
nv <- nv + 2*length(cats)

rm(cats, resilience, resistance, Tregime, Sregime)


nv_new <- nv + length(cats)
resMeans[nv:(nv_new - 1)] <- RR
nv <- nv_new

rm(RR)
}
rm(regimes_done)
rm(regimes_done, Tregime, Sregime)

#35.2
if(any(simulation_timescales=="daily") & aon$dailyWetDegreeDays){ #Wet degree days on daily temp and swp
if(print.debug) print("Aggregation of dailyWetDegreeDays")
Expand Down

0 comments on commit 04cb829

Please sign in to comment.