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

Fix the code that makes surfaces compliant with the right hand rule #9771

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions openquake/hazardlib/geo/surface/kite_fault.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from openquake.hazardlib.geo.geodetic import (
npoints_towards, distance, azimuth)
from openquake.hazardlib.geo.surface import SimpleFaultSurface
from openquake.hazardlib.geo.surface.gridded import GriddedSurface
#from openquake.hazardlib.geo.surface.gridded import GriddedSurface

TOL = 0.4
SMALL = 1e-5
Expand Down Expand Up @@ -331,10 +331,10 @@ def _fix_right_hand(self):

# Compare the dip direction from the strike against the one from
# the quadrilateral
# tmp = geo_utils._angles_diff(azi_strike, 90)
# if abs(geo_utils._angles_diff(tmp, azi_dip)) < 40:
tmp = (azi_strike + 90.0) % 360
if abs(geo_utils._angles_diff(tmp, azi_dip)) > 40:
tmp = geo_utils._angles_diff(azi_strike, 90)
if abs(geo_utils._angles_diff(tmp, azi_dip)) < 40:
#tmp = (azi_strike + 90.0) % 360
#if abs(geo_utils._angles_diff(tmp, azi_dip)) > 40:
tlo = np.fliplr(self.mesh.lons)
tla = np.fliplr(self.mesh.lats)
tde = np.fliplr(self.mesh.depths)
Expand Down Expand Up @@ -855,7 +855,7 @@ def _dbg_plot_mesh(mesh):
set_axes_equal(ax)
plt.show()


def _fix_right_hand(msh):
# This function checks that the array describing the surface complies with
# the right hand rule and, if required, flips the mesh to make it compliant
Expand All @@ -871,8 +871,9 @@ def _fix_right_hand(msh):
# Flip the grid to make it compliant with the right hand rule
nmsh = np.empty_like(msh)
nmsh[:, :, :] = msh[:, ::-1, :]
chk_flip = ((msh[:, 0, 0] == nmsh[:, -1, 0]) &
(msh[:, 0, 2] == nmsh[:, -1, 2]))

#chk_flip = ((msh[:, 0, 0] == nmsh[:, -1, 0]) &
# (msh[:, 0, 2] == nmsh[:, -1, 2]))

# Check again the average azimuth for the top edge of the surface
msg = "The mesh still does not comply with the right hand rule"
Expand Down
Loading