Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
python -m pip install flake8==7.1.0 flake8-docstrings==1.7.0 flake8-annotations==3.1.1
- name: Run lint with flake8
run: |
flake8 src floodresilience
flake8 src floodresilience wrfhydro

linting-pylint:
name: Lint Python with pylint
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
python -m pip install pylint==3.2.6
- name: Run lint with pylint
run: |
pylint src floodresilience
pylint src floodresilience wrfhydro

unit-tests:
name: Run unit tests with pytest
Expand Down
1 change: 1 addition & 0 deletions src/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ def wkt_to_gdf(wkt: str) -> gpd.GeoDataFrame:

# These must be imported after app to remove a circular dependency
import floodresilience.tasks # pylint: disable=wrong-import-position,unused-import # noqa: E402, F401
import wrfhydro.tasks # pylint: disable=wrong-import-position,unused-import # noqa: E402, F401
17 changes: 17 additions & 0 deletions wrfhydro/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright © 2021-2025 Geospatial Research Institute Toi Hangarau
# LICENSE: https://github.com/GeospatialResearch/Digital-Twins/blob/master/LICENSE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Top-level package for the WRF-Hydro® extension for the Digital Twin."""
30 changes: 30 additions & 0 deletions wrfhydro/blueprint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Endpoints and flask configuration for running WRF-Hydro module within the digital twin"""

from flask import Blueprint
from pywps import Service

from wrfhydro.scenario.flood_scenario_process_service import FloodScenarioProcessService
from src.check_celery_alive import check_celery_alive

wrf_hydro_blueprint = Blueprint('wrfhydro', __name__)
processes = [
FloodScenarioProcessService()
]

process_descriptor = {process.identifier: process.abstract for process in processes}

service = Service(processes, ['src/pywps.cfg'])


@wrf_hydro_blueprint.route('/wps', methods=['GET', 'POST'])
@check_celery_alive
def wps() -> Service:
"""
End point for OGC WebProcessingService spec, allowing clients such as TerriaJS to request processing.

Returns
-------
Service
The PyWPS WebProcessing Service instance
"""
return service
18 changes: 18 additions & 0 deletions wrfhydro/forcing_data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright © 2021-2025 Geospatial Research Institute Toi Hangarau
# LICENSE: https://github.com/GeospatialResearch/Digital-Twins/blob/master/LICENSE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Package to handle data and operations specific to meteorological forcing data."""
39 changes: 39 additions & 0 deletions wrfhydro/forcing_data/read_forcing_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# # -*- coding: utf-8 -*-
# Copyright © 2021-2025 Geospatial Research Institute Toi Hangarau
# LICENSE: https://github.com/GeospatialResearch/Digital-Twins/blob/master/LICENSE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Read meteorological forcing data into a form ready for use within WRF-Hydro modelling."""

import geopandas as gpd

from src.digitaltwin.utils import LogLevel


def main(
selected_polygon_gdf: gpd.GeoDataFrame,
log_level: LogLevel = LogLevel.DEBUG
) -> None:
"""
Read meteorological forcing data into a form ready for use within WRF-Hydro modelling.

Parameters
----------
selected_polygon_gdf : gpd.GeoDataFrame
A GeoDataFrame representing the selected polygon, i.e., the catchment area.
log_level : LogLevel = LogLevel.DEBUG
The log level to set for the root logger. Defaults to LogLevel.DEBUG.
"""
pass
18 changes: 18 additions & 0 deletions wrfhydro/land_surface_model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright © 2021-2025 Geospatial Research Institute Toi Hangarau
# LICENSE: https://github.com/GeospatialResearch/Digital-Twins/blob/master/LICENSE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Package to handle data and operations specific to forming land surface models."""
39 changes: 39 additions & 0 deletions wrfhydro/land_surface_model/create_land_surface_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# # -*- coding: utf-8 -*-
# Copyright © 2021-2025 Geospatial Research Institute Toi Hangarau
# LICENSE: https://github.com/GeospatialResearch/Digital-Twins/blob/master/LICENSE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Create a land surface model for use within WRF-Hydro modelling."""

import geopandas as gpd

from src.digitaltwin.utils import LogLevel


def main(
selected_polygon_gdf: gpd.GeoDataFrame,
log_level: LogLevel = LogLevel.DEBUG
) -> None:
"""
Create a land surface model for use within WRF-Hydro modelling.

Parameters
----------
selected_polygon_gdf : gpd.GeoDataFrame
A GeoDataFrame representing the selected polygon, i.e., the catchment area.
log_level : LogLevel = LogLevel.DEBUG
The log level to set for the root logger. Defaults to LogLevel.DEBUG.
"""
pass
48 changes: 48 additions & 0 deletions wrfhydro/run_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# Copyright © 2021-2025 Geospatial Research Institute Toi Hangarau
# LICENSE: https://github.com/GeospatialResearch/Digital-Twins/blob/master/LICENSE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""This script runs each module in the Digital Twin using a Sample Polygon."""
import pathlib

from src.digitaltwin import retrieve_from_instructions
from src.digitaltwin.utils import LogLevel
from src.run_all import create_sample_polygon, main
from wrfhydro.forcing_data import read_forcing_data
from wrfhydro.land_surface_model import create_land_surface_model
from wrfhydro.scenario import run_wrf_hydro_scenario

DEFAULT_MODULES_TO_PARAMETERS = {
retrieve_from_instructions: {
"log_level": LogLevel.INFO,
"instruction_json_path": pathlib.Path("wrfhydro/static_boundary_instructions.json").as_posix()
},
create_land_surface_model: {
"log_level": LogLevel.INFO,
},
read_forcing_data: {
"log_level": LogLevel.INFO,
},
run_wrf_hydro_scenario: {
"log_level": LogLevel.INFO,
},
}

if __name__ == '__main__':
sample_polygon = create_sample_polygon()

# Run all modules with sample polygon that intentionally contains slight rounding errors.
main(sample_polygon, DEFAULT_MODULES_TO_PARAMETERS)
18 changes: 18 additions & 0 deletions wrfhydro/scenario/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright © 2021-2025 Geospatial Research Institute Toi Hangarau
# LICENSE: https://github.com/GeospatialResearch/Digital-Twins/blob/master/LICENSE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Package to handle data and operations specific to running WRF-Hydro scenarios."""
Loading
Loading