Skip to content

Commit

Permalink
Merge pull request #127 from Deltares/docs_update
Browse files Browse the repository at this point in the history
Update example .ini files
  • Loading branch information
hboisgon authored Nov 22, 2022
2 parents a397fcd + 357c6e9 commit 9ccce13
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ target/

# Jupyter Notebook / examples
.ipynb_checkpoints
examples/wflow_piave_subbasin/staticmaps
examples/wflow_piave_subbasin_updated
examples/wflow_test_base
examples/wflow_test_full
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ Added

Changed
-------
- update forcing example with multiple forcing files #122
- New window smoothing algorithm in `setup_rivers` to avoid cells with small river length.
Set the min_rivlen_ratio argument to a value larger than zero to apply the smoothing.
Note: requires pyflwdir v0.5.6 `PR #92 <https://github.com/Deltares/hydromt_wflow/pull/92>`_

Fixed
-----
- write_forcing with time of type cftime.DatetimeNoLeap #109
- write_forcing: re-write config in case of multiple forcing files
- read_forcing with multiple files (* key in toml)
- bug in setup_gauges in update mode with crs.is_epsg_code #108
- bug in self.rivers if no staticgeoms and rivmsk is found #113
- bug in wflow_build_sediment.ini template in examples
- wrong defaults in wflow_build.ini teamplate in examples #116
- temporary fix to update staticgeoms basins+rivers in clip_staticmaps (update when moving away from deprecated staticgeoms).
- fix wrong default value for lai_fn in setup_laimaps #119

Expand Down
10 changes: 5 additions & 5 deletions examples/wflow_build.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ smooth_len = 5000 # length over which to smooth river depth an
# land_routing = kinematic-wave # {'kinematic-wave', 'local-inertial'}

[setup_reservoirs]
reservoirs_fn = hydro_reservoirs # source for reservoirs based on GRAND: {hydro_reservoirs}; None to skip
reservoirs_fn = hydro_reservoirs # source for reservoirs based on GRAND: {hydro_reservoirs}
min_area = 1.0 # minimum lake area to consider [km2]
priority_jrc = True # if True then JRC data from hydroengine is used to calculate some reservoir attributes instead of the GRanD and HydroLAKES db.
priority_jrc = True # if True then JRC data from hydroengine is used to calculate some reservoir attributes instead of the GRanD and HydroLAKES db.

[setup_lakes]
lakes_fn = hydro_lakes # source for lakes based on hydroLAKES: {hydro_lakes}; None to skip
lakes_fn = hydro_lakes # source for lakes based on hydroLAKES: {hydro_lakes}
min_area = 10.0 # minimum reservoir area to consider [km2]

[setup_glaciers]
glaciers_fn = rgi # source for glaciers based on Randolph Glacier Inventory {rgi}; None to skip
glaciers_fn = rgi # source for glaciers based on Randolph Glacier Inventory {rgi}
min_area = 1.0 # minimum glacier area to consider [km2]

[setup_lulcmaps]
Expand Down Expand Up @@ -73,7 +73,7 @@ Cfmax = 3.75653
cf_soil = 0.038
EoverR = 0.11
InfiltCapPath = 5
InfiltCapSoil = 600
InfiltCapSoil = 600
MaxLeakage = 0
rootdistpar = -500
TT = 0
Expand Down
6 changes: 3 additions & 3 deletions examples/wflow_sediment_build.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ slope_len = 2000 # length over which tp calculate river slope
smooth_len = 5000 # length over which to smooth river depth and river width [m]

[setup_reservoirs]
reservoirs_fn = hydro_reservoirs # source for reservoirs based on GRAND: {hydro_reservoirs}; None to skip
reservoirs_fn = hydro_reservoirs # source for reservoirs based on GRAND: {hydro_reservoirs}
min_area = 1.0 # minimum lake area to consider [km2]
priority_jrc = True # if True then JRC data from hydroengine is used to calculate some reservoir attributes instead of the GRanD and HydroLAKES db.
priority_jrc = True # if True then JRC data from hydroengine is used to calculate some reservoir attributes instead of the GRanD and HydroLAKES db.

