Skip to content

Commit

Permalink
Merge pull request #196 from changliao1025/development
Browse files Browse the repository at this point in the history
version upgrade
  • Loading branch information
changliao1025 authored Oct 27, 2023
2 parents e2028d3 + aca36dd commit 03f3fb2
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 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.2.6"
version: "0.2.7"
# 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.2.6" %}
{% set version = "0.2.7" %}

package:
name: {{ name|lower }}
Expand Down
14 changes: 9 additions & 5 deletions pyflowline/formats/export_flowline.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,21 @@ def export_flowline_to_shapefile(iFlag_projected_in, aFlowline_in, pSpatial_refe
for i in range(nFlowline):
pFlowline = aFlowline_in[i]
dummy =pFlowline.aVertex
aPoint=list()
#aPoint=list()
pLine = ogr.Geometry(ogr.wkbLineString)
for j in dummy:
if iFlag_projected_in ==1:
aPoint.append( Point( j.dx, j.dy ) )
#aPoint.append( Point( j.dx, j.dy ) )
pLine.AddPoint(j.dx, j.dy)
pass
else:
aPoint.append( Point( j.dLongitude_degree, j.dLatitude_degree ) )
#aPoint.append( Point( j.dLongitude_degree, j.dLatitude_degree ) )
pLine.AddPoint(j.dLongitude_degree, j.dLatitude_degree)
pass

dummy1= LineString( aPoint )
pGeometry_out = ogr.CreateGeometryFromWkb(dummy1.wkb)
#dummy1= LineString( aPoint )
pGeometry_out = ogr.CreateGeometryFromWkb(pLine.ExportToWkb())
#pGeometry_out = ogr.CreateGeometryFromWkb(dummy1.wkb)
pFeature_out.SetGeometry(pGeometry_out)

pFeature_out.SetField("id", lID)
Expand Down
10 changes: 7 additions & 3 deletions pyflowline/formats/export_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,18 @@ def export_vertex_to_shapefile(aVertex_in, sFilename_shapefile_out,\
lID = 0
for i in range(nVertex):
pVertex = aVertex_in[i]
pPoint = ogr.Geometry(ogr.wkbPoint)
if iFlag_projected_in ==1:
dummy1= Point( pVertex.dx, pVertex.dy )
#dummy1= Point( pVertex.dx, pVertex.dy )
pPoint.AddPoint(pVertex.dx, pVertex.dy)
pass
else:
dummy1= Point( pVertex.dLongitude_degree, pVertex.dLatitude_degree )
#dummy1= Point( pVertex.dLongitude_degree, pVertex.dLatitude_degree )
pPoint.AddPoint(pVertex.dLongitude_degree, pVertex.dLatitude_degree)
pass

pGeometry_out = ogr.CreateGeometryFromWkb(dummy1.wkb)
#pGeometry_out = ogr.CreateGeometryFromWkb(dummy1.wkb)
pGeometry_out = ogr.CreateGeometryFromWkb(pPoint.ExportToWkb())
pFeature_out.SetGeometry(pGeometry_out)
pFeature_out.SetField("id", lID)
if iFlag_attribute ==1:
Expand Down
10 changes: 6 additions & 4 deletions pyflowline/mesh/hexagon/create_hexagon_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ def add_cell_into_list2(aList, lCellID, iRow, iColumn, dLongitude_center, dLatit
aHexagon_out = list()

if iFlag_fill_hole ==1:

#find the virtual neighbors
for pCell in aHexagon:
aNeighbor_land = pCell.aNeighbor_land #including both holes and maps land cutoff by boundary
Expand All @@ -449,9 +450,11 @@ def add_cell_into_list2(aList, lCellID, iRow, iColumn, dLongitude_center, dLatit
if lNeighbor in aHexagon_dict:
nNeighbor_land_update = nNeighbor_land_update + 1
aNeighbor_land_update.append(lNeighbor)
pass
else:
#a hole or boundary mpas land cell
aNeighbor_land_virtual.append(lNeighbor)
pass

pCell.nNeighbor= len(aNeighbor_land_update)
pCell.aNeighbor = aNeighbor_land_update
Expand All @@ -460,11 +463,10 @@ def add_cell_into_list2(aList, lCellID, iRow, iColumn, dLongitude_center, dLatit
pCell.aNeighbor_land_virtual = aNeighbor_land_virtual

pCell.nNeighbor_land_virtual = len(aNeighbor_land_virtual)
aHexagon_middle.append(pCell)


#add holes back, we also need to add into the unsorted map
for pCell in aHexagon:

if pCell.nNeighbor_land_virtual ==1: #only one virtual land means it is likely next to a hole
lNeighbor_hole = pCell.aNeighbor_land_virtual[0]
#now find its row and column indices
Expand Down Expand Up @@ -528,7 +530,7 @@ def add_cell_into_list2(aList, lCellID, iRow, iColumn, dLongitude_center, dLatit
dLatitude_center = np.mean(aCoords[0:6,1])

if lCellID not in aHexagon_dict:
aHexagon_middle, dArea = add_cell_into_list1(aHexagon_middle, lCellID, iRow, iColumn, dLongitude_center,dLatitude_center, aCoords)
aHexagon, dArea = add_cell_into_list1(aHexagon, lCellID, iRow, iColumn, dLongitude_center,dLatitude_center, aCoords)
aHexagon_dict[lCellID] = lCellIndex
lCellIndex = lCellIndex + 1
pFeature.SetGeometry(pPolygon)
Expand Down Expand Up @@ -598,7 +600,7 @@ def add_cell_into_list2(aList, lCellID, iRow, iColumn, dLongitude_center, dLatit
dLatitude_center = np.mean(aCoords[0:6,1])

if lCellID not in aHexagon_dict:
aHexagon_middle, dArea = add_cell_into_list1(aHexagon_middle, lCellID, iRow, iColumn, dLongitude_center,dLatitude_center, aCoords)
aHexagon, dArea = add_cell_into_list1(aHexagon, lCellID, iRow, iColumn, dLongitude_center,dLatitude_center, aCoords)
aHexagon_dict[lCellID] = lCellIndex
lCellIndex = lCellIndex + 1
pFeature.SetGeometry(pPolygon)
Expand Down
5 changes: 3 additions & 2 deletions pyflowline/mesh/mpas/create_mpas_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ def add_cell_into_list(aList, i, lCellID, dArea, dElevation_mean, dElevation_pro
aMpas_out = list()
ncell = len(aMpas)
#generate the list of cell ID that are already certain
if iFlag_fill_hole == 1:
if iFlag_fill_hole == 1:

#first update neighbor information because some cell should have vitual land neighbor (not present in the mesh)
#this operation does not increase the number of cells, but it update the neighbor information
#specifically, it divided the land neighbor into two parts: land and virtual land
Expand Down Expand Up @@ -485,7 +486,7 @@ def add_cell_into_list(aList, i, lCellID, dArea, dElevation_mean, dElevation_pro
dArea = float(aCellArea[j])

if lCellID not in aMpas_dict:
aMpas_middle = add_cell_into_list(aMpas_middle, j, lCellID, dArea, dElevation_mean, dElevation_profile0, aCoords )
aMpas = add_cell_into_list(aMpas, j, lCellID, dArea, dElevation_mean, dElevation_profile0, aCoords )
aMpas_dict[lCellID] = lCellIndex
lCellIndex = lCellIndex + 1
#now we need to update the neightboring information as well
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
AUTHOR = "Chang Liao"
AUTHOR_EMAIL = "[email protected]"
URL = "https://github.com/changliao1025/pyflowline"
VERSION = "0.2.6"
VERSION = "0.2.7"
REQUIRES_PYTHON = ">=3.8.0"
KEYWORDS = "Earth Science"

Expand Down

0 comments on commit 03f3fb2

Please sign in to comment.