Metadata-Version: 2.1
Name: mhm-qgis
Version: 0.1.0
Summary: Prepare, configure and run mHM 5.13 and v6 models in QGIS or as a standalone app
Author-email: Sanjeev Bashyal <sanjeev.bashyal@ufz.de>
Maintainer-email: Sanjeev Bashyal <sanjeev.bashyal@ufz.de>
License: # SOFTWARE LICENCE
        
        mHM-QGIS is a QGIS plugin and standalone application to prepare, configure, run and
        analyse setups of the mesoscale Hydrologic Model (mHM).
        
        ## Copyright Notice
        
        Copyright © 2025 - 2026, the mHM-QGIS developers from Helmholtz-Zentrum für Umweltforschung GmbH - UFZ. All rights reserved.
        
        ***The code is a property of:***
        
        > Helmholtz-Zentrum für Umweltforschung GmbH - UFZ<br/>
        > Registered Office: Leipzig<br/>
        > Registration Office: Amtsgericht Leipzig<br/>
        > Trade Register Nr. B 4703<br/>
        
        The list of developers is provided in the AUTHORS.md file.
        
        ***Contact:***
        
        - mHM Admins (E-mail: <mhm-admin@ufz.de>)
        - Sebastian Müller (E-mail: <sebastian.mueller@ufz.de>)
        - Stephan Thober (E-mail: <stephan.thober@ufz.de>)
        - Luis Samaniego (E-mail: <luis.samaniego@ufz.de>)
        - Sabine Attinger (E-mail: <sabine.attinger@ufz.de>)
        
        > Department Computational Hydrosystems (CHS)<br/>
        > Helmholtz Centre for Environmental Research - UFZ<br/>
        > Permoserstr. 15<br/>
        > 04318 Leipzig, Germany
        
        This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
        
        This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
        
        You should have received a copy of the GNU Lesser General Public License along with this program.
        It can be found in the files `COPYING` and `COPYING.LESSER` provided with this software.
        The complete GNU license text can also be found at < https://www.gnu.org/licenses/>.
        
        ## Redistribution
        
        Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
        - Redistributions of source code must retain the above copyright notice, the list of conditions for redistribution and modification as well as the following GNU Lesser General Public License.
        - Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following GNU Lesser General Public License and the modification conditions in the documentation and/or other materials provided with the distribution.
        - Neither the name of Helmholtz-Zentrum für Umweltforschung GmbH - UFZ, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
        
        ## Modification
        
        If software is modified to produce derivative works, such modified software should be clearly marked, so as not to confuse it with the version available from Helmholtz-Zentrum für Umweltforschung GmbH - UFZ.
        
        ## Third-party software and data
        
        mHM-QGIS does not include the software it depends on. Its dependencies are installed
        separately: by pip, by the plugin's dependency dialog in QGIS, or, for the standalone
        application, in a private runtime from conda-forge and PyPI. Each of them is distributed
        under its own license. Please refer to the license files in their respective repositories
        or distributions. These include, among others: QGIS, mHM (the `mhm` package and any mHM
        executable you select), mhm-tools, nml-tools, GDAL, PROJ, NumPy, SciPy, pandas, xarray,
        rioxarray, netCDF4, pyproj, pyflwdir, pyqtgraph, QtPy, guidata, PyYAML, pixi, and
        the conda-forge packages of the private runtime.
        
        The namelist schemas in `nml-schemas/` are derived from the namelist definitions of mHM
        (<https://git.ufz.de/mhm/mhm>). They retain the copyright of the mHM developers and the
        license of mHM.
        
Project-URL: Homepage, https://github.com/mhm-ufz/mHM-QGIS
Project-URL: Repository, https://github.com/mhm-ufz/mHM-QGIS
Project-URL: Bug Tracker, https://github.com/mhm-ufz/mHM-QGIS/issues
Keywords: hydrology,modeling,mesoscale,water,environment,qgis,plugin
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Hydrology
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: COPYING
License-File: COPYING.LESSER
License-File: AUTHORS.md
Provides-Extra: full
Requires-Dist: numpy>=1.24; extra == "full"
Requires-Dist: scipy>=1.10; extra == "full"
Requires-Dist: pandas>=2.0; extra == "full"
Requires-Dist: pyproj>=3.5; extra == "full"
Requires-Dist: pyqtgraph>=0.13.3; extra == "full"
Requires-Dist: pyflwdir>=0.5.12; python_version >= "3.11" and extra == "full"
Requires-Dist: pyflwdir>=0.5.11; python_version < "3.11" and extra == "full"
Requires-Dist: mhm<5.14,>=5.13.4; extra == "full"
Requires-Dist: mhm-tools<0.4,>=0.3.2; extra == "full"
Requires-Dist: nml-tools[gui]<0.7,>=0.6.0; extra == "full"
Requires-Dist: qtpy>=2.0; extra == "full"
Requires-Dist: guidata>=3.6; extra == "full"
Requires-Dist: netCDF4>=1.6.3; extra == "full"
Requires-Dist: pyyaml>=5.4; extra == "full"
Requires-Dist: xarray>=2023.4; extra == "full"
Requires-Dist: rioxarray>=0.14; extra == "full"
Requires-Dist: tomli>=1.1; python_version < "3.11" and extra == "full"
Provides-Extra: check
Requires-Dist: isort[colors]>=5.13; extra == "check"
Requires-Dist: ruff<0.17,>=0.16; extra == "check"
Provides-Extra: test
Requires-Dist: pytest>=6.0; extra == "test"
Requires-Dist: pytest-cov>=3; extra == "test"
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: mhm-qgis[check,full,test]; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"

# mHM QGIS — QGIS plugin for Mesoscale Hydrological Model

Prepare model inputs and namelists for **mHM 5.13 and v6**, then run mHM, in QGIS
or as a standalone application.

- Delineate domains, snap outlets, and assign discharge observations.
- Prepare DEM derivatives, soil, land cover, geology, and LAI.
- Align morphology and meteorology on compatible model grids.
- Edit namelists with nml-tools, guided by an introduction wizard, and combine prepared
  domains into one multi-domain run.
- Run mHM as named cases, each in its own `runs/<name>/` folder, and analyse them in the
  Outputs tab: water balance, hydrographs and scores, signatures, events, validation
  against observations, run comparison, extremes, droughts and plausibility checks.

## Install

### Standalone application (PyPI)

```bash
python -m pip install mhm-qgis
mhm-qgis
```

This works in any Python 3.10+: plain, a virtual environment or a conda environment.
`pip install mhm-qgis` installs only the small launcher. On first launch, after you
confirm, it installs a private QGIS 3.44 runtime with the app and everything it needs
(conda-forge and PyPI), then opens the app; later launches open it directly. Your own
environment is not changed. The runtime needs about a 1 GB download and several GB of
disk, and no administrator rights. It goes into:

- Linux: `~/.local/share/mhm-qgis` (or `$XDG_DATA_HOME/mhm-qgis`)
- macOS: `~/Library/Application Support/mhm-qgis`
- Windows: `%LOCALAPPDATA%\mhm-qgis`

If the environment already has QGIS (for example `conda install -c conda-forge qgis`),
install the app's packages there instead and `mhm-qgis` uses that QGIS:

```bash
python -m pip install "mhm-qgis[full]"
```

On an HPC, run the first launch on a login node (it downloads), set `XDG_DATA_HOME` if
the home quota is small, and use a desktop session or X11 forwarding for the window.

Manage the runtime without opening the GUI:

```bash
mhm-qgis-runtime install --yes   # unattended installation
mhm-qgis-runtime status
mhm-qgis-runtime remove          # repair = remove, then install
```

### QGIS plugin

Install **mHM QGIS** from the QGIS Plugin Manager (QGIS 3.34 or newer, including
QGIS 4). Enable *Show also experimental plugins* while the plugin is experimental. On
first start the plugin lists its missing Python dependencies (see `requirements.txt`)
and offers to install them for the Python that QGIS uses, into its own folder in the
QGIS profile (`<profile>/python/mhm-qgis-packages/numpy<major>`), not `~/.local`: removing
the profile removes them, no other Python sees them, and a QGIS on another NumPy major
version gets its own. QGIS's own packages (NumPy, GDAL) are reused, never replaced; if a
NumPy installed elsewhere (e.g. in `~/.local`) hides QGIS's, the plugin names it for removal. If that fails, the plugin shows the exact commands to run
with that same Python (on Windows, in the OSGeo4W Shell).

### mHM executables

mHM 5.13 (the latest 5.13 release) is installed with the `mhm` Python package, as the
`mhm` command. For mHM v6, choose a
compatible executable in the Configuration tab (or set `MHM_QGIS_MHMV6`).

## Workflow

In **0. Configuration**, select a project folder, then open a saved domain or
choose **<new>** and press **Create Project Structure**. Each setup has its own
settings, state and outputs under `<project>/mhm-qgis/<domain-name>/`; legacy
workspaces are left untouched.

Choose a DEM, configure precipitation's folder, glob, units and cadence, then
confirm its metadata dialog to scan and establish the common grid. Add other
meteorology variables through the same dialog. Choose simulation dates and
catchments; no selected catchments means valid DEM cells.

Run **▶** on *A. Morphology*, then on *B. Meteorology* in the project tree. Review inputs,
edit namelists, and run mHM. Each setup is one model domain and may contain
disconnected catchments. Meteorology preparation preserves input cadence,
converts units and optionally deaccumulates running totals. Historical land-use
periods share exact datetime boundaries (v5 changes must fall on year boundaries).
Both model versions can generate L0/L1/L11/L2 coordinates in `data/latlon.nc`.

In **5. Outputs**, pick a run (the current `output/`, a named run or an archived one)
and a view. Each view arranges the QGIS main window (or the standalone map window): its
panel in the centre, its side panels as tabs beside Layers; Map Explorer draws on the
map canvas itself. **Export** writes the shown tables, plots and maps to a folder.

Displayed layers appear on QGIS Desktop's map canvas. In the standalone application
they appear in its own map window, which has a layer tree and accepts dropped raster
and vector files. The Map Canvas button focuses whichever canvas is in use.

## Development

```bash
git clone https://github.com/mhm-ufz/mHM-QGIS
cd mhm-qgis
python3 -m pip install -e '.[dev]'
python3 -m pytest tests/ -q
```

For QGIS Desktop development, symlink `src/mhm_qgis` into your QGIS profile's
`python/plugins/` directory. GUI tests require real QGIS and run offscreen; they are
skipped when its runtime libraries are unavailable. Core tests remain
QGIS-independent. Designer `.ui` files load at runtime through `qgis.PyQt`, so no
UI or resource compilation is needed.

See [CONTRIBUTING.md](https://github.com/mhm-ufz/mHM-QGIS/blob/main/CONTRIBUTING.md) and
[CHANGELOG.md](https://github.com/mhm-ufz/mHM-QGIS/blob/main/CHANGELOG.md).

## License

mHM-QGIS is free software under the GNU Lesser General Public License, version 3 or
later; see [LICENSE](LICENSE), [COPYING](COPYING) and [COPYING.LESSER](COPYING.LESSER).
Copyright © 2025 - 2026, the mHM-QGIS developers from the Helmholtz-Zentrum für
Umweltforschung GmbH - UFZ ([AUTHORS.md](AUTHORS.md)). Its dependencies, such as QGIS,
mHM, mhm-tools and nml-tools, are not included and keep their own licenses.
