示例#1
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()
示例#2
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)
示例#3
0
# Base subfault - based on reconstruction by UCSB
# http://www.geol.ucsb.edu/faculty/ji/big_earthquakes/2011/03/0311_v3/Honshu.html
#
subfault = dtopotools.SubFault()
subfault.strike = 198.0
subfault.length = 19 * 25.0 * 1000.0
subfault.width = 10 * 20.0 * 1000.0
subfault.depth = 7.50520 * 1000.0
subfault.slip = ave_slip
subfault.rake = 90.0
subfault.dip = 10.0
subfault.latitude = 37.64165
subfault.longitude = 143.72745
subfault.coordinate_specification = "top center"
fault = dtopotools.SubdividedPlaneFault(subfault)

# Create dtopo for comparison
x, y = UCSB_fault.create_dtopo_xy()
UCSB_dtopo = UCSB_fault.create_dtopography(x, y)
x, y = fault.create_dtopo_xy()
dtopo = fault.create_dtopography(x, y)

# Plot results
fig = plt.figure()
axes = fig.add_subplot(121)
UCSB_dtopo.plot_dZ_colors(t=numpy.max(UCSB_dtopo.times), axes=axes)
axes = fig.add_subplot(122)
dtopo.plot_dZ_colors(t=numpy.max(dtopo.times), axes=axes)

fig = plt.figure()
示例#4
0
    def __init__(self, slips):
        r"""
        Initialize a FaultJob object.
        
        See :class:`FaultJob` for full documentation
        
        """

        super(FaultJob, self).__init__()

        # Create fault
        # Based on UCSB reconstruction and assumption of single subfault
        # Lengths are based on num_fault_segments * dx * m/km in each direction
        #
        # Top edge    Bottom edge
        #   a ----------- b          ^
        #   |             |          |         ^
        #   |             |          |         |
        #   |             |          |         | along-strike direction
        #   |             |          |         |
        #   0------1------2          | length  |
        #   |             |          |
        #   |             |          |
        #   |             |          |
        #   |             |          |
        #   d ----------- c          v
        #   <------------->
        #       width
        # <-- up dip direction
        #
        #  Given
        #      Long            Lat             Depth
        #  a = 144.56380       39.66720        7.50520
        #  b = 140.76530       36.15960       41.96770
        #  c = 142.43800       40.21080       41.96770
        #  d = 142.89110       35.61610        7.50520
        #  Computed
        #      Long            Lat             Depth
        #  0 = 143.72745       37.64165        7.50520
        # Comparison Fault System
        UCSB_fault = dtopotools.UCSBFault('./UCSB_model3_subfault.txt')

        # Use data from the reconstruced UCSB fault to setup our fault system
        # Calculate average quantities across all subfaults
        ave_rake = 0.0
        ave_strike = 0.0
        ave_slip = 0.0
        for subfault in UCSB_fault.subfaults:
            ave_rake = subfault.rake
            ave_strike = subfault.strike
            ave_slip = subfault.slip

        ave_rake /= len(UCSB_fault.subfaults)
        ave_strike /= len(UCSB_fault.subfaults)
        ave_slip /= len(UCSB_fault.subfaults)

        # Base subfault
        self.base_subfault = dtopotools.SubFault()
        self.base_subfault.strike = 198.0
        self.base_subfault.length = 19 * 25.0 * 1000.0
        self.base_subfault.width = 10 * 20.0 * 1000.0
        self.base_subfault.depth = 7.50520 * 1000.0
        self.base_subfault.slip = slip
        self.base_subfault.rake = 90.0
        self.base_subfault.dip = 10.0
        self.base_subfault.latitude = 37.64165
        self.base_subfault.longitude = 143.72745
        self.base_subfault.coordinate_specification = "top center"

        # Create base subdivided fault
        self.fault = dtopotools.SubdividedPlaneFault(self.base_subfault,
                                                     nstrike=3,
                                                     ndip=2)
        for (k, subfault) in enumerate(self.fault.subfaults):
            subfault.slip = slips[k]

        self.type = "tohoku"
        self.name = "okada-fault-PC-analysis"
        self.prefix = "fault_s%s" % (self.base_subfault.slip)
        self.executable = 'xgeoclaw'

        # Data objects
        import setrun
        self.rundata = setrun.setrun()

        # No variable friction for the time being
        self.rundata.friction_data.variable_friction = False

        # Replace dtopo file with our own
        self.dtopo_path = 'fault_s%s.tt3' % self.base_subfault.slip
        self.rundata.dtopo_data.dtopofiles = [[3, 4, 4, self.dtopo_path]]
示例#5
0
# subfault parameters for full fault width:
subfault = dtopotools.SubFault()
subfault.coordinate_specification = coordinate_specification
subfault.longitude = 0.
subfault.latitude = 0.
subfault.depth = depth0
subfault.strike = 0.
subfault.length = 1000.e3  # very long since we want 1d cross section
subfault.width = W
subfault.dip = dip
subfault.rake = 90.
subfault.slip = 1.  # will be reset for each realization

# split up into fault with ndip subfaults
#base_fault = dtopotools.Fault([subfault], input_units, coordinate_specification) # needed to set units
fault = dtopotools.SubdividedPlaneFault(subfault, nstrike=1, ndip=ndip)

# grid on which to compute deformation:
n_dtopo = 1001  
x_dtopo = linspace(-2,2,n_dtopo)
xkm_dtopo = x_dtopo * 111.  # convert from degrees to km
y_dtopo = array([-1,0.,1.])  # for 1d slice

nterms = 20
dZ = zeros((n_dtopo,nterms+1)) # to store sea floor deformation corresponding to each mode V[:,j]

for j in range(nterms+1):
    for k,s in enumerate(fault.subfaults):
        s.slip = V[k,j]

    dtopo = fault.create_dtopography(x_dtopo,y_dtopo,times=[1.], verbose=False)
示例#6
0
fault.plot_subfaults(ax)
xticks(range(-128, -123))

# Now subdivide each subfault further

new_subfaults = []  # to accumulate all new subfaults

phi_plate = 60.  # angle oceanic plate moves clockwise from north, to set rake

for subfault in fault.subfaults:
    subfault.rake = subfault.strike - phi_plate - 180.
    # subdivide into nstrike x ndip subfaults, based on the dimensions of the
    # fault:
    nstrike = int(subfault.length / 12000)
    ndip = int(subfault.width / 10000)
    f = dtopotools.SubdividedPlaneFault(subfault, nstrike, ndip)
    new_subfaults = new_subfaults + f.subfaults

# reset fault.subfaults to the new list of all subfaults after subdividing:
new_fault = dtopotools.Fault(subfaults=new_subfaults)
n = len(new_fault.subfaults)
print "Subdivided fault has %s subfaults" % n

ax = subplot(122)
new_fault.plot_subfaults(ax)
xticks(range(-128, -123))

figure(figsize=(6, 10))
ax = subplot(111)
contourf(topo.X, topo.Y, topo.Z, [0, 20000], colors=[[.3, 1, .3]])
fault.plot_subfaults(ax)