Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ocean boundary nodes #140

Open
yunfangsun opened this issue Apr 1, 2024 · 3 comments
Open

Ocean boundary nodes #140

yunfangsun opened this issue Apr 1, 2024 · 3 comments

Comments

@yunfangsun
Copy link

yunfangsun commented Apr 1, 2024

Hi @SorooshMani-NOAA ,

When I am using Ocsmesh to plot the ocean boundary nodes by using

mesh_obj_2 = ocsmesh.Mesh.open('wave_obc/hgrid.gr3', crs=4326)
base_mesh = mesh_obj_2

base_mesh.boundaries.ocean().plot(ax=ax_tidal_5, color='b', label='Ocean')
base_mesh.boundaries.land().plot(ax=ax_tidal_5, color='r', label='Land')

It gives

Screenshot 2024-04-01 at 3 07 22 PM

However, when I use

boundaries_df = base_mesh.boundaries.ocean()

for index, row in boundaries_df.iterrows():

    index_ids = row['index_id']
    
    for index_id in index_ids:
        print(f'Index ID: {index_id}')
        
        with open('wave_obc/index_ids_2.txt', 'a') as f:
            f.write(f'{index_id}\n')

It gives me 334 points, and when I do scatter plot, it shows
Screenshot 2024-04-01 at 3 11 07 PM
Screenshot 2024-04-01 at 3 26 10 PM

Where some interior nodes are shown, could you please let me know how to take out the ocean boundary node id correctly?

Thank you!

@SorooshMani-NOAA
Copy link
Collaborator

I think it's just an issue of mixing IDs vs indices, you need to subtract 1 from the index_id to be able to get the correct nodes:

ax = m.boundaries.ocean().plot()
ax = m.boundaries.land().plot(ax=ax)
ax.scatter(*(m.msh_t.vert2['coord'][[i - 1 for i in gdf.index_id.loc[0]]].T))
plt.show()

image

Note that you have some places like this on your boundary which is not completely straight:
image

@yunfangsun
Copy link
Author

Hi @SorooshMani-NOAA,

Is there an easy way to make the boundary straight? Thank you!

@SorooshMani-NOAA
Copy link
Collaborator

No, that's on my wishlist for OCSmesh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants