Skip to content

Commit

Permalink
Merge pull request #113 from changliao1025/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
changliao1025 authored Jan 24, 2023
2 parents 787021e + 5942eed commit a079205
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
7 changes: 4 additions & 3 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ Users can run a PyFlowline simulation in the following steps:
* `gdal`
* `netCDF4`
* `shapely`
* `cython` (optional)
* `cython` (optional, for performance)
* `cartopy` (optional, for visualization)
* `matplotlib` (optional, for visualization)

2. Clone the latest PyFlowline repository from https://github.com/changliao1025/pyflowline. Or Install the PyFlowline through Conda for a released version.
3. Download the additional large files (DEM and MPAS mesh) and move them under the `data/susquehanna/input` folder.
4. Change the `sFilename_mesh_netcdf` and `sFilename_basins` to the actual paths,
4. Change the `sFilename_mesh_netcdf`, `sFilename_basins`, and `sFilename_flowline_filter` to the actual paths,
5. Open the preferred Python IDE and run the `examples/susquehanna/run_simulation_mpas.py` Python script. Optionally, you can also run the `notebooks/pyflowline.ipynb` notebook.
6. You should produce a list of model outputs in the `data/susquehanna/output` folder.

If you encountered any issues, refer to the FAQ or submit a Github issue (https://github.com/changliao1025/pyflowline/issues).
If you encounter any issues, refer to the FAQ or submit a GitHub issue (https://github.com/changliao1025/pyflowline/issues).
2 changes: 1 addition & 1 deletion examples/susquehanna/pyflowline_susquehanna_basins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dAccumulation_threshold": 100000,
"dThreshold_small_river": 10000,
"iFlag_dam": 0,
"iFlag_debug":1,
"iFlag_debug":0,
"iFlag_disconnected": 0,
"lBasinID": 1,
"sFilename_dam": "/qfs/people/liao313/data/hexwatershed/susquehanna/auxiliary/ICoM_dams.csv",
Expand Down
7 changes: 4 additions & 3 deletions examples/susquehanna/run_simulation_hexagon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
from pathlib import Path
from os.path import realpath

from pyflowline.pyflowline_read_model_configuration_file import pyflowline_read_model_configuration_file


#===================================
#set up workspace path
#===================================
sPath_parent = str(Path(__file__).parents[2]) # data is located two dir's up
import sys
sys.path.append(sPath_parent)
from pyflowline.pyflowline_read_model_configuration_file import pyflowline_read_model_configuration_file

sPath_data = realpath( sPath_parent + '/data/susquehanna' )
sWorkspace_input = str(Path(sPath_data) / 'input')
sWorkspace_output= str(Path(sPath_data) / 'output')
Expand Down Expand Up @@ -42,8 +45,6 @@
oPyflowline.flowline_simplification()
aCell = oPyflowline.mesh_generation()
oPyflowline.reconstruct_topological_relationship(aCell)
oPyflowline.analyze()
oPyflowline.evaluate()
oPyflowline.export()
iCase_index= iCase_index+1

Expand Down
9 changes: 4 additions & 5 deletions examples/susquehanna/run_simulation_latlon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
from pathlib import Path
from os.path import realpath

from pyflowline.pyflowline_read_model_configuration_file import pyflowline_read_model_configuration_file


#===================================
#set up workspace path
#===================================
sPath_parent = str(Path(__file__).parents[2]) # data is located two dir's up
sPath_parent = str(Path(__file__).parents[2]) # data is located two dir's up
import sys
sys.path.append(sPath_parent)
from pyflowline.pyflowline_read_model_configuration_file import pyflowline_read_model_configuration_file
sPath_data = realpath( sPath_parent + '/data/susquehanna' )
sWorkspace_input = str(Path(sPath_data) / 'input')
sWorkspace_output= str(Path(sPath_data) / 'output')
Expand Down Expand Up @@ -41,8 +42,6 @@
oPyflowline.flowline_simplification()
aCell = oPyflowline.mesh_generation()
oPyflowline.reconstruct_topological_relationship(aCell)
oPyflowline.analyze()
oPyflowline.evaluate()
oPyflowline.export()


Expand Down
2 changes: 0 additions & 2 deletions examples/susquehanna/run_simulation_mpas.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
oPyflowline.flowline_simplification()
aCell = oPyflowline.mesh_generation()
oPyflowline.reconstruct_topological_relationship(aCell)
oPyflowline.analyze()
oPyflowline.evaluate()
oPyflowline.export()

print('Finished')
8 changes: 4 additions & 4 deletions examples/susquehanna/run_simulation_square.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
from pathlib import Path
from os.path import realpath

from pyflowline.pyflowline_read_model_configuration_file import pyflowline_read_model_configuration_file


#===================================
#set up workspace path
#===================================
sPath_parent = str(Path(__file__).parents[2]) # data is located two dir's up
sPath_parent = str(Path(__file__).parents[2]) # data is located two dir's up
import sys
sys.path.append(sPath_parent)
from pyflowline.pyflowline_read_model_configuration_file import pyflowline_read_model_configuration_file
sPath_data = realpath( sPath_parent + '/data/susquehanna' )
sWorkspace_input = str(Path(sPath_data) / 'input')
sWorkspace_output= str(Path(sPath_data) / 'output')
Expand Down Expand Up @@ -41,8 +43,6 @@
oPyflowline.flowline_simplification()
aCell = oPyflowline.mesh_generation()
oPyflowline.reconstruct_topological_relationship(aCell)
oPyflowline.analyze()
oPyflowline.evaluate()
oPyflowline.export()


Expand Down
4 changes: 2 additions & 2 deletions pyflowline/algorithms/auxiliary/find_index_in_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def check_if_duplicates(aList_in):
return iFlag_unique


def add_unique_vertex(aVertex_in, pVertex_in):
def add_unique_vertex(aVertex_in, pVertex_in, dThreshold_in = 1.0E-6):
"""[add a vertex to a list if it is not already included]
Args:
Expand All @@ -162,7 +162,7 @@ def add_unique_vertex(aVertex_in, pVertex_in):
iFlag_exist = 0
nVertex = len(aVertex_in)

iFlag_exist, dummy = find_vertex_in_list(aVertex_in, pVertex_in)
iFlag_exist, dummy = find_vertex_in_list(aVertex_in, pVertex_in, dThreshold_in)

if iFlag_exist == 1:
pass
Expand Down
6 changes: 4 additions & 2 deletions pyflowline/algorithms/auxiliary/find_vertex_in_list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

def find_vertex_in_list(aVertex_in, pVertex_in):
def find_vertex_in_list(aVertex_in, pVertex_in, dThreshold_in=1.0E-6):
"""[find the index of a vertex in a list]
Args:
Expand All @@ -18,7 +18,9 @@ def find_vertex_in_list(aVertex_in, pVertex_in):
if nVertex > 0 :
for i in np.arange( nVertex):
pVertex = aVertex_in[i]
if pVertex == pVertex_in:
dDistance = pVertex.calculate_distance(pVertex_in)
#if pVertex == pVertex_in:
if dDistance < dThreshold_in:
iFlag_exist = 1
lIndex = i
break
Expand Down

0 comments on commit a079205

Please sign in to comment.