AgroCares / BedrijfsBodemWaterPlanCalculator

Algorithms to support field specific solutions for optimized agronomic land use.
https://agrocares.github.io/BedrijfsBodemWaterPlanCalculator/
GNU General Public License v3.0
2 stars 1 forks source link

Modify correction for small wet surroundings #90

Open yuki-nmi opened 4 months ago

yuki-nmi commented 4 months ago

The risk indicators for wet surroundings (D_NSW_WS and D_NSW_SLOPE) are reduced when wet surroundings are smaller than 20% and 10% (under the condition that slope is smaller than 1%). This is now coded in bbwp_field_indicators.R, L. 106-125 as follows:

  # minimize risks when there are no ditches around the field (wet surrounding fraction < 0.2)

    # add criteria properties as column (to use as filter)
    dt.melt[,WS := value[risk=='D_NSW_WS'],by='id']
    dt.melt[,SLOPE := value[risk=='D_NSW_SLOPE'],by='id']

    # ensure that the final risk after aggregation gets the value 0.1 or 0.01
    dt.melt[WS <= 0.2 & SLOPE < 1 & group %in% c('NSW','PSW'), c('mcf','risk_cor','value') :=  list(1,1000,0.1)]
    dt.melt[WS <= 0.1 & SLOPE < 1 & group %in% c('NSW','PSW'), c('mcf','risk_cor','value') :D_=  list(1,1000,0.01)]
    dt.melt[,c('WS','SLOPE') := NULL]

This is not an elegant way, because the resulting risk values are discrete. See figure below. (black line: slope < 1%, light blue: slope >= 1%). Further, it is not nice to calculate this in the function to calculate indicator (bbwp_field_indicators). It's more consistent if the calculation is done in the function to calculate properties bbwp_field_properties.

Rpsw_ws_current

Suggestion to improve

I suggest to change the equation inbbwp_field_properties as follows:

_the current equation(L.200 in bbwp_fieldproperties.R) dt[,nsw_ws := pmin(1,pmax(0,D_SA_W))]

Suggested equation dt[B_SLOPE_DEGREE >= 1, nsw_ws := pmin(1, pmax(0, D_SA_W))] dt[B_SLOPE_DEGREE < 1, nsw_ws := pmin(1, pmax(0, 1.125 * D_SA_W - 0.125))] # this goes through point x = 0.2, y = 0.1

Resulting risk values looks like this: Rpsw_ws_suggested