Skip to content

Commit 6101c1a

Browse files
Merge pull request #160 from changliao1025/development
Development
2 parents 608b6d5 + 77b5c23 commit 6101c1a

File tree

12 files changed

+58
-26
lines changed

12 files changed

+58
-26
lines changed

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ PyFlowline also has three optional dependency packages
3838
1. `cython` for performance
3939
2. `matplotlin` for visualization
4040
3. `cartopy` for visulization
41+
4. `simplekml` for Google Earth KML support
4142

4243
### Quickstart
4344

@@ -55,6 +56,8 @@ We provide several examples in the `examples` folder to demonstrate the model ca
5556

5657
This work was supported by the Earth System Model Development program areas of the U.S. Department of Energy, Office of Science, Office of Biological and Environmental Research as part of the multi-program, collaborative Integrated Coastal Modeling (ICoM) project and the Interdisciplinary Research for Arctic Coastal Environments (InteRFACE) project.
5758

59+
This research was supported as part of the Next Generation Ecosystem Experiments-Tropics, funded by the U.S. Department of Energy, Office of Science, Office of Biological and Environmental Research at Pacific Northwest National Laboratory. The study was also partly supported by U.S. Department of Energy Office of Science Biological and Environmental Research through the Earth and Environmental System Modeling program as part of the Energy Exascale Earth System Model (E3SM) project.
60+
5861
### License
5962

6063
BSD 3-Clause License

Diff for: data/susquehanna/input/boundary_wgs.geojson

+8
Large diffs are not rendered by default.

Diff for: docs/source/quickstart.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ Users can run a PyFlowline simulation in the following steps:
88
2. Install the package using `conda install -c conda-forge pyflowline`. Conda will automatically install all the required dependencies.
99
3. Clone the latest PyFlowline repository from https://github.com/changliao1025/pyflowline.
1010
4. Download the additional large MPAS mesh file `lnd_cull_mesh.nc` from https://github.com/changliao1025/pyflowline/releases/tag/0.2.0 and move it under the `data/susquehanna/input` folder.
11-
5. Open the `examples/susquehanna/pyflowline_susquehanna_mpas.json` file and change `sWorkspace_output` to the full path to the directory where you want to save the output (e.g. `/full/path/to/pyflowline/data/susquehanna/output`), change `"sFilename_mesh_netcdf"` to the full path to `lnd_cull_mesh.nc`, `"sFilename_mesh_boundary"` to the full path to `data/susquehanna/input/mesh_boundary_buffer.geojson`, and `"sFilename_basins"` to the full path to `examples/susquehanna/pyflowline_susquehanna_basins.json`.
11+
5. Open the `examples/susquehanna/pyflowline_susquehanna_mpas.json` file and change `sWorkspace_output` to the full path to the directory where you want to save the output (e.g. `/full/path/to/pyflowline/data/susquehanna/output`), change `"sFilename_mesh_netcdf"` to the full path to `lnd_cull_mesh.nc`, `"sFilename_mesh_boundary"` to the full path to `data/susquehanna/input/boundary_wgs.geojson`, and `"sFilename_basins"` to the full path to `examples/susquehanna/pyflowline_susquehanna_basins.json`.
1212
6. Open the `examples/susquehanna/pyflowline_susquehanna_basins.json` file and change `"sFilename_flowline_filter"` to the full path to `data/susquehanna/input/flowline.geojson`. Ignore the other settings in these json files for now.
1313
7. Open the preferred Python IDE (Visual Studio Code recommended) and run the `examples/susquehanna/run_simulation_mpas.py` Python script. Optionally, you can also run the `notebooks/mpas_example.ipynb` notebook.
14+
The visualization of the model outputs is only experimental, and you can use other tools to visualize the model outputs.
1415
8. You should produce a list of model outputs in the `data/susquehanna/output` folder or the user-specified output folder.
1516