[setup_lakes]
lakes_fn = hydro_lakes # source for lakes based on hydroLAKES: {hydro_lakes}; None to skip
lakes_fn = hydro_lakes # source for lakes based on hydroLAKES: {hydro_lakes}
min_area = 1.0 # minimum reservoir area to consider [km2]

[setup_riverbedsed]
Expand Down
9 changes: 8 additions & 1 deletion examples/wflow_update_forcing.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
starttime = 2010-02-01T00:00:00
endtime = 2010-02-10T00:00:00
timestepsecs = 86400
input.path_forcing = inmaps-chirps-2010.nc
input.path_forcing = inmaps-chirps.nc

[setup_precip_forcing]
precip_fn = chirps_global # source for precipitation.
Expand All @@ -15,3 +15,10 @@ temp_correction = True # if True pressure is corrected with elevation l
dem_forcing_fn = era5_orography # source of elevation grid corresponding to temp_pet_fn. Used for lapse rate correction.
pet_method = debruin # method to compute PET: {debruin, makkink}
skip_pet = False # if True, only temperature is prepared.

[write_forcing] # Write forcing and re-write config if forcing filename or times are updated
freq_out = M # Set frequency at which forcing files are written, following pandas offset aliases

[write_staticmaps] # to make sure that the staticmaps are written as well, can be skipped if update in the same model folder

[write_staticgeoms] # to make sure that the staticgeoms are written as well, can be skipped if update in the same model folder
19 changes: 14 additions & 5 deletions hydromt_wflow/wflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,17 +591,17 @@ def setup_lulcmaps(
):
"""
This component derives several wflow maps are derived based on landuse-
landcover (LULC) data.
landcover (LULC) data.
Currently, ``lulc_fn`` can be set to the "vito", "globcover"
or "corine", fo which lookup tables are constructed to convert lulc classses to
model parameters based on literature. The data is remapped at its original
resolution and then resampled to the model resolution using the average
value, unless noted differently.
Adds model layers:
* **landuse** map: Landuse class [-]
* **landuse** map: Landuse class [-]
* **Kext** map: Extinction coefficient in the canopy gap fraction equation [-]
* **Sl** map: Specific leaf storage [mm]
* **Swood** map: Fraction of wood in the vegetation/plant [-]
Expand Down Expand Up @@ -1852,6 +1852,14 @@ def read_forcing(self):
ds = xr.open_dataset(fn, chunks={"time": 30}, decode_coords="all")
for v in ds.data_vars:
self.set_forcing(ds[v])
elif "*" in str(fn):
self.logger.info(f"Read multiple forcing files using {fn}")
fns = list(fn.parent.glob(fn.name))
if len(fns) == 0:
raise IOError(f"No forcing files found using {fn}")
ds = xr.open_mfdataset(fns, chunks={"time": 30}, decode_coords="all")
for v in ds.data_vars:
self.set_forcing(ds[v])

def write_forcing(
self,
Expand Down Expand Up @@ -1881,7 +1889,7 @@ def write_forcing(
For more options, see https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases
chunksize: int, optional
Chunksize on time dimension when saving to disk. By default 1.
decimals, int, optional
decimals: int, optional
Round the ouput data to the given number of decimals.
time_units: str, optional
Common time units when writting several netcdf forcing files. By default "days since 1900-01-01T00:00:00".
Expand Down Expand Up @@ -2011,6 +2019,7 @@ def write_forcing(
fns_out = os.path.relpath(fn_out, self.root)
fns_out = f"{str(fns_out)[0:-3]}_*.nc"
self.set_config("input.path_forcing", fns_out)
self.write_config() # re-write config
for label, ds_gr in ds.resample(time=freq_out):
# ds_gr = group[1]
start = ds_gr["time"].dt.strftime("%Y%m%d")[0].item()
Expand Down

0 comments on commit 9ccce13

Please sign in to comment.