コード例 #1
0
def compute_params_for_MT_source(MT, rake, lon, lat, zerolon, zerolat, mu, lame1):
    """ Given information about point sources from moment tensors,
    Return the right components that get packaged into input_obj. """
    [xcenter, ycenter] = fault_vector_functions.latlon2xy(lon, lat, zerolon, zerolat);
    potency = get_MT_potency(MT, rake, mu, lame1);
    comment = '';
    return [xcenter, ycenter, 0, 0, potency, comment];
コード例 #2
0
def compute_ll_def(inputs, alpha, disp_points):
    """
    Loop through a list of lon/lat and compute their displacements due to all sources put together.
    """
    if not disp_points:
        return []
    model_disp_points = []
    print("Number of disp_points:", len(disp_points))
    for point in disp_points:
        [xi,
         yi] = fault_vector_functions.latlon2xy(point.lon, point.lat,
                                                inputs.zerolon, inputs.zerolat)
        u_disp, v_disp, w_disp, _ = compute_surface_disp_point(
            inputs, alpha, xi, yi)
        model_point = cc.Displacement_points(lon=point.lon,
                                             lat=point.lat,
                                             dE_obs=u_disp[0],
                                             dN_obs=v_disp[0],
                                             dU_obs=w_disp[0],
                                             Se_obs=0,
                                             Sn_obs=0,
                                             Su_obs=0,
                                             name=point.name)
        model_disp_points.append(model_point)
    return model_disp_points
コード例 #3
0
def compute_params_for_point_source(rake, magnitude, lon, lat, zerolon, zerolat, mu):
    """ Given information about point sources from focal mechanisms,
    Return the right components that get packaged into input_obj. """
    [xcenter, ycenter] = fault_vector_functions.latlon2xy(lon, lat, zerolon, zerolat);
    potency = get_DC_potency(rake, magnitude, mu);
    comment = '';
    return [xcenter, ycenter, 0, 0, potency, comment];
コード例 #4
0
def compute_params_for_slip_source(strike, dip, rake, depth, L, W, fault_lon, fault_lat, slip, zerolon, zerolat):
    [xcorner, ycorner] = fault_vector_functions.latlon2xy(fault_lon, fault_lat, zerolon, zerolat);
    # if  hypocenter is really the center of the rupture:
    # xstart, ystart = fault_vector_functions.add_vector_to_point(xcorner, ycorner, -L/2, strike);
    # xfinish, yfinish = fault_vector_functions.add_vector_to_point(xcorner, ycorner, L/2, strike);
    # top, bottom = fault_vector_functions.get_top_bottom_from_center(depth, W, dip);
    # if hypocenter is on one side of rupture:
    xstart, ystart = fault_vector_functions.add_vector_to_point(xcorner, ycorner, 0, strike);
    xfinish, yfinish = fault_vector_functions.add_vector_to_point(xcorner, ycorner, L, strike);
    top, bottom = fault_vector_functions.get_top_bottom_from_top(depth, W, dip);
    rtlat, reverse = fault_vector_functions.get_rtlat_dip_slip(slip, rake);
    comment = '';
    return [xstart, xfinish, ystart, yfinish, rtlat, reverse, top, bottom, comment]
コード例 #5
0
def compute_params_for_WC_source(strike, dip, rake, depth, mag, faulting_type, fault_lon, fault_lat, zerolon, zerolat):
    [xcenter, ycenter] = fault_vector_functions.latlon2xy(fault_lon, fault_lat, zerolon, zerolat);
    L = wells_and_coppersmith.RLD_from_M(mag, faulting_type);  # rupture length
    W = wells_and_coppersmith.RW_from_M(mag, faulting_type);  # rupture width
    slip = wells_and_coppersmith.rectangular_slip(L * 1000, W * 1000, mag);  # must input in meters
    # if hypocenter is really the center of the rupture:
    # xstart, ystart = fault_vector_functions.add_vector_to_point(xcenter, ycenter, -L/2, strike);
    # xfinish, yfinish = fault_vector_functions.add_vector_to_point(xcenter, ycenter, L/2, strike);
    # top, bottom = fault_vector_functions.get_top_bottom_from_center(depth, W, dip);
    # if hypocenter is on one side of rupture:
    xstart, ystart = fault_vector_functions.add_vector_to_point(xcenter, ycenter, 0, strike);
    xfinish, yfinish = fault_vector_functions.add_vector_to_point(xcenter, ycenter, L, strike);
    rtlat, reverse = fault_vector_functions.get_rtlat_dip_slip(slip, rake);
    top, bottom = fault_vector_functions.get_top_bottom_from_top(depth, W, dip);
    comment = '';
    return [xstart, xfinish, ystart, yfinish, rtlat, reverse, top, bottom, comment];