1617
If you encounter any issues, refer to the FAQ or submit a GitHub issue (https://github.com/changliao1025/pyflowline/issues).

Diff for: docs/source/readme.rst

+9
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ All the existing river network representation methods (except vector-based) only
2323
As a result, if a spatially-distributed hydrologic model uses the unstructured mesh as the spatial discretization, there is no way to represent the river network.
2424

2525
To close this gap, PyFlowline was developed using a mesh-independent approach. At its core, PyFlowline uses the intersection between the vector river network and mesh to reconstruct the conceptual river network.
26+
27+
28+
*****************
29+
Important notice
30+
*****************
31+
32+
1. PyFlowline is designed to run at regional to global scale, so all the datasets use the geographic coordinate system (GCS) with the WGS84 datum. See more details at https://pyflowline.readthedocs.io/en/latest/data/data.html
33+
34+
2. Visualization of the PyFlowline outputs is only experimental. This feature is not fully developed yet. There is ongoing effort to use the `PyEarth` pythong package to provide this feature.

Diff for: examples/susquehanna/pyflowline_susquehanna_mpas.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
"sFilename_spatial_reference": "/qfs/people/liao313/workspace/python/pyhexwatershed_icom/data/susquehanna/input/boundary_proj_buff.shp",
3232
"sFilename_dem": "/qfs/people/liao313/workspace/python/pyhexwatershed_icom/data/susquehanna/input/dem_buff_ext.tif",
3333
"sFilename_mesh_netcdf": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/input/lnd_cull_mesh.nc" ,
34-
"sFilename_mesh_boundary": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/input/mesh_boundary_buffer.geojson",
34+
"sFilename_mesh_boundary": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/input/boundary_wgs.geojson",
3535
"sFilename_basins": "/qfs/people/liao313/workspace/python/pyflowline/examples/susquehanna/pyflowline_susquehanna_basins.json"
3636
}

Diff for: examples/susquehanna/run_simulation_mpas.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
iCase_index = 1
3030
iFlag_visualization = 1
3131
sMesh = 'mpas'
32-
sDate='20230101'
32+
sDate='20230701'
3333

3434
oPyflowline = pyflowline_read_model_configuration_file(sFilename_configuration_in,
3535
iCase_index_in=iCase_index, sDate_in=sDate)
@@ -40,30 +40,31 @@
4040

4141
oPyflowline.setup()
4242
if iFlag_visualization ==1:
43-
oPyflowline.plot(sFilename_output_in = 'filter_flowline.png', sVariable_in = 'flowline_filter' )
43+
#oPyflowline.plot(sVariable_in = 'flowline_filter', sFilename_output_in = 'filter_flowline.png' )
4444
pass
4545

4646
oPyflowline.flowline_simplification()
4747

4848
if iFlag_visualization == 1:
4949

5050
aExtent_meander = [-76.5,-76.2, 41.6,41.9]
51-
oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' , sFilename_output_in = 'flowline_simplified.png', )
51+
oPyflowline.plot( sVariable_in='flowline_simplified' , sFilename_output_in = 'flowline_simplified.png' )
5252

53-
oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' , aExtent_in =aExtent_meander, sFilename_output_in = 'flowline_simplified_zoom.png', )
53+
oPyflowline.plot( sVariable_in='flowline_simplified' , sFilename_output_in = 'flowline_simplified_zoom.png', aExtent_in =aExtent_meander )
5454

5555
pass
5656
aCell = oPyflowline.mesh_generation()
5757

5858
if iFlag_visualization == 1:
59-
oPyflowline.plot( iFlag_title=1 ,sVariable_in='mesh', sFilename_output_in = 'mesh.png' )
59+
oPyflowline.plot( sVariable_in='mesh', sFilename_output_in = 'mesh.png' )
6060
pass
6161

6262
oPyflowline.reconstruct_topological_relationship(aCell)
6363

6464
if iFlag_visualization == 1:
65-
oPyflowline.plot( iFlag_title=1, sVariable_in='overlap', sFilename_output_in = 'mesh_w_flowline.png',)
65+
oPyflowline.plot( sVariable_in='overlap', sFilename_output_in = 'mesh_w_flowline.png',)
6666
pass
67+
6768
oPyflowline.export()
6869

6970
print('Finished')

Diff for: mesh.png

-37.5 KB
Loading

Diff for: mesh_w_flowline.png

160 KB
Loading

