Skip to content

Commit

Permalink
Merge pull request #170 from changliao1025/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
changliao1025 committed Aug 7, 2023
2 parents 1b5d87b + 2c02943 commit 74be60b
Show file tree
Hide file tree
Showing 13 changed files with 875 additions and 471 deletions.
9 changes: 5 additions & 4 deletions pyflowline/classes/hexagon.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ class pyhexagon(pycell):
aFlowline=None
nNeighbor=-1
nNeighbor_land=-1
nNeighbor_ocean=-1
nNeighbor_ocean=-1 #cell that actually on ocean
nNeighbor_land_virtual = -1
aNeighbor_land_virtual = None
aNeighbor=None #the global ID of all neighbors
aNeighbor_land_virtual = None #cell that on land but not considered as neighbor
aNeighbor=None #the global ID of all neighbors, including both virtual and real land neighbors
aNeighbor_land=None #the global ID of all neighbors
aNeighbor_ocean=None #the global ID of all neighbors

aNeighbor_distance = None

def __init__(self, dLon, dLat, aEdge, aVertex):
"""
Initilize a hexagon cell object
Expand Down
2 changes: 2 additions & 0 deletions pyflowline/classes/latlon.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class pylatlon(pycell):
aNeighbor=None #the global ID of all neighbors
aNeighbor_land=None #the global ID of all neighbors
aNeighbor_ocean=None #the global ID of all neighbors

aNeighbor_distance = None


def __init__(self, dLon, dLat, aEdge, aVertex):
"""
Expand Down
1 change: 1 addition & 0 deletions pyflowline/classes/mpas.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class pympas(pycell):

aNeighbor_ocean=None #the global ID of all neighbors
aNeighbor_distance = None


def __init__(self, dLon, dLat, aEdge, aVertex):
"""
Expand Down
11 changes: 8 additions & 3 deletions pyflowline/classes/pycase.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ def mesh_generation(self, iFlag_antarctic_in=None):

aHexagon = create_hexagon_mesh(iFlag_rotation, dX_lowerleft, dY_lowerleft, dResolution_meter, ncolumn, nrow,
sFilename_mesh, sFilename_spatial_reference, pBoundary_wkt)
pass

return aHexagon
else:
Expand All @@ -670,7 +671,9 @@ def mesh_generation(self, iFlag_antarctic_in=None):
pBoundary_wkt = pBoundary.ExportToWkt()
aSquare = create_square_mesh(dX_lowerleft, dY_lowerleft, dResolution_meter, ncolumn, nrow,
sFilename_mesh, sFilename_spatial_reference, pBoundary_wkt)
return aSquare
pass

return aSquare
else:
if iMesh_type ==3: #latlon
dResolution_meter = degree_to_meter(dLatitude_mean, dResolution_degree)
Expand Down Expand Up @@ -702,8 +705,6 @@ def mesh_generation(self, iFlag_antarctic_in=None):

return aLatlon



else:
if iMesh_type == 4: #mpas
iFlag_use_mesh_dem = self.iFlag_use_mesh_dem
Expand Down Expand Up @@ -741,6 +742,8 @@ def mesh_generation(self, iFlag_antarctic_in=None):
#new method using polygon object
aMpas = create_mpas_mesh(iFlag_global, iFlag_use_mesh_dem, iFlag_save_mesh,
sFilename_mesh_netcdf, sFilename_mesh, iFlag_antarctic_in= iFlag_antarctic_in, pBoundary_in = pBoundary_wkt )
pass

return aMpas
else:
if iMesh_type == 5: #dggrid
Expand All @@ -760,13 +763,15 @@ def mesh_generation(self, iFlag_antarctic_in=None):
sWorkspace_output,
iFlag_antarctic_in=iFlag_antarctic_in,
sFilename_boundary_in = self.sFilename_mesh_boundary)

pass
else:
aDggrid = create_dggrid_mesh(iFlag_global,
iFlag_save_mesh,
dResolution_meter,
sFilename_mesh,
sWorkspace_output)
pass


return aDggrid
Expand Down
1 change: 1 addition & 0 deletions pyflowline/classes/square.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class pysquare(pycell):
aNeighbor_land=None #the global ID of all neighbors
aNeighbor_ocean=None #the global ID of all neighbors
aNeighbor_distance = None


def __init__(self, dLon, dLat, aEdge, aVertex):
"""
Expand Down
4 changes: 4 additions & 0 deletions pyflowline/classes/tin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class pytin(pycell):
nNeighbor_land_virtual = -1
aNeighbor_land_virtual = None
nNeighbor=-1

aNeighbor_distance = None


def __init__(self, aEdge,aVertex, dLon, dLat):
nEdge = len(aEdge)
if nEdge !=3:
Expand Down
12 changes: 12 additions & 0 deletions pyflowline/external/pyearth/visual/choose_line_width.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def choose_line_width(iFigure_width, iDPI):
# Calculate line width based on the figure width and iDPI
dummy = 0.01 * iFigure_width * iDPI / 80
dummy1 = max(2.5, dummy)
iWidth_out = min(1.5, dummy1)
return iWidth_out

if __name__ == '__main__':
iFigure_width = 8 #inch
iDPI = 300 #dot per inch
iWidth_out = choose_line_width(iFigure_width, iDPI)
print(iWidth_out)
14 changes: 14 additions & 0 deletions pyflowline/formats/convert_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ def convert_gcs_attributes_to_cell(iMesh_type_in, dLongitude_center_in, dLatitud
aVertexID_in,
aEdgeID_in,
aVertexIndexOnEdge_in):
"""_summary_
Args:
iMesh_type_in (_type_): _description_
dLongitude_center_in (_type_): _description_
dLatitude_center_in (_type_): _description_
aCoordinates_gcs_in (_type_): _description_
aVertexID_in (_type_): _description_
aEdgeID_in (_type_): _description_
aVertexIndexOnEdge_in (_type_): _description_
Returns:
_type_: _description_
"""

npoint = len(aVertexID_in)
aVertex=list()
Expand Down
17 changes: 10 additions & 7 deletions pyflowline/formats/convert_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@
from pyflowline.external.pyearth.gis.gdal.gdal_functions import calculate_angle_betwen_vertex
from pyflowline.external.pyearth.gis.gdal.gdal_functions import calculate_distance_to_plane

def convert_gcs_coordinates_to_cell(iMesh_type_in,
dLongitude_center_in,
dLatitude_center_in,
aCoordinates_gcs_in,
iFlag_simplify_in=None):
def convert_gcs_coordinates_to_cell(iMesh_type_in,
dLongitude_center_in,
dLatitude_center_in,
aCoordinates_gcs_in,
iFlag_simplify_in=None):




if iFlag_simplify_in is None:
iFlag_simplify_in = 0
else:
iFlag_simplify_in = iFlag_simplify_in

#the closed polygon has a duplicate point (start and end are the same)
npoint = len(aCoordinates_gcs_in)
aVertex=list()
aEdge=list()
Expand Down Expand Up @@ -90,8 +94,7 @@ def convert_gcs_coordinates_to_cell(iMesh_type_in,
aEdge.append(pEdge)


if iMesh_type_in ==1: #hexagon

if iMesh_type_in ==1: #hexagon

pHexagon = pyhexagon( dLongitude_center_in, dLatitude_center_in, aEdge, aVertex)
return pHexagon
Expand Down
Loading

0 comments on commit 74be60b

Please sign in to comment.