Skip to content

Commit

Permalink
Merge pull request #209 from changliao1025/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
changliao1025 authored Apr 16, 2024
2 parents 86efd74 + 178874c commit 4d320f0
Show file tree
Hide file tree
Showing 67 changed files with 12,331 additions and 9,760 deletions.
2 changes: 1 addition & 1 deletion conda-recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ metadata:
# Package name
name: pyflowline
# Package version
version: "0.3.4"
version: "0.3.5"
# Package summary
summary: A mesh-independent river network generator for hydrologic models.
# Package homepage
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% set name = "hexwatershed" %}
{% set git_rev = "main" %}
{% set version = "0.3.4" %}
{% set version = "0.3.5" %}

package:
name: {{ name|lower }}
Expand Down
19 changes: 10 additions & 9 deletions docs/source/data/data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,16 @@ Inputs
The following recommended workspace structure and example input files are provided to run a PyFlowline simulation. Although the repo includes example configuration files in the examples/ directory, they can be placed wherever the user prefers, as long as the paths within them point to the correct locations for input (and output) data.

::
data
└── <domain_name>
├── input
│ ├── boundary_wgs.geojson
│ ├── flowline.geojson
│ ├── pyflowline_<domain_name>_<meshtype>.json
│ └── pyflowline_<domain_name>_basins.json
└── output
└── ...

data
└── <domain_name>
├── input
│ ├── boundary_wgs.geojson
│ ├── flowline.geojson
│ ├── pyflowline_<domain_name>_<meshtype>.json
│ └── pyflowline_<domain_name>_basins.json
└── output
└── ...

==============================
Outputs
Expand Down
2 changes: 1 addition & 1 deletion notebooks/mpas_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"import sys\n",
"from pathlib import Path\n",
"from os.path import realpath\n",
"import importlib\n",
"import importlib.util\n",
"#check dependencies\n",
"\n",
"iFlag_numpy = importlib.util.find_spec(\"numpy\")\n",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import numpy as np
from osgeo import ogr, osr
import importlib
import importlib.util

from pyflowline.algorithms.auxiliary.find_index_in_list import find_list_in_list
from pyflowline.external.pyearth.gis.gdal.gdal_functions import calculate_angle_betwen_vertex_normal
from pyflowline.external.pyearth.gis.gdal.gdal_functions import calculate_polygon_area

from pyearth.gis.geometry.calculate_polygon_area import calculate_polygon_area

iFlag_cython = importlib.util.find_spec("cython")
if iFlag_cython is not None:
Expand Down
46 changes: 27 additions & 19 deletions pyflowline/algorithms/auxiliary/check_head_water.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,30 @@ def check_head_water(aFlowline_in, pVertex_start_in):
Returns:
[int]: [0: not headwater; 1: is headwater]
"""
nFlowline = len(aFlowline_in)
iFlag_head_water = -1
iCount = 0
for i in range(nFlowline):
pFlowline = aFlowline_in[i]
pVerter_start = pFlowline.pVertex_start
pVerter_end = pFlowline.pVertex_end
if pVerter_start == pVertex_start_in:
iCount = iCount + 1
pass
if pVerter_end == pVertex_start_in:
iCount = iCount + 1
pass
pass
if iCount == 1:
iFlag_head_water=1

return iFlag_head_water
"""
start_vertices = {flowline.pVertex_start for flowline in aFlowline_in}
end_vertices = {flowline.pVertex_end for flowline in aFlowline_in}
# Check if the vertex is a headwater
is_headwater = pVertex_start_in in start_vertices and pVertex_start_in not in end_vertices
return int(is_headwater)

#nFlowline = len(aFlowline_in)
#iFlag_head_water = -1
#iCount = 0
#for i in range(nFlowline):
# pFlowline = aFlowline_in[i]
# pVerter_start = pFlowline.pVertex_start
# pVerter_end = pFlowline.pVertex_end
# if pVerter_start == pVertex_start_in:
# iCount = iCount + 1
# pass
# if pVerter_end == pVertex_start_in:
# iCount = iCount + 1
# pass
# pass
#if iCount == 1:
# iFlag_head_water=1
#
#return iFlag_head_water
#Create sets of all start and end vertices

52 changes: 17 additions & 35 deletions pyflowline/algorithms/auxiliary/find_index_in_list.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import copy
import numpy as np


import importlib
import importlib.util
iFlag_cython = importlib.util.find_spec("cython")
if iFlag_cython is not None:
from pyflowline.algorithms.cython.kernel import find_vertex_in_list
Expand All @@ -27,10 +25,10 @@ def find_vertex_on_edge(aVertex_in, pEdge_in):
lID = i
x = aVertex_in[i].dLongitude_degree
y = aVertex_in[i].dLatitude_degree
left= x - 1E-5
right= x + 1E-5
bottom= y-1E-5
top= y+1E-5
left = x - 1E-5
right = x + 1E-5
bottom = y - 1E-5
top = y + 1E-5
pBound= (left, bottom, right, top)
index_vertex.insert(lID, pBound) #
pass
Expand Down Expand Up @@ -111,13 +109,7 @@ def find_edge_in_list(aEdge_in, pEdge_in):
iFlag_exist = 1
lIndex = i
break
else:
pass

pass

else:
pass


return iFlag_exist, lIndex

Expand All @@ -142,14 +134,7 @@ def find_flowline_in_list(aFlowline_in, pFlowline_in):
if pFlowline == pFlowline_in:
iFlag_exist = 1
lIndex = i
break
else:
pass

pass

else:
pass
break

return iFlag_exist, lIndex

Expand All @@ -169,10 +154,7 @@ def find_hexagon_through_edge(aHexagon_in, pEdge_in):
for i in range(nHexagon):
pHexagon = aHexagon_in[i]
if pHexagon.has_this_edge(pEdge_in) ==1:
aHexagon_out.append(pHexagon)
pass
else:
pass
aHexagon_out.append(pHexagon)

return aHexagon_out

Expand All @@ -182,15 +164,15 @@ def check_if_duplicates(aList_in):
Returns:
[type]: [description]
"""
iFlag_unique = 1
for elem in aList_in:
if aList_in.count(elem) > 1:
iFlag_unique = 0
break
else:
pass

return iFlag_unique
#iFlag_unique = 1
#for elem in aList_in:
# if aList_in.count(elem) > 1:
# iFlag_unique = 0
# break
# else:
# pass
#return iFlag_unique
return int(len(aList_in) == len(set(aList_in)))


def add_unique_vertex(aVertex_in, pVertex_in, dThreshold_in = 1.0E-6):
Expand Down
4 changes: 1 addition & 3 deletions pyflowline/algorithms/auxiliary/find_vertex_in_list.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import importlib
import importlib.util
import numpy as np
iFlag_cython = importlib.util.find_spec("cython")
if iFlag_cython is not None:
Expand All @@ -23,9 +23,7 @@ def find_vertex_in_list(aVertex_in, pVertex_in, dThreshold_in=1.0E-6):
iFlag_exist = 0
lIndex= -1
nVertex= len(aVertex_in)

if iFlag_use_rtree == 1:

#can we use rtree here?
#index_vertex = rtree.index.Index()
index_vertex = RTree(max_cap=5, min_cap=2)
Expand Down
9 changes: 0 additions & 9 deletions pyflowline/algorithms/auxiliary/longlat_to_3d.py

This file was deleted.

Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 4d320f0

Please sign in to comment.