Skip to content

Commit

Permalink
Improve input parameter names (not directly part of model)
Browse files Browse the repository at this point in the history
Use `count` instead of `number` as quantity as it preferable according CSDMS. Move reservoir and lake location and area IDs to this list (from `input.parameters`), for the `sediment` model type reservoir and lake area  IDS were already part of `input`.
  • Loading branch information
vers-w committed Jan 17, 2025
1 parent 899ca40 commit f52d8ca
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 91 deletions.
16 changes: 8 additions & 8 deletions server/test/sbm_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ path_forcing = "forcing-moselle.nc"
path_static = "staticmaps-moselle.nc"

# these are not directly part of the model
gauges = "wflow_gauges_grdc"
river_gauge = "wflow_gauges_grdc"
local_drain_direction = "wflow_ldd"
river_location = "wflow_river"
subcatchment = "wflow_subcatch"
river_location__mask = "wflow_river"
reservoir_area__count = "wflow_reservoirareas"
reservoir_location__count = "wflow_reservoirlocs"
subcatchment_location__count = "wflow_subcatch"

[input.forcing]
atmosphere_water__precipitation_volume_flux = "precip"
Expand Down Expand Up @@ -99,8 +101,6 @@ river_bank_water__elevation = "RiverZ"
land_surface_water_flow__manning_n_parameter = "N"
land_surface__slope = "Slope"

reservoir_area__number = "wflow_reservoirareas"
reservoir_location__number = "wflow_reservoirlocs"
reservoir_surface__area = "ResSimpleArea"
"reservoir_water_demand~required~downstream__volume_flow_rate" = "ResDemand"
reservoir_water_release-below-spillway__max_volume_flow_rate = "ResMaxRelease"
Expand Down Expand Up @@ -159,7 +159,7 @@ path = "output_scalar_moselle.nc"

[[netcdf.variable]]
name = "Q"
map = "gauges"
map = "river_gauge"
parameter = "routing.river_flow.variables.q"

[[netcdf.variable]]
Expand Down Expand Up @@ -210,12 +210,12 @@ parameter = "atmosphere_air__temperature"

[[csv.column]]
header = "Q"
map = "gauges"
map = "river_gauge"
parameter = "river_water__volume_flow_rate"

[[csv.column]]
header = "recharge"
map = "subcatchment"
map = "subcatchment_location__count"
parameter = "soil_water_sat-zone_top__recharge_volume_flux"
reducer = "mean"

Expand Down
2 changes: 1 addition & 1 deletion src/demand/water_demand.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ end
irrigation_efficiency::Vector{T} | "-" # irrigation efficiency [-]
maximum_irrigation_rate::Vector{T} # maximum irrigation rate [mm Δt⁻¹]
irrigation_areas::Vector{Bool} | "-" # irrigation areas [-]
irrigation_trigger::Vector{Bool} | "-" # irrigation on or off [-]end
irrigation_trigger::Vector{Bool} | "-" # irrigation on or off [-]
end

"Non-paddy (other crops than flooded rice) irrigation model"
Expand Down
10 changes: 5 additions & 5 deletions src/routing/lake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ function LakeParameters(config, dataset, inds_riv, nriv, pits)
# read only lake data if lakes true
# allow lakes only in river cells
# note that these locations are only the lake outlet pixels
lens = lens_input("lake_location__number")
lens = lens_input("lake_location__count")
lakelocs_2d = ncread(dataset, config, lens; optional = false, type = Int, fill = 0)
lakelocs = lakelocs_2d[inds_riv]