コード例 #6
0
def compute_stresses_horiz_profile(params, inputs):
    """
    Pseudocode: Create a grid of points, and compute all stresses on them, given specified strike/dip/rake.
    horiz_profile = [depth_km, strike, dip, rake, centerlon, centerlat, length_km, width_km, inc_km];
    """
    if not inputs.receiver_horiz_profile:
        return None

    # Build a regular grid and iterate through.
    print("Resolving stresses on a horizontal profile.")
    profile = inputs.receiver_horiz_profile
    receiver_normal, receiver_shear, receiver_coulomb = [], [], []
    for i in range(len(inputs.receiver_horiz_profile.lon1d)):
        [xi,
         yi] = fault_vector_functions.latlon2xy(profile.lon1d[i],
                                                profile.lat1d[i],
                                                inputs.zerolon, inputs.zerolat)
        normal_sum, shear_sum, coulomb_sum = 0, 0, 0
        for source in inputs.source_object:
            # A major compute loop for each source object.

            desired_coords_grad_u, _ = compute_strains_stresses_from_one_fault(
                source, xi, yi, profile.depth_km, params.alpha)

            # Then rotate again into receiver coordinates.
            strain_tensor = conversion_math.get_strain_tensor(
                desired_coords_grad_u)
            stress_tensor = conversion_math.get_stress_tensor(
                strain_tensor, params.lame1, params.mu)

            # Then compute shear, normal, and coulomb stresses.
            [normal, shear, coulomb] = conversion_math.get_coulomb_stresses(
                stress_tensor, profile.strike, profile.rake, profile.dip,
                inputs.FRIC, params.B)
            normal_sum = normal_sum + normal
            shear_sum = shear_sum + shear
            coulomb_sum = coulomb_sum + coulomb

        receiver_normal.append(normal_sum)
        receiver_shear.append(shear_sum)
        receiver_coulomb.append(coulomb_sum)

    return receiver_normal, receiver_shear, receiver_coulomb
コード例 #7
0
def compute_ll_strain(inputs, alpha, strain_points):
    """
    Loop through a list of lon/lat and compute their strains due to all sources put together.
    """
    if not strain_points:
        return []
    x, y = [], []
    print("Number of strain_points:", len(strain_points))
    for i in range(len(strain_points)):
        [xi,
         yi] = fault_vector_functions.latlon2xy(strain_points[i].lon,
                                                strain_points[i].lat,
                                                inputs.zerolon, inputs.zerolat)
        x.append(xi)
        y.append(yi)

    strain_tensor_results = []
    # For each coordinate requested.
    for k in range(len(x)):
        _, _, _, strain_tensor = compute_surface_disp_point(
            inputs, alpha, x[k], y[k])
        strain_tensor_results.append(strain_tensor)

    return strain_tensor_results
コード例 #8
0
def read_four_corners_fault_file(filename):
    """
    Read fault file from Shengji Wei, EPSL, 2015.
    Provided: lat/lon/depth of each corner.
    Read into an internal fault dictionary
    """
    print("Reading file %s" % filename);
    lons, lats, depths = [], [], [];
    ifile = open(filename, 'r');
    for line in ifile:
        temp = line.split();
        if len(temp) == 0:
            continue;
        if temp[0][0] == "#":
            continue;
        else:
            lons.append(float(temp[0]))
            lats.append(float(temp[1]))
            depths.append(float(temp[2]))
    ifile.close();

    # Get parameters of fault patch; assuming four vertices are given, and top depth is same between two top vertices.
    x, y = fault_vector_functions.latlon2xy(lons, lats, lons[0], lats[0]);

    # Find the top of the fault plane
    shallow_depth = np.min(depths);
    deep_depth = np.max(depths);
    shallow_depth_idx = np.where(depths == shallow_depth)
    idx0 = shallow_depth_idx[0][0];
    idx1 = shallow_depth_idx[0][1];

    deltax = x[idx1] - x[idx0];
    deltay = y[idx1] - y[idx0];
    strike_initial = fault_vector_functions.get_strike(deltax, deltay)  # STRIKE MIGHT BE 180 DEGREES AWAY
    dip = fault_vector_functions.get_dip_degrees(x[-2], y[-2], depths[-2], x[-1], y[-1], depths[-1]);
    # Assuming the last two entries go from the bottom to the top.

    # MIGHT REVERSE THE STRIKE HERE.
    strike_vector = fault_vector_functions.get_strike_vector(strike_initial);
    dip_vector = fault_vector_functions.get_dip_vector(strike_initial, dip);
    xp = np.cross(dip_vector, strike_vector);  # dip x strike for outward facing normal, by right hand rule.
    if xp[2] < 0:
        print("WARNING: STRIKE AND DIP DON'T OBEY RIGHT HAND RULE. FLIPPING STRIKE.");
        strike = strike_initial+180;
    else:
        strike = strike_initial;
    if strike > 360:
        strike = strike-360;

    length = fault_vector_functions.get_strike_length(x[idx0], x[idx1], y[idx0], y[idx1]);
    width = fault_vector_functions.get_downdip_width(shallow_depth, deep_depth, dip);

    # GET THE TOP CORNER OF THE FAULT PLANE (ONE OF TWO OPTIONS)
    print("  ", strike, "degrees strike");
    print("  ", dip, "degrees dip");
    print("  ", length, "km length");
    print("  ", width, "km width");

    if strike_initial == strike:
        updip_corner_lon = lons[idx0];
        updip_corner_lat = lats[idx0];
        updip_corner_depth = depths[idx0];
    else:
        updip_corner_lon = lons[idx1];
        updip_corner_lat = lats[idx1];
        updip_corner_depth = depths[idx1];

    fault_object = {'strike': strike, 'slip': 0, 'tensile': 0, 'rake': 0, 'length': length, 'width': width, 'dip': dip,
                    'lon': updip_corner_lon, 'lat': updip_corner_lat, 'depth': updip_corner_depth};
    return fault_object;