Skip to content

Commit 0ff633a

Browse files
committed
Update output.csv.map if pointing to lake.locs
Fixes #439 v0 to v1 upgrade now also checks for csv.column.map and updates it in the new output variable output.csv.column.map. "lateral.river.lake.locs" and "lateral.river.reservoir.locs" become "reservoir_location__count"
1 parent f9503a4 commit 0ff633a

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

examples/data/wflow_upgrade/sbm/wflow_sbm_v0x.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ gauges = "wflow_gauges"
1818
ldd = "wflow_ldd"
1919
river_location = "wflow_river"
2020
subcatchment = "wflow_subcatch"
21-
forcing = [ "vertical.precipitation", "vertical.temperature", "vertical.potential_evaporation",]
22-
cyclic = [ "vertical.leaf_area_index",]
21+
forcing = [
22+
"vertical.precipitation",
23+
"vertical.temperature",
24+
"vertical.potential_evaporation",
25+
]
26+
cyclic = ["vertical.leaf_area_index"]
2327
gauges_grdc = "wflow_gauges_grdc"
2428

2529
[model]
@@ -35,7 +39,7 @@ river_routing = "kinematic-wave"
3539
kin_wave_iteration = true
3640
kw_river_tstep = 900
3741
kw_land_tstep = 3600
38-
thicknesslayers = [ 100, 300, 800,]
42+
thicknesslayers = [100, 300, 800]
3943

4044
[state.vertical]
4145
satwaterdepth = "satwaterdepth"
@@ -190,7 +194,7 @@ parameter = "vertical.temperature"
190194

191195
[[csv.column]]
192196
header = "Q"
193-
map = "gauges_grdc"
197+
map = "lateral.river.lake.locs"
194198
parameter = "lateral.river.q_av"
195199

196200
[[csv.column]]

hydromt_wflow/version_upgrade.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ def _update_output_netcdf_grid(wflow_var, var_name):
249249
config_out["output"]["netcdf_scalar"]["variable"] = []
250250
nc_scalar_vars = get_config(config, "netcdf.variable", fallback=[])
251251
for nc_scalar in nc_scalar_vars:
252-
if nc_scalar["parameter"] in WFLOW_CONVERSION.keys():
252+
if nc_scalar["parameter"] in WFLOW_CONVERSION:
253253
nc_scalar["parameter"] = WFLOW_CONVERSION[nc_scalar["parameter"]]
254-
if "map" in nc_scalar and nc_scalar["map"] in input_options.keys():
254+
if "map" in nc_scalar and nc_scalar["map"] in input_options:
255255
nc_scalar["map"] = input_options[nc_scalar["map"]]
256256
config_out["output"]["netcdf_scalar"]["variable"].append(nc_scalar)
257257
else:
@@ -269,10 +269,16 @@ def _update_output_netcdf_grid(wflow_var, var_name):
269269
config_out["output"]["csv"]["column"] = []
270270
csv_vars = get_config(config, "csv.column", fallback=[])
271271
for csv_var in csv_vars:
272-
if csv_var["parameter"] in WFLOW_CONVERSION.keys():
272+
if csv_var["parameter"] in WFLOW_CONVERSION:
273273
csv_var["parameter"] = WFLOW_CONVERSION[csv_var["parameter"]]
274-
if csv_var.get("map", None) in input_options.keys():
275-
csv_var["map"] = input_options[csv_var["map"]]
274+
if map_var := csv_var.get("map", None):
275+
if map_var in input_options:
276+
csv_var["map"] = input_options[map_var]
277+
elif map_var in [
278+
"lateral.river.lake.locs",
279+
"lateral.river.reservoir.locs",
280+
]:
281+
csv_var["map"] = "reservoir_location__count"
276282
config_out["output"]["csv"]["column"].append(csv_var)
277283
else:
278284
_warn_str(csv_var["parameter"], "csv")

tests/data/wflow_v0x/sbm/wflow_sbm_v1.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ river_routing = "kinematic-wave"
1818
kinematic_wave__adaptive_time_step_flag = true
1919
river_kinematic_wave__time_step = 900
2020
land_kinematic_wave__time_step = 3600
21-
soil_layer__thickness = [ 100, 300, 800,]
21+
soil_layer__thickness = [100, 300, 800]
2222
reservoir__flag = true
2323

2424
[state]
@@ -162,7 +162,7 @@ x = 11
162162
y = 6
163163
[[output.csv.column]]
164164
header = "Q"
165-
map = "gauges_grdc"
165+
map = "reservoir_location__count"
166166
parameter = "river_water__volume_flow_rate"
167167

168168
[[output.csv.column]]

0 commit comments

Comments
 (0)