Skip to content

Commit 093a63c

Browse files
committed
Convert into a Python package
1 parent bc36870 commit 093a63c

13 files changed

+89
-31
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Kitware, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ This is a proof of concept for the Charles River in Boston that could be transla
2828

2929
## Example usage
3030

31-
Install requirements with `pip install -r requirements.txt`.
31+
Install requirements with `pip install -e .`.
3232

3333
To run a flood simulation with default inputs:
3434

3535
```
36-
python main.py
36+
python -m uvdat_flood_sim
3737
```
3838

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

4141
```
42-
python main.py -h
42+
python -m uvdat_flood_sim -h
4343
```
4444

4545
## Viewing Results

pyproject.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[build-system]
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "uvdat-flood-sim"
7+
description = "An end-to-end dynamic flood simulation."
8+
readme = "README.md"
9+
requires-python = ">=3.10"
10+
license = "MIT"
11+
license-files = ["LICENSE"]
12+
maintainers = [
13+
{ name = "Kitware, Inc.", email = "kitware@kitware.com" },
14+
{ name = "August Posch", email = "augustposch@augustposch.us" },
15+
]
16+
dependencies = [
17+
"matplotlib",
18+
"numpy<2",
19+
"pandas",
20+
"pyproj",
21+
"rasterio",
22+
"requests",
23+
"scikit-learn==1.3.0",
24+
"scipy",
25+
]
26+
dynamic = ["version"]
27+
28+
[project.optional-dependencies]
29+
large-image-writer = [
30+
"large-image[zarr]",
31+
"tifftools",
32+
]
33+
34+
[project.urls]
35+
Repository = "https://github.com/OpenGeoscience/uvdat-flood-sim"
36+
"Bug Reports" = "https://github.com/OpenGeoscience/uvdat-flood-sim/issues"
37+
38+
[tool.hatch.build]
39+
only-include = [
40+
"uvdat_flood_sim",
41+
]
42+
43+
[tool.hatch.version]
44+
source = "vcs"

requirements.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

uvdat_flood_sim/__init__.py

Whitespace-only changes.

main.py renamed to uvdat_flood_sim/__main__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import argparse
2-
import numpy
32
import json
43
from datetime import datetime
54
from pathlib import Path
65

7-
from downscaling_prediction import downscale_boston_cesm
8-
from hydrological_prediction import calculate_discharge_from_precipitation
9-
from hydrodynamic_prediction import generate_flood_from_discharge
10-
from animate_results import animate as animate_results
11-
from save_results import write_multiframe_geotiff
12-
13-
from constants import PERCENTILES_URL, PERCENTILES_PATH, HYDROGRAPHS, SECONDS_PER_DAY
14-
from utils import download_file
6+
from .constants import PERCENTILES_URL, PERCENTILES_PATH, HYDROGRAPHS, SECONDS_PER_DAY
7+
from .downscaling_prediction import downscale_boston_cesm
8+
from .hydrological_prediction import calculate_discharge_from_precipitation
9+
from .hydrodynamic_prediction import generate_flood_from_discharge
10+
from .animate_results import animate as animate_results
11+
from .save_results import write_multiframe_geotiff
12+
from .utils import download_file
1513

1614

1715
def run_end_to_end(
@@ -100,7 +98,7 @@ def validate_args(args):
10098
)
10199

102100

103-
if __name__ == '__main__':
101+
def main():
104102
parser = argparse.ArgumentParser(
105103
prog='Dynamic Flood Simulation'
106104
)
@@ -172,3 +170,7 @@ def validate_args(args):
172170
)
173171
args = parser.parse_args()
174172
run_end_to_end(*validate_args(args))
173+
174+
175+
if __name__ == '__main__':
176+
main()

animate_results.py renamed to uvdat_flood_sim/animate_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import matplotlib.pyplot as plt
44
import matplotlib.animation as ani
55

6-
from constants import OUTPUTS_FOLDER
6+
from .constants import OUTPUTS_FOLDER
77

88
def animate(results):
99
OUTPUTS_FOLDER.mkdir(parents=True, exist_ok=True)

constants.py renamed to uvdat_flood_sim/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import numpy
21
from pathlib import Path
32

43

downscaling_prediction.py renamed to uvdat_flood_sim/downscaling_prediction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import math
66
from scipy.stats import genextreme as gev
77

8-
from utils import download_file
9-
from constants import CESM_DATA, DOWNSCALING_MODEL_URL, DOWNSCALING_MODEL_PATH
8+
from .utils import download_file
9+
from .constants import CESM_DATA, DOWNSCALING_MODEL_URL, DOWNSCALING_MODEL_PATH
1010

1111

1212
def annual_precipitation_maxima(daily):

hydrodynamic_prediction.py renamed to uvdat_flood_sim/hydrodynamic_prediction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import numpy
55
import pandas
66

7-
from utils import download_file
8-
from constants import (
7+
from .utils import download_file
8+
from .constants import (
99
RATING_CURVE_URL,
1010
RATING_CURVE_PATH,
1111
HAND_URL,

0 commit comments

Comments
 (0)