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

Find a decent WKT representation for NonParametric sources #5648

Open
micheles opened this issue Mar 14, 2020 · 2 comments
Open

Find a decent WKT representation for NonParametric sources #5648

micheles opened this issue Mar 14, 2020 · 2 comments
Assignees
Labels

Comments

@micheles
Copy link
Contributor

micheles commented Mar 14, 2020

The South America model fails: https://gitlab.openquake.org/hazard/mosaic/SAM/-/jobs/16426.
The reason is that the engine computes a WKT string for the seismic sources; such string is used in the oq plot sources command. For nonparametric sources the WKT is obtained from this formula which is ultra-slow:

    def wkt(self):
        """
        :returns: the geometry as a WKT string
        """
        polys = [rup.surface.mesh.get_convex_hull()._polygon2d
                for rup, pmf in self.data]
        return shapely.geometry.MultiPolygon(polys).wkt

This is a bad idea, we are generating one polygon for each rupture in the source, and then even the realization is ultra-slow. We need a decent formula from @mmpagani . For the moment I am just producing the WKT of the convex hull (see #5652).

NB: in the past the SAM model did not fail but only by accident (the .wkt() calls were made in parallel and not sequentially as now). It was still impossible to visualize the sources, so the problem of the wrong formula was still there (BTW, I am responsible for the formula since I had no idea of what to put there).

@micheles
Copy link
Contributor Author

micheles commented Mar 16, 2020

@mmpagani says that we should use a concave hull. Here are two references:
https://gist.github.com/dwyerk/10561690
https://towardsdatascience.com/the-concave-hull-c649795c0f0f

@micheles
Copy link
Contributor Author

micheles commented Nov 29, 2023

Another alternative would be to use the library alpha_shapes. The line to change would be https://github.com/gem/oq-engine/blob/engine-3.18/openquake/hazardlib/source/non_parametric.py#L236

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

No branches or pull requests

3 participants