Skip to content

Add Shapely Geometry Properties to Fault Objects#8

Merged
lispandfound merged 2 commits intomainfrom
polygons
Sep 30, 2024
Merged

Add Shapely Geometry Properties to Fault Objects#8
lispandfound merged 2 commits intomainfrom
polygons

Conversation

@lispandfound
Copy link
Copy Markdown
Contributor

What Does This PR Add

This PR adds the geometry property to the Point, Plane, and Fault classes in the sources module. These properties return the shapely Geometry of the (projected) corners, so point.geometry returns a shapely.Point, and plane.geometry, fault.geometry both return shapely.Polygon.

Why Do We Need This Code

Shapely geometries have a couple of interesting use cases in the workflow and velocity modelling code:

  1. We currently compute the minimum area bounding box from the corners of the faults using velocity_modelling.bounding_box.minimum_area_bounding_box. But, it turns out, shapely can already do this for geometries using shapely.minimum_rotated_rectangle. So we can remove code from the bounding box class.
  2. In the workflow.scripts.generate_velocity_model_parameters stage, we have two pieces of code that I would like to swap out with shapely code:
    • We compute the largest corner -> domain-edge distance manually at the moment to figure out the longest distance that an s-wave would travel (in order to compute maximum s-wave travel time and thus simulation duration). A more robust measure of this is Hausdorff distance (maximum distance between Fault geometry and domain edge), which shapely natively supports.
    • Having a fault geometry object in shapely would let me add a buffer around this geometry when computing the bounding box for the domain. This buffer would ensure that the domain always includes the fault + x km around the fault for simulations.

"""float: The dip angle of the fault."""
return np.degrees(np.arcsin(np.abs(self.bottom_m - self.top_m) / self.width_m))

# TODO: change this to take width and dip rather than projected width.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still important?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to make it a GitHub Issue instead because it's easier to track that way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yeah it should do that.

@lispandfound lispandfound merged commit cff98b9 into main Sep 30, 2024
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

Successfully merging this pull request may close these issues.

5 participants