Skip to content

Commit

Permalink
Merge pull request #31 from Burke-Lauenroth-Lab/newagg
Browse files Browse the repository at this point in the history
New overall aggregation 'dailyNRCS_Maestas2016_ResilienceResistance'

Former-commit-id: a5f7ee40e8fafea2a5595b2fd2f53e133c9d2aa1 [formerly 53be61d307013c70d59d412261b453d7a68830f1]
Former-commit-id: 43d1ce1
  • Loading branch information
dschlaep authored Oct 4, 2016
2 parents 0a243c4 + 04cb829 commit da85e09
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
1 change: 1 addition & 0 deletions 2_SWSF_p1of5_Settings_v51.R
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ output_aggregates <- c(
#---Aggregation: Ecological dryness
"dailyNRCS_SoilMoistureTemperatureRegimes", 0, #Requires at least soil layers at 10, 20, 30, 50, 60, 90 cm
"dailyNRCS_Chambers2014_ResilienceResistance", 0, #Requires "dailyNRCS_SoilMoistureTemperatureRegimes"
"dailyNRCS_Maestas2016_ResilienceResistance", 0,
"dailyWetDegreeDays", 1,
"dailyThermalDrynessStartEnd", 1,
"dailyThermalSWPConditionCount", 1,
Expand Down
24 changes: 19 additions & 5 deletions R/2_SWSF_p2of5_CreateDB_Tables_v51.R
Original file line number Diff line number Diff line change
Expand Up @@ -818,11 +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)
}
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
36 changes: 34 additions & 2 deletions R/2_SWSF_p4of5_Code_v51.R
Original file line number Diff line number Diff line change
Expand Up @@ -4176,10 +4176,42 @@ 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)

}
rm(regimes_done)

#35c
if(any(simulation_timescales=="daily") && aon$dailyNRCS_Maestas2016_ResilienceResistance && aon$dailyNRCS_SoilMoistureTemperatureRegimes){ #Requires "dailyNRCS_SoilMoistureTemperatureRegimes"
#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)
}

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

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

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

0 comments on commit da85e09

Please sign in to comment.