This issue will overhaul the scaling of biomass fractions. The previous scaling approaches for biomass fractions coming out of scale_phenology (scale to the sum of the defaults, scale to the max of the defaults) were not sufficient in retaining the frequency of peak biomass (1.0) represented in the default biomass fractions.
@dschlaep came up with a new algorithm that determines the number of peak biomass months specified in inputs (defaults) and then re-scales the derived values to maintain that number of peak biomass months. Here is his algorithm:
# Normalize each row of biomass so that the
# frequency of months with biomass < max(default biomass) is the same as
# months with default biomass < max(default biomass)
for(thisRow in 1:nrow(biomass)){
# Value of peak default biomass
dmax <- max(biomass.default[thisRow,])
# Number of peak default biomass
nmax <- max(1, 12 - sum(biomass.default[thisRow, ] < dmax))
# Un-scaled minimum value of peak number months
ids <- order(biomass[thisRow,], decreasing = TRUE)[seq_len(nmax)]
pmin <- min(biomass[thisRow, ids])
# Scale
biomass2[thisRow,] <- biomass[thisRow,] * dmax / pmin
# Make sure no values exceed 1
biomass2[thisRow, ] <- pmin(biomass2[thisRow, ], 1)
}
This issue will overhaul the scaling of biomass fractions. The previous scaling approaches for biomass fractions coming out of scale_phenology (scale to the sum of the defaults, scale to the max of the defaults) were not sufficient in retaining the frequency of peak biomass (1.0) represented in the default biomass fractions.
@dschlaep came up with a new algorithm that determines the number of peak biomass months specified in inputs (defaults) and then re-scales the derived values to maintain that number of peak biomass months. Here is his algorithm: