Skip to content

Commit

Permalink
added orthogonality plot to preprocess_modelbuilder.py (#923)
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer authored Aug 5, 2024
1 parent da35528 commit c222d5d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/examples/preprocess_modelbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,24 @@

#cutcells
dfmt.meshkernel_delete_withcoastlines(mk=mk_object, res='h') #TODO: write used coastline to ldbfile?
#TODO: illegalcells.pol necessary?
#TODO: illegalcells.pol can be acquired with dfmt.meshkernel_get_illegalcells()

#convert to xugrid
xu_grid_uds = dfmt.meshkernel_to_UgridDataset(mk=mk_object, crs=crs)

#TODO: cleanup grid necessary?
# print('mk_object.mesh2d_get_obtuse_triangles_mass_centers()')
# print(mk_object.mesh2d_get_obtuse_triangles_mass_centers().values)
# print('mk_object.mesh2d_get_orthogonality()')
# print(mk_object.mesh2d_get_orthogonality().values.max()) #TODO: couple back to uds, currently ordering mismatch: https://github.com/Deltares/MeshKernelPy/issues/72
# print(mk_object.mesh2d_get_orthogonality().values.max())
# print('mk_object.mesh2d_get_hanging_edges()')
# print(mk_object.mesh2d_get_hanging_edges())
# mk_object.mesh2d_delete_hanging_edges()

#convert to xugrid
xu_grid_uds = dfmt.meshkernel_to_UgridDataset(mk=mk_object, crs=crs)
mk_ortho = mk_object.mesh2d_get_orthogonality()
mk_ortho_vals = mk_ortho.values
mk_ortho_vals[mk_ortho_vals==mk_ortho.geometry_separator] = 0 # or np.nan, but results in invisible edges (grey would be better)
xu_grid_uds['orthogonality'] = xr.DataArray(mk_ortho_vals, dims=xu_grid_uds.grid.edge_dimension)
xu_grid_uds['orthogonality'].ugrid.plot()

#interp bathy
data_bathy_interp = data_bathy_sel.interp(lon=xu_grid_uds.obj.mesh2d_node_x, lat=xu_grid_uds.obj.mesh2d_node_y)
Expand Down

0 comments on commit c222d5d

Please sign in to comment.