MESH-Model / MESH-Scripts

This repository is for sharing and improving pre-processing, post-processing, and run scripts for the MESH hydrology land-surface model.
9 stars 9 forks source link

Routing issue with short river segments #28

Open kasra-keshavarz opened 1 year ago

kasra-keshavarz commented 1 year ago

When the river segments are shorted than a certain threshold, MESH routing scheme, RTE, throws a bunch warnings (and possible error) that it is not able to route through short channels.

Here is the code to re-produce the issue with the BowAtBanff setup of the current repository:

>>> import xarray as xr
>>> ncfile = xr.open_dataset('MESH_drainage_database.nc')
>>> ncfile.ChnlLength[21] = 0.210 # changing the channel length of river segment 71031687 - a headwater one
>>> ncfile.to_netcdf('MESH_drainage_database2.nc')

and

foo@bar: mv MESH_drainage_database.nc MESH_drainage_database_backup.nc
foo@bar: mv MESH_drainage_database2.nc MESH_drainage_database.nc
foo@bar: ./BowAtBanff_MESH_RDRSV2.1.sh

And MESH output with DIAGNOSEMODE on flag is:

Click for error details ```console foo@bar: ./BowAtBanff_MESH_RDRSV2.1.sh MESH 1.4 --- (1813) READING: MESH_input_run_options.ini READING: MESH_drainage_database.nc WARNING: The calendar 'proleptic_gregorian' of the 'time' variable is unknown or not supported. WARNING: The reference calendar for the 'time' variable is not set or is not equal to 'gregorian' or 'standard'. Errors may occur with deriving time-stamps from the file. WARNING: The variable 'LandUse' is an unknown or unsupported data format (Code: 1). 4 attributes found in the file. 34 variables found in the file. 35 valid fields found in the file. INFO: Found the variable 'Author'. INFO: Found the variable 'History'. INFO: Found the variable 'Purpose'. INFO: Found the variable 'featureType'. INFO: Found the variable 'seg_id'. INFO: Found the variable 'tosegment'. INFO: Found the variable 'ChnlSlope'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'ChnlLength'. INFO: Found the variable 'hruid'. INFO: Found the variable 'seg_hr_id'. INFO: Found the variable 'GridArea'. INFO: Found the variable 'width'. INFO: Found the variable 'R2N'. INFO: Found the variable 'Rank'. INFO: Found the variable 'Next'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'ngru'. INFO: Found the variable 'gru 1'. INFO: Found the variable 'gru 2'. INFO: Found the variable 'gru 3'. INFO: Found the variable 'gru 4'. INFO: Found the variable 'gru 5'. INFO: Found the variable 'gru 6'. INFO: Found the variable 'gru 7'. INFO: Found the variable 'gru 8'. INFO: Found the variable 'gru 9'. INFO: Found the variable 'gru 10'. INFO: Found the variable 'gru 11'. INFO: Found the variable 'gru 12'. INFO: Found the variable 'gru 13'. INFO: Found the variable 'gru 14'. REMARK: At least one river class is required when channel routing is enabled. The number of river classes is not defined or the 'IAK' or 'IRVR' map is missing in the file. Assuming one river class. INFO: Assigned the variable 'ChnlSlope'. INFO: Assigned the variable 'ChnlLength'. INFO: Assigned the variable 'GridArea'. INFO: Assigned the variable 'Next'. REMARK: No drainage area 'DA' variable found. Accumulating areas from surface area 'GridArea' by flow direction 'Next'. REMARK: No 'Reach' or 'IREACH' variable found. Assuming no reservoirs or routed lakes exist inside the basin. REMARK: No 'Bankfull' variable found. Setting the background field to zero. REMARK: No 'Chnl' or 'ICHNL' variable found. Assuming a single channel class. Total number of grids: 51 Total number of grids inside the basin: 50 Side length of grid: 1.00000000 m Number of GRUs: 13 Number of land-based tiles: 530 Number of river classes: 1 READING: MESH_input_soil_levels.txt Number of soil layers: 3 Level Thickness (m) Bottom (m) 1 0.1000000 0.1000000 2 0.2500000 0.3500000 3 3.750000 4.100000 READING: MESH_parameters_CLASS.ini READING: MESH_parameters_hydrology.ini READING: MESH_parameters.txt Reading parameter: DTMINUSR. REMARK: Overwriting or updating the existing 'DTMINUSR' value. Active parameters in file: 1 READING: Resume run configuration RESUMEFLAG is not active: RESUMEFLAG off SAVERESUMEFLAG is not active: SAVERESUMEFLAG off READING: MESH_input_streamflow.txt Number of streamflow gauges: 2 GAUGE IY JX RANK DA (km2) 05BB001 1 51 51 2216.040 05BA001 1 16 16 731.1786 READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. REMARK: Mapping the field 'RDRS_v2.1_P_FB_SFC' to the 'FSIN' variable. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_FB_SFC'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. REMARK: Mapping the field 'RDRS_v2.1_P_FI_SFC' to the 'FLIN' variable. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_FI_SFC'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. REMARK: Mapping the field 'RDRS_v2.1_A_PR0_SFC' to the 'PRE' variable. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_A_PR0_SFC'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. REMARK: Mapping the field 'RDRS_v2.1_P_TT_09944' to the 'TA' variable. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_TT_09944'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. REMARK: Mapping the field 'RDRS_v2.1_P_UVC_09944' to the 'UV' variable. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_UVC_09944'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. REMARK: Mapping the field 'RDRS_v2.1_P_P0_SFC' to the 'PRES' variable. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_P0_SFC'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. REMARK: Mapping the field 'RDRS_v2.1_P_HU_09944' to the 'QA' variable. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_HU_09944'. The simulation starts at: 1980/01/01 07:00:00.000000 Checking the start dates of the input files... INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 RUNCLASS36 is active. ICEBAL_FREEZE_THRESHOLD (FREZTH) override is ACTIVE. Uniform value: -2.000000 ICEBAL_SWE_LIMIT (SWELIM) override is ACTIVE. Uniform value: 1500.000 ICEBAL_SNOW_DENSITY_LIMIT (SNDENLIM) override is ACTIVE. Uniform value: 600.0000 BASEFLOW component is ACTIVE. BASEFLOWFLAG wf_lzs grid hf=60 pwr_iak 1.361000 flz_iak 0.4200000E-04 READING: outputs_balance.txt Reading output variable: LQWSCAN Reading output variable: FZWSCAN Reading output variable: SNO Reading output variable: LQWSSNO Reading output variable: LQWSPND Reading output variable: LQWSSOL Reading output variable: FZWSSOL Reading output variable: STGGW Reading output variable: STGW Reading output variable: RFF REMARK: The option 'ts' is not recognized for output (Variable 'RFF'). Output variables: 10 DONE INTITIALIZATION STARTING MESH WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 WARNING: NON-CONVERGENCE AT POINT AT X,Y: 22 1 route yields a negative store2 value at dtmin = mindtmin: 10.0 It's likely that qo1 is so large that store2 is negative even with qo2=0.0 If this run was started from shed2flowinit utility, then try lowering the QI, QO, and STORE ratios until this error is resolved Else rerun with a smaller value of dtmin ```

This has been tried with MESH v1813 and MESH-Scripts with commit 0b87a6d.

kasra-keshavarz commented 1 year ago

Copying @mee067

mee067 commented 1 year ago

it is really about channel storage because the routing in RTE is based on that. If there is a large volume entering a small channel, it can leave the channel before the time step had elapsed causing issues if the leaving amount is more than the inflow depleting the storage to the extent of having negative values which is unreasonable. From that came the idea of the adaptive time step, reducing the time step (by half each time) to try to solve the issue. The alternative is to have enough channel storage by making the channel bigger (longer, deeper, wider - it is about volume). Given that the rivers are too short in MERIT-hydro headwater basins, especially if the area is just above the channelization threshold used (25 sqkm) which is larger than needed, in my opinion, for regional studies.