Skip to content

Commit

Permalink
fix neighbor distance bug
Browse files Browse the repository at this point in the history
  • Loading branch information
changliao1025 committed Aug 8, 2023
1 parent f0c37aa commit f271223
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
13 changes: 11 additions & 2 deletions pyflowline/classes/_visual_basin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ def replace_last_occurrence(sFilename_path_in, sSubstring_in, sSubstring_out):


def basin_plot(self,
iFlag_type_in,
iFlag_type_in,
sMesh_type,
sFilename_output_in=None,
sFilename_mesh_in = None,
iFont_size_in = None,
iFlag_title_in=None,
iFlag_colorbar_in=None,
iFlag_scientific_notation_colorbar_in=None,
dData_min_in = None,
dData_max_in = None,
Expand Down Expand Up @@ -65,6 +66,7 @@ def basin_plot(self,
self._plot_polygon_variable( sVariable_in,
iFlag_title_in= iFlag_title_in,
iFont_size_in=iFont_size_in,
iFlag_colorbar_in=iFlag_colorbar_in,
iFlag_scientific_notation_colorbar_in=iFlag_scientific_notation_colorbar_in,
dData_min_in = dData_min_in,
dData_max_in = dData_max_in,
Expand Down Expand Up @@ -221,6 +223,7 @@ def _plot_polygon_variable(self,
sVariable_in,
iFigwidth_in=None,
iFigheight_in=None,
iFlag_colorbar_in=None,
iFlag_title_in=None,
iFont_size_in=None,
iFlag_scientific_notation_colorbar_in = None,
Expand Down Expand Up @@ -250,6 +253,7 @@ def _plot_polygon_variable(self,
sVariable='elevation' #Elevation_profile'
sTitle = 'Surface elevation'
sUnit = 'Unit: m'
sColormap ='terrain'
dData_min = dData_min_in
dData_max = dData_max_in
sFilename = self.sFilename_elevation
Expand All @@ -274,6 +278,7 @@ def _plot_polygon_variable(self,
sVariable='slope'
sTitle = 'Surface slope'
sUnit = 'Unit: percent'
sColormap='plasma'
dData_min = 0.0
dData_max = dData_max_in
sFilename = self.sFilename_variable_polygon
Expand All @@ -283,6 +288,7 @@ def _plot_polygon_variable(self,
sVariable='elevation'
sTitle = 'Surface elevation'
sUnit = r'Unit: m'
sColormap ='terrain'
dData_min = dData_min_in
dData_max = dData_max_in
sFilename = self.sFilename_variable_polygon
Expand All @@ -308,6 +314,7 @@ def _plot_polygon_variable(self,
sVariable='slope'
sTitle = 'Surface slope'
sUnit = r'Unit: percent'
sColormap='plasma'
dData_min = dData_min_in
dData_max = dData_max_in
sFilename = self.sFilename_variable_polygon
Expand All @@ -324,12 +331,14 @@ def _plot_polygon_variable(self,

map_vector_polygon_data(sFilename,
iFlag_color_in = 1,
iFlag_colorbar_in = 1,
iFlag_colorbar_in = iFlag_colorbar_in,
iFont_size_in = iFont_size_in,
iFlag_scientific_notation_colorbar_in = iFlag_scientific_notation_colorbar_in,
sFilename_output_in=sFilename_output_in,
sVariable_in= sVariable,
sTitle_in= sTitle,
sUnit_in= sUnit,
sColormap_in = sColormap,
aExtent_in = aExtent_in,
aLegend_in = aLegend_in,
pProjection_map_in = pProjection_map_in)
Expand Down
6 changes: 3 additions & 3 deletions pyflowline/mesh/mpas/create_mpas_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,14 @@ def add_cell_into_list(aList, i, lCellID, dArea,dElevation_mean,dElevation_profi
nNeighbor_land_virtual = pCell.nNeighbor_land_virtual

aNeighbor_distance = pCell.aNeighbor_distance
aNeighbor_distance_update = list()
#aNeighbor_distance_update = list()

for j in range(nNeighbor_land):
lNeighbor = int(aNeighbor_land[j])
dDistance = aNeighbor_distance[j]
if lNeighbor in aCellID:
aNeighbor_land_update.append(lNeighbor)
aNeighbor_distance_update.append(dDistance)
#aNeighbor_distance_update.append(dDistance)
pass
else:
#this is a land cell in mpas, but it may be clipped by boundary
Expand All @@ -563,7 +563,7 @@ def add_cell_into_list(aList, i, lCellID, dArea,dElevation_mean,dElevation_profi
pCell.aNeighbor_land_virtual = aNeighbor_land_virtual_update #for book keeping only
pCell.nNeighbor_land_virtual = len(aNeighbor_land_virtual_update)

pCell.aNeighbor_distance = aNeighbor_distance_update
#pCell.aNeighbor_distance = aNeighbor_distance_update
aMpas_out.append(pCell)


Expand Down
8 changes: 6 additions & 2 deletions pyflowline/mesh/square/create_square_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def add_cell_into_list(aList, lCellID, iRow, iColumn, dLongitude_center, dLatitu
x = [x1, x2, x3, x4]
y = [y1, y2, y3, y4]

x_new , y_new = reproject_coordinates_batch(x, y, pSpatial_reference)
x_new , y_new = reproject_coordinates_batch(x, y, pSpatial_reference, pSpatial_reference_gcs)
x1, x2, x3, x4 = x_new
y1, y2, y3, y4 = y_new
coordinates = [(x1, y1), (x2, y2), (x3, y3), (x4, y4), (x1, y1)]
Expand Down Expand Up @@ -188,7 +188,8 @@ def add_cell_into_list(aList, lCellID, iRow, iColumn, dLongitude_center, dLatitu
iFlag = True
else:
pass



if ( iFlag == True ):
aSquare, dArea = add_cell_into_list(aSquare, lCellID, iRow, iColumn, dLongitude_center,dLatitude_center, dummy1 )

Expand Down Expand Up @@ -353,6 +354,9 @@ def add_cell_into_list(aList, lCellID, iRow, iColumn, dLongitude_center, dLatitu
for pSquare in aSquare_out:
aNeighbor = pSquare.aNeighbor
pSquare.aNeighbor_distance=list()
if pSquare.lCellID == 41:
print('debug')

for lCellID1 in aNeighbor:
for pSquare1 in aSquare_out:
if pSquare1.lCellID == lCellID1:
Expand Down

0 comments on commit f271223

Please sign in to comment.