# ------------------- The OpenQuake Model Building Toolkit --------------------
# ------------------- FERMI: Fault nEtwoRks ModellIng -------------------------
# Copyright (C) 2023 GEM Foundation
# .-.
# / \ .-.
# | .`. ; .--. ___ .-. ___ .-. .-. ( __)
# | |(___) / \ ( ) \ ( ) ' \ (''")
# | |_ | .-. ; | ' .-. ; | .-. .-. ; | |
# ( __) | | | | | / (___) | | | | | | | |
# | | | |/ | | | | | | | | | | |
# | | | ' _.' | | | | | | | | | |
# | | | .'.-. | | | | | | | | | |
# | | ' `-' / | | | | | | | | | |
# (___) `.__.' (___) (___)(___)(___)(___)
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# coding: utf-8
import os
import json
import pathlib
import unittest
import numpy as np
import pandas as pd
from scipy.stats import circmean
from openquake.hazardlib.geo.mesh import RectangularMesh
from openquake.hazardlib.geo.surface import SimpleFaultSurface
from openquake.fnm.fault_modeler import (
simple_fault_from_feature,
get_trace_from_mesh,
subdivide_simple_fault_surface,
subdivide_rupture_mesh,
get_subsections_from_fault,
_build_subfaults_for_one_fault,
build_subfaults_parallel,
make_subfault_df,
group_subfaults_by_fault,
angular_mean_degrees,
weighted_angular_mean_degrees,
make_rupture_df,
get_boundary_3d,
make_subfault_gdf,
make_rupture_gdf,
merge_meshes_no_overlap,
make_mesh_from_subfaults,
make_sf_rupture_mesh,
make_sf_rupture_meshes,
)
from openquake.fnm.rupture_connections import (
get_rupture_adjacency_matrix,
make_binary_adjacency_matrix,
make_binary_adjacency_matrix_sparse,
get_multifault_ruptures_fast,
get_rupture_grouping,
)
HERE = pathlib.Path(__file__).parent.absolute()
[docs]
class Test3Faults(unittest.TestCase):
[docs]
def setUp(self):
test_data_dir = HERE / 'data'
fgj_name = os.path.join(test_data_dir, "motagua_3_faults.geojson")
with open(fgj_name) as f:
fgj = json.load(f)
self.features = fgj['features']
self.faults = [
simple_fault_from_feature(
feature, edge_sd=2.0, lsd_default=20.0, usd_default=0.0
)
for feature in self.features
]
self.fault_surfaces = [fault['surface'] for fault in self.faults]
[docs]
def test_simple_fault_from_feature(self):
fault = simple_fault_from_feature(
self.features[0], edge_sd=2.0, lsd_default=20.0, usd_default=0.0
)
[docs]
def test_subdivide_simple_fault_surface(self):
fault = self.faults[0]['surface']
def get_rows_cols(subsecs):
rows = []
cols = []
for ss in subsecs:
if ss['row'] not in rows:
rows.append(ss["row"])
if ss['col'] not in cols:
cols.append(ss["col"])
rows = sorted(list(set(rows)))
cols = sorted(list(set(cols)))
return rows, cols
subsecs_15_15 = subdivide_simple_fault_surface(
fault, subsection_size=[15, 15]
)
rows_15_15, cols_15_15 = get_rows_cols(subsecs_15_15)
assert rows_15_15 == [0]
assert cols_15_15 == [0, 1, 2]
assert len(subsecs_15_15) == 3
subsecs_10_10 = subdivide_simple_fault_surface(
fault, subsection_size=[10.0, 10.0]
)
rows_10_10, cols_10_10 = get_rows_cols(subsecs_10_10)
assert rows_10_10 == [0, 1]
assert cols_10_10 == [0, 1, 2, 3]
assert len(subsecs_10_10) == 8
subsecs_30_20 = subdivide_simple_fault_surface(
fault, subsection_size=[30.0, 20.0]
)
rows_30_20, cols_30_20 = get_rows_cols(subsecs_30_20)
assert rows_30_20 == [0]
assert cols_30_20 == [0]
assert len(subsecs_30_20) == 1
subsecs_2_2 = subdivide_simple_fault_surface(
fault,
subsection_size=[2.0, 2.0],
edge_sd=2.0,
dip_sd=2.0,
)
rows_2_2, cols_2_2 = get_rows_cols(subsecs_2_2)
assert rows_2_2 == [0, 1, 2, 3, 4, 5, 6, 7, 8]
assert cols_2_2 == [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
]
assert len(subsecs_2_2) == 180
[docs]
def test_subdivide_rupture_mesh(self):
# fmt: off
lons = np.array([
[-89.59956649, -89.59701028, -89.59787751, -89.6003022 ,
-89.59402206, -89.59086509, -89.59456132, -89.59812005,
-89.59856159, -89.59629232, -89.59619498, -89.59341402,
-89.58824138, -89.58301093, -89.57809418, -89.57215448,
-89.56436336, -89.55442844, -89.54281225],
[-89.61109019, -89.60853299, -89.60939924, -89.61182295,
-89.60554188, -89.60238395, -89.60607921, -89.60963698,
-89.61007755, -89.6078073 , -89.60770898, -89.60492706,
-89.59975348, -89.59452209, -89.58960439, -89.58366376,
-89.57587175, -89.56593599, -89.55431902],
[-89.62261366, -89.62005548, -89.62092074, -89.62334349,
-89.61706147, -89.61390259, -89.61759688, -89.62115368,
-89.62159328, -89.61932206, -89.61922276, -89.61643987,
-89.61126535, -89.60603302, -89.60111438, -89.59517282,
-89.58737992, -89.57744332, -89.56582557],
[-89.63413692, -89.63157775, -89.63244201, -89.6348638 ,
-89.62858085, -89.62542101, -89.62911434, -89.63267016,
-89.6331088 , -89.63083661, -89.63073632, -89.62795248,
-89.62277701, -89.61754374, -89.61262415, -89.60668166,
-89.59888787, -89.58895044, -89.57733191],
[-89.64565995, -89.64309979, -89.64396307, -89.64638389,
-89.6401 , -89.63693921, -89.64063157, -89.64418642,
-89.64462409, -89.64235093, -89.64224966, -89.63946486,
-89.63428845, -89.62905423, -89.6241337 , -89.61819029,
-89.6103956 , -89.60045734, -89.58883803],
[-89.65718276, -89.65462162, -89.6554839 , -89.65790376,
-89.65161894, -89.64845719, -89.65214858, -89.65570246,
-89.65613917, -89.65386503, -89.65376279, -89.65097702,
-89.64579966, -89.64056451, -89.63564303, -89.6296987 ,
-89.62190312, -89.61196402, -89.60034393],
[-89.66870534, -89.66614322, -89.66700452, -89.66942341,
-89.66313765, -89.65997495, -89.66366537, -89.66721829,
-89.66765402, -89.66537892, -89.66527569, -89.66248896,
-89.65731067, -89.65207457, -89.64715215, -89.64120688,
-89.63341042, -89.62347048, -89.61184961]])
lats = np.array([
[14.6509712 , 14.63221277, 14.61332561, 14.59489276, 14.57696668,
14.55868079, 14.54008879, 14.52147226, 14.50286329, 14.48414405,
14.46521161, 14.4466369 , 14.42837862, 14.41013577, 14.39181252,
14.37378745, 14.35644062, 14.34015726, 14.32494183],
[14.64885476, 14.63009634, 14.61120917, 14.59277632, 14.57485024,
14.55656435, 14.53797235, 14.51935583, 14.50074686, 14.48202762,
14.46309518, 14.44452046, 14.42626219, 14.40801934, 14.38969609,
14.37167101, 14.35432418, 14.33804083, 14.3228254 ],
[14.64673776, 14.62797933, 14.60909217, 14.59065932, 14.57273324,
14.55444735, 14.53585536, 14.51723883, 14.49862986, 14.47991062,
14.46097818, 14.44240347, 14.4241452 , 14.40590235, 14.3875791 ,
14.36955403, 14.3522072 , 14.33592384, 14.32070841],
[14.64462019, 14.62586176, 14.6069746 , 14.58854176, 14.57061567,
14.55232979, 14.5337378 , 14.51512127, 14.49651231, 14.47779307,
14.45886063, 14.44028592, 14.42202765, 14.4037848 , 14.38546156,
14.36743648, 14.35008965, 14.3338063 , 14.31859087],
[14.64250205, 14.62374363, 14.60485647, 14.58642363, 14.56849755,
14.55021167, 14.53161967, 14.51300315, 14.49439419, 14.47567495,
14.45674252, 14.43816781, 14.41990954, 14.4016667 , 14.38334345,
14.36531838, 14.34797156, 14.3316882 , 14.31647278],
[14.64038334, 14.62162493, 14.60273777, 14.58430493, 14.56637885,
14.54809298, 14.52950099, 14.51088447, 14.49227551, 14.47355628,
14.45462384, 14.43604914, 14.41779088, 14.39954804, 14.3812248 ,
14.36319973, 14.34585291, 14.32956955, 14.31435413],
[14.63826407, 14.61950566, 14.60061851, 14.58218567, 14.5642596 ,
14.54597373, 14.52738174, 14.50876522, 14.49015627, 14.47143704,
14.45250461, 14.43392992, 14.41567165, 14.39742882, 14.37910558,
14.36108052, 14.3437337 , 14.32745035, 14.31223493]])
depths = np.array([
[ 0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. ],
[ 1.86181722, 1.86181722, 1.86181722, 1.86181722, 1.86181722,
1.86181722, 1.86181722, 1.86181722, 1.86181722, 1.86181722,
1.86181722, 1.86181722, 1.86181722, 1.86181722, 1.86181722,
1.86181722, 1.86181722, 1.86181722, 1.86181722],
[ 3.72363443, 3.72363443, 3.72363443, 3.72363443, 3.72363443,
3.72363443, 3.72363443, 3.72363443, 3.72363443, 3.72363443,
3.72363443, 3.72363443, 3.72363443, 3.72363443, 3.72363443,
3.72363443, 3.72363443, 3.72363443, 3.72363443],
[ 5.58545165, 5.58545165, 5.58545165, 5.58545165, 5.58545165,
5.58545165, 5.58545165, 5.58545165, 5.58545165, 5.58545165,
5.58545165, 5.58545165, 5.58545165, 5.58545165, 5.58545165,
5.58545165, 5.58545165, 5.58545165, 5.58545165],
[ 7.44726887, 7.44726887, 7.44726887, 7.44726887, 7.44726887,
7.44726887, 7.44726887, 7.44726887, 7.44726887, 7.44726887,
7.44726887, 7.44726887, 7.44726887, 7.44726887, 7.44726887,
7.44726887, 7.44726887, 7.44726887, 7.44726887],
[ 9.30908608, 9.30908608, 9.30908608, 9.30908608, 9.30908608,
9.30908608, 9.30908608, 9.30908608, 9.30908608, 9.30908608,
9.30908608, 9.30908608, 9.30908608, 9.30908608, 9.30908608,
9.30908608, 9.30908608, 9.30908608, 9.30908608],
[11.1709033 , 11.1709033 , 11.1709033 , 11.1709033 , 11.1709033 ,
11.1709033 , 11.1709033 , 11.1709033 , 11.1709033 , 11.1709033 ,
11.1709033 , 11.1709033 , 11.1709033 , 11.1709033 , 11.1709033 ,
11.1709033 , 11.1709033 , 11.1709033 , 11.1709033 ]])
# fmt: on
num_segs_along_strike = 2
num_segs_down_dip = 2
n_subsec_pts_strike = 10
n_subsec_pts_dip = 4
meshes = subdivide_rupture_mesh(
lons,
lats,
depths,
num_segs_down_dip,
num_segs_along_strike,
n_subsec_pts_dip,
n_subsec_pts_strike,
)
assert len(meshes) == 4
for subsec in meshes:
assert subsec['mesh'].shape == (
n_subsec_pts_dip,
n_subsec_pts_strike,
)
np.testing.assert_array_equal(
meshes[0]['mesh'].lons,
lons[:n_subsec_pts_dip, :n_subsec_pts_strike],
)
np.testing.assert_array_equal(
meshes[1]['mesh'].lons,
lons[:n_subsec_pts_dip, n_subsec_pts_strike - 1 :],
)
np.testing.assert_array_equal(
meshes[2]['mesh'].lons,
lons[n_subsec_pts_dip - 1 :, :n_subsec_pts_strike],
)
np.testing.assert_array_equal(
meshes[3]['mesh'].lons,
lons[n_subsec_pts_dip - 1 :, n_subsec_pts_strike - 1 :],
)
[docs]
def test_get_subsections_from_fault(self):
edge_sd = 2.0
dip_sd = 2.0
fault = self.faults[0]
meshes = subdivide_simple_fault_surface(
fault['surface'],
subsection_size=[15, 15],
edge_sd=edge_sd,
dip_sd=dip_sd,
)
subs = [
{
'fid': 'ccaf121',
'net_slip_rate': 0.441,
'net_slip_rate_err': 3.876,
'rake': 10.2,
'rake_err': 99.3,
'fault_position': (0, 0),
'trace': [
[-89.59956649068211, 14.650971199748858, 0.0],
[-89.59710726337345, 14.634007292493084, 0.0],
[-89.597430743347, 14.616891370558022, 0.0],
[-89.60073300222084, 14.600087261014995, 0.0],
[-89.59628538428522, 14.583835681151804, 0.0],
[-89.59116943142133, 14.567441374774988, 0.0],
[-89.59245490995265, 14.550713846729888, 0.0],
[-89.59578300718147, 14.533889540342335, 0.0],
],
'surface': meshes[0]['mesh'],
'length': 13.253905257174676,
'width': 17.986534016754575,
'area': 235.9699746856274,
'strike': 178.1224980936142,
'dip': 56.66081911365165,
'subsec_id': 0,
},
{
'fid': 'ccaf121',
'net_slip_rate': 0.441,
'net_slip_rate_err': 3.876,
'rake': 10.2,
'rake_err': 99.3,
'fault_position': (0, 1),
'trace': [
[-89.59578300718147, 14.533889540342335, 0.0],
[-89.59892035366687, 14.517031452311487, 0.0],
[-89.59799905106092, 14.50021396325144, 0.0],
[-89.5962813575188, 14.483242536484289, 0.0],
[-89.59619328928964, 14.46611318507276, 0.0],
[-89.59414046104891, 14.449248544530342, 0.0],
[-89.58948685201833, 14.43272214179378, 0.0],
[-89.58475432135026, 14.41621673602384, 0.0],
],
'surface': meshes[1]['mesh'],
'length': 13.276013401947099,
'width': 17.986534016754817,
'area': 237.4066527215742,
'strike': 174.76592026790934,
'dip': 56.27736990220573,
'subsec_id': 1,
},
{
'fid': 'ccaf121',
'net_slip_rate': 0.441,
'net_slip_rate_err': 3.876,
'rake': 10.2,
'rake_err': 99.3,
'fault_position': (0, 2),
'trace': [
[-89.58475432135026, 14.41621673602384, 0.0],
[-89.58014380152352, 14.399680103361012, 0.0],
[-89.57546779302906, 14.383171084700502, 0.0],
[-89.5694132511034, 14.36709132935591, 0.0],
[-89.56174883886632, 14.35167206636428, 0.0],
[-89.55233883843646, 14.337177658317602, 0.0],
[-89.54176321589082, 14.32345506817629, 0.0],
[-89.53255055779402, 14.308834813538137, 0.0],
],
'surface': meshes[2]['mesh'],
'length': 13.327484258102922,
'width': 17.986534016754227,
'area': 236.43868296018368,
'strike': 154.8650689240886,
'dip': 56.98387657815828,
'subsec_id': 2,
},
]
'''
subs = [
{'fid': 'ccaf121', 'net_slip_rate': 0.441, 'net_slip_rate_err': 3.876, 'rake': 10.2, 'rake_err': 99.3, 'fault_position': (0, 0),
#'trace': [[-89.59956649068211, 14.650971199748858, 0.0], [-89.59710726337345, 14.634007292493084, 0.0], [-89.597430743347, 14.616891370558022, 0.0], [-89.60073300222084, 14.600087261014995, 0.0], [-89.59628538428522, 14.583835681151804, 0.0], [-89.59116943142133, 14.567441374774988, 0.0], [-89.59245490995265, 14.550713846729888, 0.0], [-89.59578300718147, 14.533889540342335, 0.0]],
'surface': meshes[0]['mesh'],
'length': 13.253905257174676, 'width': 17.986534016754575, 'area': 235.9699746856274, 'strike': 178.1224980936142, 'dip': 56.66081911365165, 'subsec_id': 0,
},
{
'fid': 'ccaf121',
'net_slip_rate': 0.441,
'net_slip_rate_err': 3.876,
'rake': 10.2,
'rake_err': 99.3,
'fault_position': (0, 1),
'trace': [
[-89.59694354884405, 14.528000246745036, 0.0],
[-89.60013675075616, 14.510281416477683, 0.0],
[-89.59639588669054, 14.492663361111372, 0.0],
[-89.59617725512942, 14.474678150115288, 0.0],
[-89.59621092560008, 14.45669173505424, 0.0],
[-89.59138007092956, 14.439324311579345, 0.0],
[-89.58641064184171, 14.421993692133194, 0.0],
],
'surface': meshes[1]['mesh'],
'length': 12.000009758489401,
'width': 15.988683441774477,
'area': 190.64118679638247,
'strike': 174.44559161552098,
'dip': 56.339203997047875,
'subsec_id': 1,
},
{
'fid': 'ccaf121',
'net_slip_rate': 0.441,
'net_slip_rate_err': 3.876,
'rake': 10.2,
'rake_err': 99.3,
'fault_position': (0, 2),
'trace': [
[-89.58144198776333, 14.404662963129736, 0.0],
[-89.57689865389952, 14.387223170155227, 0.0],
[-89.57088949762748, 14.37020466701995, 0.0],
[-89.{56313983955417, 14.353859917457635, 0.0],
[-89.55340367701965, 14.338545216923173, 0.0],
[-89.54222390169573, 14.324186105544184, 0.0],
[-89.53255055779402, 14.308834813538137, 0.0],
],
'surface': meshes[2]['mesh'],
'length': 12.000024257919673,
'width': 15.988683441773809,
'area': 188.9937701880861,
'strike': 153.78128801293633,
'dip': 57.11105140551114,
'subsec_id': 2,
},
]
'''
fault_subs = get_subsections_from_fault(
fault,
subsection_size=[15, 15],
surface=fault['surface'],
edge_sd=edge_sd,
dip_sd=dip_sd,
)
for i, fsub in enumerate(fault_subs):
for k in fsub.keys():
if k == 'surface':
np.testing.assert_almost_equal(
fsub[k].mesh.lats, subs[i][k].lats
)
np.testing.assert_almost_equal(
fsub[k].mesh.lons, subs[i][k].lons
)
np.testing.assert_almost_equal(
fsub[k].mesh.depths, subs[i][k].depths
)
else:
if isinstance(fsub[k], str):
assert fsub[k] == subs[i][k]
else:
np.testing.assert_almost_equal(fsub[k], subs[i][k])
[docs]
def test_make_subfault_df(self):
all_subs = [
get_subsections_from_fault(
fault, subsection_size=[15, 15], surface=fault['surface']
)
for fault in self.faults
]
subfault_df = make_subfault_df(all_subs)
subfault_df_data = {
'fid': {
0: 'ccaf121',
1: 'ccaf121',
2: 'ccaf121',
3: 'ccaf134',
4: 'ccaf148',
},
'net_slip_rate': {
0: 0.441,
1: 0.441,
2: 0.441,
3: 0.518,
4: 0.509,
},
'net_slip_rate_err': {
0: 3.876,
1: 3.876,
2: 3.876,
3: 4.658,
4: 4.379,
},
'rake': {0: 10.2, 1: 10.2, 2: 10.2, 3: -34.9, 4: 48.9},
'rake_err': {0: 99.3, 1: 99.3, 2: 99.3, 3: 97.7, 4: 97.3},
'fault_position': {
0: (0, 0),
1: (0, 1),
2: (0, 2),
3: (0, 0),
4: (0, 0),
},
'trace': {
0: [
[-89.59956649068211, 14.650971199748858, 0.0],
[-89.59710726337345, 14.634007292493084, 0.0],
[-89.597430743347, 14.616891370558022, 0.0],
[-89.60073300222084, 14.600087261014995, 0.0],
[-89.59628538428522, 14.583835681151804, 0.0],
[-89.59116943142133, 14.567441374774988, 0.0],
[-89.59245490995265, 14.550713846729888, 0.0],
[-89.59578300718147, 14.533889540342335, 0.0],
],
1: [
[-89.59578300718147, 14.533889540342335, 0.0],
[-89.59892035366687, 14.517031452311487, 0.0],
[-89.59799905106092, 14.50021396325144, 0.0],
[-89.5962813575188, 14.483242536484289, 0.0],
[-89.59619328928964, 14.46611318507276, 0.0],
[-89.59414046104891, 14.449248544530342, 0.0],
[-89.58948685201833, 14.43272214179378, 0.0],
[-89.58475432135026, 14.41621673602384, 0.0],
],
2: [
[-89.58475432135026, 14.41621673602384, 0.0],
[-89.58014380152352, 14.399680103361012, 0.0],
[-89.57546779302906, 14.383171084700502, 0.0],
[-89.5694132511034, 14.36709132935591, 0.0],
[-89.56174883886632, 14.35167206636428, 0.0],
[-89.55233883843646, 14.337177658317602, 0.0],
[-89.54176321589082, 14.32345506817629, 0.0],
[-89.53255055779402, 14.308834813538137, 0.0],
],
3: [
[-89.55679619239645, 14.820769283943088, 0.0],
[-89.57519388239037, 14.823450272833801, 0.0],
[-89.5935338618384, 14.826479700887486, 0.0],
[-89.61151704157392, 14.831094860324418, 0.0],
[-89.62985585107408, 14.834134548047093, 0.0],
[-89.64507512567809, 14.84448241197329, 0.0],
],
4: [
[-89.59657256980212, 14.678914461295516, 0.0],
[-89.58947831138866, 14.695540305322709, 0.0],
[-89.58380082797113, 14.712667910511147, 0.0],
[-89.57657922714323, 14.729242830662981, 0.0],
[-89.5705428234846, 14.746255528839862, 0.0],
[-89.56498266053296, 14.76341949310828, 0.0],
[-89.56203794864808, 14.78117911669114, 0.0],
[-89.56024650349677, 14.799081959421132, 0.0],
[-89.55741828819535, 14.81685935493518, 0.0],
],
},
#'surface': {0: <openquake.hazardlib.geo.surface.simple_fault.SimpleFaultSurface object at 0x2a989dff0>, 1: <openquake.hazardlib.geo.surface.simple_fault.SimpleFaultSurface object at 0x2a989ddb0>, 2: <openquake.hazardlib.geo.surface.simple_fault.SimpleFaultSurface object at 0x2a989ceb0>, 3: <openquake.hazardlib.geo.surface.simple_fault.SimpleFaultSurface object at 0x2a989f5b0>, 4: <openquake.hazardlib.geo.surface.simple_fault.SimpleFaultSurface object at 0x2a989dd50>},
'length': {
0: 13.253905257174676,
1: 13.276013401947099,
2: 13.327484258102922,
3: 10.00000091224596,
4: 16.00000405931091,
},
'width': {
0: 17.986534016754575,
1: 17.986534016754817,
2: 17.986534016754227,
3: 15.993574936253552,
4: 17.986348780777668,
},
'area': {
0: 235.9699746856274,
1: 237.4066527215742,
2: 236.43868296018368,
3: 159.32071917732935,
4: 286.91660195498446,
},
'strike': {
0: 178.1224980936142,
1: 174.76592026790934,
2: 154.8650689240886,
3: 285.49485227465607,
4: 15.355212789239824,
},
'dip': {
0: 56.66081911365165,
1: 56.27736990220573,
2: 56.98387657815828,
3: 65.6745050569039,
4: 55.32297855459656,
},
'subsec_id': {0: 0, 1: 1, 2: 2, 3: 0, 4: 0},
'slip_azimuth': {
0: 10.276735777486735,
1: 6.972563454877567,
2: 346.97590453139776,
3: 68.05799351572101,
4: 249.69951531986558,
},
}
# subfault_df_data = {
# 'fid': ['ccaf121', 'ccaf121', 'ccaf121', 'ccaf134', 'ccaf148'],
# 'net_slip_rate': [0.441, 0.441, 0.441, 0.518, 0.509],
# 'net_slip_rate_err': [3.876, 3.876, 3.876, 4.658, 4.379],
# 'rake': [10.2, 10.2, 10.2, -34.9, 48.9],
# 'rake_err': [99.3, 99.3, 99.3, 97.7, 97.3],
# 'fault_position': [(0, 0), (0, 1), (0, 2), (0, 0), (0, 0)],
# 'trace': [
# [
# [-89.59956649068211, 14.650971199748858, 0.0],
# [-89.59698431199297, 14.633159096452792, 0.0],
# [-89.59747773318917, 14.615178978270805, 0.0],
# [-89.60127550616845, 14.597571970762491, 0.0],
# [-89.5951113157921, 14.580603598485542, 0.0],
# [-89.58993769097732, 14.563328165813516, 0.0],
# [-89.59346173801414, 14.545668110499353, 0.0],
# ],
# [
# [-89.59694354884405, 14.528000246745036, 0.0],
# [-89.60013675075616, 14.510281416477683, 0.0],
# [-89.59639588669054, 14.492663361111372, 0.0],
# [-89.59617725512942, 14.474678150115288, 0.0],
# [-89.59621092560008, 14.45669173505424, 0.0],
# [-89.59138007092956, 14.439324311579345, 0.0],
# [-89.58641064184171, 14.421993692133194, 0.0],
# ],
# [
# [-89.58144198776333, 14.404662963129736, 0.0],
# [-89.57689865389952, 14.387223170155227, 0.0],
# [-89.57088949762748, 14.37020466701995, 0.0],
# [-89.56313983955417, 14.353859917457635, 0.0],
# [-89.55340367701965, 14.338545216923173, 0.0],
# [-89.54222390169573, 14.324186105544184, 0.0],
# [-89.53255055779402, 14.308834813538137, 0.0],
# ],
# [
# [-89.55679619239645, 14.820769283943088, 0.0],
# [-89.5797788294412, 14.824207765985568, 0.0],
# [-89.6025253556863, 14.828787455050259, 0.0],
# [-89.62527110075153, 14.833374762361236, 0.0],
# [-89.64507512567809, 14.84448241197329, 0.0],
# ],
# [
# [-89.59657256980212, 14.678914461295516, 0.0],
# [-89.58866729625906, 14.697987114697545, 0.0],
# [-89.58173762588684, 14.717403625189661, 0.0],
# [-89.57399231234237, 14.73653400588445, 0.0],
# [-89.56736569445788, 14.756063526157611, 0.0],
# [-89.56287934325236, 14.77610494699755, 0.0],
# [-89.56050244176562, 14.796524416973563, 0.0],
# [-89.55741828819535, 14.81685935493518, 0.0],
# ],
# ],
# "length": [
# 12.00001331,
# 12.00000976,
# 12.00002426,
# 9.95610889,
# 15.98921294,
# ],
# "width": [
# 15.98868344,
# 15.98868344,
# 15.98868344,
# 13.99472512,
# 15.98853708,
# ],
# "area": [
# 189.83128301,
# 190.6411868,
# 188.99377019,
# 138.91982246,
# 254.96235572,
# ],
# "strike": [
# 176.68303719,
# 174.44559162,
# 153.78128801,
# 285.51212231,
# 15.35495475,
# ],
# "dip": [
# 56.71260868,
# 56.339204,
# 57.11105141,
# 65.57978283,
# 55.30489265,
# ],
# "subsec_id": [0, 1, 2, 0, 0],
# "slip_azimuth": [
# 8.83027121,
# 6.64371806,
# 345.87522374,
# 68.05454803,
# 249.70518548,
# ],
# }
subfault_df_ = pd.DataFrame(subfault_df_data)
subfault_df_.index.name = 'subfault_id'
# doesn't test the 'surface' column because they are hard
# to construct independently
test_df = subfault_df[list(subfault_df_data.keys())]
# pd.testing.assert_frame_equal(test_df, subfault_df_)
for col in test_df.columns:
if col not in ['trace']:
pd.testing.assert_series_equal(test_df[col], subfault_df_[col])
[docs]
def test_group_subfaults_by_fault(self):
all_subs = [
get_subsections_from_fault(
fault, subsection_size=[15, 15], surface=fault['surface']
)
for fault in self.faults
]
f_groups = group_subfaults_by_fault(all_subs)
f_groups_ = {
'ccaf121': [
{
'fid': 'ccaf121',
'net_slip_rate': 0.441,
'net_slip_rate_err': 3.876,
'rake': 10.2,
'rake_err': 99.3,
'fault_position': (0, 0),
'trace': [
[-89.59956649068211, 14.650971199748858, 0.0],
[-89.59710726337345, 14.634007292493084, 0.0],
[-89.597430743347, 14.616891370558022, 0.0],
[-89.60073300222084, 14.600087261014995, 0.0],
[-89.59628538428522, 14.583835681151804, 0.0],
[-89.59116943142133, 14.567441374774988, 0.0],
[-89.59245490995265, 14.550713846729888, 0.0],
[-89.59578300718147, 14.533889540342335, 0.0],
],
'surface': None,
'length': 13.253905257174676,
'width': 17.986534016754575,
'area': 235.9699746856274,
'strike': 178.1224980936142,
'dip': 56.66081911365165,
'subsec_id': 0,
},
{
'fid': 'ccaf121',
'net_slip_rate': 0.441,
'net_slip_rate_err': 3.876,
'rake': 10.2,
'rake_err': 99.3,
'fault_position': (0, 1),
'trace': [
[-89.59578300718147, 14.533889540342335, 0.0],
[-89.59892035366687, 14.517031452311487, 0.0],
[-89.59799905106092, 14.50021396325144, 0.0],
[-89.5962813575188, 14.483242536484289, 0.0],
[-89.59619328928964, 14.46611318507276, 0.0],
[-89.59414046104891, 14.449248544530342, 0.0],
[-89.58948685201833, 14.43272214179378, 0.0],
[-89.58475432135026, 14.41621673602384, 0.0],
],
'surface': None,
'length': 13.276013401947099,
'width': 17.986534016754817,
'area': 237.4066527215742,
'strike': 174.76592026790934,
'dip': 56.27736990220573,
'subsec_id': 1,
},
{
'fid': 'ccaf121',
'net_slip_rate': 0.441,
'net_slip_rate_err': 3.876,
'rake': 10.2,
'rake_err': 99.3,
'fault_position': (0, 2),
'trace': [
[-89.58475432135026, 14.41621673602384, 0.0],
[-89.58014380152352, 14.399680103361012, 0.0],
[-89.57546779302906, 14.383171084700502, 0.0],
[-89.5694132511034, 14.36709132935591, 0.0],
[-89.56174883886632, 14.35167206636428, 0.0],
[-89.55233883843646, 14.337177658317602, 0.0],
[-89.54176321589082, 14.32345506817629, 0.0],
[-89.53255055779402, 14.308834813538137, 0.0],
],
'surface': None,
'length': 13.327484258102922,
'width': 17.986534016754227,
'area': 236.43868296018368,
'strike': 154.8650689240886,
'dip': 56.98387657815828,
'subsec_id': 2,
},
],
'ccaf134': [
{
'fid': 'ccaf134',
'net_slip_rate': 0.518,
'net_slip_rate_err': 4.658,
'rake': -34.9,
'rake_err': 97.7,
'fault_position': (0, 0),
'trace': [
[-89.55679619239645, 14.820769283943088, 0.0],
[-89.57519388239037, 14.823450272833801, 0.0],
[-89.5935338618384, 14.826479700887486, 0.0],
[-89.61151704157392, 14.831094860324418, 0.0],
[-89.62985585107408, 14.834134548047093, 0.0],
[-89.64507512567809, 14.84448241197329, 0.0],
],
'surface': None,
'length': 10.00000091224596,
'width': 15.993574936253552,
'area': 159.32071917732935,
'strike': 285.49485227465607,
'dip': 65.6745050569039,
'subsec_id': 0,
}
],
'ccaf148': [
{
'fid': 'ccaf148',
'net_slip_rate': 0.509,
'net_slip_rate_err': 4.379,
'rake': 48.9,
'rake_err': 97.3,
'fault_position': (0, 0),
'trace': [
[-89.59657256980212, 14.678914461295516, 0.0],
[-89.58947831138866, 14.695540305322709, 0.0],
[-89.58380082797113, 14.712667910511147, 0.0],
[-89.57657922714323, 14.729242830662981, 0.0],
[-89.5705428234846, 14.746255528839862, 0.0],
[-89.56498266053296, 14.76341949310828, 0.0],
[-89.56203794864808, 14.78117911669114, 0.0],
[-89.56024650349677, 14.799081959421132, 0.0],
[-89.55741828819535, 14.81685935493518, 0.0],
],
'surface': None,
'length': 16.00000405931091,
'width': 17.986348780777668,
'area': 286.91660195498446,
'strike': 15.355212789239824,
'dip': 55.32297855459656,
'subsec_id': 0,
}
],
}
"""
f_groups_ = {
'ccaf121': [
{
'fid': 'ccaf121',
'net_slip_rate': 0.441,
'net_slip_rate_err': 3.876,
'rake': 10.2,
'rake_err': 99.3,
'fault_position': (0, 0),
'trace': [
[-89.59956649068211, 14.650971199748858, 0.0],
[-89.59698431199297, 14.633159096452792, 0.0],
[-89.59747773318917, 14.615178978270805, 0.0],
[-89.60127550616845, 14.597571970762491, 0.0],
[-89.5951113157921, 14.580603598485542, 0.0],
[-89.58993769097732, 14.563328165813516, 0.0],
[-89.59346173801414, 14.545668110499353, 0.0],
],
'surface': None,
'length': 12.00001331237004,
'width': 15.988683441773759,
'area': 189.83128301196695,
'strike': 176.68303719068055,
'dip': 56.71260867881627,
'subsec_id': 0,
},
{
'fid': 'ccaf121',
'net_slip_rate': 0.441,
'net_slip_rate_err': 3.876,
'rake': 10.2,
'rake_err': 99.3,
'fault_position': (0, 1),
'trace': [
[-89.59694354884405, 14.528000246745036, 0.0],
[-89.60013675075616, 14.510281416477683, 0.0],
[-89.59639588669054, 14.492663361111372, 0.0],
[-89.59617725512942, 14.474678150115288, 0.0],
[-89.59621092560008, 14.45669173505424, 0.0],
[-89.59138007092956, 14.439324311579345, 0.0],
[-89.58641064184171, 14.421993692133194, 0.0],
],
'surface': None,
'length': 12.000009758489401,
'width': 15.988683441774477,
'area': 190.64118679638247,
'strike': 174.44559161552098,
'dip': 56.339203997047875,
'subsec_id': 1,
},
{
'fid': 'ccaf121',
'net_slip_rate': 0.441,
'net_slip_rate_err': 3.876,
'rake': 10.2,
'rake_err': 99.3,
'fault_position': (0, 2),
'trace': [
[-89.58144198776333, 14.404662963129736, 0.0],
[-89.57689865389952, 14.387223170155227, 0.0],
[-89.57088949762748, 14.37020466701995, 0.0],
[-89.56313983955417, 14.353859917457635, 0.0],
[-89.55340367701965, 14.338545216923173, 0.0],
[-89.54222390169573, 14.324186105544184, 0.0],
[-89.53255055779402, 14.308834813538137, 0.0],
],
'surface': None,
'length': 12.000024257919673,
'width': 15.988683441773809,
'area': 188.9937701880861,
'strike': 153.78128801293633,
'dip': 57.11105140551114,
'subsec_id': 2,
},
],
'ccaf134': [
{
'fid': 'ccaf134',
'net_slip_rate': 0.518,
'net_slip_rate_err': 4.658,
'rake': -34.9,
'rake_err': 97.7,
'fault_position': (0, 0),
'trace': [
[-89.55679619239645, 14.820769283943088, 0.0],
[-89.5797788294412, 14.824207765985568, 0.0],
[-89.6025253556863, 14.828787455050259, 0.0],
[-89.62527110075153, 14.833374762361236, 0.0],
[-89.64507512567809, 14.84448241197329, 0.0],
],
'surface': None,
'length': 9.956108887980372,
'width': 13.994725123921308,
'area': 138.91982246088745,
'strike': 285.5121223062609,
'dip': 65.57978283162466,
'subsec_id': 0,
}
],
'ccaf148': [
{
'fid': 'ccaf148',
'net_slip_rate': 0.509,
'net_slip_rate_err': 4.379,
'rake': 48.9,
'rake_err': 97.3,
'fault_position': (0, 0),
'trace': [
[-89.59657256980212, 14.678914461295516, 0.0],
[-89.58866729625906, 14.697987114697545, 0.0],
[-89.58173762588684, 14.717403625189661, 0.0],
[-89.57399231234237, 14.73653400588445, 0.0],
[-89.56736569445788, 14.756063526157611, 0.0],
[-89.56287934325236, 14.77610494699755, 0.0],
[-89.56050244176562, 14.796524416973563, 0.0],
[-89.55741828819535, 14.81685935493518, 0.0],
],
'surface': None,
'length': 15.98921293792161,
'width': 15.988537081692549,
'area': 254.96235571923052,
'strike': 15.354954754568299,
'dip': 55.30489265384065,
'subsec_id': 0,
}
],
}
"""
assert f_groups.keys() == f_groups_.keys()
for f_id, group in f_groups.items():
for i, sub in enumerate(group):
for k in sub.keys():
if k == 'surface':
continue
else:
if isinstance(sub[k], str):
assert sub[k] == f_groups_[f_id][i][k]
# elif np.isscalar(sub[k]):
else:
np.testing.assert_almost_equal(
sub[k], f_groups_[f_id][i][k]
)
# @unittest.skip('needs to be updated')
[docs]
def test_make_rupture_df(self):
all_subs = [
get_subsections_from_fault(
fault, subsection_size=[15, 15], surface=fault['surface']
)
for fault in self.faults
]
subfault_df = make_subfault_df(all_subs)
single_rup_df, dist_mat = get_rupture_adjacency_matrix(
self.faults,
all_subfaults=all_subs,
max_dist=10.0,
full_fault_only_mf_ruptures=False,
)
bm = make_binary_adjacency_matrix_sparse(dist_mat, max_dist=10.0)
rup_groups = get_rupture_grouping(self.faults, single_rup_df)
mf_rups = get_multifault_ruptures_fast(
bm,
rup_groups=rup_groups,
max_sf_rups_per_mf_rup=7,
)
rup_df = make_rupture_df(
single_fault_rup_df=single_rup_df,
multi_fault_rups=mf_rups,
subfault_df=subfault_df,
)
rup_df_data = {
'subfaults': {
0: [0],
1: [0, 1],
2: [0, 1, 2],
3: [1],
4: [1, 2],
5: [2],
6: [3],
7: [4],
8: [0, 1, 4],
9: [0, 1, 2, 3, 4],
10: [0, 3, 4],
11: [3, 4],
12: [0, 1, 3, 4],
13: [0, 4],
14: [0, 1, 2, 4],
},
'ruptures': {
0: [0],
1: [1],
2: [2],
3: [3],
4: [4],
5: [5],
6: [6],
7: [7],
8: [1, 7],
9: [2, 6, 7],
10: [0, 6, 7],
11: [6, 7],
12: [1, 6, 7],
13: [0, 7],
14: [2, 7],
},
'faults': {
0: ['ccaf121'],
1: ['ccaf121'],
2: ['ccaf121'],
3: ['ccaf121'],
4: ['ccaf121'],
5: ['ccaf121'],
6: ['ccaf134'],
7: ['ccaf148'],
8: ['ccaf121', 'ccaf148'],
9: ['ccaf121', 'ccaf134', 'ccaf148'],
10: ['ccaf121', 'ccaf134', 'ccaf148'],
11: ['ccaf134', 'ccaf148'],
12: ['ccaf121', 'ccaf134', 'ccaf148'],
13: ['ccaf121', 'ccaf148'],
14: ['ccaf121', 'ccaf148'],
},
'frac_area': {
0: [1.0],
1: [0.4985, 0.5015],
2: [0.3324, 0.3345, 0.3331],
3: [1.0],
4: [0.501, 0.499],
5: [1.0],
6: [1.0],
7: [1.0],
8: [0.3104, 0.3123, 0.3774],
9: [0.2041, 0.2054, 0.2045, 0.1378, 0.2482],
10: [0.3459, 0.2335, 0.4206],
11: [0.357, 0.643],
12: [0.2566, 0.2582, 0.1732, 0.312],
13: [0.4513, 0.5487],
14: [0.2367, 0.2382, 0.2372, 0.2879],
},
'fault_frac_area': {
0: [1.0],
1: [1.0],
2: [1.0],
3: [1.0],
4: [1.0],
5: [1.0],
6: [1.0],
7: [1.0],
8: [0.6, 0.4],
9: [0.6, 0.1, 0.2],
10: [0.3, 0.2, 0.4],
11: [0.4, 0.6],
12: [0.5, 0.2, 0.3],
13: [0.5, 0.5],
14: [0.7, 0.3],
},
'mean_rake': {
0: 10.2,
1: 10.2,
2: 10.2,
3: 10.2,
4: 10.2,
5: 10.2,
6: -34.9,
7: 48.9,
8: 24.6,
9: 13.8,
10: 16.8,
11: 21.4,
12: 14.9,
13: 31.5,
14: 21.1,
},
'slip_azimuth': {
0: [10.3],
1: [8.6],
2: [1.4],
3: [7.0],
4: [-3.0],
5: [-13.0],
6: [68.1],
7: [-110.3],
8: [8.6, -110.3],
9: [1.4, 68.1, -110.3],
10: [10.3, 68.1, -110.3],
11: [68.1, -110.3],
12: [8.6, 68.1, -110.3],
13: [10.3, -110.3],
14: [1.4, -110.3],
},
'mag': {
0: 6.4,
1: 6.7,
2: 6.8,
3: 6.4,
4: 6.7,
5: 6.4,
6: 6.2,
7: 6.5,
8: 6.9,
9: 7.1,
10: 6.8,
11: 6.6,
12: 7.0,
13: 6.7,
14: 7.0,
},
'area': {
0: 236.0,
1: 473.4,
2: 709.8,
3: 237.4,
4: 473.8,
5: 236.4,
6: 159.3,
7: 286.9,
8: 760.3,
9: 1156.1,
10: 682.2,
11: 446.2,
12: 919.6,
13: 522.9,
14: 996.7,
},
'displacement': {
0: 0.591,
1: 0.831,
2: 0.783,
3: 0.588,
4: 0.83,
5: 0.59,
6: 0.439,
7: 0.687,
8: 1.032,
9: 1.355,
10: 0.815,
11: 0.624,
12: 1.206,
13: 0.752,
14: 1.112,
},
}
rup_df_ = pd.DataFrame(rup_df_data)
pd.testing.assert_frame_equal(rup_df_, rup_df)
[docs]
def test_get_boundary_3d(self):
trace, boundary = get_boundary_3d(self.faults[0]['surface'])
trace_lons = np.array(
[
-89.59956649068211,
-89.59698430469041,
-89.59747773548364,
-89.60127552671314,
-89.5951112786632,
-89.58993765973256,
-89.59346175717457,
-89.59694356436408,
-89.60013676128483,
-89.59639587898764,
-89.59617725498434,
-89.59621092560008,
-89.59138007092956,
-89.58641064184171,
-89.58144198776333,
-89.57689865389952,
-89.57088949762748,
-89.56313983955417,
-89.55340367701965,
-89.54222390169573,
-89.53255055763515,
]
)
trace_lats = np.array(
[
14.650971199748858,
14.633159046074937,
14.615178894655815,
14.597571875507006,
14.58060349627213,
14.563328061474328,
14.545668014474291,
14.528000167984867,
14.510281358050092,
14.49266332483088,
14.47467813817926,
14.45669173505424,
14.439324311579345,
14.421993692133194,
14.404662963129736,
14.387223170155227,
14.37020466701995,
14.353859917457635,
14.338545216923173,
14.324186105544184,
14.308834813285978,
]
)
np.testing.assert_array_almost_equal(trace.xy[0], trace_lons)
np.testing.assert_array_almost_equal(trace.xy[1], trace_lats)
bound_lons = np.array(
[
-89.59956649068211,
-89.59698430469041,
-89.59747773548364,
-89.60127552671314,
-89.5951112786632,
-89.58993765973256,
-89.59346175717457,
-89.59694356436408,
-89.60013676128483,
-89.59639587898764,
-89.59617725498434,
-89.59621092560008,
-89.59138007092956,
-89.58641064184171,
-89.58144198776333,
-89.57689865389952,
-89.57088949762748,
-89.56313983955417,
-89.55340367701965,
-89.54222390169573,
-89.53255055763515,
-89.53255055763515,
-89.54300583326216,
-89.55346092754343,
-89.56391584046536,
-89.57437057201433,
-89.58482512217682,
-89.59527949093932,
-89.60573367828827,
-89.61618768421023,
-89.62664150869175,
-89.62664150869175,
-89.63632127839041,
-89.64750707096154,
-89.65724965854953,
-89.66500618220415,
-89.67102249627143,
-89.67557317486634,
-89.68054913752017,
-89.68552588488653,
-89.69036408316086,
-89.69033802820499,
-89.69056427786484,
-89.69431264034247,
-89.6911269765706,
-89.68765269103288,
-89.6841361220747,
-89.6893171153537,
-89.69548861614216,
-89.6916983605405,
-89.69121263550005,
-89.69380246563993,
-89.69380246563993,
-89.68333254669648,
-89.67286244148184,
-89.66239215001143,
-89.6519216723006,
-89.64145100836487,
-89.63098015821964,
-89.62050912188043,
-89.61003789936274,
-89.59956649068211,
]
)
bound_lats = np.array(
[
14.650971199748858,
14.633159046074937,
14.615178894655815,
14.597571875507006,
14.58060349627213,
14.563328061474328,
14.545668014474291,
14.528000167984867,
14.510281358050092,
14.49266332483088,
14.47467813817926,
14.45669173505424,
14.439324311579345,
14.421993692133194,
14.404662963129736,
14.387223170155227,
14.37020466701995,
14.353859917457635,
14.338545216923173,
14.324186105544184,
14.308834813285978,
14.308834813285978,
14.306886607015946,
14.304937943912059,
14.302988824047128,
14.301039247493975,
14.299089214325436,
14.297138724614353,
14.295187778433588,
14.293236375856011,
14.291284516954507,
14.291284516954507,
14.306635788511533,
14.320994880524745,
14.336309560401913,
14.352654287914442,
14.369672768087579,
14.387112537527909,
14.404443243140717,
14.421773839192735,
14.439141239220161,
14.457127618058182,
14.475112780420512,
14.492730789842467,
14.510449575840047,
14.528117398457308,
14.545777421591907,
14.563052833040334,
14.580021189337284,
14.597628184681124,
14.61560831178686,
14.633420441370644,
14.633420441370644,
14.635372397238491,
14.637323885376862,
14.639274905712277,
14.641225458171254,
14.643175542680329,
14.64512515916606,
14.647074307555004,
14.64902298777374,
14.650971199748858,
]
)
np.testing.assert_array_almost_equal(
boundary.boundary.coords.xy[0], bound_lons
)
np.testing.assert_array_almost_equal(
boundary.boundary.coords.xy[1], bound_lats
)
[docs]
@unittest.skip("Not implemented")
def test_make_subfault_gdf(self):
pass
[docs]
@unittest.skip("Not implemented")
def test_make_rupture_gdf(self):
pass
[docs]
def test_merge_meshes_no_overlap(self):
subs = get_subsections_from_fault(
self.faults[0],
[15, 15],
2.0,
2.0,
surface=self.faults[0]['surface'],
)
lons = [sf['surface'].mesh.lons for sf in subs]
positions = [sf['fault_position'] for sf in subs]
merged_mesh = merge_meshes_no_overlap(lons, positions)
# fmt: off
lons = np.array([[-89.59956649, -89.59710726, -89.59743074, -89.600733 ,
-89.59628538, -89.59116943, -89.59245491, -89.59578301,
-89.59578301, -89.59892035, -89.59799905, -89.59628136,
-89.59619329, -89.59414046, -89.58948685, -89.58475432,
-89.58475432, -89.5801438 , -89.57546779, -89.56941325,
-89.56174884, -89.55233884, -89.54176322, -89.53255056],
[-89.60980979, -89.60734977, -89.60767245, -89.61097393,
-89.60652555, -89.60140884, -89.60269354, -89.60602086,
-89.60602086, -89.60915742, -89.60823534, -89.60651687,
-89.60642801, -89.6043744 , -89.59972004, -89.59498675,
-89.59498675, -89.59037547, -89.5856987 , -89.57964343,
-89.57197831, -89.56256765, -89.5519914 , -89.54277807],
[-89.62005291, -89.6175921 , -89.61791398, -89.62121468,
-89.61676555, -89.61164807, -89.612932 , -89.61625853,
-89.61625853, -89.61939432, -89.61847146, -89.6167522 ,
-89.61666256, -89.61460817, -89.60995305, -89.605219 ,
-89.605219 , -89.60060696, -89.59592944, -89.58987343,
-89.58220761, -89.57279628, -89.56221941, -89.55300542],
[-89.63029586, -89.62783425, -89.62815534, -89.63145525,
-89.62700537, -89.62188713, -89.62317028, -89.62649604,
-89.62649604, -89.62963104, -89.62870741, -89.62698737,
-89.62689693, -89.62484177, -89.62018588, -89.61545108,
-89.61545108, -89.61083828, -89.60616001, -89.60010326,
-89.59243673, -89.58302475, -89.57244725, -89.56323259],
[-89.64053863, -89.63807623, -89.63839652, -89.64169565,
-89.63724501, -89.63212601, -89.63340839, -89.63673337,
-89.63673337, -89.63986759, -89.63894318, -89.63722235,
-89.63713113, -89.6350752 , -89.63041855, -89.62568299,
-89.62568299, -89.62106943, -89.6163904 , -89.61033292,
-89.60266569, -89.59325304, -89.58267492, -89.5734596 ],
[-89.65078122, -89.64831804, -89.64863753, -89.65193587,
-89.64748448, -89.64236472, -89.64364632, -89.64697052,
-89.64697052, -89.65010397, -89.64917878, -89.64745717,
-89.64736515, -89.64530845, -89.64065104, -89.63591472,
-89.63591472, -89.63130041, -89.62662062, -89.6205624 ,
-89.61289447, -89.60348116, -89.59290241, -89.58368643],
[-89.66102364, -89.65855966, -89.65887836, -89.66217592,
-89.65772377, -89.65260325, -89.65388408, -89.6572075 ,
-89.6572075 , -89.66034017, -89.6594142 , -89.65769181,
-89.65759901, -89.65554152, -89.65088336, -89.64614628,
-89.64614628, -89.64153121, -89.63685067, -89.63079172,
-89.62312308, -89.61370911, -89.60312974, -89.59391309],
[-89.67126588, -89.66880112, -89.66911901, -89.6724158 ,
-89.66796289, -89.66284161, -89.66412166, -89.6674443 ,
-89.6674443 , -89.67057619, -89.66964945, -89.66792628,
-89.66783269, -89.66577443, -89.6611155 , -89.65637767,
-89.65637767, -89.65176184, -89.64708055, -89.64102086,
-89.63335152, -89.62393689, -89.61335689, -89.60413958],
[-89.68150795, -89.67904239, -89.67935949, -89.6826555 ,
-89.67820183, -89.67307979, -89.67435907, -89.67768093,
-89.67768093, -89.68081204, -89.67988453, -89.67816057,
-89.67806619, -89.67600716, -89.67134747, -89.66660889,
-89.66660889, -89.6619923 , -89.65731025, -89.65124983,
-89.64357978, -89.6341645 , -89.62358387, -89.61436589],
[-89.69174984, -89.68928349, -89.6895998 , -89.69289502,
-89.6884406 , -89.6833178 , -89.6845963 , -89.68791739,
-89.68791739, -89.69104772, -89.69011943, -89.68839469,
-89.68829953, -89.68623972, -89.68157927, -89.67683993,
-89.67683993, -89.67222259, -89.66753978, -89.66147863,
-89.65380788, -89.64439193, -89.63381068, -89.62459204]])
# fmt: on
np.testing.assert_array_almost_equal(merged_mesh, lons)
[docs]
def test_make_mesh_from_subfaults(self):
subs = get_subsections_from_fault(
self.faults[0],
[15, 15],
2.0,
2.0,
surface=self.faults[0]['surface'],
)
merged_mesh = make_mesh_from_subfaults(subs)
# fmt: off
lons = np.array([
[-89.59956649, -89.59710726, -89.59743074, -89.600733 ,
-89.59628538, -89.59116943, -89.59245491, -89.59578301,
-89.59578301, -89.59892035, -89.59799905, -89.59628136,
-89.59619329, -89.59414046, -89.58948685, -89.58475432,
-89.58475432, -89.5801438 , -89.57546779, -89.56941325,
-89.56174884, -89.55233884, -89.54176322, -89.53255056],
[-89.60980979, -89.60734977, -89.60767245, -89.61097393,
-89.60652555, -89.60140884, -89.60269354, -89.60602086,
-89.60602086, -89.60915742, -89.60823534, -89.60651687,
-89.60642801, -89.6043744 , -89.59972004, -89.59498675,
-89.59498675, -89.59037547, -89.5856987 , -89.57964343,
-89.57197831, -89.56256765, -89.5519914 , -89.54277807],
[-89.62005291, -89.6175921 , -89.61791398, -89.62121468,
-89.61676555, -89.61164807, -89.612932 , -89.61625853,
-89.61625853, -89.61939432, -89.61847146, -89.6167522 ,
-89.61666256, -89.61460817, -89.60995305, -89.605219 ,
-89.605219 , -89.60060696, -89.59592944, -89.58987343,
-89.58220761, -89.57279628, -89.56221941, -89.55300542],
[-89.63029586, -89.62783425, -89.62815534, -89.63145525,
-89.62700537, -89.62188713, -89.62317028, -89.62649604,
-89.62649604, -89.62963104, -89.62870741, -89.62698737,
-89.62689693, -89.62484177, -89.62018588, -89.61545108,
-89.61545108, -89.61083828, -89.60616001, -89.60010326,
-89.59243673, -89.58302475, -89.57244725, -89.56323259],
[-89.64053863, -89.63807623, -89.63839652, -89.64169565,
-89.63724501, -89.63212601, -89.63340839, -89.63673337,
-89.63673337, -89.63986759, -89.63894318, -89.63722235,
-89.63713113, -89.6350752 , -89.63041855, -89.62568299,
-89.62568299, -89.62106943, -89.6163904 , -89.61033292,
-89.60266569, -89.59325304, -89.58267492, -89.5734596 ],
[-89.65078122, -89.64831804, -89.64863753, -89.65193587,
-89.64748448, -89.64236472, -89.64364632, -89.64697052,
-89.64697052, -89.65010397, -89.64917878, -89.64745717,
-89.64736515, -89.64530845, -89.64065104, -89.63591472,
-89.63591472, -89.63130041, -89.62662062, -89.6205624 ,
-89.61289447, -89.60348116, -89.59290241, -89.58368643],
[-89.66102364, -89.65855966, -89.65887836, -89.66217592,
-89.65772377, -89.65260325, -89.65388408, -89.6572075 ,
-89.6572075 , -89.66034017, -89.6594142 , -89.65769181,
-89.65759901, -89.65554152, -89.65088336, -89.64614628,
-89.64614628, -89.64153121, -89.63685067, -89.63079172,
-89.62312308, -89.61370911, -89.60312974, -89.59391309],
[-89.67126588, -89.66880112, -89.66911901, -89.6724158 ,
-89.66796289, -89.66284161, -89.66412166, -89.6674443 ,
-89.6674443 , -89.67057619, -89.66964945, -89.66792628,
-89.66783269, -89.66577443, -89.6611155 , -89.65637767,
-89.65637767, -89.65176184, -89.64708055, -89.64102086,
-89.63335152, -89.62393689, -89.61335689, -89.60413958],
[-89.68150795, -89.67904239, -89.67935949, -89.6826555 ,
-89.67820183, -89.67307979, -89.67435907, -89.67768093,
-89.67768093, -89.68081204, -89.67988453, -89.67816057,
-89.67806619, -89.67600716, -89.67134747, -89.66660889,
-89.66660889, -89.6619923 , -89.65731025, -89.65124983,
-89.64357978, -89.6341645 , -89.62358387, -89.61436589],
[-89.69174984, -89.68928349, -89.6895998 , -89.69289502,
-89.6884406 , -89.6833178 , -89.6845963 , -89.68791739,
-89.68791739, -89.69104772, -89.69011943, -89.68839469,
-89.68829953, -89.68623972, -89.68157927, -89.67683993,
-89.67683993, -89.67222259, -89.66753978, -89.66147863,
-89.65380788, -89.64439193, -89.63381068, -89.62459204]])
lats = np.array([
[14.6509712 , 14.63400729, 14.61689137, 14.60008726, 14.58383568,
14.56744137, 14.55071385, 14.53388954, 14.53388954, 14.51703145,
14.50021396, 14.48324254, 14.46611319, 14.44924854, 14.43272214,
14.41621674, 14.41621674, 14.3996801 , 14.38317108, 14.36709133,
14.35167207, 14.33717766, 14.32345507, 14.30883481],
[14.64908995, 14.63212604, 14.61501012, 14.59820601, 14.58195443,
14.56556013, 14.5488326 , 14.53200829, 14.53200829, 14.5151502 ,
14.49833272, 14.48136129, 14.46423194, 14.4473673 , 14.4308409 ,
14.41433549, 14.41433549, 14.39779886, 14.38128984, 14.36521008,
14.34979082, 14.33529641, 14.32157382, 14.30695357],
[14.64720825, 14.63024435, 14.61312842, 14.59632432, 14.58007274,
14.56367843, 14.5469509 , 14.5301266 , 14.5301266 , 14.51326851,
14.49645102, 14.4794796 , 14.46235025, 14.44548561, 14.42895921,
14.4124538 , 14.4124538 , 14.39591717, 14.37940815, 14.3633284 ,
14.34790914, 14.33341473, 14.31969214, 14.30507189],
[14.64532611, 14.6283622 , 14.61124628, 14.59444217, 14.5781906 ,
14.56179629, 14.54506877, 14.52824446, 14.52824446, 14.51138638,
14.49456889, 14.47759747, 14.46046812, 14.44360348, 14.42707708,
14.41057168, 14.41057168, 14.39403505, 14.37752603, 14.36144628,
14.34602701, 14.33153261, 14.31781002, 14.30318977],
[14.64344351, 14.62647961, 14.60936369, 14.59255959, 14.57630801,
14.55991371, 14.54318618, 14.52636188, 14.52636188, 14.5095038 ,
14.49268631, 14.47571489, 14.45858554, 14.44172091, 14.42519451,
14.40868911, 14.40868911, 14.39215248, 14.37564346, 14.35956371,
14.34414445, 14.32965005, 14.31592746, 14.30130721],
[14.64156047, 14.62459657, 14.60748065, 14.59067655, 14.57442498,
14.55803068, 14.54130316, 14.52447886, 14.52447886, 14.50762078,
14.49080329, 14.47383187, 14.45670253, 14.43983789, 14.4233115 ,
14.4068061 , 14.4068061 , 14.39026947, 14.37376046, 14.35768071,
14.34226146, 14.32776705, 14.31404447, 14.29942422],
[14.63967698, 14.62271308, 14.60559717, 14.58879307, 14.5725415 ,
14.5561472 , 14.53941968, 14.52259539, 14.52259539, 14.50573731,
14.48891983, 14.47194841, 14.45481907, 14.43795444, 14.42142805,
14.40492265, 14.40492265, 14.38838603, 14.37187702, 14.35579727,
14.34037802, 14.32588362, 14.31216104, 14.29754079],
[14.63779304, 14.62082915, 14.60371324, 14.58690914, 14.57065758,
14.55426328, 14.53753577, 14.52071147, 14.52071147, 14.5038534 ,
14.48703592, 14.47006451, 14.45293517, 14.43607054, 14.41954415,
14.40303876, 14.40303876, 14.38650214, 14.36999314, 14.35391339,
14.33849414, 14.32399975, 14.31027717, 14.29565692],
[14.63590866, 14.61894477, 14.60182886, 14.58502477, 14.56877321,
14.55237892, 14.53565141, 14.51882712, 14.51882712, 14.50196905,
14.48515157, 14.46818016, 14.45105083, 14.43418621, 14.41765982,
14.40115443, 14.40115443, 14.38461782, 14.36810882, 14.35202908,
14.33660983, 14.32211544, 14.30839286, 14.29377262],
[14.63402382, 14.61705994, 14.59994404, 14.58313995, 14.56688839,
14.55049411, 14.5337666 , 14.51694232, 14.51694232, 14.50008425,
14.48326678, 14.46629538, 14.44916605, 14.43230143, 14.41577505,
14.39926966, 14.39926966, 14.38273305, 14.36622406, 14.35014432,
14.33472508, 14.32023069, 14.30650812, 14.29188788]])
depths = np.array([
[ 0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. ],
[ 1.65494864, 1.65494864, 1.65494864, 1.65494864, 1.65494864,
1.65494864, 1.65494864, 1.65494864, 1.65494864, 1.65494864,
1.65494864, 1.65494864, 1.65494864, 1.65494864, 1.65494864,
1.65494864, 1.65494864, 1.65494864, 1.65494864, 1.65494864,
1.65494864, 1.65494864, 1.65494864, 1.65494864],
[ 3.30989727, 3.30989727, 3.30989727, 3.30989727, 3.30989727,
3.30989727, 3.30989727, 3.30989727, 3.30989727, 3.30989727,
3.30989727, 3.30989727, 3.30989727, 3.30989727, 3.30989727,
3.30989727, 3.30989727, 3.30989727, 3.30989727, 3.30989727,
3.30989727, 3.30989727, 3.30989727, 3.30989727],
[ 4.96484591, 4.96484591, 4.96484591, 4.96484591, 4.96484591,
4.96484591, 4.96484591, 4.96484591, 4.96484591, 4.96484591,
4.96484591, 4.96484591, 4.96484591, 4.96484591, 4.96484591,
4.96484591, 4.96484591, 4.96484591, 4.96484591, 4.96484591,
4.96484591, 4.96484591, 4.96484591, 4.96484591],
[ 6.61979455, 6.61979455, 6.61979455, 6.61979455, 6.61979455,
6.61979455, 6.61979455, 6.61979455, 6.61979455, 6.61979455,
6.61979455, 6.61979455, 6.61979455, 6.61979455, 6.61979455,
6.61979455, 6.61979455, 6.61979455, 6.61979455, 6.61979455,
6.61979455, 6.61979455, 6.61979455, 6.61979455],
[ 8.27474318, 8.27474318, 8.27474318, 8.27474318, 8.27474318,
8.27474318, 8.27474318, 8.27474318, 8.27474318, 8.27474318,
8.27474318, 8.27474318, 8.27474318, 8.27474318, 8.27474318,
8.27474318, 8.27474318, 8.27474318, 8.27474318, 8.27474318,
8.27474318, 8.27474318, 8.27474318, 8.27474318],
[ 9.92969182, 9.92969182, 9.92969182, 9.92969182, 9.92969182,
9.92969182, 9.92969182, 9.92969182, 9.92969182, 9.92969182,
9.92969182, 9.92969182, 9.92969182, 9.92969182, 9.92969182,
9.92969182, 9.92969182, 9.92969182, 9.92969182, 9.92969182,
9.92969182, 9.92969182, 9.92969182, 9.92969182],
[11.58464046, 11.58464046, 11.58464046, 11.58464046, 11.58464046,
11.58464046, 11.58464046, 11.58464046, 11.58464046, 11.58464046,
11.58464046, 11.58464046, 11.58464046, 11.58464046, 11.58464046,
11.58464046, 11.58464046, 11.58464046, 11.58464046, 11.58464046,
11.58464046, 11.58464046, 11.58464046, 11.58464046],
[13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 ,
13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 ,
13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 ,
13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 ,
13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 ],
[14.89453773, 14.89453773, 14.89453773, 14.89453773, 14.89453773,
14.89453773, 14.89453773, 14.89453773, 14.89453773, 14.89453773,
14.89453773, 14.89453773, 14.89453773, 14.89453773, 14.89453773,
14.89453773, 14.89453773, 14.89453773, 14.89453773, 14.89453773,
14.89453773, 14.89453773, 14.89453773, 14.89453773]])
"""
lons = np.array([
[-89.59956649, -89.59698431, -89.59747773, -89.60127551,
-89.59511132, -89.58993769, -89.59346174, -89.59694355,
-89.60013675, -89.59639589, -89.59617726, -89.59621093,
-89.59138007, -89.58641064, -89.58144199, -89.57689865,
-89.5708895 , -89.56313984, -89.55340368, -89.5422239 ,
-89.53255056],
[-89.60980979, -89.60722678, -89.60771936, -89.61151631,
-89.60535133, -89.60017691, -89.60370013, -89.60718113,
-89.61037351, -89.60663183, -89.60641237, -89.60644521,
-89.60161356, -89.59664333, -89.59167388, -89.58712975,
-89.58111981, -89.57336941, -89.56363255, -89.55245212,
-89.54277807],
[-89.62005291, -89.61746907, -89.61796081, -89.62175695,
-89.61559118, -89.61041595, -89.61393836, -89.61741853,
-89.62061009, -89.6168676 , -89.61664731, -89.61667932,
-89.61184687, -89.60687585, -89.60190561, -89.59736067,
-89.59134996, -89.58359881, -89.57386125, -89.56268016,
-89.55300542],
[-89.63029586, -89.62771118, -89.62820209, -89.6319974 ,
-89.62583085, -89.62065482, -89.6241764 , -89.62765576,
-89.6308465 , -89.6271032 , -89.62688208, -89.62691326,
-89.62208001, -89.61710819, -89.61213716, -89.60759142,
-89.60157993, -89.59382803, -89.58408977, -89.57290803,
-89.56323259],
[-89.64053863, -89.63795312, -89.63844319, -89.64223769,
-89.63607034, -89.63089351, -89.63441428, -89.63789282,
-89.64108274, -89.63733862, -89.63711667, -89.63714703,
-89.63231298, -89.62734037, -89.62236853, -89.617822 ,
-89.61180973, -89.60405709, -89.59431813, -89.58313574,
-89.5734596 ],
[-89.65078122, -89.64819489, -89.64868412, -89.65247779,
-89.64630966, -89.64113202, -89.64465198, -89.6481297 ,
-89.6513188 , -89.64757387, -89.64735109, -89.64738062,
-89.64254577, -89.63757237, -89.63259974, -89.62805241,
-89.62203936, -89.61428597, -89.60454631, -89.59336327,
-89.58368643],
[-89.66102364, -89.65843648, -89.65892487, -89.66271773,
-89.6565488 , -89.65137037, -89.6548895 , -89.6583664 ,
-89.66155469, -89.65780895, -89.65758534, -89.65761404,
-89.6527784 , -89.64780419, -89.64283077, -89.63828264,
-89.63226882, -89.62451468, -89.61477432, -89.60359062,
-89.59391309],
[-89.67126588, -89.66867789, -89.66916544, -89.67295748,
-89.66678777, -89.66160853, -89.66512685, -89.66860294,
-89.67179041, -89.66804385, -89.66781941, -89.66784729,
-89.66301084, -89.65803585, -89.65306163, -89.6485127 ,
-89.6424981 , -89.63474322, -89.62500216, -89.61381781,
-89.60413958],
[-89.68150795, -89.67891912, -89.67940584, -89.68319706,
-89.67702657, -89.67184653, -89.67536403, -89.6788393 ,
-89.68202595, -89.67827858, -89.67805331, -89.67808036,
-89.67324312, -89.66826733, -89.66329232, -89.65874259,
-89.65272721, -89.64497158, -89.63522983, -89.62404482,
-89.61436589]])
lats = np.array([
[14.6509712 , 14.6331591 , 14.61517898, 14.59757197, 14.5806036 ,
14.56332817, 14.54566811, 14.52800025, 14.51028142, 14.49266336,
14.47467815, 14.45669174, 14.43932431, 14.42199369, 14.40466296,
14.38722317, 14.37020467, 14.35385992, 14.33854522, 14.32418611,
14.30883481],
[14.64908995, 14.63127785, 14.61329773, 14.59569072, 14.57872235,
14.56144692, 14.54378686, 14.526119 , 14.50840017, 14.49078211,
14.4727969 , 14.45481049, 14.43744306, 14.42011245, 14.40278172,
14.38534192, 14.36832342, 14.35197867, 14.33666397, 14.32230486,
14.30695357],
[14.64720825, 14.62939615, 14.61141603, 14.59380903, 14.57684065,
14.55956522, 14.54190517, 14.52423731, 14.50651848, 14.48890042,
14.47091521, 14.4529288 , 14.43556138, 14.41823076, 14.40090003,
14.38346024, 14.36644174, 14.35009699, 14.33478229, 14.32042318,
14.30507189],
[14.64532611, 14.627514 , 14.60953389, 14.59192688, 14.57495851,
14.55768308, 14.54002303, 14.52235517, 14.50463634, 14.48701829,
14.46903308, 14.45104667, 14.43367925, 14.41634863, 14.3990179 ,
14.38157811, 14.36455961, 14.34821487, 14.33290017, 14.31854106,
14.30318977],
[14.64344351, 14.62563141, 14.6076513 , 14.5900443 , 14.57307593,
14.5558005 , 14.53814045, 14.52047259, 14.50275376, 14.48513571,
14.46715051, 14.4491641 , 14.43179668, 14.41446606, 14.39713534,
14.37969555, 14.36267705, 14.3463323 , 14.33101761, 14.3166585 ,
14.30130721],
[14.64156047, 14.62374837, 14.60576826, 14.58816126, 14.5711929 ,
14.55391747, 14.53625742, 14.51858957, 14.50087074, 14.48325269,
14.46526749, 14.44728108, 14.42991367, 14.41258305, 14.39525233,
14.37781254, 14.36079405, 14.34444931, 14.32913461, 14.31477551,
14.29942422],
[14.63967698, 14.62186489, 14.60388478, 14.58627778, 14.56930942,
14.552034 , 14.53437395, 14.5167061 , 14.49898728, 14.48136923,
14.46338403, 14.44539763, 14.42803021, 14.4106996 , 14.39336888,
14.3759291 , 14.35891061, 14.34256587, 14.32725118, 14.31289207,
14.29754079],
[14.63779304, 14.61998095, 14.60200085, 14.58439385, 14.5674255 ,
14.55015008, 14.53249004, 14.51482219, 14.49710337, 14.47948533,
14.46150013, 14.44351373, 14.42614632, 14.40881571, 14.391485 ,
14.37404522, 14.35702673, 14.34068199, 14.3253673 , 14.3110082 ,
14.29565692],
[14.63590866, 14.61809657, 14.60011647, 14.58250948, 14.56554113,
14.54826571, 14.53060568, 14.51293783, 14.49521902, 14.47760098,
14.45961579, 14.44162939, 14.42426198, 14.40693138, 14.38960067,
14.3721609 , 14.35514241, 14.33879768, 14.32348299, 14.3091239 ,
14.29377262]])
depths = np.array([
[ 0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. ],
[ 1.65494864, 1.65494864, 1.65494864, 1.65494864, 1.65494864,
1.65494864, 1.65494864, 1.65494864, 1.65494864, 1.65494864,
1.65494864, 1.65494864, 1.65494864, 1.65494864, 1.65494864,
1.65494864, 1.65494864, 1.65494864, 1.65494864, 1.65494864,
1.65494864],
[ 3.30989727, 3.30989727, 3.30989727, 3.30989727, 3.30989727,
3.30989727, 3.30989727, 3.30989727, 3.30989727, 3.30989727,
3.30989727, 3.30989727, 3.30989727, 3.30989727, 3.30989727,
3.30989727, 3.30989727, 3.30989727, 3.30989727, 3.30989727,
3.30989727],
[ 4.96484591, 4.96484591, 4.96484591, 4.96484591, 4.96484591,
4.96484591, 4.96484591, 4.96484591, 4.96484591, 4.96484591,
4.96484591, 4.96484591, 4.96484591, 4.96484591, 4.96484591,
4.96484591, 4.96484591, 4.96484591, 4.96484591, 4.96484591,
4.96484591],
[ 6.61979455, 6.61979455, 6.61979455, 6.61979455, 6.61979455,
6.61979455, 6.61979455, 6.61979455, 6.61979455, 6.61979455,
6.61979455, 6.61979455, 6.61979455, 6.61979455, 6.61979455,
6.61979455, 6.61979455, 6.61979455, 6.61979455, 6.61979455,
6.61979455],
[ 8.27474318, 8.27474318, 8.27474318, 8.27474318, 8.27474318,
8.27474318, 8.27474318, 8.27474318, 8.27474318, 8.27474318,
8.27474318, 8.27474318, 8.27474318, 8.27474318, 8.27474318,
8.27474318, 8.27474318, 8.27474318, 8.27474318, 8.27474318,
8.27474318],
[ 9.92969182, 9.92969182, 9.92969182, 9.92969182, 9.92969182,
9.92969182, 9.92969182, 9.92969182, 9.92969182, 9.92969182,
9.92969182, 9.92969182, 9.92969182, 9.92969182, 9.92969182,
9.92969182, 9.92969182, 9.92969182, 9.92969182, 9.92969182,
9.92969182],
[11.58464046, 11.58464046, 11.58464046, 11.58464046, 11.58464046,
11.58464046, 11.58464046, 11.58464046, 11.58464046, 11.58464046,
11.58464046, 11.58464046, 11.58464046, 11.58464046, 11.58464046,
11.58464046, 11.58464046, 11.58464046, 11.58464046, 11.58464046,
11.58464046],
[13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 ,
13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 ,
13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 ,
13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 , 13.2395891 ,
13.2395891 ]])
"""
# fmt: on
mesh = RectangularMesh(lons, lats, depths)
assert mesh == merged_mesh
[docs]
def test_make_sf_rupture_mesh(self):
fault = self.faults[0]
subs = get_subsections_from_fault(
fault, subsection_size=[10, 10], surface=fault['surface']
)
mesh = make_sf_rupture_mesh([1, 2, 5, 6], subs)
# fmt: off
lons = np.array([
[-89.58993769, -89.59346174, -89.59694355, -89.60013675,
-89.59639589, -89.59617726, -89.59617726, -89.59621093,
-89.59138007, -89.58641064, -89.58144199, -89.57689865],
[-89.6014568 , -89.60497992, -89.60846081, -89.61165309,
-89.60791131, -89.60769175, -89.60769175, -89.60772449,
-89.60289273, -89.59792241, -89.59295286, -89.58840862],
[-89.61297568, -89.61649789, -89.61997785, -89.62316921,
-89.61942652, -89.61920602, -89.61920602, -89.61923783,
-89.61440517, -89.60943395, -89.60446351, -89.59991838],
[-89.62449434, -89.62801563, -89.63149468, -89.63468511,
-89.6309415 , -89.63072007, -89.63072007, -89.63075095,
-89.6259174 , -89.62094528, -89.61597394, -89.61142791],
[-89.63601279, -89.63953315, -89.64301128, -89.64620079,
-89.64245627, -89.6422339 , -89.6422339 , -89.64226385,
-89.6374294 , -89.63245639, -89.62748416, -89.62293723],
[-89.63601279, -89.63953315, -89.64301128, -89.64620079,
-89.64245627, -89.6422339 , -89.6422339 , -89.64226385,
-89.6374294 , -89.63245639, -89.62748416, -89.62293723],
[-89.64753101, -89.65105045, -89.65452766, -89.65771625,
-89.65397081, -89.65374752, -89.65374752, -89.65377653,
-89.64894118, -89.64396728, -89.63899415, -89.63444633],
[-89.65904901, -89.66256753, -89.66604382, -89.66923149,
-89.66548514, -89.66526091, -89.66526091, -89.66528899,
-89.66045275, -89.65547795, -89.65050393, -89.64595521],
[-89.67056679, -89.67408439, -89.67755976, -89.68074651,
-89.67699925, -89.67677409, -89.67677409, -89.67680124,
-89.67196409, -89.6669884 , -89.66201349, -89.65746387],
[-89.68208435, -89.68560103, -89.68907548, -89.69226131,
-89.68851313, -89.68828704, -89.68828704, -89.68831326,
-89.68347522, -89.67849863, -89.67352283, -89.66897231]])
lats = np.array([
[14.56332817, 14.54566811, 14.52800025, 14.51028142, 14.49266336,
14.47467815, 14.47467815, 14.45669174, 14.43932431, 14.42199369,
14.40466296, 14.38722317],
[14.56121173, 14.54355167, 14.52588381, 14.50816498, 14.49054693,
14.47256172, 14.47256172, 14.4545753 , 14.43720788, 14.41987726,
14.40254653, 14.38510674],
[14.55909473, 14.54143468, 14.52376681, 14.50604799, 14.48842993,
14.47044472, 14.47044472, 14.45245831, 14.43509089, 14.41776027,
14.40042954, 14.38298975],
[14.55697717, 14.53931711, 14.52164925, 14.50393043, 14.48631238,
14.46832717, 14.46832717, 14.45034076, 14.43297334, 14.41564272,
14.39831199, 14.3808722 ],
[14.55485904, 14.53719899, 14.51953113, 14.50181231, 14.48419426,
14.46620905, 14.46620905, 14.44822264, 14.43085523, 14.41352461,
14.39619389, 14.3787541 ],
[14.55485904, 14.53719899, 14.51953113, 14.50181231, 14.48419426,
14.46620905, 14.46620905, 14.44822264, 14.43085523, 14.41352461,
14.39619389, 14.3787541 ],
[14.55274035, 14.5350803 , 14.51741245, 14.49969363, 14.48207558,
14.46409038, 14.46409038, 14.44610397, 14.42873656, 14.41140595,
14.39407523, 14.37663544],
[14.5506211 , 14.53296106, 14.5152932 , 14.49757439, 14.47995634,
14.46197115, 14.46197115, 14.44398474, 14.42661733, 14.40928673,
14.39195601, 14.37451623],
[14.54850128, 14.53084124, 14.5131734 , 14.49545459, 14.47783655,
14.45985135, 14.45985135, 14.44186496, 14.42449755, 14.40716695,
14.38983624, 14.37239646],
[14.5463809 , 14.52872087, 14.51105303, 14.49333422, 14.47571619,
14.457731 , 14.457731 , 14.43974461, 14.42237721, 14.40504661,
14.38771591, 14.37027614]])
depths = np.array([
[ 0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. ],
[ 1.86181722, 1.86181722, 1.86181722, 1.86181722, 1.86181722,
1.86181722, 1.86181722, 1.86181722, 1.86181722, 1.86181722,
1.86181722, 1.86181722],
[ 3.72363443, 3.72363443, 3.72363443, 3.72363443, 3.72363443,
3.72363443, 3.72363443, 3.72363443, 3.72363443, 3.72363443,
3.72363443, 3.72363443],
[ 5.58545165, 5.58545165, 5.58545165, 5.58545165, 5.58545165,
5.58545165, 5.58545165, 5.58545165, 5.58545165, 5.58545165,
5.58545165, 5.58545165],
[ 7.44726887, 7.44726887, 7.44726887, 7.44726887, 7.44726887,
7.44726887, 7.44726887, 7.44726887, 7.44726887, 7.44726887,
7.44726887, 7.44726887],
[ 7.44726887, 7.44726887, 7.44726887, 7.44726887, 7.44726887,
7.44726887, 7.44726887, 7.44726887, 7.44726887, 7.44726887,
7.44726887, 7.44726887],
[ 9.30908608, 9.30908608, 9.30908608, 9.30908608, 9.30908608,
9.30908608, 9.30908608, 9.30908608, 9.30908608, 9.30908608,
9.30908608, 9.30908608],
[11.1709033 , 11.1709033 , 11.1709033 , 11.1709033 , 11.1709033 ,
11.1709033 , 11.1709033 , 11.1709033 , 11.1709033 , 11.1709033 ,
11.1709033 , 11.1709033 ],
[13.03272052, 13.03272052, 13.03272052, 13.03272052, 13.03272052,
13.03272052, 13.03272052, 13.03272052, 13.03272052, 13.03272052,
13.03272052, 13.03272052],
[14.89453773, 14.89453773, 14.89453773, 14.89453773, 14.89453773,
14.89453773, 14.89453773, 14.89453773, 14.89453773, 14.89453773,
14.89453773, 14.89453773]])
# fmt: on
mesh_ = RectangularMesh(lons, lats, depths)
assert mesh == mesh_
[docs]
@unittest.skip("Not implemented")
def test_make_sf_rupture_meshes(self):
all_subs = [
get_subsections_from_fault(f, [10, 10], f['surface'])
for f in self.faults
]
# not sure how make_sf_rupture_meshes is supposed to be called
[docs]
class MiscTests(unittest.TestCase):
[docs]
def setUp(self) -> None:
return super().setUp()
[docs]
def test_subdivide_simple_fault_surface_small_fault(self):
# fmt: off
lons = np.array([
[70.35170579, 70.34631924, 70.34093482, 70.33555253, 70.3281443 ,
70.32017616, 70.31221103, 70.30461295, 70.29715165, 70.28969318,
70.27944614, 70.26791978, 70.25623503, 70.24120386, 70.22659756,
70.21569018, 70.20478657, 70.19287356, 70.18088533, 70.16459853,
70.14866996, 70.13491515, 70.12206197, 70.11335365, 70.10521899,
70.09778772, 70.09035922, 70.08589394, 70.08557274, 70.08525165,
70.0837769 , 70.08188016, 70.07875238, 70.07503563, 70.06974698,
70.06377094, 70.05731175, 70.04578904, 70.03413644, 70.02214265,
70.01015276],
[70.35136513, 70.34597865, 70.3405943 , 70.33521208, 70.3278039 ,
70.31983583, 70.31187076, 70.30427275, 70.29681151, 70.28935311,
70.27910613, 70.26757983, 70.25589514, 70.24086401, 70.22625776,
70.21535044, 70.20444689, 70.19253394, 70.18054576, 70.16425901,
70.14833048, 70.13457572, 70.1217226 , 70.11301434, 70.10487975,
70.09744854, 70.0900201 , 70.08555488, 70.08523375, 70.08491274,
70.08343805, 70.08154138, 70.07841366, 70.07469698, 70.06940839,
70.06343242, 70.05697329, 70.04545064, 70.0337981 , 70.02180436,
70.00981453]])
lats = np.array([
[32.89095075, 32.87354212, 32.85613329, 32.83872425, 32.82184914,
32.80515565, 32.78846167, 32.77164772, 32.75479099, 32.73793383,
32.72214748, 32.70699942, 32.69193861, 32.6791532 , 32.66602526,
32.65055963, 32.63509307, 32.62016491, 32.60528066, 32.59365105,
32.58167646, 32.56792293, 32.55356467, 32.53714443, 32.52051695,
32.50365748, 32.48679757, 32.46920998, 32.45122556, 32.43324112,
32.41529776, 32.39738267, 32.37959112, 32.36188062, 32.34445773,
32.32719441, 32.31005607, 32.29493446, 32.27988517, 32.26502979,
32.25017325],
[32.89108002, 32.87367139, 32.85626256, 32.83885353, 32.82197842,
32.80528492, 32.78859095, 32.77177699, 32.75492026, 32.73806311,
32.72227675, 32.70712869, 32.69206788, 32.67928247, 32.66615454,
32.6506889 , 32.63522234, 32.62029418, 32.60540994, 32.59378033,
32.58180573, 32.5680522 , 32.55369394, 32.5372737 , 32.52064622,
32.50378675, 32.48692684, 32.46933925, 32.45135483, 32.43337039,
32.41542703, 32.39751194, 32.37972039, 32.36200989, 32.34458701,
32.32732368, 32.31018534, 32.29506373, 32.28001444, 32.26515906,
32.25030252]])
depths = np.array([
[0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. ],
[1.99969535, 1.99969535, 1.99969535, 1.99969535, 1.99969535,
1.99969535, 1.99969535, 1.99969535, 1.99969535, 1.99969535,
1.99969535, 1.99969535, 1.99969535, 1.99969535, 1.99969535,
1.99969535, 1.99969535, 1.99969535, 1.99969535, 1.99969535,
1.99969535, 1.99969535, 1.99969535, 1.99969535, 1.99969535,
1.99969535, 1.99969535, 1.99969535, 1.99969535, 1.99969535,
1.99969535, 1.99969535, 1.99969535, 1.99969535, 1.99969535,
1.99969535, 1.99969535, 1.99969535, 1.99969535, 1.99969535,
1.99969535]])
# fmt: on
surface = SimpleFaultSurface(RectangularMesh(lons, lats, depths))
subs = subdivide_simple_fault_surface(
surface, [15, 15], edge_sd=2.0, dip_sd=5.0
)
# max depth should be max depth of original surface
# even though it is shallower than the dip pt spacing
np.testing.assert_almost_equal(
subs[0]['mesh'].depths[-1][0], 1.99969535, decimal=3
)
[docs]
def test_angular_mean_degrees(self):
angles = [350, 10, 20, 30, 40]
mean = angular_mean_degrees(angles)
scipy_mean = np.degrees(circmean(np.radians(angles)))
np.testing.assert_almost_equal(mean, scipy_mean, decimal=3)
[docs]
def test_weighted_angular_mean_degrees(self):
angles = [350, 10, 20, 30, 40]
weights = [1, 2, 3, 4, 5]
mean = weighted_angular_mean_degrees(angles, weights)
np.testing.assert_almost_equal(mean, 26.141656559913944, decimal=3)