Skip to content

Commit 5f301f4

Browse files
committed
Do not require input column "sealed" any more
1 parent a09d91a commit 5f301f4

10 files changed

Lines changed: 12 additions & 18 deletions

R/generate_rabimo_area.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@ generate_rabimo_area <- function(code, ..., column_info = read_column_info())
3333
# Compose a one-row data frame from the key-value pairs
3434
result <- kwb.utils::callWith(data.frame, key_value_pairs, ...)
3535

36-
# Add columns "code", "main_frac", "sealed"
36+
# Add columns "code", "main_frac"
3737
fetch <- create_accessor(result)
3838
result["code"] <- code
3939
result["main_frac"] <- round(fetch("area_main")/fetch("total_area") , 2L)
40-
result["sealed"] <- round(fetch("roof") + fetch("pvd"), 2L)
41-
4240
result
4341
}

R/natural-scenario.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ data_to_natural <- function(data, type = "undeveloped")
2626
stop_on_invalid_data(data)
2727

2828
# Columns related to urbanisation
29-
urban_columns <- grep("pv|swg|roof|sealed", names(data), value = TRUE)
29+
urban_columns <- grep("pv|swg|roof", names(data), value = TRUE)
3030

3131
# non urbanized state: no building, no pavements
3232
nat_data <- data

R/prepare_input_data.R

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ prepare_input_data <- function(data, config, dbg = TRUE)
9898
# Convert percentages to fractions
9999
data <- calculate_fractions(data)
100100

101-
# insert column with total sealed area
102-
data[["sealed"]] <- with(data, roof + pvd)
103-
104101
# insert empty to_swale column (fraction of the area connected to a swale)
105102
data[["to_swale"]] <- 0
106103

R/run_rabimo.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,10 @@ run_rabimo <- function(data, config, controls = define_controls())
179179
with(data, road_frac * (1 - pvd_r)) *
180180
runoff_sealed[, ncol(runoff_sealed)] # last (less sealed) surface class
181181

182-
fraction_unsealed <- if (control("reproduce_abimo_error")) {
183-
with(data, 1 - sealed)
184-
} else {
185-
with(data, main_frac * (1 - sealed))
186-
}
182+
fraction_unsealed <- with(
183+
data,
184+
ifelse(control("reproduce_abimo_error"), 1, main_frac) * (1 - (roof + pvd))
185+
)
187186

188187
infiltration_unsealed_surfaces <- fraction_unsealed * runoff_unsealed
189188

R/run_rabimo_with_measures.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ run_rabimo_with_measures <- function(
2121

2222
run_rabimo(
2323
distribute_measures(blocks = blocks, targets = rescaled_targets),
24-
config = config)
24+
config = config
25+
)
2526
}
2627

2728
# config_file = kwb.abimo::default_config()

inst/extdata/column-names.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ srf1_pvd_r,STR_BELAG1,x,Fraction of road area belonging to surface class 1,0..1,
2626
srf2_pvd_r,STR_BELAG2,x,Fraction of road area belonging to surface class 2,0..1,required,numeric,0.1
2727
srf3_pvd_r,STR_BELAG3,x,Fraction of road area belonging to surface class 3,0..1,required,numeric,0.0
2828
srf4_pvd_r,STR_BELAG4,x,Fraction of road area belonging to surface class 4,0..1,required,numeric,0.0
29-
sealed,,,Fraction of sealed non-road area including buildings,0..1,required,numeric,
3029
to_swale,,,Fraction of total area connected to an infiltration swale,0..1,required,numeric,0.0
3130
gw_dist,FLUR,,Depth to the water table,m,required,numeric,3.0
3231
ufc30,FELD_30,,Usable field capacity 0..30 cm,% by volume,required,numeric,13.0

tests/testthat/test-function-get_column_selection.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_that("get_column_selection() works", {
55
f <- kwb.rabimo:::get_column_selection
66

77
expect_silent(result <- f())
8-
expect_length(result, 36L)
98
expect_identical(result[1L], "code")
9+
expect_false("sealed" %in% result)
1010
})
11+

tests/testthat/test-function-prepare_berlin_inputs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_that("prepare_berlin_inputs() works", {
2222
"pvd", "swg_pvd",
2323
"srf1_pvd", "srf2_pvd", "srf3_pvd", "srf4_pvd", "srf5_pvd",
2424
"road_frac", "pvd_r", "swg_pvd_r", "srf1_pvd_r", "srf2_pvd_r",
25-
"srf3_pvd_r", "srf4_pvd_r", "sealed", "to_swale", "gw_dist", "ufc30",
25+
"srf3_pvd_r", "srf4_pvd_r", "to_swale", "gw_dist", "ufc30",
2626
"ufc150", "land_type", "veg_class", "irrigation", "block_type"
2727
))
2828

tests/testthat/test-function-run_rabimo.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ test_that("run_rabimo() works", {
3636
road_frac = 0.1,
3737
pvd_r = 0,
3838
swg_pvd_r = c(0.2, 1, 0),
39-
sealed = 0.1,
4039
to_swale = 0.0,
4140
total_area = 100
4241
)

tests/testthat/test-function-run_rabimo_with_measures.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test_that("run_rabimo_with_measures() works", {
3636
to_swale = measures_max$to_swale + 0.01
3737
)
3838

39-
result <- f(blocks, measures = measures_max)
39+
expect_output(result <- f(blocks, measures = measures_max))
4040
expect_true(all(result$surface_runoff == 0))
4141

4242
expect_error(f(blocks, measures = measures_too_big_1))

0 commit comments

Comments
 (0)