Skip to content

Commit

Permalink
Feature/dei 122 add selection of tests to testbench (#51)
Browse files Browse the repository at this point in the history
* feat[DEI-122]: add tests at testbench

* feat[DEI-122]: add tests for testbench

* feat[DEI-122]: add tests at testbench

* feat[DEI-122]: add tests at testbench

* DEI-122 removed new line

* DEI-122 added missing new lines

---------

Co-authored-by: David Rodriguez Aguilera <32545627+Davidrag@users.noreply.github.com>
  • Loading branch information
IoannaMi and Davidrag authored Sep 28, 2023
1 parent 545baab commit e1f444d
Show file tree
Hide file tree
Showing 74 changed files with 1,017 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,5 @@ dmypy.json
!tests_acceptance/input_nc_files/*.nc
!tests_acceptance/reference_nc_files/*.nc
!tests_acceptance/input_yaml_files/*.yaml
!tests_acceptance/input_yaml_files/tables/*.yaml
/tests_acceptance/output_nc_files/*.nc
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,5 @@ rules:
input_variables: ["FL_HGI_P_pectinatus_water_depth", "FL_HGI_P_pectinatus_flow_velocity","FL_HGI_P_pectinatus_chloride"]
output_variable: FL_HSI_P_pectinatus
output-data:
filename: ./tests_acceptance/output_nc_files/DHYDRO_VKZM_Potamogeton_testcase_boundaries_vs_fuzzylogic.nc
filename: ./tests_acceptance/output_nc_files/DHYDRO_VKZM_Potamogeton_testcase_boundaries_vs_fuzzylogic.nc

Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ rules:
output_variable: chloride_gp

output-data:
filename: ./tests_acceptance/output_nc_files/DHYDRO_VKZM_testcase_filter_chloride_in_time_with_multiply_rule.nc
filename: ./tests_acceptance/output_nc_files/DHYDRO_VKZM_testcase_filter_chloride_in_time_with_multiply_rule.nc

12 changes: 12 additions & 0 deletions tests_acceptance/input_yaml_files/tables/input_IRM1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# - response_curve_rule:
name: test name
description: Get flowing value waterlevel
response_table:
- ["input" , "output"]
- [-999.0 , 0.0 ]
- [ 0.5 , 0.0 ]
- [ 1.0 , 1.0 ]
- [ 999.0 , 1.0 ]
input_variable: water_level
output_variable: water_level_policy

12 changes: 12 additions & 0 deletions tests_acceptance/input_yaml_files/tables/input_IRM2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# - response_curve_rule:
name: test name
description: Get flowing value waterlevel
response_table:
- ["input" , "output"]
- [-999.0 , 0.0 ]
- [ 0.5 , 0.0 ]
- [ 1.0 , 1.0 ]
- [ 999.0 , 1.0 ]
input_variable: water_level
output_variable: water_level_policy2

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- ["input" , "output"]
- [-999.0 , 0.0 ]
- [-999.0 , 0.0 ]
- [ 0.5 , 0.0 ]
- [ 1.0 , 1.0 ]
- [ 999.0 , 1.0 ]
13 changes: 13 additions & 0 deletions tests_acceptance/input_yaml_files/tables/stepfunction.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: test name
description: Get boundaries waterlevel
limit_response_table:
[
[ limit , response],
[-999.0 , 0.00],
[ -0.10 , 1.00],
[ 0.15 , 0.00],
[ 999.0 , 0.00],
]
input_variable: water_level
output_variable: water_level_policy

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
input-data:
- dataset:
filename: ./tests_acceptance/input_nc_files/small_subset_FM-VZM_0000_map.nc
variable_mapping:
salinity_PSU: "salinity"
water_level_mNAP: "water_level"
water_depth_mNAP: "water_depth"

rules:
- formula_rule:
name: Classify salinity
description: Reponse of Pond weed (Potamogeton nodosus) to water depth
formula: salinity < 1
input_variables: [salinity]
output_variable: salinity_class

- formula_rule:
name: Classify dryfall
description: Classify when dry-fall occurs and if so label it with 1 (or zero if no dry-fall)
formula: water_depth < 0.05
input_variables: [water_depth]
output_variable: dry_fall

output-data:
filename: ./tests_acceptance/output_nc_files/test10_formula_based_comparison.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
input-data:
- dataset:
filename: ./tests_acceptance/input_nc_files/small_subset_FM-VZM_0000_map.nc
variable_mapping:
salinity_PSU: "salinity"
water_level_mNAP: "water_level"
water_depth_mNAP: "water_depth"

rules:
- formula_rule:
name: Amplify water_level
description: Amplify waterlevel with 25%
formula: water_level * 1.25
input_variables: [water_level]
output_variable: water_level_scenario

- formula_rule:
name: calculate water_depth_scenario
description: Amplify waterdepth scenario
formula: (water_depth - water_level) + water_level_scenario
input_variables: [water_level, water_depth, water_level_scenario]
output_variable: water_depth_scenario

output-data:
filename: ./tests_acceptance/output_nc_files/test10b_formula_based_arithmatic.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
input-data:
- dataset:
filename: ./tests_acceptance/input_nc_files/small_subset_FM-VZM_0000_map.nc
variable_mapping:
salinity_PSU: "salinity"
water_level_mNAP: "water_level"
water_depth_mNAP: "water_depth"

rules:
- formula_rule:
name: Subset water level
description: Subset water level to where water is
formula: -999 if(water_depth <= 0.10) else water_level
input_variables: [water_level, water_depth]
output_variable: water_level_subset

- formula_rule:
name: Classify water depths
description: Classify water depths (0 = dry, 1 = <1m, 2 = >1m)
formula: 0 if(water_depth <= 0.10) else (1 if(water_depth <= 1.00) else 2)
input_variables: [water_depth]
output_variable: water_depth_class

- formula_rule:
name: Calculate deviation allowed water level
description: Only show deviation (in m) from allowed water levels (-0.10 - 0.15 m NAP)
formula: >
water_level + 0.10 if(water_level < -0.10) else
(water_level - 0.15 if(water_level > 0.15) else 0)
input_variables: [water_level]
output_variable: water_level_deviation

output-data:
filename: ./tests_acceptance/output_nc_files/test10c_formula_based_ifelse.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
input-data:
- dataset:
filename: ./tests_acceptance/input_nc_files/small_subset_FM-VZM_0000_map.nc
variable_mapping:
salinity_PSU: "salinity"
water_level_mNAP: "water_level"
water_depth_mNAP: "water_depth"

rules:
- step_function_rule: !include tables/stepfunction.yaml

- response_curve_rule:
name: test name
description: Get flowing value waterlevel
response_table: !include tables/input_response_curve.yaml
input_variable: water_level
output_variable: water_level_policy

output-data:
filename: ./tests_acceptance/output_nc_files/test11_yaml_include_file_response_curve_stepfunction.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
input-data:
- dataset:
filename: ./tests_acceptance/input_nc_files/small_subset_FM-VZM_0000_map.nc
variable_mapping:
salinity_PSU: "salinity"
water_level_mNAP: "water_level"
water_depth_mNAP: "water_depth"

rules:
- response_curve_rule: !include tables/input_IRM1.yaml

- response_curve_rule: !include tables/input_IRM2.yaml

output-data:
filename: ./tests_acceptance/output_nc_files/test11b_yaml_include_file_response_curve_stepfunction_fullfunction.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
input-data:
- dataset:
filename: ./tests_acceptance/input_nc_files/small_subset_FM-VZM_0000_map.nc
variable_mapping:
salinity_PSU: "salinity_PHU"
temperature_degreesC: "temperature_C"
flow_velocity_ms: "flow_velocity_msec"
water_level_mNAP: "water_level_meterNAP"
water_depth_mNAP: "water_depth_meterNAP"

rules:
- multiply_rule:
name: Get chloride concentration
description: Converts salinity to chloride
multipliers: [0.0018066, 1e5]
input_variable: salinity_PHU
output_variable: chloride_mgL

- layer_filter_rule:
name: Get chloride top layer
description: get first layer of model
layer_number: 22
input_variable: chloride_mgL
output_variable: chloride_mgL_top_layer

- layer_filter_rule:
name: Get temperature top layer
description: get first layer of model
layer_number: 22
input_variable: temperature_C
output_variable: temperature_C_top_layer

- layer_filter_rule:
name: Get flow velocity top layer
description: get first layer of model
layer_number: 22
input_variable: flow_velocity_msec
output_variable: flow_velocity_ms_top_layer

- time_aggregation_rule:
name: Get maximum chloride level
description: Get maximum chloride level
operation: MAX
input_variable: chloride_mgL_top_layer
time_scale: year
output_variable: MAX_chloride

- time_aggregation_rule:
name: Get minimum water temperature
description: Get minimum water temperature
operation: MIN
input_variable: temperature_C_top_layer
time_scale: year
output_variable: MIN_water_temperature

- time_aggregation_rule:
name: Get maximum flow velocity
description: Get maximum flow velocity
operation: MIN
input_variable: flow_velocity_ms_top_layer
time_scale: year
output_variable: MAX_flow_velocity

- time_aggregation_rule:
name: Get minimum water_depth
description: Get minimum water depth
operation: MIN
input_variable: water_depth_meterNAP
time_scale: year
output_variable: MIN_water_depth_mNAP

- classification_rule:
name: test calssification for aquatic plants
description: Get flowing value waterlevel
criteria_table:
- [
"output",
"MIN_water_depth_mNAP",
"MAX_flow_velocity",
"MAX_chloride",
]
- [1, "<0.10", "-", "-"] # to dry
- [2, ">4.0", "-", "-"] # to deep
- [3, "-", "-", ">400"] # to salty
- [4, "-", ">1.5", "-"] # to fast flowing
- [5, "0.10:4.0", "0.0:1.5", "0:400"] # perfect for aquatic plants
input_variables:
["MIN_water_depth_mNAP", "MAX_flow_velocity", "MAX_chloride"]
output_variable: aquatic_plant_classes

output-data:
filename: ./tests_acceptance/output_nc_files/test12_multiple_reclassification.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
input-data:
- dataset:
filename: ./tests_acceptance/input_nc_files/small_subset_FM-VZM_0000_map.nc
variable_mapping:
# salinity_PSU : "IN_salinity_PSU"
# water_level_mNAP : "IN_water_level_mNAP"
water_depth_mNAP: "IN_water_depth_mNAP"
# flow_velocity_ms : "IN_flow_velocity_ms"

rules:
- step_function_rule:
name: Calculate dryfall moments
description: Calculate dryfall moments from water depth
limit_response_table:
- [limit, response]
- [-999.0, 1.00]
- [0.10, 0.00]
- [999.0, 0.00]
input_variable: IN_water_depth_mNAP
output_variable: dry_fall

- time_aggregation_rule:
name: Calculate dryfall occurance
description: Calculate dryfall occurance (nr of occurances/periods)
operation: COUNT_PERIODS
time_scale: YEAR
input_variable: dry_fall
output_variable: number_of_dry_periods

- time_aggregation_rule:
name: test for flooding
description: Test for flooding in area
operation: MIN
time_scale: YEAR
input_variable: dry_fall
output_variable: no_flooding

- step_function_rule:
name: Set land to -1
description: Set land to -1 for visualisation
limit_response_table:
- [limit, response]
- [0, 366]
- [1, -1]
input_variable: no_flooding
output_variable: land_filter

- combine_results_rule:
name: Set land to -1
description: Set land to -1 for visualisation
operation: min
input_variables: ["number_of_dry_periods", "land_filter"]
output_variable: Visualisation_number_of_dry_fall_periods

output-data:
filename: ./tests_acceptance/output_nc_files/test13_time_condition_rule_occurance.nc
Loading

0 comments on commit e1f444d

Please sign in to comment.