Skip to content

Commit

Permalink
updated acc to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
strobba committed Oct 13, 2024
1 parent d82d441 commit 3772648
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github-action-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[lint]"
pip install ".[lint]"
- name: Lint with ruff
run: |
ruff check --output-format=github src tests
Expand Down
23 changes: 8 additions & 15 deletions notebooks/topo_playground.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -36,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -83,7 +83,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -98,7 +98,7 @@
"p Setting up boolean flood array matrix...\u001b[39m\n",
"p Adding cells to the priority queue...\u001b[39m\n",
"p Performing Priority-Flood+Epsilon...\u001b[39m\n",
"\u001b[2Kt succeeded in 1.58435 s\u001b[39m======================] (100% - 0.0s - 1 threads)\n",
"\u001b[2Kt succeeded in 1.72164 s\u001b[39m======================] (100% - 0.0s - 1 threads)\n",
"m Cells processed = 4000000\u001b[39m\n",
"m Cells in pits = 777150\u001b[39m\n",
"\u001b[91mW \u001b[91mW In assigning negligible gradients to depressions, some depressions rose above the surrounding cells. This implies that a larger storage type should be used. The problem occured for 2781 of 4000000.\u001b[39m\u001b[39m\n",
Expand All @@ -107,20 +107,13 @@
"C O'Callaghan, J.F., Mark, D.M., 1984. The Extraction of Drainage Networks from Digital Elevation Data. Computer vision, graphics, and image processing 28, 323--344.\u001b[39m\n",
"\n",
"c topology = D8\u001b[39m\n",
"\u001b[2K[==================================================] (100% - 0.0s - 1 threads) ] (59% - 0.1s - 1 threads)\n",
"\u001b[2K[==================================================] (100% - 0.0s - 1 threads) ] (35% - 0.1s - 1 threads)\n",
"A Generic Flow Accumulation Algorithm\u001b[39m\n",
"p Creating dependencies array...\n",
"\u001b[39m\n",
"\u001b[95md Source cells found = 1457392\u001b[39m\n",
"p Calculating flow accumulation...\u001b[39m\n",
"\u001b[2K[=========================== ] (54% - 0.1s - 1 threads)"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[2Kt Wall-time = 0.44261 s\u001b[39m=================] (100% - 0.0s - 1 threads)\n"
"\u001b[2Kt Wall-time = 0.493803 s\u001b[39m================] (100% - 0.0s - 1 threads)\n"
]
}
],
Expand All @@ -134,7 +127,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -289,7 +282,7 @@
"source": [
"import geopandas\n",
"\n",
"geojson_data = utils.get_coordinate_center_points_from_tfw(\n",
"geojson_data = utils.compile_data_to_geojson(\n",
" tfw, elevation_data, accum_d8, rda_fill_diff, 200, 200\n",
")\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion src/storm_water_management/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def main(tif_filename):
n_x = elevation_data.shape[0]
n_y = elevation_data.shape[1]

geojson_data = utils.get_coordinate_center_points_from_tfw(
geojson_data = utils.compile_data_to_geojson(
tfw, elevation_data, accum_d8, rda_fill_diff, n_x, n_y
)
utils.save_to_geojson(geojson_data, "64_3_2023")
Expand Down
6 changes: 3 additions & 3 deletions src/storm_water_management/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
import richdem


def get_coordinate_center_points_from_tfw(
def compile_data_to_geojson(
tfw: list,
elev_data: richdem.rdarray,
flow_data: richdem.rdarray,
depression_filling_data: richdem.rdarray,
n_points_x: int,
n_points_y: int,
) -> list:
"""Get coordinates for centerpoints.
"""Compile data to geojson format.
Args:
tfw: coordinate info.
tfw: coordinate info
elev_data: elevation data
flow_data: data from flow analysis
depression_filling_data: data from depression filling analysis
Expand Down
6 changes: 3 additions & 3 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from storm_water_management import utils


def test_unit_temp():
"""Unit test of temp function."""
def test_compile_data_to_geojson():
"""Test compile_data_to_geojson"""

Check failure on line 9 in tests/test_unit.py

View workflow job for this annotation

GitHub Actions / lint (3.10)

Ruff (D415)

tests/test_unit.py:9:5: D415 First line should end with a period, question mark, or exclamation point
n_x = 2
n_y = 2
rda_fill_diff = rd.rdarray([[1.0, 1.0], [2.0, 2.0]], no_data=-9999)
Expand All @@ -16,7 +16,7 @@ def test_unit_temp():

print(rda_fill_diff[1])

geojson_data = utils.get_coordinate_center_points_from_tfw(
geojson_data = utils.compile_data_to_geojson(
tfw, elevation_data, accum_d8, rda_fill_diff, n_x, n_y
)

Expand Down

0 comments on commit 3772648

Please sign in to comment.