You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/intro.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ The NanoFASE model is a multimedia spatiotemporal environmental fate and exposur
8
8
9
9
## Quickstart guide
10
10
11
-
The easiest way to install the model is to use the [Fortran Package Manager]([https://fpm.fortran-lang.org/en/install/index.html#install](https://fpm.fortran-lang.org/install/index.html#install)), which can be installed using Conda (`conda install -c conda-forge fpm`). The model also requires a recent version of GFortran, NetCDF Fortran and Git installed (see [](./getting-started/building-the-model.md)).
11
+
The easiest way to install the model is to use the [Fortran Package Manager](https://fpm.fortran-lang.org/install/index.html#installing-fpm), which can be installed using Conda (`conda install -c conda-forge fpm`). The model also requires a recent version of GFortran, NetCDF Fortran and Git installed (see [](./getting-started/building-the-model.md)).
12
12
13
13
Clone the code (make sure to `--recurse-submodules`) and use *fpm* to install:
The model routes water by using a flow direction raster, which uses standard eight-direction (D8) flow direction enconding. In `nfdata`, this flow direction can either be provided by the `flow_dir` parameter, or `nfdata` can attempt to deduce it from a digital elevation model (DEM) provided by the `dem` parameter.
4
+
5
+
:::{admonition} `flow_dir` or `dem` as a basis for the grid
6
+
:class: important
7
+
Either the `flow_dir`, or if `flow_dir` isn't present, the `dem` variable, is used as the basis for the grid that defines the NetCDF file output by `nfdata`. That is, parameters such as the CRS, bounds, resolution and mask are obtained from this variable. `nfdata` does not do any reprojection of rasters from other grid systems (therefore, all provided rasters should be the same CRS and resolution), but it does clip rasters to the extent of `flow_dir`/`dem`. This clipping includes masking over nodata values in `flow_dir`/`dem`, and therefore it is one of these variable that decides which grid cells are modelled.
8
+
:::
9
+
10
+
## Directly providing `flow_dir`
11
+
12
+
```{figure} ../img/flowdir.gif
13
+
---
14
+
align: right
15
+
---
16
+
```
17
+
18
+
If the `flow_dir` variable is present in `nfdata`'s config, this will be used as the flow direction (regardless of whether `dem` is present). This variable should be a raster (openable by [Rasterio](https://rasterio.readthedocs.io/en/latest/index.html)) and have an integer data type with either D8 values or nodata values.
19
+
20
+
This flow direction _must_ be resolved, otherwise running the model with it will fail. By resolved, we mean that all non-masked (nodata) cells must have a non-zero D8 value (1, 2, 4, 8, 16, 32, 64, 128), and that these values must not result in "pools" where cells flow into each other (e.g. neighbouring cells with the northerly cell having `flow_dir=4` and a southerly cell having `flow_dir=64`).
21
+
22
+
The `flow_dir` group in the config file must contain a `path`, and optionally a `crs` value. The CRS is usually deduced from the provided raster, but in the case of rasters with ill-defined CRSs, the `crs` option gives the ability to override this. Note that this _does not_ reproject the raster to this CRS, it simply assigns the CRS to the raster.
23
+
24
+
## Calculating `flow_dir` from a DEM
25
+
26
+
Alternatively, if the `dem` variable is present and `flow_dir` is not, the model will _attempt_ to deduce the flow direction from this DEM. To achieve this, either a _conditioned_ DEM should be provided, or the config option `condition_dem` must be present to instruct `nfdata` to attempt to condition the DEM.
27
+
28
+
By _conditioned_, we mean that no pits, depressions or flats should be present in the DEM, as these will prevent a fully-resolved flow direction from being calculated. If an unconditioned DEM is provided (and the `condition_dem` option is not specified), `nfdata` will raise an error. There are [numerous](https://mattbartos.com/pysheds/)[tools](https://richdem.readthedocs.io/)[available](https://www.whiteboxgeo.com/manual/wbt_book/available_tools/hydrological_analysis.html) that can help condition DEMs.
29
+
30
+
If `condition_dem` is present, `nfdata` will attempt to condition the DEM using [Whitebox Tools' `breach_depressions_least_cost` routine](https://www.whiteboxgeo.com/manual/wbt_book/available_tools/hydrological_analysis.html#BreachDepressionsLeastCost). This is a fairly robust tool that is usually able to resolve most DEMs without significant alterations, but it might not work in all cases. `condition_dem` can either be `True`, or be a dict of further config options:
31
+
32
+
```yaml
33
+
condition_dem:
34
+
# If `save_dem_to_path` is set, the conditioned DEM will be saved to this path
35
+
# (even if the conditioning hasn't fully worked). If not, a temporary directory
36
+
# is used and the resulting DEM is deleted after the processing.
37
+
save_dem_to_path: ./dem.tif
38
+
# Additional config options specified here will be passed to `breach_depressions_least_cost`
39
+
# See https://www.whiteboxgeo.com/manual/wbt_book/available_tools/hydrological_analysis.html#BreachDepressionsLeastCost
40
+
# If a value for `callback` is provided, it is ignored as we implement our own callback to
41
+
# deal with errors. The only required (by Whitebox) parameter is `dist`, which specifies
42
+
# the maximum search distance for breach paths in cells. The default value used in nfdata is 10000.
43
+
dist: 10000
44
+
```
45
+
46
+
:::{important}
47
+
Currently, `nfdata`'s flow direction algorithm assumes that nodata (masked) cells and cells immediately outside of the DEM's bounding box are at a very low elevation, therefore forcing the flow direction from neighbouring cells towards them. Effectively, this means that nodata cells and the region outside of the DEM are treated as waterbodies into which neighbouring cell drain. Therefore, we only recommend to use this flow direction calculation functionality if this is a valid assumption for your scenario, otherwise you should provide a pre-resolved flow direction raster.
Copy file name to clipboardExpand all lines: docs/users/nanofase-data.md
+41-11Lines changed: 41 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,19 +116,40 @@ The examples are annotated and should be self-explanatory. However, there are a
116
116
The `create` and `edit` config files follow a similar layout. A variety of setup data is required and in the examples is placed at the top of the file. This includes file paths to input and output path, and model config info (e.g. timestep info):
117
117
118
118
```yaml
119
-
# Setup
120
-
nanomaterial: TiO2 # Name of the nanomaterial. Not used in model.
119
+
# Name of the nanomaterial. Not used in the model.
120
+
nanomaterial: TiO2
121
+
# Where do you want the output NetCDF and constants files to be stored?
121
122
output:
122
-
nc_file: ./data.nc # Where do you want the output NetCDF file to be stored?
123
-
constants_file: ./constants.nml # Where do you want the output constants file to be stored?
124
-
constants_file: ./data.example/thames_tio2_2015/constants.yaml # Where is the input constants file?
125
-
land_use_config: ./data.example/thames_tio2_2015/land_use.yaml # Where is the input land use config file?
126
-
root_dir: ./data.example/thames_tio2_2015/ # Root dir, can be used in path variables below as <root_dir>
# Root directory can be used in path variables below as <root_dir> (optional)
130
+
root_dir: ./data.example/thames_tio2_2015/
131
+
# ISO3 code using for filtering point source emissions to specific countries
132
+
iso3: GBR
133
+
# Number of timesteps, length of each timestep (in seconds) and start date
134
+
# for the model run
128
135
time:
129
-
n: 365# Number of timesteps to run the model for
130
-
dt: 86400# Length of each timestep in seconds
131
-
start_date: 2015-01-01# Start date for the model run
136
+
n: 365
137
+
dt: 86400
138
+
start_date: 2015-01-01
139
+
# If the `condition_dem` config option is present, the compiler will attempt to remove
140
+
# pits, depressions and flat areas from the DEM using WhiteboxTools'
141
+
# `breach_depressions_least_cost`. It can either be True or a dict of config options
142
+
condition_dem:
143
+
# If `save_dem_to_path` is set, the conditioned DEM will be saved to this path
144
+
# (even if the conditioning hasn't fully worked). If not, a temporary directory
145
+
# is used and the resulting DEM is deleted after the processing.
146
+
save_dem_to_path: ./dem.tif
147
+
# Additional config options specified here will be passed to `breach_depressions_least_cost`
148
+
# See https://www.whiteboxgeo.com/manual/wbt_book/available_tools/hydrological_analysis.html#BreachDepressionsLeastCost
149
+
# If a value for `callback` is provided, it is ignored as we implement our own callback to
150
+
# deal with errors. The only required (by Whitebox) parameter is `dist`, which specifies
151
+
# the maximum search distance for breach paths in cells. The default value used in nfdata is 10000.
152
+
dist: 10000
132
153
```
133
154
134
155
```{warning}
@@ -201,6 +222,11 @@ For reference, the NanoFASE land use categories are:
201
222
- `other`
202
223
```
203
224
225
+
(nanofase-data:dem-conditioning)
226
+
#### DEM conditioning - `condition_dem`
227
+
228
+
See [](./flow-dir-dem-conditioning).
229
+
204
230
205
231
(nanofase-data:parameters)=
206
232
### Parameters
@@ -222,6 +248,10 @@ A few parameters require additional information:
222
248
Individual model runs have constant emissions for the whole run. However, individual model runs can be chained together in a multi-year model run, each year having different areal emissions. See [](batch). This is how multi-year simulations with varying areal emissions are currently performed.
223
249
```
224
250
251
+
#### Flow direction and DEM
252
+
253
+
See [](flow-dir-dem-conditioning) for details on the `flow_dir` and `dem` variables.
Copy file name to clipboardExpand all lines: docs/users/netcdf-namelist-input.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,17 @@ If you are manually creating this NetCDF file, pay careful attention to units, w
25
25
26
26
This selection of parameters pertains to the geographical region modelled, such as its climate, topography and soil properties.
27
27
28
+
(input-data:flow_dir)=
29
+
`int flow_dir(y, x)`
30
+
: *Required, unitless*\
31
+
Flow direction of water in the grid cell, relating to the topography. In `nfdata`, this can be [deduced from the DEM](flow-dir-dem-conditioning). Uses the standard eight-direction (D8) flow direction encoding.
32
+
33
+
```{figure} ../img/flowdir.gif
34
+
---
35
+
align: right
36
+
---
37
+
```
38
+
28
39
(input-data:dem)=
29
40
`int dem(y, x)`
30
41
: *Optional, if not present then default slope of 0.0005 m/m is assumed. Units: dm. Standard name: `height_above_mean_sea_level`.*\
@@ -245,17 +256,8 @@ Grid resolution - the size of each grid cell.
245
256
: *Required, units: metres*\
246
257
Coordinates of the bounding box for the model grid, in order (left, top, right, bottom).
247
258
248
-
The following variables are ultimately deduced from the [digital elevation model](input-data:dem) (DEM) and are used to define the surface water network within the model, meaning the surface water network is automatically deduced and does not need to be provided as an input (see [](conceptual-structure:surface-water-network)).
259
+
The following variables are ultimately deduced from the [digital elevation model](input-data:dem) (DEM) and/or [flow direction](input-data:flow_dir) and are used to define the surface water network within the model, meaning the surface water network is automatically deduced and does not need to be provided as an input (see [](conceptual-structure:surface-water-network)).
249
260
250
-
```{figure} ../img/flowdir.gif
251
-
---
252
-
align: right
253
-
---
254
-
```
255
-
256
-
`int flow_dir(y, x)`
257
-
: *Required, unitless*\
258
-
Flow direction of water in the grid cell, relating to the topography and deduced from the [DEM](input-data:dem). Uses the standard eight-direction (D8) flow direction encoding.
Copy file name to clipboardExpand all lines: docs/users/parameters/met-hydro-parameters.csv
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
Name(dimensions),Specified in,Data type,Required or optional,Model units,Description,Potential source
2
-
"`dem(y, x)`",{bdg-primary}`data.nc` {bdg-success}`config.yaml` ,float,"Required in {bdg-success}`config.yaml`, optional in {bdg-primary}`data.nc`",dm,"Digital elevation model (height above mean sea level). In the model, this is only used to calculate slope, which defaults to 0.0005 m/m. In the NanoFASE data module, it is used to calculate numerous [secondary variables](netcdf-namelist-input:secondary-derived-variables) for input to the model. Standard name: `height_above_mean_sea_level`",[HydroSHEDS](https://www.hydrosheds.org/) or [Copernicus DEM](https://dataspace.copernicus.eu/explore-data/data-collections/copernicus-contributing-missions/collections-description/COP-DEM)
2
+
"`flow_dir(y, x)`",{bdg-primary}`data.nc` {bdg-success}`config.yaml` ,int,"Optional in {bdg-success}`config.yaml` if `dem` present",-,"Flow direction using D8 indices. `nfdata` will attempt to calculate this from `dem` if this is not provided in {bdg-success}`config.yaml`.,
3
+
"`dem(y, x)`",{bdg-primary}`data.nc` {bdg-success}`config.yaml` ,float,"Required in {bdg-success}`config.yaml`, optional in {bdg-primary}`data.nc`",dm,"Digital elevation model (height above mean sea level). In the model, this is only used to calculate slope, which defaults to 0.0005 m/m. In the NanoFASE data module, it can be used to calculate flow direction. Standard name: `height_above_mean_sea_level`",[HydroSHEDS](https://www.hydrosheds.org/) or [Copernicus DEM](https://dataspace.copernicus.eu/explore-data/data-collections/copernicus-contributing-missions/collections-description/COP-DEM)
3
4
"`quickflow(t, y, x)`",{bdg-primary}`data.nc` {bdg-success}`config.yaml` ,float,Required,m/dt,"Also called surface runoff, this is the component of runoff that is responsible for driving soil erosion. Standard name: `surface_runoff_flux`",Usually obtained from a hydrological model
4
5
"`runoff(t, y, x)`",{bdg-primary}`data.nc` {bdg-success}`config.yaml` ,float,Required,m/dt,This is the total runoff (subsurface and surface) that is routed by the model to provide surface water flows. Standard name: `runoff_flux`,Usually obtained from a hydrological model
5
6
"`precip(t, y, x)`",{bdg-primary}`data.nc` {bdg-success}`config.yaml` ,float,Required,m/dt,"Amount of precipitation, used to drive soil percolation. Standard name: `rainfall_flux`",[Copernicus E-OBS](https://cds.climate.copernicus.eu/cdsapp#!/dataset/10.24381/cds.151d3ec6?tab=overview) or [CEH-GEAR](https://doi.org/10.5285/dbf13dd5-90cd-457a-a986-f2f9dd97e93c) for the UK
0 commit comments