Source code for openquake.man.tests.single_source_utils.fault_utils_test

# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright (C) 2014-2025 GEM Foundation
#
# OpenQuake is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OpenQuake. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import unittest

from openquake.hazardlib.source import SimpleFaultSource
from openquake.hazardlib.mfd import EvenlyDiscretizedMFD
from openquake.hazardlib.scalerel import WC1994
from openquake.hazardlib.tom import PoissonTOM
from openquake.hazardlib.geo import Line, Point

from openquake.man.single_source_utils.faults_utils import fault_surface_distance


[docs] class TestFaultSurfaceDistance(unittest.TestCase):
[docs] def setUp(self): mspa = 2.5 # Simple fault source mfd = EvenlyDiscretizedMFD(6.0, 0.1, [1.]) msr = WC1994() tom = PoissonTOM(1.0) trace = Line([Point(10, 45.), Point(10., 45.2)]) sfs = SimpleFaultSource(source_id='1', name='1', tectonic_region_type='none', mfd=mfd, rupture_mesh_spacing=mspa, magnitude_scaling_relationship=msr, rupture_aspect_ratio=1.0, temporal_occurrence_model=tom, upper_seismogenic_depth=0., lower_seismogenic_depth=10., fault_trace=trace, dip=90., rake=90) self.srcs = [sfs] mfd = EvenlyDiscretizedMFD(6.0, 0.1, [1.]) msr = WC1994() tom = PoissonTOM(1.0) trace = Line([Point(10.2, 45.), Point(10.2, 45.2)]) sfs = SimpleFaultSource(source_id='2', name='2', tectonic_region_type='none', mfd=mfd, rupture_mesh_spacing=mspa, magnitude_scaling_relationship=msr, rupture_aspect_ratio=1.0, temporal_occurrence_model=tom, upper_seismogenic_depth=0., lower_seismogenic_depth=10., fault_trace=trace, dip=90., rake=90) self.srcs.append(sfs) mfd = EvenlyDiscretizedMFD(6.0, 0.1, [1.]) msr = WC1994() tom = PoissonTOM(1.0) trace = Line([Point(10.4, 45.), Point(10.4, 45.2)]) sfs = SimpleFaultSource(source_id='3', name='3', tectonic_region_type='none', mfd=mfd, rupture_mesh_spacing=mspa, magnitude_scaling_relationship=msr, rupture_aspect_ratio=1.0, temporal_occurrence_model=tom, upper_seismogenic_depth=0., lower_seismogenic_depth=10., fault_trace=trace, dip=90., rake=90) self.srcs.append(sfs) mfd = EvenlyDiscretizedMFD(6.0, 0.1, [1.]) msr = WC1994() tom = PoissonTOM(1.0) trace = Line([Point(10.5, 45.), Point(10.6, 45.2)]) sfs = SimpleFaultSource(source_id='4', name='4', tectonic_region_type='none', mfd=mfd, rupture_mesh_spacing=mspa, magnitude_scaling_relationship=msr, rupture_aspect_ratio=1.0, temporal_occurrence_model=tom, upper_seismogenic_depth=0., lower_seismogenic_depth=10., fault_trace=trace, dip=90., rake=90) self.srcs.append(sfs)
[docs] def test01(self): computed = fault_surface_distance(self.srcs, 5.0) expected = np.array([ [0., 15.67589056, 31.35175709, 39.313281], [40., 00., 15.67589056, 23.587993], [40., 40., 00., 7.862668], [40., 40., 40., 0.]]) np.testing.assert_allclose(computed, expected, rtol=1e-2)