# this holds the same ids as lakelocs, but covers the entire lake
lens = lens_input("lakes_area__number")
lens = lens_input("lakes_area__count")
lakecoverage_2d = ncread(dataset, config, lens; optional = false, allow_missing = true)
# for each lake, a list of 2D indices, needed for getting the mean precipitation
inds_lake_cov = Vector{CartesianIndex{2}}[]
Expand Down Expand Up @@ -90,10 +90,10 @@ function LakeParameters(config, dataset, inds_riv, nriv, pits)
type = Float,
fill = 0,
)
lens = lens_input_parameter("lake~lower_location__number")
lens = lens_input("lake~lower_location__count")
linked_lakelocs =
ncread(dataset, config, lens; sel = inds_lake, defaults = 0, type = Int, fill = 0)
lens = lens_input_parameter("lake_water__storage_curve_type_number")
lens = lens_input_parameter("lake_water__storage_curve_type_count")
lake_storfunc = ncread(
dataset,
config,
Expand All @@ -103,7 +103,7 @@ function LakeParameters(config, dataset, inds_riv, nriv, pits)
type = Int,
fill = 0,
)
lens = lens_input_parameter("lake_water__rating_curve_type_number")
lens = lens_input_parameter("lake_water__rating_curve_type_count")
lake_outflowfunc = ncread(
dataset,
config,
Expand Down
4 changes: 2 additions & 2 deletions src/routing/reservoir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function ReservoirParameters(dataset, config, indices_river, n_river_cells, pits
# read only reservoir data if reservoirs true
# allow reservoirs only in river cells
# note that these locations are only the reservoir outlet pixels
lens = lens_input_parameter("reservoir_location__number")
lens = lens_input("reservoir_location__count")
reslocs = ncread(
dataset,
config,
Expand All @@ -25,7 +25,7 @@ function ReservoirParameters(dataset, config, indices_river, n_river_cells, pits
)

# this holds the same ids as reslocs, but covers the entire reservoir
lens = lens_input_parameter("reservoir_area__number")
lens = lens_input("reservoir_area__count")
rescoverage_2d = ncread(dataset, config, lens; optional = false, allow_missing = true)
# for each reservoir, a list of 2D indices, needed for getting the mean precipitation
inds_res_cov = Vector{CartesianIndex{2}}[]
Expand Down
6 changes: 3 additions & 3 deletions src/sbm_gwf_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ function initialize_sbm_gwf_model(config::Config)

dataset = NCDataset(static_path)

lens = lens_input("subcatchment")
lens = lens_input("subcatchment_location__count")
subcatch_2d = ncread(dataset, config, lens; optional = false, allow_missing = true)
# indices based on catchment
indices, reverse_indices = active_indices(subcatch_2d, missing)
n_land_cells = length(indices)
modelsize_2d = size(subcatch_2d)

lens = lens_input("river_location")
lens = lens_input("river_location__mask")
river_location_2d =
ncread(dataset, config, lens; optional = false, type = Bool, fill = false)
river_location = river_location_2d[indices]
Expand All @@ -61,7 +61,7 @@ function initialize_sbm_gwf_model(config::Config)
ncread(dataset, config, lens; optional = false, type = Float, fill = 0)
river_length = river_length_2d[indices]

lens = lens_input("altitude")
lens = lens_input_parameter("land_surface__elevation")
altitude = ncread(dataset, config, lens; optional = false, sel = indices, type = Float)

# read x, y coordinates and calculate cell length [m]
Expand Down
4 changes: 2 additions & 2 deletions src/sbm_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ function initialize_sbm_model(config::Config)

dataset = NCDataset(static_path)

lens = lens_input("subcatchment")
lens = lens_input("subcatchment_location__count")
subcatch_2d = ncread(dataset, config, lens; optional = false, allow_missing = true)
# indices based on sub-catchments
indices, reverse_indices = active_indices(subcatch_2d, missing)
n_land_cells = length(indices)
modelsize_2d = size(subcatch_2d)

lens = lens_input("river_location")
lens = lens_input("river_location__mask")
river_location_2d =
ncread(dataset, config, lens; optional = false, type = Bool, fill = false)
river_location = river_location_2d[indices]
Expand Down
4 changes: 2 additions & 2 deletions src/sediment/sediment_transport/river_transport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function SedimentRiverTransportParameters(dataset, config, indices)
do_lakes = get(config.model, "dolake", false)::Bool

if do_reservoirs
lens = lens_input_parameter("reservoir_location__number")
lens = lens_input("reservoir_location__count")
reslocs = ncread(
dataset,
config,
Expand Down Expand Up @@ -237,7 +237,7 @@ function SedimentRiverTransportParameters(dataset, config, indices)
end

if do_lakes
lens = lens_input_parameter("lake_location__number")
lens = lens_input("lake_location__count")
lakelocs = ncread(
dataset,
config,
Expand Down
8 changes: 4 additions & 4 deletions src/sediment_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ function initialize_sediment_model(config::Config)
clock = Clock(config, reader)
dataset = NCDataset(static_path)

lens = lens_input("subcatchment")
lens = lens_input("subcatchment_location__count")
subcatch_2d = ncread(dataset, config, lens; optional = false, allow_missing = true)
# indices based on catchment
indices, rev_indices = active_indices(subcatch_2d, missing)
n = length(indices)

lens = lens_input("river_location")
lens = lens_input("river_location__mask")
river_2d = ncread(dataset, config, lens; optional = false, type = Bool, fill = false)
river = river_2d[indices]

Expand All @@ -32,7 +32,7 @@ function initialize_sediment_model(config::Config)
do_lakes = get(config.model, "dolake", false)::Bool
waterbodies = fill(0.0, n)
if do_reservoirs
lens = lens_input("reservoir_area__number")
lens = lens_input("reservoir_area__count")
reservoirs = ncread(
dataset,
config,
Expand All @@ -45,7 +45,7 @@ function initialize_sediment_model(config::Config)
waterbodies = waterbodies .+ reservoirs
end
if do_lakes
lens = lens_input("lake_area__number")
lens = lens_input("lake_area__count")
lakes = ncread(
dataset,
config,
Expand Down
4 changes: 2 additions & 2 deletions test/run_sbm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ end
8.601765f0,
2.7730224f0,
]
@test ds["Q_gauges"].attrib["cf_role"] == "timeseries_id"
@test ds["Q_river_gauge"].attrib["cf_role"] == "timeseries_id"
@test ds["temp_index"][:] [2.39f0]
@test ds["temp_coord"][:] [2.39f0]
@test keys(ds.dim) == ["time", "layer", "Q_gauges", "temp_bycoord", "temp_byindex"]
@test keys(ds.dim) == ["time", "layer", "Q_river_gauge", "temp_bycoord", "temp_byindex"]
end

@testset "first timestep" begin
Expand Down
16 changes: 8 additions & 8 deletions test/sbm_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ path_forcing = "forcing-moselle.nc"
path_static = "staticmaps-moselle.nc"

# these are not directly part of the model
gauges = "wflow_gauges_grdc"
local_drain_direction = "wflow_ldd"
river_location = "wflow_river"
subcatchment = "wflow_subcatch"
river_location__mask = "wflow_river"
reservoir_area__count = "wflow_reservoirareas"
reservoir_location__count = "wflow_reservoirlocs"
subcatchment_location__count = "wflow_subcatch"
river_gauge = "wflow_gauges_grdc"

[input.forcing]
atmosphere_water__precipitation_volume_flux = "precip"
Expand Down Expand Up @@ -99,8 +101,6 @@ river_bank_water__elevation = "RiverZ"
land_surface_water_flow__manning_n_parameter = "N"
land_surface__slope = "Slope"

reservoir_area__number = "wflow_reservoirareas"
reservoir_location__number = "wflow_reservoirlocs"
reservoir_surface__area = "ResSimpleArea"
"reservoir_water_demand~required~downstream__volume_flow_rate" = "ResDemand"
reservoir_water_release-below-spillway__max_volume_flow_rate = "ResMaxRelease"
Expand Down Expand Up @@ -159,7 +159,7 @@ path = "output_scalar_moselle.nc"

[[netcdf.variable]]
name = "Q"
map = "gauges"
map = "river_gauge"
parameter = "routing.river_flow.variables.q"

[[netcdf.variable]]
Expand Down Expand Up @@ -210,12 +210,12 @@ parameter = "atmosphere_air__temperature"

[[csv.column]]
header = "Q"
map = "gauges"
map = "river_gauge"
parameter = "river_water__volume_flow_rate"

[[csv.column]]
header = "recharge"
map = "subcatchment"
map = "subcatchment_location__count"
parameter = "soil_water_sat-zone_top__net_recharge_volume_flux"
reducer = "mean"

Expand Down
16 changes: 8 additions & 8 deletions test/sbm_gw.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ path_forcing = "forcing-moselle.nc"
path_static = "staticmaps-moselle.nc"

# these are not directly part of the model
gauges = "wflow_gauges_grdc"
local_drain_direction = "wflow_ldd"
river_location = "wflow_river"
subcatchment = "wflow_subcatch"
river_location__mask = "wflow_river"
reservoir_area__count = "wflow_reservoirareas"
reservoir_location__count = "wflow_reservoirlocs"
subcatchment_location__count = "wflow_subcatch"
river_gauge = "wflow_gauges_grdc"

[input.forcing]
atmosphere_water__precipitation_volume_flux = "precip"
Expand Down Expand Up @@ -93,8 +95,6 @@ river__width = "wflow_riverwidth"
land_surface_water_flow__manning_n_parameter = "N"
land_surface__slope = "Slope"

reservoir_area__number = "wflow_reservoirareas"
reservoir_location__number = "wflow_reservoirlocs"
reservoir_surface__area = "ResSimpleArea"
"reservoir_water_demand~required~downstream__volume_flow_rate" = "ResDemand"
reservoir_water_release-below-spillway__max_volume_flow_rate = "ResMaxRelease"
Expand Down Expand Up @@ -144,7 +144,7 @@ path = "output_scalar_moselle.nc"

[[netcdf.variable]]
name = "Q"
map = "gauges"
map = "river_gauge"
parameter = "river_water__volume_flow_rate"

[[netcdf.variable]]
Expand Down Expand Up @@ -188,12 +188,12 @@ parameter = "atmosphere_air__temperature"

[[csv.column]]
header = "Q"
map = "gauges"
map = "river_gauge"
parameter = "river_water__volume_flow_rate"

[[csv.column]]
header = "recharge"
map = "subcatchment"
map = "subcatchment_location__count"
parameter = "soil_water_sat-zone_top__recharge_volume_flux"
reducer = "mean"

Expand Down
6 changes: 3 additions & 3 deletions test/sbm_gwf_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ path_static = "staticmaps-sbm-groundwater.nc"

# these are not directly part of the model
local_drain_direction = "wflow_ldd"
river_location = "wflow_river"
subcatchment = "wflow_subcatch"
altitude = "wflow_dem"
river_location__mask = "wflow_river"
subcatchment_location__count = "wflow_subcatch"

[input.forcing]
atmosphere_water__precipitation_volume_flux = "P"
Expand All @@ -69,6 +68,7 @@ river__slope = "RiverSlope"
river__width = "wflow_riverwidth"

land_surface_water_flow__manning_n_parameter = "N"
land_surface__elevation = "wflow_dem"
land_surface__slope = "Slope"

subsurface_surface_water__horizontal_saturated_hydraulic_conductivity = "k"
Expand Down
14 changes: 7 additions & 7 deletions test/sbm_gwf_piave_demand_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ path_forcing = "forcing-piave.nc"
path_static = "staticmaps-piave.nc"

local_drain_direction = "wflow_ldd"
river_location = "wflow_river"
altitude = "wflow_dem"
subcatchment = "wflow_subcatch"
gauges = "wflow_gauges"
gauges_grdc = "wflow_gauges_grdc"
river_location__mask = "wflow_river"
subcatchment_location__count = "wflow_subcatch"
river_gauge = "wflow_gauges"
river_gauge_grdc = "wflow_gauges_grdc"

[input.forcing]
atmosphere_water__precipitation_volume_flux = "precip"
Expand Down Expand Up @@ -105,6 +104,7 @@ river__width = "wflow_riverwidth"
river_bank_water__depth = "RiverDepth"

land_surface_water_flow__manning_n_parameter = "N"
land_surface__elevation = "wflow_dem"
land_surface__slope = "Slope"

land_water_allocation_area__number = "allocation_areas"
Expand Down Expand Up @@ -183,10 +183,10 @@ path = "output.csv"

[[csv.column]]
header = "Q"
map = "gauges"
map = "river_gauge"
parameter = "river_water__time_average_of_volume_flow_rate"

[[csv.column]]
header = "Q"
map = "gauges_grdc"
map = "river_gauge_grdc"
parameter = "river_water__time_average_of_volume_flow_rate"
Loading

0 comments on commit f52d8ca

Please sign in to comment.