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

Duplicate node in subsetting #129

Open
SorooshMani-NOAA opened this issue Dec 8, 2023 · 4 comments
Open

Duplicate node in subsetting #129

SorooshMani-NOAA opened this issue Dec 8, 2023 · 4 comments
Assignees

Comments

@SorooshMani-NOAA
Copy link
Collaborator

SorooshMani-NOAA commented Dec 8, 2023

The mesh in the seam section seem to sometimes include two nodes that are almost at the same spot. See https://github.com/noaa-ocs-modeling/SurgeTeamCoordination/issues/143#issuecomment-1844362533

And example in a local test is:
File seam_mesh.2dm

ND 7855 -7.7202011351507991E+01 3.5937568127835952E+01 0.0000000000000000E+00
ND 7856 -7.7202011351507991E+01 3.5937568127835959E+01 0.0000000000000000E+00

which then reappears in the final mesh as:

ND 1897211 -7.7202011351507991E+01 3.5937568127835959E+01 2.1569783265873127E+01
ND 1897212 -7.7202011351507991E+01 3.5937568127835952E+01 2.1569783265877248E+01

image

@SorooshMani-NOAA SorooshMani-NOAA self-assigned this Dec 8, 2023
@SorooshMani-NOAA
Copy link
Collaborator Author

This issues seems to be coming from the geometry (shape) used for meshing the seam region (image in UTM17):

image

@SorooshMani-NOAA
Copy link
Collaborator Author

This issue is a results of this section of the code:

poly_seam_3 = self._add_one_mesh_layer_to_polygon(
poly_seam_2,
mesh_fine.msh_t, poly_clip_hires_0,
mesh_coarse.msh_t, poly_clip_lowres_0)

Here one layer from each mesh (hi and low-res) are taken - in addition to the clipped section by the clipper polygon and then added to the last iteration seam polygon (which doesn't have duplicate). This union operation results in the duplicate in this case:

return unary_union(
[polygon, poly_1_lyr_hires, poly_1_lyr_lowres])

poly_seam_2 doesn't have duplicate. Tested by debugging and using helper function:

def debug(poly):
    from shapely import get_coordinates, points
    gdf = gpd.GeoDataFrame(geometry=[poly]).explode()
    gdf = gdf[gdf.intersects(points(
                [842651.955858, 3.983695e+06] # Point in UTM17 from duplicate issue
    ).buffer(10))]
    if len(gdf) == 0:
        return
    return get_coordinates(gdf)

@SorooshMani-NOAA
Copy link
Collaborator Author

SorooshMani-NOAA commented Dec 8, 2023

The issue seems to go away after dropping extra verts:

poly_seam_7 = utils.drop_extra_vertex_from_polygon(poly_seam_6)

but reappears in poly_seam_8 (the final version) again due to operation:

poly_seam_8 = poly_seam_7.difference(
unary_union([poly_clip_hires, poly_clip_lowres]))

correction
Actually upon inspecting the resulting shape 8, it seems that those point do not reappear! So why do we have them in the seam mesh?

@SorooshMani-NOAA
Copy link
Collaborator Author

After the number of layers fix, if I use 8 layers, I do not get the issue with duplicate nodes, but with 9 I do!! WHY?!

@SorooshMani-NOAA SorooshMani-NOAA changed the title Duplicate element in subsetting Duplicate node in subsetting Dec 11, 2023
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

1 participant