Skip to content

Commit

Permalink
Merge pull request #154 from changliao1025/development
Browse files Browse the repository at this point in the history
update the notebook
  • Loading branch information
changliao1025 committed Jul 18, 2023
2 parents c96f637 + e726eeb commit f6cbc86
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 22 deletions.
103 changes: 83 additions & 20 deletions notebooks/mpas_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,25 @@
}
],
"source": [
"oPyflowline.plot(sVariable_in = 'flowline_filter' )\n",
"#if you provide a filename, a png file will be saved\n",
"oPyflowline.plot(sFilename_in = 'filter_flowline.png', sVariable_in = 'flowline_filter' )"
"iVisualization_method = 1\n",
"if iVisualization_method == 1: # you need to install the geopanda package and matplotlib package using conda or pip\n",
" import geopandas as gpd\n",
" import matplotlib.pyplot as plt\n",
" #use the geopanda package\n",
" #the raw/original geojson file \n",
" sFilename_geojson = oPyflowline.aBasin[0].sFilename_flowline_filter_geojson\n",
" gdf = gpd.read_file(sFilename_geojson)\n",
" gdf.plot()\n",
" plt.show()\n",
"\n",
" pass\n",
"\n",
"else: #use the default visualization method, only experimental\n",
"\n",
" oPyflowline.plot(sVariable_in = 'flowline_filter' )\n",
" #if you provide a filename, a png file will be saved\n",
" oPyflowline.plot(sFilename_in = 'filter_flowline.png', sVariable_in = 'flowline_filter' )\n",
" pass"
]
},
{
Expand Down Expand Up @@ -474,9 +490,11 @@
],
"source": [
"\n",
"#aExtent_full = [-78.5,-75.5, 39.2,42.5]\n",
"aExtent_meander = [-76.5,-76.2, 41.6,41.9] \n",
"oPyflowline.plot( sVariable_in = 'flowline_filter', aExtent_in = aExtent_meander )"
"#the default visualization method has an option to set the extent you want to plot\n",
"if iVisualization_method ==2:\n",
" #aExtent_full = [-78.5,-75.5, 39.2,42.5]\n",
" aExtent_meander = [-76.5,-76.2, 41.6,41.9] \n",
" oPyflowline.plot( sVariable_in = 'flowline_filter', aExtent_in = aExtent_meander )"
]
},
{
Expand All @@ -497,8 +515,9 @@
}
],
"source": [
"aExtent_braided = [-77.3,-76.5, 40.2,41.0] \n",
"oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_filter' , aExtent_in =aExtent_braided ) "
"if iVisualization_method ==2:\n",
" aExtent_braided = [-77.3,-76.5, 40.2,41.0] \n",
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_filter' , aExtent_in =aExtent_braided ) "
]
},
{
Expand Down Expand Up @@ -585,7 +604,20 @@
],
"source": [
"\n",
"oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' ) "
"if iVisualization_method == 1: # you need to install the geopanda package and matplotlib package using conda or pip\n",
" import geopandas as gpd\n",
" import matplotlib.pyplot as plt\n",
" #use the geopanda package\n",
" #the raw/original geojson file \n",
" sFilename_geojson = oPyflowline.aBasin[0].sFilename_flowline_simplified_geojson\n",
" gdf = gpd.read_file(sFilename_geojson)\n",
" gdf.plot()\n",
" plt.show()\n",
"\n",
" pass\n",
"\n",
"else: #use the default visualization method, only experimental\n",
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' ) "
]
},
{
Expand Down Expand Up @@ -615,8 +647,9 @@
}
],
"source": [
"aExtent_meander = [-76.5,-76.2, 41.6,41.9] \n",
"oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' , aExtent_in =aExtent_meander ) "
"if iVisualization_method == 2:\n",
" aExtent_meander = [-76.5,-76.2, 41.6,41.9] \n",
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' , aExtent_in =aExtent_meander ) "
]
},
{
Expand All @@ -637,8 +670,9 @@
}
],
"source": [
"aExtent_braided = [-77.3,-76.5, 40.2,41.0] \n",
"oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' , aExtent_in =aExtent_braided ) "
"if iVisualization_method == 2:\n",
" aExtent_braided = [-77.3,-76.5, 40.2,41.0] \n",
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' , aExtent_in =aExtent_braided ) "
]
},
{
Expand All @@ -659,8 +693,9 @@
}
],
"source": [
"aExtent_confluence = [-77.3,-76.5, 40.2,41.0] \n",
"oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' , aExtent_in =aExtent_confluence ) "
"if iVisualization_method == 2:\n",
" aExtent_confluence = [-77.3,-76.5, 40.2,41.0] \n",
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='flowline_simplified' , aExtent_in =aExtent_confluence ) "
]
},
{
Expand Down Expand Up @@ -716,7 +751,20 @@
}
],
"source": [
"oPyflowline.plot( iFlag_title=1 ,sVariable_in='mesh' ) "
"if iVisualization_method == 1: # you need to install the geopanda package and matplotlib package using conda or pip\n",
" import geopandas as gpd\n",
" import matplotlib.pyplot as plt\n",
" #use the geopanda package\n",
" #the raw/original geojson file \n",
" sFilename_geojson = oPyflowline.aBasin[0].sFilename_mesh_geojson\n",
" gdf = gpd.read_file(sFilename_geojson)\n",
" gdf.plot()\n",
" plt.show()\n",
"\n",
" pass\n",
"\n",
"else:\n",
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='mesh' ) "
]
},
{
Expand Down Expand Up @@ -765,7 +813,8 @@
}
],
"source": [
"oPyflowline.plot( iFlag_title=1 ,sVariable_in='mesh' ) "
"if iVisualization_method == 2:\n",
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='mesh' ) "
]
},
{
Expand Down Expand Up @@ -830,7 +879,20 @@
],
"source": [
"\n",
"oPyflowline.plot( iFlag_title=1 ,sVariable_in='overlap') "
"if iVisualization_method == 1: \n",
" #\n",
" file1_path = oPyflowline.aBasin[0].sFilename_mesh_geojson\n",
" file2_path = oPyflowline.aBasin[0].sFilename_flowline_conceptual_geojson\n",
" gdf1 = gpd.read_file(file1_path)\n",
" gdf2 = gpd.read_file(file2_path)\n",
" fig, ax = plt.subplots()\n",
" gdf1.plot(ax=ax, color='blue')\n",
" gdf2.plot(ax=ax, color='red')\n",
" plt.show()\n",
" pass\n",
"else:\n",
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='overlap') \n",
" pass"
]
},
{
Expand Down Expand Up @@ -860,8 +922,9 @@
}
],
"source": [
"aExtent_outlet = [-76.0,-76.5, 39.5,40.0] #outlet\n",
"oPyflowline.plot( iFlag_title=1 ,sVariable_in='overlap' , aExtent_in =aExtent_outlet) "
"if iVisualization_method == 2:\n",
" aExtent_outlet = [-76.0,-76.5, 39.5,40.0] #outlet\n",
" oPyflowline.plot( iFlag_title=1 ,sVariable_in='overlap' , aExtent_in =aExtent_outlet) "
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions pyflowline/classes/_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def _plot_mesh(self, sFilename_output_in=None, aExtent_in=None, pProjection_map_
sMesh_type = self.sMesh_type

map_vector_polygon_data(sFilename_in,
sFilename_output_in=sFilename_output_in,
sTitle_in= sMesh_type,
sFilename_output_in = sFilename_output_in,
sTitle_in = sMesh_type,
aExtent_in = aExtent_in,
pProjection_map_in = pProjection_map_in)

Expand Down

0 comments on commit f6cbc86

Please sign in to comment.