Skip to content

Commit

Permalink
rename variables to variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mKlapwijk committed Sep 4, 2024
1 parent e2480ea commit 66f10c7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions decoimpact/business/entities/rules/depth_average_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def execute(
# the ordering defined in the parser.
values_list = list(value_arrays.values())

variables = values_list[0]
variable = values_list[0]
bed_level_values = values_list[1]
water_level_values = values_list[2]
depths_interfaces = values_list[3]
Expand All @@ -52,9 +52,9 @@ def execute(
interfaces_len = depths_interfaces[dim_interfaces_name].size

dim_layer_name = [
d for d in variables.dims if d not in water_level_values.dims
d for d in variable.dims if d not in water_level_values.dims
][0]
layer_len = variables[dim_layer_name].size
layer_len = variable[dim_layer_name].size

# interface dimension should always be one larger than layer dimension
# Otherwise give an error to the user
Expand All @@ -63,7 +63,7 @@ def execute(
f"The number of interfaces should be number of layers + 1. Number of "
f"interfaces = {interfaces_len}. Number of layers = {layer_len}."
)
return variables
return variable

# Deal with open layer system at water level and bed level
depths_interfaces.values[depths_interfaces.values.argmin()] = -100000
Expand Down Expand Up @@ -92,11 +92,11 @@ def execute(
layer_heights = corrected_depth_bed.diff(dim=dim_interfaces_name)
layer_heights = layer_heights.rename({dim_interfaces_name: dim_layer_name})

# Use the NaN filtering of the variables to set the correct depth per column
layer_heights = layer_heights.where(variables.notnull())
# Use the NaN filtering of the variable to set the correct depth per column
layer_heights = layer_heights.where(variable.notnull())

# Calculate depth average using relative value
relative_values = variables * layer_heights
relative_values = variable * layer_heights

# Calculate average
return relative_values.sum(dim=dim_layer_name) / layer_heights.sum(
Expand Down

0 comments on commit 66f10c7

Please sign in to comment.