diff --git a/src/Wflow.jl b/src/Wflow.jl index b54db1c60..794c10c53 100644 --- a/src/Wflow.jl +++ b/src/Wflow.jl @@ -113,7 +113,6 @@ function Clock(config, reader) return Clock(starttime, 0, dt) end -include("standard_name.jl") include("io.jl") """ @@ -181,6 +180,7 @@ include("erosion.jl") include("sediment_flux.jl") include("sediment_model.jl") include("sbm_gwf_model.jl") +include("standard_name.jl") include("utils.jl") include("bmi.jl") include("subdomains.jl") diff --git a/src/io.jl b/src/io.jl index 7c58540c3..8edb2792a 100644 --- a/src/io.jl +++ b/src/io.jl @@ -215,7 +215,7 @@ mover_params = ( ) function load_fixed_forcing!(model) - (; reader, network, config) = model + (; reader, vertical, network, config) = model (; forcing_parameters) = reader do_reservoirs = get(config.model, "reservoirs", false)::Bool @@ -234,7 +234,7 @@ function load_fixed_forcing!(model) for (par, ncvar) in forcing_parameters if ncvar.name === nothing val = ncvar.value * ncvar.scale + ncvar.offset - lens = standard_name_map[par] + lens = standard_name_map(vertical)[par] param_vector = lens(model) param_vector .= val # set fixed precipitation and evaporation over the lakes and reservoirs and put @@ -261,7 +261,7 @@ end "Get dynamic netCDF input for the given time" function update_forcing!(model) - (; clock, reader, network, config) = model + (; clock, reader, vertical, network, config) = model (; dataset, dataset_times, forcing_parameters) = reader do_reservoirs = get(config.model, "reservoirs", false)::Bool @@ -311,7 +311,7 @@ function update_forcing!(model) end end end - lens = standard_name_map[par] + lens = standard_name_map(vertical)[par] param_vector = lens(model) sel = active_indices(network, par) data_sel = data[sel] @@ -352,7 +352,7 @@ end "Get cyclic netCDF input for the given time" function update_cyclic!(model) - (; clock, reader, network) = model + (; clock, reader, vertical, network) = model (; cyclic_dataset, cyclic_times, cyclic_parameters) = reader # pick up the data that is valid for the past model time step @@ -368,7 +368,7 @@ function update_cyclic!(model) error("Could not find applicable cyclic timestep for $month_day") # load from netCDF into the model according to the mapping data = get_at(cyclic_dataset, ncvar.name, i) - lens = standard_name_map[par] + lens = standard_name_map(vertical)[par] param_vector = lens(model) sel = active_indices(network, par) param_vector .= data[sel] @@ -419,6 +419,7 @@ function setup_scalar_netcdf( config, float_type = Float32, ) + (; vertical) = modelmap ds = create_tracked_netcdf(path) defDim(ds, "time", Inf) # unlimited defVar( @@ -439,8 +440,8 @@ function setup_scalar_netcdf( (nc.location_dim,); attrib = ["cf_role" => "timeseries_id"], ) - v = if haskey(standard_name_map, nc.par) - lens = standard_name_map[nc.par] + v = if haskey(standard_name_map(vertical), nc.par) + lens = standard_name_map(vertical)[nc.par] lens(modelmap) else param(modelmap, nc.par) @@ -906,9 +907,10 @@ Create a Dict that maps parameter netCDF names to arrays in the Model. """ function out_map(ncnames_dict, modelmap) output_map = Dict{String, Any}() + (; vertical) = modelmap for (par, ncname) in ncnames_dict - A = if haskey(standard_name_map, par) - lens = standard_name_map[par] + A = if haskey(standard_name_map(vertical), par) + lens = standard_name_map(vertical)[par] lens(modelmap) else param(modelmap, par) @@ -1081,12 +1083,12 @@ end "Write a new timestep with scalar data to a netCDF file" function write_netcdf_timestep(model, dataset) - (; writer, clock, config) = model + (; writer, vertical, clock, config) = model time_index = add_time(dataset, clock.time) for (nt, nc) in zip(writer.nc_scalar, config.netcdf.variable) - A = if haskey(standard_name_map, nt.parameter) - lens = standard_name_map[nt.parameter] + A = if haskey(standard_name_map(vertical), nt.parameter) + lens = standard_name_map(vertical)[nt.parameter] lens(model) else param(model, nt.parameter) @@ -1336,13 +1338,13 @@ function reducer(col, rev_inds, x_nc, y_nc, config, dataset, fileformat) end function write_csv_row(model) - (; writer, clock, config) = model + (; writer, vertical, clock, config) = model isnothing(writer.csv_path) && return nothing io = writer.csv_io print(io, string(clock.time)) for (nt, col) in zip(writer.csv_cols, config.csv.column) - A = if haskey(standard_name_map, nt.parameter) - lens = standard_name_map[nt.parameter] + A = if haskey(standard_name_map(vertical), nt.parameter) + lens = standard_name_map(vertical)[nt.parameter] lens(model) else param(model, nt.parameter) diff --git a/src/parameters.jl b/src/parameters.jl index 1ca2eb7d3..e562bf6b1 100644 --- a/src/parameters.jl +++ b/src/parameters.jl @@ -86,16 +86,11 @@ function LandGeometry(nc, config, inds) sizeinmetres = get(config.model, "sizeinmetres", false)::Bool xl, yl = cell_lengths(y, cellength, sizeinmetres) area = xl .* yl - ldd = ncread(nc, config, "ldd"; optional = false, sel = inds, allow_missing = true) + lens = lens_input("ldd") + ldd = ncread(nc, config, lens; optional = false, sel = inds, allow_missing = true) drain_width = map(get_flow_width, ldd, xl, yl) - landslope = ncread( - nc, - config, - "vertical.land_parameter_set.slope"; - optional = false, - sel = inds, - type = Float, - ) + lens = lens_input_parameter("land_surface__slope") + landslope = ncread(nc, config, lens; optional = false, sel = inds, type = Float) clamp!(landslope, 0.00001, Inf) land_parameter_set = @@ -115,30 +110,13 @@ end "Initialize river geometry parameters" function RiverGeometry(nc, config, inds) - riverwidth = ncread( - nc, - config, - "lateral.river_parameter_set.width"; - optional = false, - sel = inds, - type = Float, - ) - riverlength = ncread( - nc, - config, - "lateral.river_parameter_set.length"; - optional = false, - sel = inds, - type = Float, - ) - riverslope = ncread( - nc, - config, - "lateral.river_parameter_set.slope"; - optional = false, - sel = inds, - type = Float, - ) + lens = lens_input_parameter("river__width") + riverwidth = ncread(nc, config, lens; optional = false, sel = inds, type = Float) + lens = lens_input_parameter("river__length") + riverlength = ncread(nc, config, lens; optional = false, sel = inds, type = Float) + lens = lens_input_parameter("river__slope") + riverslope = ncread(nc, config, lens; optional = false, sel = inds, type = Float) + minimum(riverlength) > 0 || error("river length must be positive on river cells") minimum(riverwidth) > 0 || error("river width must be positive on river cells") clamp!(riverslope, 0.00001, Inf) diff --git a/src/sediment/erosion/overland_flow_erosion.jl b/src/sediment/erosion/overland_flow_erosion.jl index 879af50fd..9e0b486ef 100644 --- a/src/sediment/erosion/overland_flow_erosion.jl +++ b/src/sediment/erosion/overland_flow_erosion.jl @@ -34,30 +34,13 @@ end "Initialize ANSWERS overland flow erosion model parameters" function OverlandFlowErosionAnswersParameters(dataset, config, indices) - usle_k = ncread( - dataset, - config, - "vertical.overland_flow_erosion.parameters.usle_k"; - sel = indices, - defaults = 0.1, - type = Float, - ) - usle_c = ncread( - dataset, - config, - "vertical.overland_flow_erosion.parameters.usle_c"; - sel = indices, - defaults = 0.01, - type = Float, - ) - answers_k = ncread( - dataset, - config, - "vertical.overland_flow_erosion.parameters.answers_k"; - sel = indices, - defaults = 0.9, - type = Float, - ) + lens = lens_input_parameter("soil_erosion__usle_k_factor") + usle_k = ncread(dataset, config, lens; sel = indices, defaults = 0.1, type = Float) + lens = lens_input_parameter("soil_erosion__usle_c_factor") + usle_c = ncread(dataset, config, lens; sel = indices, defaults = 0.01, type = Float) + lens = lens_input_parameter("soil_erosion__answers_overland_flow_factor") + answers_k = ncread(dataset, config, lens; sel = indices, defaults = 0.9, type = Float) + answers_parameters = OverlandFlowErosionAnswersParameters(; usle_k = usle_k, usle_c = usle_c, diff --git a/src/sediment/erosion/rainfall_erosion.jl b/src/sediment/erosion/rainfall_erosion.jl index 73016f874..62e01f912 100644 --- a/src/sediment/erosion/rainfall_erosion.jl +++ b/src/sediment/erosion/rainfall_erosion.jl @@ -51,46 +51,22 @@ end "Initialize EUROSEM rainfall erosion model parameters" function RainfallErosionEurosemParameters(dataset, config, indices) - soil_detachability = ncread( - dataset, - config, - "vertical.rainfall_erosion.parameters.soil_detachability"; - sel = indices, - defaults = 0.6, - type = Float, - ) - eurosem_exponent = ncread( - dataset, - config, - "vertical.rainfall_erosion.parameters.eurosem_exponent"; - sel = indices, - defaults = 2.0, - type = Float, - ) - canopyheight = ncread( - dataset, - config, - "vertical.rainfall_erosion.parameters.canopyheight"; - sel = indices, - defaults = 0.5, - type = Float, - ) - canopygapfraction = ncread( - dataset, - config, - "vertical.rainfall_erosion.parameters.canopygapfraction"; - sel = indices, - defaults = 0.1, - type = Float, - ) - soilcover_fraction = ncread( - dataset, - config, - "vertical.rainfall_erosion.parameters.pathfrac"; - sel = indices, - defaults = 0.01, - type = Float, - ) + lens = lens_input_parameter("soil_erosion__rainfall_soil_detachability_factor") + soil_detachability = + ncread(dataset, config, lens; sel = indices, defaults = 0.6, type = Float) + lens = lens_input_parameter("soil_erosion__eurosem_exponent") + eurosem_exponent = + ncread(dataset, config, lens; sel = indices, defaults = 2.0, type = Float) + lens = lens_input_parameter("vegetation_canopy__height") + canopyheight = + ncread(dataset, config, lens; sel = indices, defaults = 0.5, type = Float) + lens = lens_input_parameter("vegetation_canopy__gap_fraction") + canopygapfraction = + ncread(dataset, config, lens; sel = indices, defaults = 0.1, type = Float) + lens = lens_input_parameter("soil~compacted__area_fraction") + soilcover_fraction = + ncread(dataset, config, lens; sel = indices, defaults = 0.01, type = Float) + eurosem_parameters = RainfallErosionEurosemParameters(; soil_detachability = soil_detachability, eurosem_exponent = eurosem_exponent, @@ -184,22 +160,10 @@ end "Initialize ANSWERS rainfall erosion model parameters" function RainfallErosionAnswersParameters(dataset, config, indices) - usle_k = ncread( - dataset, - config, - "vertical.rainfall_erosion.parameters.usle_k"; - sel = indices, - defaults = 0.1, - type = Float, - ) - usle_c = ncread( - dataset, - config, - "vertical.rainfall_erosion.parameters.usle_c"; - sel = indices, - defaults = 0.01, - type = Float, - ) + lens = lens_input_parameter("soil_erosion__usle_k_factor") + usle_k = ncread(dataset, config, lens; sel = indices, defaults = 0.1, type = Float) + lens = lens_input_parameter("soil_erosion__usle_c_factor") + usle_c = ncread(dataset, config, lens; sel = indices, defaults = 0.01, type = Float) answers_parameters = RainfallErosionAnswersParameters(; usle_k = usle_k, usle_c = usle_c) return answers_parameters diff --git a/src/sediment/erosion/river_erosion.jl b/src/sediment/erosion/river_erosion.jl index 9e6e470e5..a0c89a8fe 100644 --- a/src/sediment/erosion/river_erosion.jl +++ b/src/sediment/erosion/river_erosion.jl @@ -43,14 +43,8 @@ end "Initialize Julian and Torres river erosion parameters" function RiverErosionParameters(dataset, config, indices) - d50 = ncread( - dataset, - config, - "lateral.river.potential_erosion.parameters.d50"; - sel = indices, - defaults = 0.1, - type = Float, - ) + lens = lens_input_parameter("river_bottom-and-bank_sediment__d50_diameter") + d50 = ncread(dataset, config, lens; sel = indices, defaults = 0.1, type = Float) river_parameters = RiverErosionParameters(; d50 = d50) return river_parameters diff --git a/src/sediment/erosion/soil_erosion.jl b/src/sediment/erosion/soil_erosion.jl index 6578a0dbe..7b3e97555 100644 --- a/src/sediment/erosion/soil_erosion.jl +++ b/src/sediment/erosion/soil_erosion.jl @@ -72,46 +72,21 @@ end "Initialize soil erosion model parameters" function SoilErosionParameters(dataset, config, indices) - clay_fraction = ncread( - dataset, - config, - "vertical.soil_erosion.parameters.clay_fraction"; - sel = indices, - defaults = 0.4, - type = Float, - ) - silt_fraction = ncread( - dataset, - config, - "vertical.soil_erosion.parameters.silt_fraction"; - sel = indices, - defaults = 0.3, - type = Float, - ) - sand_fraction = ncread( - dataset, - config, - "vertical.soil_erosion.parameters.sand_fraction"; - sel = indices, - defaults = 0.3, - type = Float, - ) - sagg_fraction = ncread( - dataset, - config, - "vertical.soil_erosion.parameters.sagg_fraction"; - sel = indices, - defaults = 0.0, - type = Float, - ) - lagg_fraction = ncread( - dataset, - config, - "vertical.soil_erosion.parameters.lagg_fraction"; - sel = indices, - defaults = 0.0, - type = Float, - ) + lens = lens_input_parameter("soil_clay__mass_fraction") + clay_fraction = + ncread(dataset, config, lens; sel = indices, defaults = 0.4, type = Float) + lens = lens_input_parameter("soil_silt__mass_fraction") + silt_fraction = + ncread(dataset, config, lens; sel = indices, defaults = 0.3, type = Float) + lens = lens_input_parameter("soil_sand__mass_fraction") + sand_fraction = + ncread(dataset, config, lens; sel = indices, defaults = 0.3, type = Float) + lens = lens_input_parameter("soil_aggregates~small__mass_fraction") + sagg_fraction = + ncread(dataset, config, lens; sel = indices, defaults = 0.0, type = Float) + lens = lens_input_parameter("soil_aggregates~large__mass_fraction") + lagg_fraction = + ncread(dataset, config, lens; sel = indices, defaults = 0.0, type = Float) # Check that soil fractions sum to 1 soil_fractions = clay_fraction + silt_fraction + sand_fraction + sagg_fraction + lagg_fraction diff --git a/src/sediment/sediment_transport/river_transport.jl b/src/sediment/sediment_transport/river_transport.jl index 9d5addde5..e276b6351 100644 --- a/src/sediment/sediment_transport/river_transport.jl +++ b/src/sediment/sediment_transport/river_transport.jl @@ -160,91 +160,36 @@ end "Initialize river sediment transport model parameters" function SedimentRiverTransportParameters(dataset, config, indices) n = length(indices) - clay_fraction = ncread( - dataset, - config, - "lateral.river.sediment_flux.parameters.clay_fraction"; - sel = indices, - defaults = 0.15, - type = Float, - ) - silt_fraction = ncread( - dataset, - config, - "lateral.river.sediment_flux.parameters.silt_fraction"; - sel = indices, - defaults = 0.65, - type = Float, - ) - sand_fraction = ncread( - dataset, - config, - "lateral.river.sediment_flux.parameters.sand_fraction"; - sel = indices, - defaults = 0.15, - type = Float, - ) - gravel_fraction = ncread( - dataset, - config, - "lateral.river.sediment_flux.parameters.sagg_fraction"; - sel = indices, - defaults = 0.05, - type = Float, - ) + lens = lens_input_parameter("river_bottom-and-bank_clay__mass_fraction") + clay_fraction = + ncread(dataset, config, lens; sel = indices, defaults = 0.15, type = Float) + lens = lens_input_parameter("river_bottom-and-bank_silt__mass_fraction") + silt_fraction = + ncread(dataset, config, lens; sel = indices, defaults = 0.65, type = Float) + lens = lens_input_parameter("river_bottom-and-bank_sand__mass_fraction") + sand_fraction = + ncread(dataset, config, lens; sel = indices, defaults = 0.15, type = Float) + lens = lens_input_parameter("river_bottom-and-bank_gravel__mass_fraction") + gravel_fraction = + ncread(dataset, config, lens; sel = indices, defaults = 0.05, type = Float) # Check that river fractions sum to 1 river_fractions = clay_fraction + silt_fraction + sand_fraction + gravel_fraction if any(abs.(river_fractions .- 1.0) .> 1e-3) error("Particle fractions in the river bed must sum to 1") end - dm_clay = ncread( - dataset, - config, - "lateral.river.sediment_flux.parameters.dm_clay"; - sel = indices, - defaults = 2.0, - type = Float, - ) - dm_silt = ncread( - dataset, - config, - "lateral.river.sediment_flux.parameters.dm_silt"; - sel = indices, - defaults = 10.0, - type = Float, - ) - dm_sand = ncread( - dataset, - config, - "lateral.river.sediment_flux.parameters.dm_sand"; - sel = indices, - defaults = 200.0, - type = Float, - ) - dm_sagg = ncread( - dataset, - config, - "lateral.river.sediment_flux.parameters.dm_sagg"; - sel = indices, - defaults = 30.0, - type = Float, - ) - dm_lagg = ncread( - dataset, - config, - "lateral.river.sediment_flux.parameters.dm_lagg"; - sel = indices, - defaults = 500.0, - type = Float, - ) - dm_gravel = ncread( - dataset, - config, - "lateral.river.sediment_flux.parameters.dm_gravel"; - sel = indices, - defaults = 2000.0, - type = Float, - ) + lens = lens_input_parameter("river_bottom-and-bank_clay__d50_diameter") + dm_clay = ncread(dataset, config, lens; sel = indices, defaults = 2.0, type = Float) + lens = lens_input_parameter("river_bottom-and-bank_silt__d50_diameter") + dm_silt = ncread(dataset, config, lens; sel = indices, defaults = 10.0, type = Float) + lens = lens_input_parameter("river_bottom-and-bank_sand__d50_diameter") + dm_sand = ncread(dataset, config, lens; sel = indices, defaults = 200.0, type = Float) + lens = lens_input_parameter("river_bottom-and-bank_aggregates~small__d50_diameter") + dm_sagg = ncread(dataset, config, lens; sel = indices, defaults = 30.0, type = Float) + lens = lens_input_parameter("river_bottom-and-bank_aggregates~large__d50_diameter") + dm_lagg = ncread(dataset, config, lens; sel = indices, defaults = 500.0, type = Float) + lens = lens_input_parameter("river_bottom-and-bank_gravel__d50_diameter") + dm_gravel = + ncread(dataset, config, lens; sel = indices, defaults = 2000.0, type = Float) # Waterbodies wblocs = zeros(Float, n) wbarea = zeros(Float, n) @@ -253,28 +198,33 @@ function SedimentRiverTransportParameters(dataset, config, indices) do_lakes = get(config.model, "dolake", false)::Bool if do_reservoirs + lens = lens_input_parameter("reservoir_location__number") reslocs = ncread( dataset, config, - "lateral.river.sediment_flux.parameters.reslocs"; + lens; optional = false, sel = indices, type = Float, fill = 0, ) + lens = lens_input_parameter("reservoir_surface__area") resarea = ncread( dataset, config, - "lateral.river.sediment_flux.parameters.resarea"; + lens; optional = false, sel = indices, type = Float, fill = 0.0, ) + lens = lens_input_parameter( + "reservoir_sediment~bedload__trapping_efficiency_coefficient", + ) restrapefficiency = ncread( dataset, config, - "lateral.river.sediment_flux.parameters.restrapeff"; + lens; optional = false, sel = indices, type = Float, @@ -287,19 +237,21 @@ function SedimentRiverTransportParameters(dataset, config, indices) end if do_lakes + lens = lens_input_parameter("lake_location__number") lakelocs = ncread( dataset, config, - "lateral.river.sediment_flux.parameters.lakelocs"; + lens; optional = false, sel = indices, type = Float, fill = 0, ) + lens = lens_input_parameter("lake_surface__area") lakearea = ncread( dataset, config, - "lateral.river.sediment_flux.parameters.lakearea"; + lems; optional = false, sel = indices, type = Float, @@ -865,54 +817,19 @@ end "Initialize river sediment concentrations model parameters" function SedimentConcentrationsRiverParameters(dataset, config, indices) - dm_clay = ncread( - dataset, - config, - "lateral.river.concentrations.parameters.dm_clay"; - sel = indices, - defaults = 2.0, - type = Float, - ) - dm_silt = ncread( - dataset, - config, - "lateral.river.concentrations.parameters.dm_silt"; - sel = indices, - defaults = 10.0, - type = Float, - ) - dm_sand = ncread( - dataset, - config, - "lateral.river.concentrations.parameters.dm_sand"; - sel = indices, - defaults = 200.0, - type = Float, - ) - dm_sagg = ncread( - dataset, - config, - "lateral.river.concentrations.parameters.dm_sagg"; - sel = indices, - defaults = 30.0, - type = Float, - ) - dm_lagg = ncread( - dataset, - config, - "lateral.river.concentrations.parameters.dm_lagg"; - sel = indices, - defaults = 500.0, - type = Float, - ) - dm_gravel = ncread( - dataset, - config, - "lateral.river.concentrations.parameters.dm_gravel"; - sel = indices, - defaults = 2000.0, - type = Float, - ) + lens = lens_input_parameter("river_water_clay__d50_diameter") + dm_clay = ncread(dataset, config, lens; sel = indices, defaults = 2.0, type = Float) + lens = lens_input_parameter("river_water_silt__d50_diameter") + dm_silt = ncread(dataset, config, lens; sel = indices, defaults = 10.0, type = Float) + lens = lens_input_parameter("river_water_sand__d50_diameter") + dm_sand = ncread(dataset, config, lens; sel = indices, defaults = 200.0, type = Float) + lens = lens_input_parameter("river_water_aggregates~small__d50_diameter") + dm_sagg = ncread(dataset, config, lens; sel = indices, defaults = 30.0, type = Float) + lens = lens_input_parameter("river_water_aggregates~large__d50_diameter") + dm_lagg = ncread(dataset, config, lens; sel = indices, defaults = 500.0, type = Float) + lens = lens_input_parameter("river_water_gravel__d50_diameter") + dm_gravel = + ncread(dataset, config, lens; sel = indices, defaults = 2000.0, type = Float) conc_parameters = SedimentConcentrationsRiverParameters(; dm_clay = dm_clay, dm_silt = dm_silt, diff --git a/src/sediment/sediment_transport/transport_capacity.jl b/src/sediment/sediment_transport/transport_capacity.jl index 9dd1e4b4b..b7d0a0bde 100644 --- a/src/sediment/sediment_transport/transport_capacity.jl +++ b/src/sediment/sediment_transport/transport_capacity.jl @@ -60,30 +60,17 @@ end "Initialize Govers overland flow transport capacity model parameters" function TransportCapacityGoversParameters(dataset, config, indices) - density = ncread( - dataset, - config, - "lateral.land.transport_capacity.parameters.density"; - sel = indices, - defaults = 2650.0, - type = Float, + lens = lens_input_parameter("land_surface_water_sediment__particle_density") + density = ncread(dataset, config, lens; sel = indices, defaults = 2650.0, type = Float) + lens = lens_input_parameter( + "land_surface_water_sediment__govers_transport_capacity_coefficient", ) - c_govers = ncread( - dataset, - config, - "lateral.land.transport_capacity.parameters.c_govers"; - sel = indices, - defaults = 0.000505, - type = Float, - ) - n_govers = ncread( - dataset, - config, - "lateral.land.transport_capacity.parameters.n_govers"; - sel = indices, - defaults = 4.27, - type = Float, + c_govers = + ncread(dataset, config, lens; sel = indices, defaults = 0.000505, type = Float) + lens = lens_input_parameter( + "land_surface_water_sediment__govers_transport_capacity_exponent", ) + n_govers = ncread(dataset, config, lens; sel = indices, defaults = 4.27, type = Float) tc_parameters = TransportCapacityGoversParameters(; density = density, c_govers = c_govers, @@ -153,22 +140,12 @@ end "Initialize Yalin overland flow transport capacity model parameters" function TransportCapacityYalinParameters(dataset, config, indices) - density = ncread( - dataset, - config, - "lateral.land.transport_capacity.parameters.density"; - sel = indices, - defaults = 2650.0, - type = Float, - ) - d50 = ncread( - dataset, - config, - "lateral.land.transport_capacity.parameters.d50"; - sel = indices, - defaults = 0.1, - type = Float, - ) + lens = lens_input_parameter("land_surface_water_sediment__particle_density") + density = ncread(dataset, config, lens; sel = indices, defaults = 2650.0, type = Float) + + lens = lens_input_parameter("land_surface_water_sediment__d50_diameter") + d50 = ncread(dataset, config, lens; sel = indices, defaults = 0.1, type = Float) + tc_parameters = TransportCapacityYalinParameters(; density = density, d50 = d50) return tc_parameters @@ -277,54 +254,19 @@ end "Initialize Yalin differentiated overland flow transport capacity model parameters" function TransportCapacityYalinDifferentiationParameters(dataset, config, indices) - density = ncread( - dataset, - config, - "lateral.land.transport_capacity.parameters.density"; - sel = indices, - defaults = 2650.0, - type = Float, - ) - dm_clay = ncread( - dataset, - config, - "lateral.land.transport_capacity.parameters.dm_clay"; - sel = indices, - defaults = 2.0, - type = Float, - ) - dm_silt = ncread( - dataset, - config, - "lateral.land.transport_capacity.parameters.dm_silt"; - sel = indices, - defaults = 10.0, - type = Float, - ) - dm_sand = ncread( - dataset, - config, - "lateral.land.transport_capacity.parameters.dm_sand"; - sel = indices, - defaults = 200.0, - type = Float, - ) - dm_sagg = ncread( - dataset, - config, - "lateral.land.transport_capacity.parameters.dm_sagg"; - sel = indices, - defaults = 30.0, - type = Float, - ) - dm_lagg = ncread( - dataset, - config, - "lateral.land.transport_capacity.parameters.dm_lagg"; - sel = indices, - defaults = 500.0, - type = Float, - ) + lens = lens_input_parameter("land_surface_water_sediment__particle_density") + density = ncread(dataset, config, lens; sel = indices, defaults = 2650.0, type = Float) + lens = lens_input_parameter("land_surface_water_clay__d50_diameter") + dm_clay = ncread(dataset, config, lens; sel = indices, defaults = 2.0, type = Float) + lens = lens_input_parameter("land_surface_water_silt__d50_diameter") + dm_silt = ncread(dataset, config, lens; sel = indices, defaults = 10.0, type = Float) + lens = lens_input_parameter("land_surface_water_sand__d50_diameter") + dm_sand = ncread(dataset, config, lens; sel = indices, defaults = 200.0, type = Float) + lens = lens_input_parameter("land_surface_water_aggregates~small__d50_diameter") + dm_sagg = ncread(dataset, config, lens; sel = indices, defaults = 30.0, type = Float) + lens = lens_input_parameter("land_surface_water_aggregates~large__d50_diameter") + dm_lagg = ncread(dataset, config, lens; sel = indices, defaults = 500.0, type = Float) + tc_parameters = TransportCapacityYalinDifferentiationParameters(; density = density, dm_clay = dm_clay, @@ -457,22 +399,11 @@ end "Initialize common river transport capacity model parameters" function TransportCapacityRiverParameters(dataset, config, indices) - density = ncread( - dataset, - config, - "lateral.river.transport_capacity.parameters.density"; - sel = indices, - defaults = 2650.0, - type = Float, - ) - d50 = ncread( - dataset, - config, - "lateral.river.transport_capacity.parameters.d50"; - sel = indices, - defaults = 0.1, - type = Float, - ) + lens = lens_input_parameter("river_water_sediment__particle_density") + density = ncread(dataset, config, lens; sel = indices, defaults = 2650.0, type = Float) + lens = lens_input_parameter("river_water_sediment__d50_diameter") + d50 = ncread(dataset, config, lens; sel = indices, defaults = 0.1, type = Float) + tc_parameters = TransportCapacityRiverParameters(; density = density, d50 = d50) return tc_parameters @@ -488,22 +419,12 @@ end "Initialize Bagnold transport capacity model parameters" function TransportCapacityBagnoldParameters(dataset, config, indices) - c_bagnold = ncread( - dataset, - config, - "lateral.river.transport_capacity.parameters.c_bagnold"; - sel = indices, - optional = false, - type = Float, - ) - e_bagnold = ncread( - dataset, - config, - "lateral.river.transport_capacity.parameters.e_bagnold"; - sel = indices, - optional = false, - type = Float, - ) + lens = + lens_input_parameter("river_water_sediment__bagnold_transport_capacity_coefficient") + c_bagnold = ncread(dataset, config, lens; sel = indices, optional = false, type = Float) + lens = lens_input_parameter("river_water_sediment__bagnold_transport_capacity_exponent") + e_bagnold = ncread(dataset, config, lens; sel = indices, optional = false, type = Float) + tc_parameters = TransportCapacityBagnoldParameters(; c_bagnold = c_bagnold, e_bagnold = e_bagnold) @@ -609,38 +530,23 @@ end "Initialize Kodatie river transport capacity model parameters" function TransportCapacityKodatieParameters(dataset, config, indices) - a_kodatie = ncread( - dataset, - config, - "lateral.river.transport_capacity.parameters.a_kodatie"; - sel = indices, - optional = false, - type = Float, + lens = lens_input_parameter( + "river_water_sediment__kodatie_transport_capacity_a-coefficient", ) - b_kodatie = ncread( - dataset, - config, - "lateral.river.transport_capacity.parameters.b_kodatie"; - sel = indices, - optional = false, - type = Float, + a_kodatie = ncread(dataset, config, lens; sel = indices, optional = false, type = Float) + lens = lens_input_parameter( + "river_water_sediment__kodatie_transport_capacity_b-coefficient", ) - c_kodatie = ncread( - dataset, - config, - "lateral.river.transport_capacity.parameters.c_kodatie"; - sel = indices, - optional = false, - type = Float, + b_kodatie = ncread(dataset, config, lens; sel = indices, optional = false, type = Float) + lens = lens_input_parameter( + "river_water_sediment__kodatie_transport_capacity_c-coefficient", ) - d_kodatie = ncread( - dataset, - config, - "lateral.river.transport_capacity.parameters.d_kodatie"; - sel = indices, - optional = false, - type = Float, + c_kodatie = ncread(dataset, config, lens; sel = indices, optional = false, type = Float) + lens = lens_input_parameter( + "river_water_sediment__kodatie_transport_capacity_d-coefficient", ) + d_kodatie = ncread(dataset, config, lens; sel = indices, optional = false, type = Float) + tc_parameters = TransportCapacityKodatieParameters(; a_kodatie = a_kodatie, b_kodatie = b_kodatie, diff --git a/src/sediment_flux.jl b/src/sediment_flux.jl index 4ba49e98d..5f1fba3e5 100644 --- a/src/sediment_flux.jl +++ b/src/sediment_flux.jl @@ -10,9 +10,10 @@ end "Initialize the overland flow sediment transport model" -function OverlandFlowSediment(dataset, config, indices, waterbodies, rivers) +function OverlandFlowSediment(dataset, soilloss, config, indices, waterbodies, rivers) n = length(indices) - hydrological_forcing = HydrologicalForcing(n) + (; hydrological_forcing) = soilloss + geometry = LandGeometry(dataset, config, indices) # Check what transport capacity equation will be used do_river = get(config.model, "run_river_model", false)::Bool diff --git a/src/sediment_model.jl b/src/sediment_model.jl index 1d43a4432..713bbea04 100644 --- a/src/sediment_model.jl +++ b/src/sediment_model.jl @@ -15,20 +15,14 @@ function initialize_sediment_model(config::Config) clock = Clock(config, reader) dataset = NCDataset(static_path) - subcatch_2d = - ncread(dataset, config, "subcatchment"; optional = false, allow_missing = true) + lens = lens_input("subcatchment") + 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) - river_2d = ncread( - dataset, - config, - "river_location"; - optional = false, - type = Bool, - fill = false, - ) + lens = lens_input("river_location") + river_2d = ncread(dataset, config, lens; optional = false, type = Bool, fill = false) river = river_2d[indices] # Needed to update the forcing @@ -42,10 +36,11 @@ 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") reservoirs = ncread( dataset, config, - "reservoir_areas"; + lens; optional = false, sel = indices, type = Float, @@ -54,10 +49,11 @@ function initialize_sediment_model(config::Config) waterbodies = waterbodies .+ reservoirs end if do_lakes + lens = lens_input("lake_area__number") lakes = ncread( dataset, config, - "lake_areas"; + lens; optional = false, sel = indices, type = Float, @@ -67,12 +63,13 @@ function initialize_sediment_model(config::Config) end waterbodies = waterbodies .> 0 - ldd_2d = ncread(dataset, config, "ldd"; optional = false, allow_missing = true) + lens = lens_input("ldd") + ldd_2d = ncread(dataset, config, lens; optional = false, allow_missing = true) ldd = ldd_2d[indices] # # lateral part sediment in overland flow overland_flow_sediment = - OverlandFlowSediment(dataset, config, indices, waterbodies, river) + OverlandFlowSediment(dataset, soilloss, config, indices, waterbodies, river) graph = flowgraph(ldd, indices, pcr_dir) @@ -87,14 +84,8 @@ function initialize_sediment_model(config::Config) graph_riv = flowgraph(ldd_riv, indices_riv, pcr_dir) # Needed for frac_to_river? - landslope = ncread( - dataset, - config, - "vertical.land_parameter_set.slope"; - optional = false, - sel = indices, - type = Float, - ) + lens = lens_input_parameter("land_surface__slope") + landslope = ncread(dataset, config, lens; optional = false, sel = indices, type = Float) clamp!(landslope, 0.00001, Inf) index_river = filter(i -> !isequal(river[i], 0), 1:n) diff --git a/src/standard_name.jl b/src/standard_name.jl index af2e4626e..ee512d6cf 100644 --- a/src/standard_name.jl +++ b/src/standard_name.jl @@ -1,5 +1,5 @@ -const standard_name_map = Dict{String, ComposedFunction}( +const sbm_standard_name_map = Dict{String, ComposedFunction}( "atmosphere_water__precipitation_volume_flux" => @optic(_.vertical.atmospheric_forcing.precipitation), "land_surface_water__potential_evaporation_volume_flux" => @@ -68,4 +68,87 @@ const standard_name_map = Dict{String, ComposedFunction}( @optic(_.lateral.subsurface.drain.variables.flux), "river_water~to-subsurface__volume_flow_rate" => @optic(_.lateral.subsurface.river.variables.flux), -) \ No newline at end of file +) + +const sediment_standard_name_map = Dict{String, ComposedFunction}( + "atmosphere_water__precipitation_volume_flux" => + @optic(_.vertical.atmospheric_forcing.precipitation), + "river_water__volume_flow_rate" => + @optic(_.lateral.river.hydrological_forcing.q_river), + "river_water__depth" => + @optic(_.lateral.river.hydrological_forcing.waterlevel_river), + "land_surface_water__volume_flow_rate" => + @optic(_.vertical.hydrological_forcing.q_land), + "land_surface_water__depth" => + @optic(_.vertical.hydrological_forcing.waterlevel_land), + "vegetation_canopy_water__interception_volume_flux" => + @optic(_.vertical.hydrological_forcing.interception), + "soil_erosion~rainfall__mass_flow_rate" => + @optic(_.vertical.rainfall_erosion.variables.amount), + "soil_erosion~overland_flow__mass_flow_rate" => + @optic(_.vertical.overland_flow_erosion.variables.amount), + "soil_erosion__mass_flow_rate" => @optic(_.vertical.soil_erosion.variables.amount), + "soil_erosion_clay__mass_flow_rate" => + @optic(_.vertical.soil_erosion.variables.clay), + "land_surface_water_sediment_transport_capacity__mass_flow_rate" => + @optic(_.lateral.land.transport_capacity.variables.amount), + "land_surface_water_clay_transport_capacity__mass_flow_rate" => + @optic(_.lateral.land.transport_capacity.variables.clay), + "land_surface_water_sediment~to-river__mass_flow_rate" => + @optic(_.lateral.land.to_river.variables.amount), + "land_surface_water_clay~to-river__mass_flow_rate" => + @optic(_.lateral.land.to_river.variables.clay), + "land_surface_water_sediment__mass_flow_rate" => + @optic(_.lateral.land.sediment_flux.variables.amount), + "land_surface_water_clay__mass_flow_rate" => + @optic(_.lateral.land.sediment_flux.variables.clay), + "river_water_sediment~bedload__mass_concentration" => + @optic(_.lateral.river.concentrations.variables.bed), + "river_water_sediment~suspended__mass_concentration" => + @optic(_.lateral.river.concentrations.variables.suspended), + "river_water_sediment__mass_concentration" => + @optic(_.lateral.river.concentrations.variables.total), + "river_water_clay__mass" => + @optic(_.lateral.river.sediment_flux.variables.leftover_clay), + "river_bed_clay__mass" => + @optic(_.lateral.river.sediment_flux.variables.store_clay), + "river_water_gravel__mass" => + @optic(_.lateral.river.sediment_flux.variables.leftover_gravel), + "river_bed_gravel__mass" => + @optic(_.lateral.river.sediment_flux.variables.store_gravel), + "river_water_aggregates~large__mass" => + @optic(_.lateral.river.sediment_flux.variables.leftover_lagg), + "river_bed_aggregates~large__mass" => + @optic(_.lateral.river.sediment_flux.variables.store_lagg), + "river_water_clay__mass_flow_rate" => + @optic(_.lateral.river.sediment_flux.variables.clay), + "river_water_gravel__mass_flow_rate" => + @optic(_.lateral.river.sediment_flux.variables.gravel), + "river_water_aggregates~large__mass_flow_rate" => + @optic(_.lateral.river.sediment_flux.variables.lagg), + "river_water_aggregates~small__mass_flow_rate" => + @optic(_.lateral.river.sediment_flux.variables.sagg), + "river_water_sand__mass_flow_rate" => + @optic(_.lateral.river.sediment_flux.variables.sand), + "river_water_silt__mass_flow_rate" => + @optic(_.lateral.river.sediment_flux.variables.silt), + "river_water_aggregates~small__mass" => + @optic(_.lateral.river.sediment_flux.variables.leftover_sagg), + "river_bed_aggregates~small__mass" => + @optic(_.lateral.river.sediment_flux.variables.store_sagg), + "river_water_sand__mass" => + @optic(_.lateral.river.sediment_flux.variables.leftover_sand), + "river_bed_sand__mass" => + @optic(_.lateral.river.sediment_flux.variables.store_sand), + "river_water_silt__mass" => + @optic(_.lateral.river.sediment_flux.variables.leftover_silt), + "river_bed_silt__mass" => + @optic(_.lateral.river.sediment_flux.variables.store_silt), + "river_water_sediment_erosion__mass" => + @optic(_.lateral.river.sediment_flux.variables.erosion), + "river_water_sediment_deposition__mass" => + @optic(_.lateral.river.sediment_flux.variables.deposition), +) + +standard_name_map(model::LandHydrologySBM) = sbm_standard_name_map +standard_name_map(model::SoilLoss) = sediment_standard_name_map diff --git a/src/utils.jl b/src/utils.jl index 4bcd013dd..ea57d9e36 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -154,7 +154,7 @@ and set states in `model` object. Active cells are selected with the correspondi - `type = nothing`: type to convert data to after reading. By default no conversion is done. """ function set_states!(instate_path, model; type = nothing, dimname = nothing) - (; network, config) = model + (; network, vertical, config) = model # Check if required states are covered # TODO: revert back to state checking @@ -190,7 +190,7 @@ function set_states!(instate_path, model; type = nothing, dimname = nothing) end end # set state in model object - lens = standard_name_map[state] + lens = standard_name_map(vertical)[state] lens(model) .= svectorscopy(A, Val{size(A)[1]}()) # 3 dims (x,y,time) elseif dims == 3 @@ -204,7 +204,7 @@ function set_states!(instate_path, model; type = nothing, dimname = nothing) end end # set state in model object, only set active cells ([1:n]) (ignore boundary conditions/ghost points) - lens = standard_name_map[state] + lens = standard_name_map(vertical)[state] lens(model)[1:n] .= A else error( diff --git a/test/io.jl b/test/io.jl index 95500a532..c95dacd05 100644 --- a/test/io.jl +++ b/test/io.jl @@ -210,31 +210,23 @@ lens = @optic(_.input.parameters.doesnt_exist) @test Wflow._lens(config, lens, -1) == -1 @testset "warm states" begin - @test Wflow.standard_name_map["reservoir_water__volume"](model)[1] ≈ - 3.2807224993363418e7 - @test Wflow.standard_name_map["soil_water_sat-zone__depth"](model)[9115] ≈ - 477.13548089422125 - @test Wflow.standard_name_map["snowpack~dry__leq-depth"](model)[5] ≈ 11.019233179897599 - @test Wflow.standard_name_map["soil_surface__temperature"](model)[5] ≈ - 0.21814478119608938 - @test Wflow.standard_name_map["soil_water_unsat-zone__depth-per-soil_layer"](model)[50063][1] ≈ + map = Wflow.standard_name_map(model.vertical) + @test map["reservoir_water__volume"](model)[1] ≈ 3.2807224993363418e7 + @test map["soil_water_sat-zone__depth"](model)[9115] ≈ 477.13548089422125 + @test map["snowpack~dry__leq-depth"](model)[5] ≈ 11.019233179897599 + @test map["soil_surface__temperature"](model)[5] ≈ 0.21814478119608938 + @test map["soil_water_unsat-zone__depth-per-soil_layer"](model)[50063][1] ≈ 9.969116007201725 - @test Wflow.standard_name_map["snowpack~liquid__depth"](model)[5] ≈ 0.0 - @test Wflow.standard_name_map["vegetation_canopy_water__storage"](model)[50063] ≈ 0.0 - @test Wflow.standard_name_map["soil_water_sat-zone_top__depth"](model)[50063] ≈ - 296.8028609104624 - @test Wflow.standard_name_map["subsurface_water__volume_flow_rate"](model)[10606] ≈ - 39.972334552895816 - @test Wflow.standard_name_map["river_water__volume_flow_rate"](model)[149] ≈ - 53.48673634956338 - @test Wflow.standard_name_map["river_water__depth"](model)[149] ≈ 1.167635369628945 - @test Wflow.standard_name_map["river_water__volume"](model)[149] ≈ 63854.60119358985 - @test Wflow.standard_name_map["land_surface_water__volume_flow_rate"](model)[2075] ≈ - 3.285909284322251 - @test Wflow.standard_name_map["land_surface_water__depth"](model)[2075] ≈ - 0.052076262033771775 - @test Wflow.standard_name_map["land_surface_water__volume"](model)[2075] ≈ - 29920.754983235012 + @test map["snowpack~liquid__depth"](model)[5] ≈ 0.0 + @test map["vegetation_canopy_water__storage"](model)[50063] ≈ 0.0 + @test map["soil_water_sat-zone_top__depth"](model)[50063] ≈ 296.8028609104624 + @test map["subsurface_water__volume_flow_rate"](model)[10606] ≈ 39.972334552895816 + @test map["river_water__volume_flow_rate"](model)[149] ≈ 53.48673634956338 + @test map["river_water__depth"](model)[149] ≈ 1.167635369628945 + @test map["river_water__volume"](model)[149] ≈ 63854.60119358985 + @test map["land_surface_water__volume_flow_rate"](model)[2075] ≈ 3.285909284322251 + @test map["land_surface_water__depth"](model)[2075] ≈ 0.052076262033771775 + @test map["land_surface_water__volume"](model)[2075] ≈ 29920.754983235012 end @testset "reducer" begin diff --git a/test/runtests.jl b/test/runtests.jl index be449af27..d05077542 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -91,7 +91,7 @@ with_logger(NullLogger()) do include("groundwater.jl") include("utils.jl") include("bmi.jl") - #include("run_sediment.jl") + include("run_sediment.jl") include("subdomains.jl") Aqua.test_all(Wflow; ambiguities = false, persistent_tasks = false) end diff --git a/test/sediment_config.toml b/test/sediment_config.toml index 6839ee4af..cdfbda299 100644 --- a/test/sediment_config.toml +++ b/test/sediment_config.toml @@ -18,25 +18,25 @@ path_output = "outstates-moselle-sed.nc" # if listed, the variable must be present in the NetCDF or error # if not listed, the variable can get a default value if it has one -[state.lateral.river.sediment_flux.variables] -leftover_clay = "clayload" -store_clay = "claystore" -leftover_gravel = "gravload" -store_gravel = "gravstore" -leftover_lagg = "laggload" -store_lagg = "laggstore" -clay = "outclay" -gravel = "outgrav" -lagg= "outlagg" -sagg = "outsagg" -sand = "outsand" -silt = "outsilt" -leftover_sagg= "saggload" -store_sagg = "saggstore" -leftover_sand = "sandload" -store_sand = "sandstore" -leftover_silt = "siltload" -store_silt = "siltstore" +[state.variables] +river_water_clay__mass = "clayload" +river_bed_clay__mass = "claystore" +river_water_gravel__mass = "gravload" +river_bed_gravel__mass = "gravstore" +"river_water_aggregates~large__mass" = "laggload" +"river_bed_aggregates~large__mass" = "laggstore" +river_water_clay__mass_flow_rate = "outclay" +river_water_gravel__mass_flow_rate = "outgrav" +"river_water_aggregates~large__mass_flow_rate" = "outlagg" +"river_water_aggregates~small__mass_flow_rate" = "outsagg" +river_water_sand__mass_flow_rate = "outsand" +river_water_silt__mass_flow_rate = "outsilt" +"river_water_aggregates~small__mass" = "saggload" +"river_bed_aggregates~small__mass" = "saggstore" +river_water_sand__mass = "sandload" +river_bed_sand__mass = "sandstore" +river_water_silt__mass = "siltload" +river_bed_silt__mass = "siltstore" [input] path_forcing = "forcing-moselle-sed.nc" @@ -47,115 +47,91 @@ gauges = "wflow_gauges" ldd = "wflow_ldd" river_location = "wflow_river" subcatchment = "wflow_subcatch" -reservoir_areas = "wflow_reservoirareas" -lake_areas = "wflow_lakeareas" +reservoir_area__number = "wflow_reservoirareas" +lake_area__number = "wflow_lakeareas" + +[input.forcing] +atmosphere_water__precipitation_volume_flux = "P" +land_surface_water__depth = "levKinL" +river_water__depth = "h" +land_surface_water__volume_flow_rate = "runL" +river_water__volume_flow_rate = "q" + +[input.parameters] +land_surface__slope = "Slope" +river__length = "wflow_riverlength" +river__slope = "RiverSlope" +river__width = "wflow_riverwidth" + +reservoir_surface__area = "ResSimpleArea" +reservoir_location__number = "wflow_reservoirlocs" +lake_surface__area = "LakeArea" +lake_location__number = "wflow_lakelocs" +"reservoir_sediment~bedload__trapping_efficiency_coefficient" = "ResTrapEff" + +vegetation_canopy__gap_fraction = "CanopyGapFraction" +"soil~compacted__area_fraction" = "PathFrac" +soil_erosion__rainfall_soil_detachability_factor = "soil_detachability" +soil_erosion__eurosem_exponent = "eros_spl_EUROSEM" +soil_erosion__usle_k_factor = "usle_k" +soil_erosion__usle_c_factor = "USLE_C" +soil_erosion__answers_overland_flow_factor = "eros_ov" + +soil_clay__mass_fraction = "fclay_soil" +soil_silt__mass_fraction = "fsilt_soil" +soil_sand__mass_fraction = "fsand_soil" +"soil_aggregates~small__mass_fraction" = "fsagg_soil" +"soil_aggregates~large__mass_fraction" = "flagg_soil" + +land_surface_water_sediment__particle_density = "sediment_density" +land_surface_water_sediment__govers_transport_capacity_coefficient = "c_govers" +land_surface_water_sediment__govers_transport_capacity_exponent = "n_govers" +land_surface_water_sediment__d50_diameter = "d50_soil" +land_surface_water_clay__d50_diameter = "dm_clay" +land_surface_water_silt__d50_diameter = "dm_silt" +land_surface_water_sand__d50_diameter = "dm_sand" +"land_surface_water_aggregates~small__d50_diameter" = "dm_sagg" +"land_surface_water_aggregates~large__d50_diameter" = "dm_lagg" + +river_water_sediment__particle_density = "sediment_density" +river_water_sediment__d50_diameter = "D50_River" +river_water_sediment__bagnold_transport_capacity_coefficient = "c_Bagnold" +river_water_sediment__bagnold_transport_capacity_exponent = "exp_Bagnold" +river_water_sediment__kodatie_transport_capacity_a-coefficient = "a_kodatie" +river_water_sediment__kodatie_transport_capacity_b-coefficient = "b_kodatie" +river_water_sediment__kodatie_transport_capacity_c-coefficient = "c_kodatie" +river_water_sediment__kodatie_transport_capacity_d-coefficient = "d_kodatie" + +river_bottom-and-bank_sediment__d50_diameter = "D50_River" +river_bottom-and-bank_clay__mass_fraction = "ClayF_River" +river_bottom-and-bank_silt__mass_fraction = "SiltF_River" +river_bottom-and-bank_sand__mass_fraction = "SandF_River" +river_bottom-and-bank_gravel__mass_fraction = "GravelF_River" +river_bottom-and-bank_clay__d50_diameter = "dm_clay" +river_bottom-and-bank_silt__d50_diameter = "dm_silt" +river_bottom-and-bank_sand__d50_diameter = "dm_sand" +"river_bottom-and-bank_aggregates~small__d50_diameter" = "dm_sagg" +"river_bottom-and-bank_aggregates~large__d50_diameter" = "dm_lagg" +river_bottom-and-bank_gravel__d50_diameter = "dm_gravel" + +river_water_clay__d50_diameter = "dm_clay" +river_water_silt__d50_diameter = "dm_silt" +river_water_sand__d50_diameter = "dm_sand" +"river_water_aggregates~small__d50_diameter" = "dm_sagg" +"river_water_aggregates~large__d50_diameter" = "dm_lagg" +river_water_gravel__d50_diameter = "dm_gravel" # specify the internal IDs of the parameters which vary over time # the external name mapping needs to be below together with the other mappings +[input.dynamic] forcing = [ - "vertical.atmospheric_forcing.precipitation", - "vertical.hydrological_forcing.waterlevel_land", - "lateral.land.hydrological_forcing.waterlevel_land", - "vertical.hydrological_forcing.q_land", - "lateral.land.hydrological_forcing.q_land", - "lateral.river.hydrological_forcing.waterlevel_river", - "lateral.river.hydrological_forcing.q_river", + "atmosphere_water__precipitation_volume_flux", + "land_surface_water__depth", + "river_water__depth", + "land_surface_water__volume_flow_rate", + "river_water__volume_flow_rate", ] -[input.vertical.atmospheric_forcing] -precipitation = "P" - -[input.vertical.hydrological_forcing] -waterlevel_land = "levKinL" -q_land = "runL" - -[input.vertical.land_parameter_set] -slope = "Slope" - -[input.vertical.rainfall_erosion.parameters] -soil_detachability = "soil_detachability" -eurosem_exponent = "eros_spl_EUROSEM" -canopygapfraction = "CanopyGapFraction" -usle_k = "usle_k" -usle_c = "USLE_C" -pathfrac = "PathFrac" - -[input.vertical.overland_flow_erosion.parameters] -usle_k = "usle_k" -usle_c = "USLE_C" -answers_k = "eros_ov" - -[input.vertical.soil_erosion.parameters] -clay_fraction = "fclay_soil" -silt_fraction = "fsilt_soil" -sand_fraction = "fsand_soil" -sagg_fraction = "fsagg_soil" -lagg_fraction = "flagg_soil" - -[input.lateral.land.hydrological_forcing] -waterlevel_land = "levKinL" -q_land = "runL" - -[input.lateral.land.transport_capacity.parameters] -density = "sediment_density" -d50 = "d50_soil" -c_govers = "c_govers" -n_govers = "n_govers" -dm_clay = "dm_clay" -dm_silt = "dm_silt" -dm_sand = "dm_sand" -dm_sagg = "dm_sagg" -dm_lagg = "dm_lagg" - -[input.lateral.river.hydrological_forcing] -waterlevel_river = "h" -q_river = "q" - -[input.lateral.river_parameter_set] -length = "wflow_riverlength" -slope = "RiverSlope" -width = "wflow_riverwidth" - -[input.lateral.river.transport_capacity.parameters] -density = "sediment_density" -d50 = "D50_River" -c_bagnold = "c_Bagnold" -e_bagnold = "exp_Bagnold" -a_kodatie = "a_kodatie" -b_kodatie = "b_kodatie" -c_kodatie = "c_kodatie" -d_kodatie = "d_kodatie" - -[input.lateral.river.potential_erosion.parameters] -d50 = "D50_River" - -[input.lateral.river.sediment_flux.parameters] -clay_fraction = "ClayF_River" -silt_fraction = "SiltF_River" -sand_fraction = "SandF_River" -gravel_fraction = "GravelF_River" -dm_clay = "dm_clay" -dm_silt = "dm_silt" -dm_sand = "dm_sand" -dm_sagg = "dm_sagg" -dm_lagg = "dm_lagg" -dm_gravel = "dm_gravel" -# Reservoir -resarea = "ResSimpleArea" -restrapeff = "ResTrapEff" -reslocs = "wflow_reservoirlocs" -# Lake -lakearea = "LakeArea" -lakelocs = "wflow_lakelocs" - -[input.lateral.river.concentrations.parameters] -dm_clay = "dm_clay" -dm_silt = "dm_silt" -dm_sand = "dm_sand" -dm_sagg = "dm_sagg" -dm_lagg = "dm_lagg" -dm_gravel = "dm_gravel" - [model] reinit = true run_river_model = true @@ -170,45 +146,33 @@ type = "sediment" [output] path = "output-moselle-sed.nc" -[output.vertical.rainfall_erosion.variables] -amount = "rainfall_erosion" - -[output.vertical.overland_flow_erosion.variables] -amount = "overland_flow_erosion" - -[output.vertical.soil_erosion.variables] -amount = "soilloss" -clay = "erosclay" - -[output.lateral.land.transport_capacity.variables] -clay = "TCclay" -amount = "TCsed" +[output.variables] +"soil_erosion~rainfall__mass_flow_rate" = "rainfall_erosion" +"soil_erosion~overland_flow__mass_flow_rate" = "overland_flow_erosion" +soil_erosion__mass_flow_rate = "soilloss" +soil_erosion_clay__mass_flow_rate = "erosclay" -[output.lateral.land.to_river.variables] -clay = "inlandclay" -amount = "inlandsed" +land_surface_water_sediment_transport_capacity__mass_flow_rate = "TCsed" +land_surface_water_clay_transport_capacity__mass_flow_rate = "TCclay" -[output.lateral.land.sediment_flux.variables] -clay = "olclay" -amount = "olsed" +"land_surface_water_sediment~to-river__mass_flow_rate" = "inlandsed" +"land_surface_water_clay~to-river__mass_flow_rate" = "inlandclay" -[output.lateral.river.concentrations.variables] -bed = "Bedconc" -suspended = "SSconc" -total = "Sedconc" +land_surface_water_sediment__mass_flow_rate = "olsed" +land_surface_water_clay__mass_flow_rate = "olclay" -[output.lateral.river.hydrological_forcing] -waterlevel_river = "h_riv" +lateral.river.hydrological_forcing.waterlevel_river = "h_riv" +lateral.river.sediment_flux.boundary_conditions.erosion_land_clay = "inlandclayriv" +lateral.river.sediment_flux.boundary_conditions.transport_capacity = "TCsed_riv" -[output.lateral.river.sediment_flux.variables] -leftover_clay = "clayload" -clay = "outclay" -erosion = "erosion_riv" -deposition = "deposition_riv" +river_water_sediment__mass_concentration = "Sedconc" +"river_water_sediment~suspended__mass_concentration" = "SSconc" +"river_water_sediment~bedload__mass_concentration" = "Bedconc" -[output.lateral.river.sediment_flux.boundary_conditions] -erosion_land_clay = "inlandclayriv" -transport_capacity = "TCsed_riv" +river_water_sediment_deposition__mass = "deposition_riv" +river_water_sediment_erosion__mass = "erosion_riv" +river_water_clay__mass_flow_rate = "outclay" +river_water_clay__mass = "clayload" [csv] path = "output-moselle-sediment.csv" @@ -217,25 +181,25 @@ path = "output-moselle-sediment.csv" coordinate.x = 6.931 coordinate.y = 48.085 header = "SL" -parameter = "vertical.soil_erosion.variables.amount" +parameter = "soil_erosion__mass_flow_rate" [[csv.column]] coordinate.x = 6.931 coordinate.y = 48.085 header = "SSPL" -parameter = "vertical.rainfall_erosion.variables.amount" +parameter = "soil_erosion~rainfall__mass_flow_rate" [[csv.column]] coordinate.x = 6.931 coordinate.y = 48.085 header = "SOV" -parameter = "vertical.overland_flow_erosion.variables.amount" +parameter = "soil_erosion~overland_flow__mass_flow_rate" [[csv.column]] coordinate.x = 6.931 coordinate.y = 48.085 header = "P" -parameter = "vertical.atmospheric_forcing.precipitation" +parameter = "atmosphere_water__precipitation_volume_flux" [[csv.column]] coordinate.x = 6.931 diff --git a/test/sediment_eurosem_engelund_config.toml b/test/sediment_eurosem_engelund_config.toml index 6c9fb3be8..4b6cc39d5 100644 --- a/test/sediment_eurosem_engelund_config.toml +++ b/test/sediment_eurosem_engelund_config.toml @@ -18,25 +18,25 @@ path_output = "outstates-moselle-sed.nc" # if listed, the variable must be present in the NetCDF or error # if not listed, the variable can get a default value if it has one -[state.lateral.river.sediment_flux.variables] -leftover_clay = "clayload" -store_clay = "claystore" -leftover_gravel = "gravload" -store_gravel = "gravstore" -leftover_lagg = "laggload" -store_lagg = "laggstore" -clay = "outclay" -gravel = "outgrav" -lagg= "outlagg" -sagg = "outsagg" -sand = "outsand" -silt = "outsilt" -leftover_sagg= "saggload" -store_sagg = "saggstore" -leftover_sand = "sandload" -store_sand = "sandstore" -leftover_silt = "siltload" -store_silt = "siltstore" +[state.variables] +river_water_clay__mass = "clayload" +river_bed_clay__mass = "claystore" +river_water_gravel__mass = "gravload" +river_bed_gravel__mass = "gravstore" +"river_water_aggregates~large__mass" = "laggload" +"river_bed_aggregates~large__mass" = "laggstore" +river_water_clay__mass_flow_rate = "outclay" +river_water_gravel__mass_flow_rate = "outgrav" +"river_water_aggregates~large__mass_flow_rate" = "outlagg" +"river_water_aggregates~small__mass_flow_rate" = "outsagg" +river_water_sand__mass_flow_rate = "outsand" +river_water_silt__mass_flow_rate = "outsilt" +"river_water_aggregates~small__mass" = "saggload" +"river_bed_aggregates~small__mass" = "saggstore" +river_water_sand__mass = "sandload" +river_bed_sand__mass = "sandstore" +river_water_silt__mass = "siltload" +river_bed_silt__mass = "siltstore" [input] path_forcing = "forcing-moselle-sed.nc" @@ -47,117 +47,93 @@ gauges = "wflow_gauges" ldd = "wflow_ldd" river_location = "wflow_river" subcatchment = "wflow_subcatch" -reservoir_areas = "wflow_reservoirareas" -lake_areas = "wflow_lakeareas" +reservoir_area__number = "wflow_reservoirareas" +lake_area__number = "wflow_lakeareas" + +[input.forcing] +atmosphere_water__precipitation_volume_flux = "P" +land_surface_water__depth = "levKinL" +river_water__depth = "h" +land_surface_water__volume_flow_rate = "runL" +river_water__volume_flow_rate = "q" +vegetation_canopy_water__interception_volume_flux = "int" + +[input.parameters] +land_surface__slope = "Slope" +river__length = "wflow_riverlength" +river__slope = "RiverSlope" +river__width = "wflow_riverwidth" + +reservoir_surface__area = "ResSimpleArea" +reservoir_location__number = "wflow_reservoirlocs" +lake_surface__area = "LakeArea" +lake_location__number = "wflow_lakelocs" +"reservoir_sediment~bedload__trapping_efficiency_coefficient" = "ResTrapEff" + +vegetation_canopy__height = "CanopyHeight" +soil_erosion__rainfall_soil_detachability_factor = "soil_detachability" +soil_erosion__eurosem_exponent = "eros_spl_EUROSEM" +soil_erosion__usle_k_factor = "usle_k" +soil_erosion__usle_c_factor = "USLE_C" +soil_erosion__answers_overland_flow_factor = "eros_ov" +"soil~compacted__area_fraction" = "PathFrac" + +soil_clay__mass_fraction = "fclay_soil" +soil_silt__mass_fraction = "fsilt_soil" +soil_sand__mass_fraction = "fsand_soil" +"soil_aggregates~small__mass_fraction" = "fsagg_soil" +"soil_aggregates~large__mass_fraction" = "flagg_soil" + +land_surface_water_sediment__particle_density = "sediment_density" +land_surface_water_sediment__d50_diameter = "d50_soil" +land_surface_water_sediment__govers_transport_capacity_coefficient = "c_govers" +land_surface_water_sediment__govers_transport_capacity_exponent = "n_govers" +land_surface_water_clay__d50_diameter = "dm_clay" +land_surface_water_silt__d50_diameter = "dm_silt" +land_surface_water_sand__d50_diameter = "dm_sand" +"land_surface_water_aggregates~small__d50_diameter" = "dm_sagg" +"land_surface_water_aggregates~large__d50_diameter" = "dm_lagg" + +river_water_sediment__particle_density = "sediment_density" +river_water_sediment__d50_diameter = "D50_River" +river_water_sediment__bagnold_transport_capacity_coefficient = "c_Bagnold" +river_water_sediment__bagnold_transport_capacity_exponent = "exp_Bagnold" +river_water_sediment__kodatie_transport_capacity_a-coefficient.value = 2829.6 +river_water_sediment__kodatie_transport_capacity_b-coefficient.value = 3.646 +river_water_sediment__kodatie_transport_capacity_c-coefficient.value = 0.406 +river_water_sediment__kodatie_transport_capacity_d-coefficient.value = 0.412 + +river_bottom-and-bank_sediment__d50_diameter = "D50_River" +river_bottom-and-bank_clay__mass_fraction = "ClayF_River" +river_bottom-and-bank_silt__mass_fraction = "SiltF_River" +river_bottom-and-bank_sand__mass_fraction = "SandF_River" +river_bottom-and-bank_gravel__mass_fraction = "GravelF_River" +river_bottom-and-bank_clay__d50_diameter = "dm_clay" +river_bottom-and-bank_silt__d50_diameter = "dm_silt" +river_bottom-and-bank_sand__d50_diameter = "dm_sand" +"river_bottom-and-bank_aggregates~small__d50_diameter" = "dm_sagg" +"river_bottom-and-bank_aggregates~large__d50_diameter" = "dm_lagg" +river_bottom-and-bank_gravel__d50_diameter = "dm_gravel" + +river_water_clay__d50_diameter = "dm_clay" +river_water_silt__d50_diameter = "dm_silt" +river_water_sand__d50_diameter = "dm_sand" +"river_water_aggregates~small__d50_diameter" = "dm_sagg" +"river_water_aggregates~large__d50_diameter" = "dm_lagg" +river_water_gravel__d50_diameter = "dm_gravel" # specify the internal IDs of the parameters which vary over time # the external name mapping needs to be below together with the other mappings +[input.dynamic] forcing = [ - "vertical.atmospheric_forcing.precipitation", - "vertical.hydrological_forcing.interception", - "vertical.hydrological_forcing.waterlevel_land", - "lateral.land.hydrological_forcing.waterlevel_land", - "vertical.hydrological_forcing.q_land", - "lateral.land.hydrological_forcing.q_land", - "lateral.river.hydrological_forcing.waterlevel_river", - "lateral.river.hydrological_forcing.q_river", + "atmosphere_water__precipitation_volume_flux", + "land_surface_water__depth", + "river_water__depth", + "land_surface_water__volume_flow_rate", + "river_water__volume_flow_rate", + "vegetation_canopy_water__interception_volume_flux", ] -[input.vertical.atmospheric_forcing] -precipitation = "P" - -[input.vertical.hydrological_forcing] -waterlevel_land = "levKinL" -q_land = "runL" -interception = "int" - -[input.vertical.land_parameter_set] -slope = "Slope" - -[input.vertical.rainfall_erosion.parameters] -soil_detachability = "soil_detachability" -eurosem_exponent = "eros_spl_EUROSEM" -canopyheight = "CanopyHeight" -usle_k = "usle_k" -usle_c = "USLE_C" -pathfrac = "PathFrac" - -[input.vertical.overland_flow_erosion.parameters] -usle_k = "usle_k" -usle_c = "USLE_C" -answers_k = "eros_ov" - -[input.vertical.soil_erosion.parameters] -clay_fraction = "fclay_soil" -silt_fraction = "fsilt_soil" -sand_fraction = "fsand_soil" -sagg_fraction = "fsagg_soil" -lagg_fraction = "flagg_soil" - -[input.lateral.land.hydrological_forcing] -waterlevel_land = "levKinL" -q_land = "runL" - -[input.lateral.land.transport_capacity.parameters] -density = "sediment_density" -d50 = "d50_soil" -c_govers = "c_govers" -n_govers = "n_govers" -dm_clay = "dm_clay" -dm_silt = "dm_silt" -dm_sand = "dm_sand" -dm_sagg = "dm_sagg" -dm_lagg = "dm_lagg" - -[input.lateral.river.hydrological_forcing] -waterlevel_river = "h" -q_river = "q" - -[input.lateral.river_parameter_set] -length = "wflow_riverlength" -slope = "RiverSlope" -width = "wflow_riverwidth" - -[input.lateral.river.transport_capacity.parameters] -density = "sediment_density" -d50 = "D50_River" -c_bagnold = "c_Bagnold" -e_bagnold = "exp_Bagnold" -a_kodatie.value = 2829.6 -b_kodatie.value = 3.646 -c_kodatie.value = 0.406 -d_kodatie.value = 0.412 - -[input.lateral.river.potential_erosion.parameters] -d50 = "D50_River" - -[input.lateral.river.sediment_flux.parameters] -clay_fraction = "ClayF_River" -silt_fraction = "SiltF_River" -sand_fraction = "SandF_River" -gravel_fraction = "GravelF_River" -dm_clay = "dm_clay" -dm_silt = "dm_silt" -dm_sand = "dm_sand" -dm_sagg = "dm_sagg" -dm_lagg = "dm_lagg" -dm_gravel = "dm_gravel" -# Reservoir -resarea = "ResSimpleArea" -restrapeff = "ResTrapEff" -reslocs = "wflow_reservoirlocs" -# Lake -lakearea = "LakeArea" -lakelocs = "wflow_lakelocs" - -[input.lateral.river.concentrations.parameters] -dm_clay = "dm_clay" -dm_silt = "dm_silt" -dm_sand = "dm_sand" -dm_sagg = "dm_sagg" -dm_lagg = "dm_lagg" -dm_gravel = "dm_gravel" - [model] reinit = true run_river_model = true