Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix CSV output for SVector #193

Merged
merged 9 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,28 @@ NCDatasets = "0.11.7"
Parameters = "0.12"
ProgressLogging = "0.1"
StaticArrays = "0.12, 1.0"
TerminalLoggers = "0.1.5"
TOML = "1.0"
TerminalLoggers = "0.1.5"
UnPack = "1"
julia = "1.6"

[extras]
BasicModelInterface = "59605e27-edc0-445a-b93d-c09a3a50b330"
CFTime = "179af706-886a-5703-950a-314cd64e0468"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[targets]
test = ["BasicModelInterface", "CFTime", "Dates", "DelimitedFiles", "Downloads", "Graphs", "Logging", "NCDatasets", "Polynomials", "QuadGK", "Random", "StaticArrays", "Statistics", "TOML", "Test", "UnPack"]
1 change: 1 addition & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed providing a cyclic parameter when the NetCDF variable is read during model
initialization with `ncread`, this gave an error about the size of the NetCDF `time`
dimension.
- Fixed CSV and NetCDF scalar output of variables with dimension `layer` (`SVector`).

## v0.5.1 - 2021-11-24

Expand Down
35 changes: 26 additions & 9 deletions docs/src/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,16 @@ required. A `reducer` can be specified to apply to the model output, see for mor
information the following section [Output CSV section](@ref). When a `map` is provided to
extract data for certain locations (e.g. `gauges`) or areas (e.g. `subcatchment`), the
NetCDF location names are extracted from these maps. For a specific location (grid cell) a
`location` is required. In the section [Output CSV section](@ref), similar functionality is
available for CSV. For integration with Delft-FEWS, see also [Run from Delft-FEWS](@ref),
it is recommended to write scalar data to NetCDF format since the General Adapter of
Delft-FEWS can ingest this data format directly.
`location` is required. For layered model parameters and variables that have an extra
dimension `layer` and are part of the vertical `sbm` concept it is possible to specify an
internal layer index (see also example below). If multiple layers are desired, this can be
specified in separate `[[netcdf.variable]]` entries. Note that the specification of the
layer is not optional when Wflow is integrated with Delft-FEWS, for NetCDF scalar data an
extra dimension is not allowed by the `importNetcdfActivity` of the Delft-FEWS General
visr marked this conversation as resolved.
Show resolved Hide resolved
Adapter. In the section [Output CSV section](@ref), similar functionality is available for
CSV. For integration with Delft-FEWS, see also [Run from Delft-FEWS](@ref), it is
recommended to write scalar data to NetCDF format since the General Adapter of Delft-FEWS
can ingest this data format directly.

```toml
[netcdf]
Expand All @@ -252,9 +258,10 @@ parameter = "lateral.river.q"
[[netcdf.variable]]
coordinate.x = 6.255
coordinate.y = 50.012
name = "temp_coord"
location = "temp_bycoord"
parameter = "vertical.temperature"
name = "vwc_layer2_bycoord"
location = "vwc_bycoord"
parameter = "vertical.vwc"
layer = 2

[[netcdf.variable]]
location = "temp_byindex"
Expand Down Expand Up @@ -282,8 +289,11 @@ with `only` as the default. To extract data for a specific location (grid cell),
of the vector, the coordinates `coordinate.x` and `coordinate.y`, or the x and y indices of
the 2D array (`index.x` and `index.y`) can be provided. Finally a `map` can be provided to
extract data for certain locations (e.g. `gauges`) or areas (e.g. `subcatchment`). In this
case a single entry can lead to multiple columns in the CSV file, which will be of the
form `header_id`, e.g. `Q_20`, for a gauge with integer ID 20.
case a single entry can lead to multiple columns in the CSV file, which will be of the form
`header_id`, e.g. `Q_20`, for a gauge with integer ID 20. For layered model parameters and
variables that have an extra dimension `layer` and are part of the vertical `sbm` concept an
internal layer index (see also example below) should be specified. If multiple layers are
desired, this can be specified in separate `[[csv.column]]` entries.

The double brackets in `[[csv.column]]` is TOML syntax to indicate that it is part of a
list. You may specify as many entries as you wish.
Expand All @@ -308,6 +318,13 @@ coordinate.y = 50.012
header = "temp_bycoord"
parameter = "vertical.temperature"

[[csv.column]]
coordinate.x = 6.255
coordinate.y = 50.012
header = "vwc_layer2_bycoord"
parameter = "vertical.vwc"
layer = 2

[[csv.column]]
header = "temp_byindex"
index.x = 100
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lateral/local-inertial.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ two cells and ``\Delta y`` [m] is the flow width. Below the staggered grid and v
the numerical solution in the x-direction, based on Almeida et al. (2012):

```@raw html
<img src="../images/numerical_scheme_almeida.png" width="75%"/>
<img src="../../images/numerical_scheme_almeida.png" width="75%"/>
```

The overland flow local inertial approach is used in combination with the local inertial
Expand Down
2 changes: 1 addition & 1 deletion src/hbv_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ function initialize_hbv_model(config::Config)
reservoir = isempty(reservoir) ? nothing : reservoir.reverse_indices,
lake = isempty(lake) ? nothing : lake.reverse_indices,
)
writer = prepare_writer(config, reader, modelmap, indices_reverse, x_nc, y_nc, nc)
writer = prepare_writer(config, modelmap, indices_reverse, x_nc, y_nc, nc)
close(nc)

# for each domain save:
Expand Down
Loading