diff --git a/.gitignore b/.gitignore index c9fd11b9..b4b69bab 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/docs/changelog.rst b/docs/changelog.rst index 4fc8b2ec..63523c10 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -16,6 +16,7 @@ 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 `_ @@ -23,9 +24,12 @@ Changed 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 diff --git a/examples/wflow_build.ini b/examples/wflow_build.ini index 4fa6af75..08c3a5f0 100644 --- a/examples/wflow_build.ini +++ b/examples/wflow_build.ini @@ -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] @@ -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 diff --git a/examples/wflow_sediment_build.ini b/examples/wflow_sediment_build.ini index 13f40720..08ec7d35 100644 --- a/examples/wflow_sediment_build.ini +++ b/examples/wflow_sediment_build.ini @@ -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] diff --git a/examples/wflow_update_forcing.ini b/examples/wflow_update_forcing.ini index 50ebba30..50824d7b 100644 --- a/examples/wflow_update_forcing.ini +++ b/examples/wflow_update_forcing.ini @@ -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. @@ -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 \ No newline at end of file diff --git a/hydromt_wflow/wflow.py b/hydromt_wflow/wflow.py index e3ce34f8..4cb67f1e 100644 --- a/hydromt_wflow/wflow.py +++ b/hydromt_wflow/wflow.py @@ -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 [-] @@ -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, @@ -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". @@ -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()