Skip to content
Open
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
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Kitware, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ This is a proof of concept for the Charles River in Boston that could be transla

## Example usage

Install requirements with `pip install -r requirements.txt`.
Install requirements with `pip install -e .`.

To run a flood simulation with default inputs:

```
python main.py
python -m uvdat_flood_sim
```

To see the help menu explaining how to use arguments to specify input values:

```
python main.py -h
python -m uvdat_flood_sim -h
```

## Viewing Results
Expand Down
44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "uvdat-flood-sim"
description = "An end-to-end dynamic flood simulation."
readme = "README.md"
requires-python = ">=3.10"
license = "MIT"
license-files = ["LICENSE"]
maintainers = [
{ name = "Kitware, Inc.", email = "kitware@kitware.com" },
{ name = "August Posch", email = "augustposch@augustposch.us" },
]
dependencies = [
"matplotlib",
"numpy<2",
"pandas",
"pyproj",
"rasterio",
"requests",
"scikit-learn==1.3.0",
"scipy",
]
dynamic = ["version"]

[project.optional-dependencies]
large-image-writer = [
"large-image[zarr]",
"tifftools",
]

[project.urls]
Repository = "https://github.com/OpenGeoscience/uvdat-flood-sim"
"Bug Reports" = "https://github.com/OpenGeoscience/uvdat-flood-sim/issues"

[tool.hatch.build]
only-include = [
"uvdat_flood_sim",
]

[tool.hatch.version]
source = "vcs"
8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

Empty file added uvdat_flood_sim/__init__.py
Empty file.
22 changes: 12 additions & 10 deletions main.py → uvdat_flood_sim/__main__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import argparse
import numpy
import json
from datetime import datetime
from pathlib import Path

from downscaling_prediction import downscale_boston_cesm
from hydrological_prediction import calculate_discharge_from_precipitation
from hydrodynamic_prediction import generate_flood_from_discharge
from animate_results import animate as animate_results
from save_results import write_multiframe_geotiff

from constants import PERCENTILES_URL, PERCENTILES_PATH, HYDROGRAPHS, SECONDS_PER_DAY
from utils import download_file
from .constants import PERCENTILES_URL, PERCENTILES_PATH, HYDROGRAPHS, SECONDS_PER_DAY
from .downscaling_prediction import downscale_boston_cesm
from .hydrological_prediction import calculate_discharge_from_precipitation
from .hydrodynamic_prediction import generate_flood_from_discharge
from .animate_results import animate as animate_results
from .save_results import write_multiframe_geotiff
from .utils import download_file


def run_end_to_end(
Expand Down Expand Up @@ -100,7 +98,7 @@ def validate_args(args):
)


if __name__ == '__main__':
def main():
parser = argparse.ArgumentParser(
prog='Dynamic Flood Simulation'
)
Expand Down Expand Up @@ -172,3 +170,7 @@ def validate_args(args):
)
args = parser.parse_args()
run_end_to_end(*validate_args(args))


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion animate_results.py → uvdat_flood_sim/animate_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import matplotlib.pyplot as plt
import matplotlib.animation as ani

from constants import OUTPUTS_FOLDER
from .constants import OUTPUTS_FOLDER

def animate(results):
OUTPUTS_FOLDER.mkdir(parents=True, exist_ok=True)
Expand Down
1 change: 0 additions & 1 deletion constants.py → uvdat_flood_sim/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import numpy
from pathlib import Path


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import math
from scipy.stats import genextreme as gev

from utils import download_file
from constants import CESM_DATA, DOWNSCALING_MODEL_URL, DOWNSCALING_MODEL_PATH
from .utils import download_file
from .constants import CESM_DATA, DOWNSCALING_MODEL_URL, DOWNSCALING_MODEL_PATH


def annual_precipitation_maxima(daily):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import numpy
import pandas

from utils import download_file
from constants import (
from .utils import download_file
from .constants import (
RATING_CURVE_URL,
RATING_CURVE_PATH,
HAND_URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import numpy

from utils import download_file
from constants import HYDROLOGICAL_MODEL_URL, HYDROLOGICAL_MODEL_PATH, WATERSHED_AREA_SQ_M, CUBIC_METERS_TO_CUBIC_FEET, SECONDS_PER_DAY
from .utils import download_file
from .constants import HYDROLOGICAL_MODEL_URL, HYDROLOGICAL_MODEL_PATH, WATERSHED_AREA_SQ_M, CUBIC_METERS_TO_CUBIC_FEET, SECONDS_PER_DAY


def calculate_discharge_from_precipitation(
Expand Down
4 changes: 2 additions & 2 deletions save_results.py → uvdat_flood_sim/save_results.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy
from pathlib import Path
from constants import OUTPUTS_FOLDER, GEOSPATIAL_PROJECTION, GEOSPATIAL_BOUNDS

from .constants import OUTPUTS_FOLDER, GEOSPATIAL_PROJECTION, GEOSPATIAL_BOUNDS


def rasterio_write(results, output_path):
Expand Down
File renamed without changes.