Diff for: notebooks/mpas_example.ipynb

+10-10
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@
436436
"\n",
437437
" oPyflowline.plot(sVariable_in = 'flowline_filter' )\n",
438438
" #if you provide a filename, a png file will be saved\n",
439-
" oPyflowline.plot(sFilename_in = 'filter_flowline.png', sVariable_in = 'flowline_filter' )\n",
439+
" oPyflowline.plot(sVariable_in = 'flowline_filter', sFilename_in = 'filter_flowline.png' )\n",
440440
" pass"
441441
]
442442
},
@@ -517,7 +517,7 @@
517517
"source": [
518518
"if iVisualization_method ==2:\n",
519519
" aExtent_braided = [-77.3,-76.5, 40.2,41.0] \n",
520-
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_filter' , aExtent_in =aExtent_braided ) "
520+
" oPyflowline.plot( sVariable_in='flowline_filter' , aExtent_in =aExtent_braided ) "
521521
]
522522
},
523523
{
@@ -617,7 +617,7 @@
617617
" pass\n",
618618
"\n",
619619
"else: #use the default visualization method, only experimental\n",
620-
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' ) "
620+
" oPyflowline.plot( sVariable_in='flowline_simplified' ) "
621621
]
622622
},
623623
{
@@ -649,7 +649,7 @@
649649
"source": [
650650
"if iVisualization_method == 2:\n",
651651
" aExtent_meander = [-76.5,-76.2, 41.6,41.9] \n",
652-
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' , aExtent_in =aExtent_meander ) "
652+
" oPyflowline.plot( sVariable_in='flowline_simplified' , aExtent_in =aExtent_meander ) "
653653
]
654654
},
655655
{
@@ -672,7 +672,7 @@
672672
"source": [
673673
"if iVisualization_method == 2:\n",
674674
" aExtent_braided = [-77.3,-76.5, 40.2,41.0] \n",
675-
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' , aExtent_in =aExtent_braided ) "
675+
" oPyflowline.plot( sVariable_in='flowline_simplified' , aExtent_in =aExtent_braided ) "
676676
]
677677
},
678678
{
@@ -695,7 +695,7 @@
695695
"source": [
696696
"if iVisualization_method == 2:\n",
697697
" aExtent_confluence = [-77.3,-76.5, 40.2,41.0] \n",
698-
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' , aExtent_in =aExtent_confluence ) "
698+
" oPyflowline.plot( sVariable_in='flowline_simplified' , aExtent_in =aExtent_confluence ) "
699699
]
700700
},
701701
{
@@ -764,7 +764,7 @@
764764
" pass\n",
765765
"\n",
766766
"else:\n",
767-
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='mesh' ) "
767+
" oPyflowline.plot( sVariable_in='mesh' ) "
768768
]
769769
},
770770
{
@@ -814,7 +814,7 @@
814814
],
815815
"source": [
816816
"if iVisualization_method == 2:\n",
817-
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='mesh' ) "
817+
" oPyflowline.plot( sVariable_in='mesh' ) "
818818
]
819819
},
820820
{
@@ -891,7 +891,7 @@
891891
" plt.show()\n",
892892
" pass\n",
893893
"else:\n",
894-
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='overlap') \n",
894+
" oPyflowline.plot( sVariable_in='overlap') \n",
895895
" pass"
896896
]
897897
},
@@ -924,7 +924,7 @@
924924
"source": [
925925
"if iVisualization_method == 2:\n",
926926
" aExtent_outlet = [-76.0,-76.5, 39.5,40.0] #outlet\n",
927-
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='overlap' , aExtent_in =aExtent_outlet) "
927+
" oPyflowline.plot(sVariable_in='overlap' , aExtent_in =aExtent_outlet) "
928928
]
929929
},
930930
{

Diff for: paper.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ PyFlowline is the only modeling software that provides these unique features:
7676
3. It can be applied at both high and coarse resolutions;
7777
4. It can provide global coverage including Greenland and the Antarctic.
7878

79-
8079
Model documentation is hosted at https://pyflowline.readthedocs.io/en/latest/, including a case study for the Susquehanna River Basin in the Mid-Atlantic region of the United States.
8180

8281
# Acknowledgment
@@ -87,10 +86,11 @@ The model described in this repository was supported by the following:
8786

8887
* the Earth System Model Development and Regional and Global Model Analysis program areas of the U.S. Department of Energy, Office of Science, Biological and Environmental Research program as part of the multi-program, collaborative Interdisciplinary Research for Arctic Coastal Environments (InteRFACE) project.
8988

89+
* the Next Generation Ecosystem Experiments-Tropics project, funded by the U.S. Department of Energy, Office of Science, Office of Biological and Environmental Research at Pacific Northwest National Laboratory.
90+
9091
A portion of this research was performed using PNNL Research Computing at Pacific Northwest National Laboratory.
9192

9293
PNNL is operated for DOE by Battelle Memorial Institute under contract DE-AC05-76RL01830.
9394

94-
9595
# References
9696

Diff for: pyflowline/classes/_visual.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ def plot(self,
2424
"""
2525

2626
if iFlag_type_in is None:
27-
iFlag_type_in = 2
27+
iFlag_type_in = 2 #polyline based, only flowline
2828

2929
if iFlag_title_in is None:
3030
iFlag_title_in = 1
3131

3232
if sVariable_in is None:
3333
sVariable_in = 'flowline_conceptual'
34+
else:
35+
if sVariable_in == 'mesh':
36+
iFlag_type_in = 3
37+
else:
38+
if sVariable_in == 'overlap':
39+
iFlag_type_in = 4
3440

3541

3642
if iFlag_type_in == 1: #point based, such as dam
@@ -87,26 +93,29 @@ def _plot_mesh(self, sFilename_output_in=None, aExtent_in=None, pProjection_map_
8793
#plot both polygon and polyline
8894
def _plot_mesh_with_flowline(self,
8995
sFilename_output_in=None,
90-
iFlag_title=None,
96+
iFlag_title_in=None,
9197
aExtent_in=None,
9298
pProjection_map_in = None):
9399

94100
aFiletype_in = list()
95101
aFilename_in = list()
102+
aFlag_color = list()
96103
aFilename_in.append(self.sFilename_mesh)
97-
aFiletype_in.append(1)
104+
aFiletype_in.append(3)
105+
aFlag_color.append(0)
98106

99107
for pBasin in self.aBasin:
100108
aFiletype_in.append(2)
101109
dummy = pBasin.sFilename_flowline_conceptual
102110
sFilename_json = os.path.join(pBasin.sWorkspace_output_basin, dummy)
103111
aFilename_in.append(sFilename_json)
112+
aFlag_color.append(1)
104113

105114
map_multiple_vector_data(aFiletype_in,
106115
aFilename_in,
107116
sFilename_output_in=sFilename_output_in,
108117
sTitle_in= 'Mesh with flowline',
109-
aFlag_color_in=[0, 1],
118+
aFlag_color_in=aFlag_color,
110119
aExtent_in = aExtent_in,
111120
pProjection_map_in = pProjection_map_in)
112121
return
@@ -176,6 +185,7 @@ def basin_plot(self,
176185
aExtent_in = aExtent_in)
177186
return
178187
else:
188+
print('Unsupported variable: ', sVariable_in, ' in basin_plot.')
179189
pass
180190
pass
181191
else:
@@ -184,7 +194,7 @@ def basin_plot(self,
184194

185195

186196
map_vector_polyline_data(sFilename_json,
187-
sFilename_output_in,
197+
sFilename_output_in= sFilename_output_in,
188198
iFlag_title_in=iFlag_title_in,
189199
iFlag_thickness_in=0 ,
190200
sTitle_in=sTitle,

Diff for: pyflowline/external/pyearth/visual/map/map_vector_polyline_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def _set_format(self, vmin=None, vmax=None):
2424
self.format = r'$ mathdefault{%s}$' % self.format
2525

2626
def map_vector_polyline_data(sFilename_in,
27-
sFilename_output_in,
27+
sFilename_output_in= None,
2828
iFlag_color_in = None,
2929
iFlag_label_in = None,
3030
iFlag_thickness_in =None,

0 commit comments

Comments
 (0)