CLI command reference#
This page is generated from the real mhm-tools Click command tree.
mhm-tools#
All tools are provided as sub-commands.
Usage
mhm-tools [OPTIONS] GROUP COMMAND [ARGS]...
Options
- -V, --version#
Show the version and exit.
- --log-level <log_level>#
Set the log level explicitly.
- -v, --verbose#
Increase verbosity
- -q, --quiet#
Reduce verbosity can be repeated e.g. -qq
- --log-file <log_file>#
Generate a log file.
- --log-file-level <log_file_level>#
Set log level for the log file. Defaults to console log level.
- --no-console-output#
Prohibit console output.
setup-creation#
Create and prepare mHM/mRM setup files.
Usage
mhm-tools setup-creation [OPTIONS] COMMAND [ARGS]...
create-catchment#
Create mHM/mRM catchment files from flow direction or DEM data.
The tool delineates global or local domains, either as full-domain basin maps or as one or multiple gauge catchments. Gauge outlets can be selected from coordinates and reference area, from catchment shapes, or from both. It writes the basin ID file, optional idgauges files, a domain mask, and optional gauge metadata and basin shapes.
crop-mhm-setup#
Crop an existing mHM setup or single setup file to a smaller domain.
The target domain can be defined by a mask file, lon/lat box, or explicit coordinate bounds. The tool recreates the input folder structure, crops NetCDF files, copies non-cropped files, rewrites headers where needed, can apply masks to DEM or all variables, and can create a new latlon file when resolutions are provided.
Authors#
Simon Lüdke
Usage
mhm-tools setup-creation crop-mhm-setup [OPTIONS]
Options
- -i, --input-dir <input_path>#
Required Path to the directory of the existing mHM setup. Can also be used with a file path to crop a single file.
- Default:
Sentinel.UNSET
- -o, --output-dir <output_path>#
Required Path of the directory where the new domain setup should be saved.
- Default:
Sentinel.UNSET
- -f, --input-name <file_name>#
Input file name. E.g. ‘.nc’ to copy only nc files or ‘pre’ to copy only precipitation files. If the file has a header in it’s folder the header is reproduced regardless of wether nor not it fits the filename.
- Default:
'*.*'
- -m, --mask-file <mask_file>#
The path the the mask file. Mask files can be created using the catchment command with the –mask flag.
- --l1-resolution <l1_resolution>#
Hydrological resolution. Without it no latlon file can be produced.
- --l11-resolution <l11_resolution>#
- --l2-resolution <l2_resolution>#
- --crs <crs>#
Coordinates reference system (e.g. ‘epsg:3035’). Needed to create a new latlon file.If not given, headers will be interpreted as given in lat-lon (‘epsg:4326’).
- --ncpus <ncpus>#
Number of cores used for parallelisation.
- Default:
1
- --folder-recursion-depth <folder_recursion_depth>#
How deep in the folder structure should the file be searched?
- Default:
5
- --lonlatbox <lonlatbox>#
coordinates in the form of ‘lon_min,lon_max,lat_min,lat_max,resolution_l0’ required unless –mask_file is provided
- --available-mem <available_mem>#
Available memory per cpu in Gb or Mb (default Gb)
- Default:
'5'
- --chunking#
Set if each dataset should be read as a chunked dask array.
- Default:
False
- --lon-min <lon_min>#
minimum longitude of the target grid required unless –mask_file is provided
- --lon-max <lon_max>#
maximum longitude of the target grid required unless –mask_file is provided
- --lat-min <lat_min>#
minimum latitude of the target grid required unless –mask_file is provided
- --lat-max <lat_max>#
maximum latitude of the target grid required unless –mask_file is provided
- --create-header#
Force creation of header file for all files.
- Default:
False
- --no-cropping#
Do not crop the file but only writes a header. This activate the forced header creation and only header functions.
- Default:
False
- --mask-all#
Apply the mask to all cropped files (not only DEM). Useful with tool will automaitcally select the mask aligning with the file resolution or upscale a higher resolution mask.
- Default:
False
- --output-var <output_var>#
Output variable name for single data var
- --lat-order <lat_order>#
Direction of the latitude coordinate. Will be forced if input has coordinates.
- Default:
'decreasing'
- --output-suffix <output_suffix>#
Suffix added to output file names leading to file type conversion.
latlon#
Create the latlon.nc file required for mHM.
The latlon file contains the lat-lon information for 3 levels in mHM: Level-0 (DEM), Level-1 (hydrology) and Level-11 (routing). All levels will be checked for compatibility including Level-2 (meteo). Level-0 can be given as a file or a dictionary containing an ascii grid header. Other levels can then be given by only a cell-size and will be determined from Level-0.
Authors#
Sebastian Müller
Usage
mhm-tools setup-creation latlon [OPTIONS]
Options
- -D, --level0 <level0>#
Required Level-0 (DEM) information. Either an ascii (header) file or a dictionary containing the header information.
- Default:
Sentinel.UNSET
- -H, --level1 <level1>#
Required Level-1 (hydrology) information. Either an ascii (header) file, a dictionary containing the header information or a cell-size to determine information from level-0.
- Default:
Sentinel.UNSET
- -R, --level11 <level11>#
Level-11 (routing) information. Either an ascii (header) file, a dictionary containing the header information or a cell-size to determine information from level-0.
- -M, --level2 <level2>#
Level-2 (meteorology) information. Either an ascii (header) file, a dictionary containing the header information or a cell-size to determine information from level-0. Level-2 information wont be written to the latlon file.
- -c, --crs <crs>#
Coordinates reference system (e.g. ‘epsg:3035’). If not given, headers will be interpreted as given in lat-lon (‘epsg:4326’).
- -d, --dtype <dtype>#
Data type for the latlon file and headers.
- Default:
'f4'
- -x, --compression <compression>#
Compression level for the NetCDF file.
- Default:
9
- -b, --add-bounds#
Add bounds to the NetCDF axis.
- Default:
False
- --h0 <h0>#
Write the level-0 header to a given file path.
- --h1 <h1>#
Write the level-1 header to a given file path.
- --h11 <h11>#
Write the level-11 header to a given file path.
- --h2 <h2>#
Write the level-2 header to a given file path.
- -o, --out-file <out_file>#
The path of the output NetCDF file containing the latlon information.
- Default:
'latlon.nc'
create-header#
Create an ASCII header.txt from a NetCDF or ASCII input file.
Authors#
Simon Lüdke
Usage
mhm-tools setup-creation create-header [OPTIONS]
Options
- -i, --input-file <input_file>#
Required Path to input file (.nc or .asc).
- Default:
Sentinel.UNSET
- -o, --output-dir <output_dir>#
Directory where header.txt is written. Default: current directory.
- Default:
'.'
- -m, --mask-file <mask_file>#
Mask file that can help provide better matching l0_coords
- --mask-var <mask_var>#
Variable to be used from the mask file. If file only contains one variable that is used automatically.
- Default:
'mask'
- --resolution <resolution>#
Optional resolution to avoid floating point errors.
calculate-pet#
Calculating pet.
Contains multiple different pet methods mainly temperature based.
Authors#
Matthias Kelbling
Simon Lüdke
Stephan Thober
Usage
mhm-tools setup-creation calculate-pet [OPTIONS]
Options
- -o, --output-file <output_file>#
Required Output directory for processed files
- Default:
Sentinel.UNSET
- --tavg <tavg>#
Temperature average file
- --tmax <tmax>#
Temperature maximum file
- --tmin <tmin>#
Temperature minimum file
- -f, --freq <freq>#
Frequency of pet output, daily or hourly.
- --method <method>#
Method of pet calculation. Currently implemented: hargreaves_samani, oudin, jensen_haise, mcguinness_bordne, hamon, blaney_criddle.
- Default:
'oudin'
- --ncpus <ncpus>#
Number of cores used for parallelisation.
- Default:
1
prepare-mhm-forcings#
mHM processing netCDF precipitation and temperature forcings.
Authors#
Jeisson Leal
Simon Lüdke
Usage
mhm-tools setup-creation prepare-mhm-forcings [OPTIONS]
Options
- -i, --input-dir <in_dir>#
Required Input directory containing forcing NetCDF files
- Default:
Sentinel.UNSET
- -f, --input-name <in_file>#
Required Input filename or glob pattern (e.g. “data_*.nc”)
- Default:
Sentinel.UNSET
- -o, --output-dir <out_dir>#
Required Output directory for processed files
- Default:
Sentinel.UNSET
- -v, --var <var>#
Variable name to convert: 2t (temperature), tp (total precipitation), tprate (precipitation rate)
- -u, --output-name <out_file>#
Output filename or pattern. Use ‘*’ to retain input basename; otherwise literal name for each output file.
- Default:
'*'
- --out-var <out_var>#
Rename output variable to this name.
- --crop#
Enable spatial cropping of the dataset
- Default:
False
- --lon-min <lon_min>#
Minimum longitude for cropping
- --lon-max <lon_max>#
Maximum longitude for cropping
- --lat-min <lat_min>#
Minimum latitude for cropping
- --lat-max <lat_max>#
Maximum latitude for cropping
- --use-mfdataset <use_mfdataset>#
Use xarray.open_mfdataset for multi-file datasets
- Default:
False
- --target-frequency <target_frequency>#
Resample the dataset to this target frequency (hourly, daily).
data-processing#
Convert, regrid, merge, and derive gridded data products.
Usage
mhm-tools data-processing [OPTIONS] COMMAND [ARGS]...
converter-nc-ascii#
Convert gridded files between supported setup formats.
The input and output formats are inferred from file suffixes, including ASCII, GeoTIFF, and NetCDF where supported. The command can set the output variable name explicitly or from file names, normalize latitude/longitude coordinates, or write only an ESRI-style header.
Authors#
Simon Lüdke
Usage
mhm-tools data-processing converter-nc-ascii [OPTIONS]
Options
- -i, --input-file <input>#
Required The path to input file. Can be ASCII, GeoTIFF, or NetCDF. The file type is determined by the file suffix.
- Default:
Sentinel.UNSET
- -o, --output-file <output>#
Required The name of the output file. Can be ASCII or NetCDF. The file type is determined by the file suffix.
- Default:
Sentinel.UNSET
- -f, --varname-eq-in-filename#
The name of the variable is set to the input file name.
- Default:
False
- -F, --varname-eq-out-filename#
The name of the variable is set to the output file name.
- Default:
False
- -v, --varname <varname>#
The name of the variable.
- --latlon#
use latlon variables
- Default:
False
- --only-header#
Only write header output.
- Default:
False
merge-files#
Merge multiple NetCDF files into combined output files.
The command searches an input directory for files matching a name pattern and merges them into a single NetCDF output. It can also preserve the top-level folder structure and merge files recursively within each subfolder.
Authors#
Simon Lüdke
Usage
mhm-tools data-processing merge-files [OPTIONS]
Options
- -i, --input-dir <input_path>#
Required The path to input files.
- Default:
Sentinel.UNSET
- --input-name <input_name>#
Input file name. E.g. ‘.nc’ to merge only nc files or ‘pre’ to merge only precipitation files.
- Default:
'*.*'
- -o, --output-file <output_file>#
Required The name of the output file.
- Default:
Sentinel.UNSET
- -p, --preserve-folders#
Preserve the top level folder structure. Recusive merge inside.
- Default:
False
- --ncpus <ncpus>#
Number of CPUs.
- Default:
1
fill-nearest#
Command-line interface for nearest-neighbour NetCDF gap filling.
This interpolator should not be used on global scale as it will be slow.
Authors - Simon Lüdke - Sebastian Müller
Usage
mhm-tools data-processing fill-nearest [OPTIONS]
Options
- -i, --input-dir <input_dir>#
Directory containing input NetCDF files.
- Default:
'.'
- -f, --fname <fname>#
Input filename pattern, for example ‘precipitation_*.nc’.
- Default:
'precipitation_*.nc'
- -o, --output-dir <output_dir>#
Required Directory where filled NetCDF files are written.
- Default:
Sentinel.UNSET
- -m, --mask-file <mask_file>#
Optional NetCDF file used to derive a fixed output mask.
- --mask-var <mask_var>#
Variable in –mask-file whose NaN cells define the fixed output mask.
- --fill-value <fill_value>#
Fill value written to cells masked by –mask-file/–mask-var.
- Default:
-9999.0
- --n-cpus <n_cpus>#
Number of cpus for parallel processing of multiple files.
- Default:
1
regrid-file#
Regrid to L2 aligned with L0 grid from mask.nc.
Authors#
Simon Lüdke
Usage
mhm-tools data-processing regrid-file [OPTIONS]
Options
- --input-file <input>#
Required Input NetCDF
- Default:
Sentinel.UNSET
- --mask-file <mask>#
Required mask.nc defining L0 grid (must have lon/lat coords)
- Default:
Sentinel.UNSET
- --output-file <output>#
Required Output NetCDF (L2 grid)
- Default:
Sentinel.UNSET
- --l2 <l2>#
Required L2 resolution: e.g. 0.05, 0.1
- Default:
Sentinel.UNSET
- --method <method>#
Regridding method
- Default:
'nearest'- Options:
nearest | linear
long-term-mean#
Computes and stores long term mean for a given NetCDF file(s).
Authors#
Jeisson Leal
Usage
mhm-tools data-processing long-term-mean [OPTIONS]
Options
- -i, --input-dir <in_dir>#
Required Input directory containing forcing NetCDF files
- Default:
Sentinel.UNSET
- -o, --output-dir <out_dir>#
Required Output directory for processed files
- Default:
Sentinel.UNSET
- -f, --input-name <in_file>#
Input filename or glob pattern.
- Default:
'*.nc'
- --long-term-mean-type <long_term_mean_type>#
Period over which to compute long-term means: hourly, daily, monthly, or yearly. Default is ‘monthly’.
- Default:
'monthly'- Options:
hourly | daily | monthly | yearly
- --aggregation-type <aggregation_type>#
Aggregation type: ‘intensive’ (mean) or ‘extensive’ (sum). Default is ‘intensive’.
- Default:
'intensive'- Options:
intensive | extensive
- --aggregation#
Perform temporal aggregation before merging.
- Default:
False
- --keep-temporal-files#
Keep intermediate temporal files generated during processing.
- Default:
False
- --output-name <out_file>#
Name of the output NetCDF file.
- Default:
'long_term_mean.nc'
- --crop#
Crop the data to the specified geographic bounds.
- Default:
False
- --lon-min <lon_min>#
Minimum longitude for cropping.
- --lon-max <lon_max>#
Maximum longitude for cropping.
- --lat-min <lat_min>#
Minimum latitude for cropping.
- --lat-max <lat_max>#
Maximum latitude for cropping.
- --lower-threshold <lower_threshold>#
If given, calculates the long-term mean for values equal or above lower-threshold.
difference#
Compute and plot the spatial difference between a reference dataset and model dataset.
This script reads CF-compliant NetCDF files for both model and reference datasets, computes the spatial difference for a specified variable, applies any provided geographic or data range limits, and generates a high-resolution PNG showing that difference with customizable title, colorbar label, and colormap.
Authors#
Jeisson Leal
Usage
mhm-tools data-processing difference [OPTIONS]
Options
- --ref-input-dir <ref_input_dir>#
Required Directory with reference NetCDF files
- Default:
Sentinel.UNSET
- --mod-input-dir <mod_input_dir>#
Required Directory with model NetCDF files
- Default:
Sentinel.UNSET
- --reference-pattern <reference_pattern>#
Required Wildcard for reference file
- Default:
Sentinel.UNSET
- --model-pattern <model_pattern>#
Required Wildcard for model file
- Default:
Sentinel.UNSET
- --ref-var <ref_var>#
Required Variable name in reference dataset
- Default:
Sentinel.UNSET
- --mod-var <mod_var>#
Required Variable name in model dataset
- Default:
Sentinel.UNSET
- -o, --output-dir <output_dir>#
Required Directory to save the output PNG
- Default:
Sentinel.UNSET
- --output-file-png <output_file_png>#
Required Filename for the output PNG
- Default:
Sentinel.UNSET
- --save-ncfile#
if set to True, stores a NetCDF file in –output_dir
- Default:
False
- --output-file-nc <output_file_nc>#
If –save_ncfile, gives the name of the file to be saved in –output_dir
- Default:
'difference.nc'
- --colorbar-label <colorbar_label>#
Label for the plot colorbar
- Default:
'Difference (model - reference)'
- --title <title>#
Title for the plot
- Default:
'Mean Difference (model - reference)'
- --x-min <x_min>#
Minimum longitude to display
- --x-max <x_max>#
Maximum longitude to display
- --y-min <y_min>#
Minimum latitude to display
- --y-max <y_max>#
Maximum latitude to display
- --cmap <cmap>#
Matplotlib colormap name to use for the difference plot
- Default:
'coolwarm'
- --vmin <vmin>#
Minimum data value for colormap (optional)
- --vmax <vmax>#
Maximum data value for colormap (optional)
relative-difference#
Compute and plot the spatial relative difference between a model dataset and a reference dataset.
This script reads CF-compliant NetCDF files for both model and reference datasets, computes the spatial realtive difference as: diff = (da_ref - da_mod) / da_ref for a specified variable, applies any provided geographic or data range limits, and generates a high-resolution PNG showing that difference with customizable title, colorbar label, and colormap.
Authors#
Jeisson Leal
Usage
mhm-tools data-processing relative-difference [OPTIONS]
Options
- --ref-input-dir <ref_input_dir>#
Required Directory with reference NetCDF files
- Default:
Sentinel.UNSET
- --mod-input-dir <mod_input_dir>#
Required Directory with model NetCDF files
- Default:
Sentinel.UNSET
- --reference-pattern <reference_pattern>#
Required Wildcard for reference file
- Default:
Sentinel.UNSET
- --model-pattern <model_pattern>#
Required Wildcard for model file
- Default:
Sentinel.UNSET
- --ref-var <ref_var>#
Required Variable name in reference dataset
- Default:
Sentinel.UNSET
- --mod-var <mod_var>#
Required Variable name in model dataset
- Default:
Sentinel.UNSET
- -o, --output-dir <output_dir>#
Required Directory to save the output PNG
- Default:
Sentinel.UNSET
- --output-file-png <output_file_png>#
Required Filename for the output PNG
- Default:
Sentinel.UNSET
- --save-ncfile#
if set to True, stores a NetCDF file in –output_dir
- Default:
False
- --output-file-nc <output_file_nc>#
If –save_ncfile, gives the name of the file to be saved in –output_dir
- Default:
'relative_difference.nc'
- --colorbar-label <colorbar_label>#
Label for the plot colorbar
- Default:
'Difference (model - reference)'
- --title <title>#
Title for the plot
- Default:
'Mean Difference (model - reference)'
- --x-min <x_min>#
Minimum longitude to display
- --x-max <x_max>#
Maximum longitude to display
- --y-min <y_min>#
Minimum latitude to display
- --y-max <y_max>#
Maximum latitude to display
- --cmap <cmap>#
Matplotlib colormap name to use for the difference plot
- Default:
'coolwarm'
- --vmin <vmin>#
Minimum data value for colormap (optional)
- --vmax <vmax>#
Maximum data value for colormap (optional)
ratio#
Compute and plot the spatial ratio between a model dataset and a reference dataset.
This script reads CF-compliant NetCDF files for both model and reference datasets, computes the spatial ratio for a specified variable, applies any provided geographic or data range limits, and generates a high-resolution PNG showing that difference with customizable title, colorbar label, and colormap.
Authors#
Jeisson Leal
Usage
mhm-tools data-processing ratio [OPTIONS]
Options
- --ref-input-dir <ref_input_dir>#
Required Directory with reference NetCDF files
- Default:
Sentinel.UNSET
- --mod-input-dir <mod_input_dir>#
Required Directory with model NetCDF files
- Default:
Sentinel.UNSET
- --reference-pattern <reference_pattern>#
Required Wildcard for reference file
- Default:
Sentinel.UNSET
- --model-pattern <model_pattern>#
Required Wildcard for model file
- Default:
Sentinel.UNSET
- --ref-var <ref_var>#
Required Variable name in reference dataset
- Default:
Sentinel.UNSET
- --mod-var <mod_var>#
Required Variable name in model dataset
- Default:
Sentinel.UNSET
- -o, --output-dir <output_dir>#
Required Directory to save the output PNG
- Default:
Sentinel.UNSET
- --output-file-png <output_file_png>#
Required Filename for the output PNG
- Default:
Sentinel.UNSET
- --save-ncfile#
if set to True, stores a NetCDF file in –output_dir
- Default:
False
- --output-file-nc <output_file_nc>#
If –save_ncfile, gives the name of the file to be saved in –output_dir
- Default:
'difference.nc'
- --colorbar-label <colorbar_label>#
Label for the plot colorbar
- Default:
'Difference (model - reference)'
- --title <title>#
Title for the plot
- Default:
'Mean Difference (model - reference)'
- --x-min <x_min>#
Minimum longitude to display
- --x-max <x_max>#
Maximum longitude to display
- --y-min <y_min>#
Minimum latitude to display
- --y-max <y_max>#
Maximum latitude to display
- --cmap <cmap>#
Matplotlib colormap name to use for the difference plot
- Default:
'coolwarm'
- --vmin <vmin>#
Minimum data value for colormap (optional)
- --vmax <vmax>#
Maximum data value for colormap (optional)
bankfull#
Calculate the river discharge at bankfull conditions and the bankfull width.
Bankfull discharge is determined as the yearly peak flow with a recurrence interval given by “return_period”, which is 1.5 years by default. The wetted perimeter is estimated from bankfull discharge with Lacey’s formula.
This routine will simply use the closest flood event in terms of its recurrence interval. Also, any input time-stepping is accepted but daily or sub-daily data is preferred. Ouput variables in the created NetCDF file are called “Q_bkfl” and “P_bkfl”.
Authors#
Sebastian Müller
Usage
mhm-tools data-processing bankfull [OPTIONS]
Options
- -r, --return-period <return_period>#
The return period of the flood in years.
- Default:
1.5
- -w, --wetted-perimeter#
Additionally estimate the wetted perimeter.
- Default:
False
- -v, --var <var>#
Variable name for routed streamflow in the NetCDF file
- Default:
'Qrouted'
- -i, --input-file <in_file>#
Required The path of the mRM NetCDF file with the discharge data.
- Default:
Sentinel.UNSET
- -o, --output-file <out_file>#
Required The path of the output NetCDF file.
- Default:
Sentinel.UNSET
evaluation#
Evaluate simulations against observations or reference data.
Usage
mhm-tools evaluation [OPTIONS] COMMAND [ARGS]...
discharge-evaluation#
Evaluate simulated discharge against observed gauge discharge.
The tool matches model and observation time series, optionally optimizes gauge locations with flow-accumulation data, filters by domain, date range, or gauge list, and computes discharge metrics with optional bootstrap sampling. It can write processed hydrographs, metric tables, and diagnostic hydrograph plots.
Authors#
Simon Lüdke
Usage
mhm-tools evaluation discharge-evaluation [OPTIONS]
Options
- --output-dir <output_dir>#
Required Path for the output dir.
- Default:
Sentinel.UNSET
- --observed-data-path <observed_data_path>#
Path to the observation data file.
- --model-data-path <model_data_path>#
Path to the model data.
- --model-file-name <model_file_name>#
File name pattern for model data files.
- Default:
'mrm_node_output.nc'
- --observed-variable <observed_variable>#
- Default:
'runoff_mean'
- --model-variable <model_variable>#
Variable name of the simulation data.
- --facc-file <facc_file>#
Path to flow-accumulation file used for gauge matching.
- --facc-variable <facc_variable>#
Variable name in –facc_file containing flow accumulation.
- Default:
'L11_fAcc'
- --scc-gauges-file <scc_gauges_file>#
Path to the scc gauges file.
- --evaluation-gauges <evaluation_gauges>#
Path to a file containing the gauge ids to be used for the evaluation. If not provided, all gauges will be used.
- --ncpus <ncpus>#
- Default:
1
- --lonlatbox <lonlatbox>#
coordinates in the form of ‘lon_min,lon_max,lat_min,lat_max’
- --mask-file <mask_file>#
path to the mask file, a .nc file with a variable ‘mask’ containing the grid mask at l0 resolution required unless –lonlatbox is provided
- --shape-folder <shape_folder>#
Folder with catchment shapefiles matched by gauge ID.
- --mask-folder <mask_folder>#
Folder with catchment mask NetCDF files matched by gauge ID.
- --mask-var <mask_var>#
Variable in catchment mask files used for median maps.
- --catchment-map-variables <catchment_map_variables>#
Metric columns to plot on catchment median maps.
- Default:
- --metric-plot-types <metric_plot_types>#
Metric plot types to create.
- Default:
'cdf', 'violin', 'map', 'catchment-map'- Options:
cdf | violin | map | catchment-map
- --n-boostrap-years <n_boostrap_years>#
Number of years to draw for each boostrap experiment
- --n-bootstrap-selections <n_bootstrap_selections>#
Number of boostrap experiments
- --start-date <start_date>#
First year allowed in the analysis.
- --end-date <end_date>#
Lates year that is allowed in the analysis.
- --min-overlapping-years <min_overlapping_years>#
Minimum number of overlapping years for evaluation.
- --gauge-location-method <gauge_location_method>#
Method used to optimize gauge location for mRM restart matching.
- Default:
'basinex'- Options:
basinex | burek
- --gauge-max-distance-cells <gauge_max_distance_cells>#
Maximum number of grid cells gauge location may be shifted.
- Default:
3
- --gauge-max-error <gauge_max_error>#
Maximum allowed relative catchment-area error (fraction; 0.1 = 10%).
- Default:
0.1
- --hydrograph-plots <hydrograph_plots>#
specifies which graphics are generated.t model timestep, y yearly, s seasonality, p flow duration, c scatter e.g. all with out seasonality (advised for performance) = typc
- Default:
'tysc'
- --use-cached-input-data#
Use cached input data if available. Otherwise, process the input data from scratch.
- Default:
False
- --save-hydrograph#
Set flag if the calculated hydrographs should be saved and not just the metrics calculated.
- Default:
False
- --only-plot#
Set Flag if existing output file should be used to create plot
- Default:
False
- --no-input-data-cache#
Set flag to not write the processed input data to file. This avoids unnecessary file I/O but may slow down subsequent runs with the same input data. If file is written overwriting is controlled by the –overwrite flag.
- Default:
False
hydrograph#
Create hydrograph plots from mHM/mRM discharge output.
The command reads one or more simulation output directories, optionally adds observed discharge and precipitation, and writes discharge diagnostics such as time series, yearly summaries, seasonality, flow-duration curves, and scatter plots.
Authors#
Simon Lüdke
Usage
mhm-tools evaluation hydrograph [OPTIONS]
Options
- -i, --input-dir <in_dir>#
Required One or more input paths (mhm output directories)
- Default:
Sentinel.UNSET
- -o, --output-file <out_file>#
The name of the output file. By default hydrograph.png If it contains no ‘/’ the file is written to the input path.
- Default:
'hydrograph.pdf'
- -t, --title <title>#
The title for the hydrograph
- Default:
''
- -s, --show#
Show the plots that are created the default is only saving them
- Default:
False
- -p, --plots <plots_to_be_created>#
specifies which graphics are generated.t model timestep, y yearly, s seasonality, p flow duration, c scatter e.g. all with out seasonality (advised for performance) = typc
- Default:
'tyspc'
- --prec <prec>#
path of the precipiation file
- Default:
''
- --name <sim_names>#
Optional simulation name(s). If one name is provided, it replaces ‘sim’ in the legend. If multiple input paths are provided and the same number of names are given, each simulation is plotted with its name.
- Default:
gridded-data-evaluation#
Evaluate gridded model data against gridded reference data.
The tool compares spatial fields and time series within an optional mask or lon/lat domain, supports unit conversion, temporal resampling, direct or bootstrap comparisons, and restricted year ranges. It writes evaluation metrics and plots for bias, seasonality, variability, and related diagnostics.
Authors#
Simon Lüdke
Usage
mhm-tools evaluation gridded-data-evaluation [OPTIONS]
Options
- --input-path <input_path>#
Required Path to the input file. Or the dictionary containing all folders with input files.
- Default:
Sentinel.UNSET
- --output-dir <output_dir>#
Required Path for the output dir.
- Default:
Sentinel.UNSET
- --input-variable <input_variable>#
Variable name in the input file.
- --input-name <input_name>#
Name of the input dataset.
- Default:
'input'
- --input-factor <input_factor>#
Unit Conversion factor. e.g. MJ/kg/day: 1 / 2.47 = 0.4
- Default:
1
- --ref-path <ref_path>#
Path to the first reference file. Or the dictionary containing all folders with ref files.
- --ref-name <ref_name>#
Name of the reference dataset.
- Default:
'ref'
- --ref-factor <ref_factor>#
Unit Conversion factor. e.g. MJ/kg/day: 1 / 2.47 = 0.4
- Default:
1
- --ref-variable <ref_variable>#
Variable name in the first reference file.
- --only-plot#
Set Flag if existing output file should be used to create plot
- Default:
False
- --lonlatbox <lonlatbox>#
coordinates in the form of ‘lon_min,lon_max,lat_min,lat_max’
- --mask-file <mask_file>#
path to the mask file, a .nc file with a variable ‘mask’ containing the grid mask at l0 resolution required unless –lonlatbox is provided
- --mask-var <mask_var>#
Variable in –mask-file to use for masking. If omitted, the mask variable is selected by resolution.
- --ncpus <ncpus>#
Number of CPUs to use
- Default:
1
- --n-boostrap-years <n_boostrap_years>#
Number of years to draw for each boostrap experiment
- --n-bootstrap-selections <n_bootstrap_selections>#
Number of boostrap experiments
- --no-direct-comparison#
Use statistics and do not compare timeseries directly. Needs ref_path.
- Default:
False
- --start-year <start_year>#
First year allowed in the analysis.
- --end-year <end_year>#
Lates year that is allowed in the analysis.
- --available-mem <available_mem>#
Available memory per cpu in Gb or Mb (default Gb)
- --input-file-name <input_file_name>#
Input file name. E.g. ‘.nc’ to copy only nc files or ‘pre’ to copy only precipitation files. If the file has a header in it’s folder the header is reproduced regardless of wether nor not it fits the filename.
- Default:
'*.nc'
- --ref-file-name <ref_file_name>#
Ref file name. E.g. ‘.nc’ to copy only nc files or ‘pre’ to copy only precipitation files. If the file has a header in it’s folder the header is reproduced regardless of wether nor not it fits the filename.
- Default:
'*.nc'
- --lon-min <lon_min>#
minimum longitude of the target grid required unless –mask_file is provided
- --lon-max <lon_max>#
maximum longitude of the target grid required unless –mask_file is provided
- --lat-min <lat_min>#
minimum latitude of the target grid required unless –mask_file is provided
- --lat-max <lat_max>#
maximum latitude of the target grid required unless –mask_file is provided
- --bias-only#
Only compare bias spatially and for the seasonality.
- Default:
False
- --global-climate#
Only compare bias and temporal standard deviation (no Spearman).
- Default:
False
- --resample-time-to <resample_time_to>#
Frequency to resample input and ref dataset to. Options: (H, D, W, ME) or hourly, daily, weekly, monthly
- --metric <metric>#
Result metric written to results.csv. Accepted values: TSM, SPAEF, ESP, WASPAEF, MSPAEF, all.
- Default:
'SPAEF'
run-overview#
Create a variable overview for an mHM run.
The tool reads an mHM namelist, resolves configured input and output files, and writes a CSV summary of variables, file paths, and basic statistics. It can search input folders recursively, compute temporal means before statistics, and convert time-based output units to the inferred meteo resolution.
Authors#
Simon Lüdke
Usage
mhm-tools evaluation run-overview [OPTIONS]
Options
- --namelist <namelist>#
Required Path to mhm.nml
- Default:
Sentinel.UNSET
- --output-dir <output_dir>#
Required Output directory for CSV (default file: variable_summary.csv), or a direct .csv file path.
- Default:
Sentinel.UNSET
- --base-path <base_path>#
Optional base path for relative paths in the namelist. If omitted, the namelist parent directory is used.
- --recursive-input-search#
Recursively search input directories for NetCDF files.
- Default:
False
- --temporal-mean#
Compute temporal means for variables with a 2 spatial dimensions and a time dimension before computing statistics.
- Default:
False
- --convert-units#
Convert output variable units with time denominators (s, d, m, y) to the inferred temporal resolution of meteo input files with time coordinates. Month length is assumed as 30.4 days.
- Default:
False
utilities#
General helper commands.
Usage
mhm-tools utilities [OPTIONS] COMMAND [ARGS]...
link-folder-tree#
Create a symlinked copy of a folder tree.
The tool recreates the input directory structure under a new output directory and links matching files instead of copying their contents. Existing links can optionally be overwritten, and the linked files can be restricted by a filename pattern.
Authors#
Simon Lüdke
Usage
mhm-tools utilities link-folder-tree [OPTIONS]
Options
- -i, --input-dir <input_dir>#
Required The path to input directory.
- Default:
Sentinel.UNSET
- -o, --output-dir <output_dir>#
Required The name of the output directory.
- Default:
Sentinel.UNSET
- --overwrite#
overwrite existing symlinks
- Default:
False
- --file-name <file_name>#
File name pattern to link, default is ‘.’
- Default:
'*.*'
visualization#
Create diagnostic plots and run summaries.
Usage
mhm-tools visualization [OPTIONS] COMMAND [ARGS]...
2d-map#
Compute and plot a 2D map for a given NetCDF dataset.
This CLI reads a CF-compliant NetCDF file, extracts a specified variable, and invokes mhm_tools.common.plotter.plot_map to generate and save a geo-aware 2D map plot with customizable labels, colormap, and spatial or data limits.
Authors#
Jeisson Leal
Usage
mhm-tools visualization 2d-map [OPTIONS]
Options
- --input-file <input_file>#
Required Path to the input NetCDF file
- Default:
Sentinel.UNSET
- --var <var>#
Required Variable name in the NetCDF dataset to plot
- Default:
Sentinel.UNSET
- -o, --output-dir <output_dir>#
Required Directory where the output PNG will be saved
- Default:
Sentinel.UNSET
- --output-file-png <output_file_png>#
Required Filename for the output PNG
- Default:
Sentinel.UNSET
- --colorbar-label <colorbar_label>#
Label for the colorbar
- Default:
''
- --title <title>#
Title for the plot
- Default:
''
- --x-min <x_min>#
Minimum longitude to display
- --x-max <x_max>#
Maximum longitude to display
- --y-min <y_min>#
Minimum latitude to display
- --y-max <y_max>#
Maximum latitude to display
- --cmap <cmap>#
Matplotlib colormap name to use
- Default:
'RdBu_r'
- --vmin <vmin>#
Minimum data value for colormap
- --vmax <vmax>#
Maximum data value for colormap
metric-plots#
Create metric comparison plots from metric CSV files.
Usage
mhm-tools visualization metric-plots [OPTIONS]
Options
- --input-path <input_paths>#
Required CSV files or directories that are searched recursively for metric CSV files.
- Default:
Sentinel.UNSET
- --variable <variables>#
Required Exact CSV column names to plot.
- Default:
Sentinel.UNSET
- --output-dir <output_dir>#
Required Directory for output PNG files.
- Default:
Sentinel.UNSET
- --input-name <input_names>#
Plot labels matching –input-paths. Defaults to path names.
- Default:
- --file-names <file_names>#
Glob pattern used when an input path is a directory.
- Default:
'*.csv'
- --output-prefix <output_prefix>#
Prefix for output PNG file names.
- Default:
'cdf'
- --plot-type <plot_types>#
Metric plot types to create: cdf, violin, catchment-map.
- Default:
'cdf', 'violin'
- --dpi <dpi>#
Output image resolution.
- Default:
450
- --shape-path <shape_paths>#
Shapefiles matched one-to-one with –input-paths.
- Default:
- --shape-folder <shape_folder>#
Folder with shapefiles matched by CSV stem, parent name, or id column.
- --mask-path <mask_paths>#
NetCDF mask files matched one-to-one with –input-paths.
- Default:
- --mask-folder <mask_folder>#
Folder with NetCDF mask files matched by CSV stem, parent name, or id column.
- --mask-var <mask_var>#
Variable in NetCDF mask files used for catchment median maps.
- --geometry-match-mode <geometry_match_mode>#
Geometry matching mode.
- Default:
'auto'- Options:
auto
- --name-field <name_fields>#
Input-name metadata fields, e.g. experiment,set.
- Default:
- --name-separator <name_separator>#
Separator used to split input names into metadata fields.
- Default:
'_'
- --group-by <group_by>#
Metadata fields used for additional grouped plots.
- Default:
- --color-by <color_by>#
Metadata field used for plot colors.
- --style-by <style_by>#
Metadata field used for CDF line styles.
taylor-diagram#
Compute and plot a Taylor diagram comparing multiple model datasets against a reference dataset.
This script reads CF-compliant NetCDF files, computes normalized standard deviation, correlation, and centered root mean square error (CRMSE) for each model variable against a single reference field, and creates one or multiple Taylor diagrams.
Authors#
Jeisson Leal
Usage
mhm-tools visualization taylor-diagram [OPTIONS]
Options
- --ref-input-dir <ref_input_dir>#
Required Directory with reference NetCDF file
- Default:
Sentinel.UNSET
- --reference-pattern <reference_pattern>#
Required Filename pattern for reference NetCDF file
- Default:
Sentinel.UNSET
- --ref-var <ref_var>#
Required Variable name in reference dataset
- Default:
Sentinel.UNSET
- --mod-input-dirs <mod_input_dirs>#
Required List of directories containing model NetCDF files (one per model)
- Default:
Sentinel.UNSET
- --model-patterns <model_patterns>#
Required List of filename patterns for model NetCDF files (one per model)
- Default:
Sentinel.UNSET
- --mod-vars <mod_vars>#
Required List of variable names in model datasets (one per model)
- Default:
Sentinel.UNSET
- -o, --output-dir <output_dir>#
Required Directory to save the output PNG.
- Default:
Sentinel.UNSET
- --output-file <output_file>#
Required Filename for the output PNG.
- Default:
Sentinel.UNSET
- --title <title>#
Title for the Taylor diagram.
- Default:
'Taylor Diagram'
- --ref-label <ref_label>#
Label to use for the reference data.
- Default:
'Ref'
- --mod-labels <mod_labels>#
List of labels to use for the model data.
- Default:
- --normalize#
If set, normalize standard deviations by the reference std.
- Default:
False
mhm-v5-v6-converter#
Convert mHM5 setup files to mHMv6 format.
Usage
mhm-tools mhm-v5-v6-converter [OPTIONS] COMMAND [ARGS]...
landcover-ascii-to-nc#
CLI for converting mHM landcover ASCII files to CF-compliant NetCDF.
Authors#
Jeisson Leal
Usage
mhm-tools mhm-v5-v6-converter landcover-ascii-to-nc [OPTIONS]
Options
- -i, --input-nml <input_nml>#
Required Path to the mHM .nml file that lists landcover scenes (the namelist containing LCoverfName, LCoverYearStart, etc.).
- Default:
Sentinel.UNSET
- -o, --output <output>#
Required Output NetCDF file path.
- Default:
Sentinel.UNSET
- -f, --varname-eq-in-filename#
Set the output variable name to the stem of the FIRST input ASCII file (i.e. derived from the namelist entry).
- Default:
False
- -F, --varname-eq-out-filename#
Set the output variable name to the stem of the output file path provided via –output.
- Default:
False
- -v, --varname <varname>#
Name of the variable to write in the NetCDF. Ignored if -f/–varname_eq_in_filename or -F/–varname_eq_out_filename is given.
- --normalize-latlon#
Normalize coordinate names/ordering to lat/lon.
- Default:
False
legacy-tools#
Legacy tools that are no longer recomended or only created for very specific usecases.
Usage
mhm-tools legacy-tools [OPTIONS] COMMAND [ARGS]...
create-id-gauges#
Create an id gauges file.
Authors#
Simon Lüdke
Usage
mhm-tools legacy-tools create-id-gauges [OPTIONS]
Options
- -f, --input-file <input_file>#
Required The path to input file in L0 resolution.
- Default:
Sentinel.UNSET
- -i, --gauge-id <gauge_id>#
Required Gauge id
- Default:
Sentinel.UNSET
- -o, --output <out_file>#
The name of the output file.
- Default:
'idgauges.asc'
- -u, --facc-file <facc_file>#
The name of the facc file used to adjust get coordinates.
- --gauge-coords <gauge_coords>#
Gauge coordinates in the form of ‘lat,lon’ take care to write –gauge_coords=’lat,lon’
- --lon <lon>#
Gauge coordinates in the form of ‘lat,lon’ take care to write –gauge_coords=’lat,lon’
- --lat <lat>#
Gauge coordinates in the form of ‘lat,lon’ take care to write –gauge_coords=’lat,lon’
- --is-id-gauges#
Is the provieded file an id_gauges file of which the existing gauge_ids should be conserved?
- Default:
False
create-subdomain-masks#
Create files containing subsets of the river network based on the provided input files.
The river network, provied as nc file containing basin ids, is split into subdomains based on the provided basin clusters. These subdomains of the global network are independent and can be run in parallel.
Authors#
Simon Lüdke
Robert Schweppe
Usage
mhm-tools legacy-tools create-subdomain-masks [OPTIONS]
Options
- -o, --output-dir <output_dir>#
Required specify an output directory path
- Default:
Sentinel.UNSET
- -b, --basin-ids <basin_ids>#
Required file containing unique basin ids for all river basins; variable ‘basin’ must exist in file
- Default:
Sentinel.UNSET
- -c, --basin-clusters <basin_clusters>#
Required file containing clustered basin ids (e.g., PGB reference); variable ‘mask’ must exist
- Default:
Sentinel.UNSET
- -l, --land-mask <land_mask>#
Required file containing land surface mask at target resolution default variable name is ‘land_mask’
- Default:
Sentinel.UNSET
- --land-mask-variable <land_mask_variable>#
variable name in the land mask file containing the land surface mask;
- Default:
'land_mask'
- -f, --output-file-name <output_file_name>#
stem for the output filename, which is then numbered for the different basin clusters
- Default:
'subdomain_masks'
create-mhm-restart-file#
Create restart files for the mHM model.
A restart file contains all the static information to run mHM on a specific grid.
Authors#
Simon Lüdke
Robert Schweppe
Usage
mhm-tools legacy-tools create-mhm-restart-file [OPTIONS]
Options
- -i, --input-dir <input_dir>#
Required Path to the input files
- Default:
Sentinel.UNSET
- -o, --output-dir <output_dir>#
Required output directory as path
- Default:
Sentinel.UNSET
- -w, --work-dir <work_dir>#
work directory as path
- -n, --nml-template <nml_template>#
Required nml_template file for mPR
- Default:
Sentinel.UNSET
- --mpr <mpr>#
Required path to the mPR executable
- Default:
Sentinel.UNSET
- --l1-resolution <l1_resolution>#
Required resolution of the mHM target grid in degrees
- Default:
Sentinel.UNSET
- --lonlatbox <lonlatbox>#
coordinates in the form of ‘lon_min,lon_max,lat_min,lat_max,resolution_l0’ required unless –mask_file is provided
- --lon-min <lon_min>#
minimum longitude of the target grid required unless –mask_file is provided
- --lon-max <lon_max>#
maximum longitude of the target grid required unless –mask_file is provided
- --lat-min <lat_min>#
minimum latitude of the target grid required unless –mask_file is provided
- --lat-max <lat_max>#
maximum latitude of the target grid required unless –mask_file is provided
- --l0-resolution <l0_resolution>#
resolution of the morphological input data grid in degrees required unless –mask_file is provided
- --mask-file <mask_file>#
path to the mask file, a .nc file with a variable ‘mask’ containing the grid mask at l0 resolution required unless –lonlatbox is provided
- -p, --mpr-params <mpr_params>#
path to the mPR parameters file
- --l1-increment <l1_increment>#
Required integer increment for l1 resolution in number of cells
- Default:
Sentinel.UNSET
- --process-domain-as-one#
do not split the grid into subgrids based on the provided basin clusters. Make sure your is not to large to run in one piece
- Default:
False
- --use-split-grids#
ommit the split files step and run MPR on existing split grids. Make sure the files cover the correct domain area
- Default:
False
- --no-merge#
do not merge the restart files after splitting the grid
- Default:
False
- --merge-only#
only merge the allready exisiting restart files, do not create new ones; opposite of –no_merge
- Default:
False
- -c, --clean-up#
delete the temporary files created during the process
- Default:
False
- --ncpus <ncpus>#
Number of CPUs to use
- Default:
1
- --mpr-packages <mpr_packages>#
Packages to load using module load before running mPR
- --land-mask-file <land_mask_file>#
Land mask file to use for l1 resolution
create-mhm-restart-from-setup#
Create mHM restart files by cropping and running an existing setup.
It can create a continues global restart file with continent specific parameters. You just have to provide as many masks as parameter sets.
As additional requirement this tool needs the install of a mhm version (tested with mhm v5.13.3) from pip.
Usage
mhm-tools legacy-tools create-mhm-restart-from-setup [OPTIONS]
Options
- -i, --input-dir <input_path>#
Required Path to the existing mHM setup.
- Default:
Sentinel.UNSET
- -o, --output-dir <output_path>#
Required Path where the cropped setup should be saved and run.
- Default:
Sentinel.UNSET
- -m, --mask-file <mask_file>#
Required Path to the mask file used to derive the crop extent.
- Default:
Sentinel.UNSET
- --l1-resolution <l1_resolution>#
Required Hydrological resolution used to define tile extents.
- Default:
Sentinel.UNSET
- -f, --input-name <file_name>#
Input file name glob used while cropping the setup.
- Default:
'*.*'
- --l11-resolution <l11_resolution>#
Routing resolution used for latlon creation.
- --l1-increment <l1_increment>#
Tile width and height in number of L1 cells.
- Default:
20
- --crs <crs>#
Coordinates reference system (e.g. ‘epsg:3035’). Needed to create a new latlon file.
- --n-cpus <n_cpus>#
Number of setup tiles prepared in parallel.
- Default:
1
- --mhm-ncpus <mhm_ncpus>#
Number of prepared tile setups to run with mHM in parallel. Defaults to –n-cpus.
- --crop-ncpus <crop_ncpus>#
Number of cores used by crop_mhm_setup inside each tile.
- Default:
1
- --available-mem <available_mem>#
Available memory per cpu in Gb or Mb (default Gb).
- Default:
'5'
- --mask-var <mask_var>#
Mask variable name.
- Default:
'mask'
- --lat-order <lat_order>#
Direction of the latitude coordinate.
- Default:
'decreasing'
- --output-var <output_var>#
Output variable name for single data var.
- --output-suffix <output_suffix>#
Suffix added to output file names leading to file type conversion.
- --mhm-packages <mhm_packages>#
Packages to load using module load before running mHM.
- --mhm-args <mhm_args>#
Additional arguments passed to the mHM Python runner.
- -p, --parameter-file <parameter_files>#
mHM parameter namelist file(s). Provide the same number as –mask-file entries to run one restart workflow per mask/parameter pair.
- Default:
- --fill-nearest-file <fill_nearest_files>#
File name or glob pattern below each cropped tile that should be filled with nearest neighbours before mHM is run. Uses the cropped tile DEM as mask. Cropped NetCDF files below meteo/ are always filled without a mask. Can be repeated.
- --l0-mask-file <l0_mask_files>#
File name or glob pattern below each cropped tile used as an L0 mask for the cropped DEM before mHM is run. The mask variable is detected with get_single_data_var, and all non-missing values are treated as active. Can be repeated.
- --restart-pattern <restart_pattern>#
Glob pattern used below the cropped setup to find mHM restart files.
- Default:
'**/mHM_restart*.nc'
- --restart-output-dir <restart_output_dir>#
Optional directory where tiled restart files are moved.
- --merged-restart-file <merged_restart_file>#
Path for the merged mHM restart file.
- --chunking#
Set if each dataset should be read as a chunked dask array.
- Default:
False
- --create-header#
Force creation of header file for all files.
- Default:
True
- --no-cropping#
Do not crop the file but only write headers where applicable.
- Default:
False
- --no-tile-creation#
Do not create or prepare setup tiles. Reuse existing tile directories below –output-dir and jump directly to running mHM.
- Default:
False
- --no-mhm-run#
Do not run mHM. Collect existing restart files below each prepared tile directory and jump directly to merging.
- Default:
False
- --no-restart-check#
Do not fail if mHM does not create or update a restart file.
- Default:
False
- --recreate-restart#
For tiles with missing restart files, regenerate the meteo header, fill fallback inputs, and rerun mHM.
- Default:
False
- --no-merge#
Do not merge the tiled mHM restart files after running mHM.
- Default:
False