Skip to content

Commit

Permalink
Merge commit 'stash@{2}' into generalized_agg_funs
Browse files Browse the repository at this point in the history
Working on implementing 'agg_fun' aggregations (part 7)


Former-commit-id: a1f6a24
  • Loading branch information
dschlaep committed Oct 11, 2016
2 parents 47fe79f + 5f94d34 commit 21cc475
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 79 deletions.
16 changes: 10 additions & 6 deletions 2_SWSF_p1of5_Settings_v51.R
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,12 @@ daily_lyr_agg <- list(

#regeneration: germination and establishment
opts_regen_bySWPSnow <- list(
season.start = "LastSnow" # either doy or "LastSnow"
season.end = "FirstSnow" # either doy or "FirstSnow"
germination.duration = 7 # in days
germination.swp.surface = -0.2 # in MPa, duration must have at least x MPa
establishment.duration = 14 # in days
establishment.swp.surface = -0.4 # in MPa, duration must have at least x MPa
season.start = "LastSnow", # either doy or "LastSnow"
season.end = "FirstSnow", # either doy or "FirstSnow"
germination.duration = 7, # in days
germination.swp.surface = -0.2, # in MPa, duration must have at least x MPa
establishment.duration = 14, # in days
establishment.swp.surface = -0.4, # in MPa, duration must have at least x MPa
establishment.delay = 1 # start of establishment needs to occur latest x days after end of germination
)

Expand All @@ -478,6 +478,10 @@ growing.season.threshold.tempC <- 10 # based on Trewartha's D temperateness defi
growing.season.threshold.tempC <- 4 # based on standard input of mean monthly biomass values for vegetation composition


# dry soil periods: minimum duration to quality for aggregations 'dailySuitablePeriodsDrySpells' and 'dailySWPdrynessANDwetness'
duration_min_drysoils_days <- 10 # used, e.g., by functions 'startDoyOfDuration' and 'endDoyOfDuration'


#------SoilWat files
sw <- "sw_v31"
sw.inputs <- "Input" #must be string of length > 0; i.e. not compatible with SoilWat versions < 21
Expand Down
45 changes: 38 additions & 7 deletions R/2_SWSF_p2of5_CreateDB_Tables_v51.R
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ if (length(Tables) == 0 || cleanDB) {
fieldtag_Tmin_crit_C <- paste0(ifelse(Tmin_crit_C < 0, "Neg", ifelse(Tmin_crit_C > 0, "Pos", "")), abs(Tmin_crit_C), "C")
fieldtag_Tmax_crit_C <- paste0(ifelse(Tmax_crit_C < 0, "Neg", ifelse(Tmax_crit_C > 0, "Pos", "")), abs(Tmax_crit_C), "C")
fieldtag_Tmean_crit_C <- paste0(ifelse(Tmean_crit_C < 0, "Neg", ifelse(Tmean_crit_C > 0, "Pos", "")), abs(Tmean_crit_C), "C")
fieldtag_drysoils <- paste0("AtLeast", duration_min_drysoils_days, "Days")

#0.
if (aon$input_SoilProfile) {
Expand Down Expand Up @@ -960,19 +961,40 @@ if (length(Tables) == 0 || cleanDB) {
"_Count_days"))
}

#TODO(drs): progress state
#36
if (aon$monthlySWPdryness) {
temp <- c(temp, paste("DrySoilPeriods.SWPcrit", rep(fieldtag_SWPcrit_MPa, times=2), ".NSadj.", rep(c("topLayers", "bottomLayers"), each=length(SWPcrit_MPa)), ".Duration.Total_months_mean", sep=""),
paste("DrySoilPeriods.SWPcrit", rep(fieldtag_SWPcrit_MPa, times=2), ".NSadj.", rep(c("topLayers", "bottomLayers"), each=length(SWPcrit_MPa)), ".Start_month_mean", sep=""))
temp <- c(temp, paste0("DrySoilPeriods.SWPcrit",
rep(fieldtag_SWPcrit_MPa, times = 2), ".NSadj.",
rep(c("topLayers", "bottomLayers"), each = length(SWPcrit_MPa)),
".Duration.Total_months"),
paste0("DrySoilPeriods.SWPcrit",
rep(fieldtag_SWPcrit_MPa, times = 2), ".NSadj.",
rep(c("topLayers", "bottomLayers"), each = length(SWPcrit_MPa)),
".Start_month"))
}

#37
if (aon$dailySWPdrynessANDwetness) {
temp <- c(temp, paste(rep(c("WetSoilPeriods", "DrySoilPeriods"), each=8), ".SWPcrit", rep(fieldtag_SWPcrit_MPa, each=16), ".NSadj.", c(rep(c("topLayers", "bottomLayers"), times=4), rep(rep(c("topLayers", "bottomLayers"), each=2), times=2)),
rep(c(".AnyLayerWet.", ".AllLayersWet.", ".AllLayersDry.", ""), each=4), c(rep(rep(c("Duration.Total_days", "Duration.LongestContinuous_days"), each=2), times=2), rep(c("Duration.Total_days", "Duration.LongestContinuous_days"), times=2), rep(c(".PeriodsForAtLeast10Days.Start_doy", ".PeriodsForAtLeast10Days.End_doy"), times=2)), "_mean", sep=""))
temp <- c(temp, paste0(rep(c("WetSoilPeriods", "DrySoilPeriods"), each = 8),
".SWPcrit",
rep(fieldtag_SWPcrit_MPa, each = 16),
".NSadj.",
c(rep(c("topLayers", "bottomLayers"), times = 4),
rep(rep(c("topLayers", "bottomLayers"), each = 2), times = 2)),
rep(c(".AnyLayerWet", ".AllLayersWet", ".AllLayersDry", ""),
each = 4),
".",
c(rep(rep(c("Duration.Total_days",
"Duration.LongestContinuous_days"), each = 2),
times = 2),
rep(c("Duration.Total_days",
"Duration.LongestContinuous_days"), times = 2),
paste0("PeriodsFor", fieldtag_drysoils, ".",
rep(c("Start_doy", "End_doy"), times = 2)))
))
}

#TODO(drs): progress state
#38
if (aon$dailySuitablePeriodsDuration) {
quantiles <- c(0.05, 0.5, 0.95)
Expand All @@ -985,7 +1007,16 @@ if (length(Tables) == 0 || cleanDB) {
}
#40
if (aon$dailySuitablePeriodsDrySpells) {
temp <- c(temp, paste("ThermalSnowfreeDryPeriods.SWPcrit", rep(paste(rep(fieldtag_SWPcrit_MPa, each=2), rep(c(".topLayers", ".bottomLayers"), times=length(SWPcrit_MPa)), sep=""), each=4), c("_DrySpellsAllLayers_meanDuration_days_mean", "_DrySpellsAllLayers_maxDuration_days_mean", "_DrySpellsAllLayers_Total_days_mean", "_DrySpellsAtLeast10DaysAllLayers_Start_doy_mean"), sep=""))
temp <- c(temp, paste0("ThermalSnowfreeDryPeriods.SWPcrit",
rep(paste0(rep(fieldtag_SWPcrit_MPa, each = 2),
rep(c(".topLayers", ".bottomLayers"),
times=length(SWPcrit_MPa))),
each=4),
"_DrySpells",
c(rep("", 3), fieldtag_drysoils),
"AllLayers_",
c("meanDuration_days", "maxDuration_days", "Total_days",
"Start_doy")))
}
#41
if (aon$dailySWPdrynessDurationDistribution) {
Expand Down Expand Up @@ -1169,7 +1200,7 @@ if (length(Tables) == 0 || cleanDB) {

#62
if (aon$dailyRegeneration_bySWPSnow) {
temp <- c(temp, "Regeneration.Potential.SuitableYears.NSadj_fraction_mean")
temp <- c(temp, "Regeneration.Potential.SuitableYears.NSadj_fraction")
}

#63
Expand Down
Loading

0 comments on commit 21cc475

Please sign in to comment.