Пример #1
0
def test_SubdividedPlaneFault_make_dtopo(save=False):
    r""""""

    # get a unit source fault plane as starting point:
    sift_slip = {'acsza1': 1.}
    fault = dtopotools.SiftFault(sift_slip)
    fault_plane = fault.subfaults[0]
    # Mo = fault_plane.Mo()
    # print "original Mo = ",Mo

    fault2 = dtopotools.SubdividedPlaneFault(fault_plane, nstrike=5, ndip=3)
    # print "new Mo = ",fault2.Mo()
    #fault2.plot_subfaults(slip_color=True)

    assert abs(fault2.Mw() - 6.83402) < 1e-4, \
           "*** Mw is wrong: %g" % fault.Mw()

    xlower = 162.
    xupper = 168.
    ylower = 53.
    yupper = 59.

    # dtopo parameters:
    points_per_degree = 4  # 15 minute resolution
    dx = 1. / points_per_degree
    mx = int((xupper - xlower) / dx + 1)
    xupper = xlower + (mx - 1) * dx
    my = int((yupper - ylower) / dx + 1)
    yupper = ylower + (my - 1) * dx

    x = numpy.linspace(xlower, xupper, mx)
    y = numpy.linspace(ylower, yupper, my)

    times = [1.]
    dtopo = fault2.create_dtopography(x, y, times)

    test_data_path = os.path.join(testdir, "data",
                                  "SubdividedFaultPlane_test_data.tt3")
    if save:
        dtopo.write(test_data_path, dtopo_type=3)
    compare_data = dtopotools.DTopography(path=test_data_path)
    compare_data.read(path=test_data_path, dtopo_type=3)

    assert dtopo.dZ.shape == compare_data.dZ.shape, \
        "dtopo.dZ.shape is %s, should be %s" \
        % (dtopo.dZ.shape, compare_data.dZ.shape)

    assert numpy.allclose(compare_data.dZ, dtopo.dZ)
Пример #2
0
def test_read_sift_make_dtopo(save=False):
    r"""Test reading and making of a SIFT subfault speficied dtopo"""

    sift_slip = {'acsza1': 2, 'acszb1': 3}
    fault = dtopotools.SiftFault(sift_slip)

    assert abs(fault.Mw() -
               7.966666666667) < 1e-4, "*** Mw is wrong: %g" % fault.Mw()

    xlower = 162.
    xupper = 168.
    ylower = 53.
    yupper = 59.

    # dtopo parameters:
    points_per_degree = 4  # 15 minute resolution
    dx = 1. / points_per_degree
    mx = int((xupper - xlower) / dx + 1)
    xupper = xlower + (mx - 1) * dx
    my = int((yupper - ylower) / dx + 1)
    yupper = ylower + (my - 1) * dx

    x = numpy.linspace(xlower, xupper, mx)
    y = numpy.linspace(ylower, yupper, my)

    times = [1.]
    dtopo = fault.create_dtopography(x, y, times)

    test_data_path = os.path.join(testdir, "data", "sift_test_data.tt3")
    if save:
        dtopo.write(test_data_path, dtopo_type=3)
    compare_data = dtopotools.DTopography(path=test_data_path)
    compare_data.read(path=test_data_path, dtopo_type=3)

    assert dtopo.dZ.shape == compare_data.dZ.shape, \
        "dtopo.dZ.shape is %s, should be %s" \
        % (dtopo.dZ.shape, compare_data.dZ.shape)

    assert numpy.allclose(compare_data.dZ, dtopo.dZ)
Пример #3
0
def test_subdivided_plane_fault(verbose=False, plot=False):
    r"""Test SubdividedPlaneFault class"""

    # get a unit source fault plane as starting point:
    sift_slip = {'acsza1': 1.}
    fault = dtopotools.SiftFault(sift_slip)
    fault_plane = fault.subfaults[0]
    Mo = fault_plane.Mo()
    if verbose:
        print("original Mo = ", Mo)

    fault2 = dtopotools.SubdividedPlaneFault(fault_plane, nstrike=5, ndip=3)
    if verbose:
        print("new Mo = ", fault2.Mo())
    if plot:
        import matplotlib.pyplot as plt
        fault2.plot_subfaults(slip_color=True)
        plt.show()

    slip_function = lambda xi, eta: xi * (1 - xi) * eta
    fault2 = dtopotools.SubdividedPlaneFault(fault_plane,
                                             nstrike=5,
                                             ndip=3,
                                             slip_function=slip_function,
                                             Mo=Mo)
    if verbose:
        print("new Mo = ", fault2.Mo())
    if plot:
        fault2.plot_subfaults(slip_color=True)
        plt.show()

    fault2.subdivide(nstrike=20, ndip=10, slip_function=slip_function, Mo=Mo)
    if verbose:
        print("with finer resolution, Mo = ", fault2.Mo())
    if plot:
        fault2.plot_subfaults(slip_color=True)
        plt.show()
Пример #4
0
import matplotlib.pyplot as plt
from clawpack.geoclaw import dtopotools

slip = {}
slip['kiszb24'] = 4.66
slip['kiszb25'] = 12.23
slip['kiszb26'] = 21.27
slip['kisza26'] = 26.31
slip['kiszb27'] = 4.98
slip['kisza27'] = 22.75

f = dtopotools.SiftFault(slip)

# create x-y arrays with 1' resolution and 1 degree buffer around bounding box
x, y = f.create_dtopo_xy(dx=1 / 60., buffer_size=1)

dtopo = f.create_dtopography(x, y, times=[0, 1.], verbose=True)

if 0:
    fname = 'tohoku_sift.tt3'
    dtopo.write(fname, dtopo_type=3)
    print "Created ", fname

# shift longitude to East:
dtopo.x = dtopo.x - 360.
dtopo.X = dtopo.X - 360.
if 1:
    fname = 'tohoku_sift_E.tt3'
    dtopo.write(fname, dtopo_type=3)
    print "Created ", fname