Ejemplo n.º 1
0
def latlon_axis(ax, xbounds, ybounds, proj, latlon_step):
    inv_latlon_step = 1.0 / latlon_step
    lon_edges = collect_dem.project(xbounds, [ybounds[0]] * 2, [0, 0],
                                    proj,
                                    inverse=True)
    min_lon = int(np.floor(lon_edges[0][0]))
    max_lon = int(np.ceil(lon_edges[1][0]))
    lon = np.linspace(min_lon, max_lon,
                      inv_latlon_step * (max_lon - min_lon) + 1)
    lon_proj = collect_dem.project(lon, [lon_edges[0][1]] * len(lon),
                                   [0] * len(lon), proj)

    ax.set_xticks(lon_proj[:, 0])
    ax.set_xticklabels(
        ['$\\mathrm{' + str(x) + '}^{\circ} ~ \mathrm{E}$' for x in lon])
    ax.set_xlabel('$\\mathrm{Longitude}$')

    lat_edges = collect_dem.project([xbounds[0]] * 2,
                                    ybounds, [0, 0],
                                    proj,
                                    inverse=True)
    min_lat = int(np.floor(lat_edges[0][1]))
    max_lat = int(np.ceil(lat_edges[1][1]))
    lat = np.linspace(min_lat, max_lat,
                      inv_latlon_step * (max_lat - min_lat) + 1)
    lat_proj = collect_dem.project([lat_edges[0][0]] * len(lat), lat,
                                   [0] * len(lat), proj)

    ax.set_yticks(lat_proj[:, 1])
    ax.set_yticklabels(
        ['$\\mathrm{' + str(y) + '}^{\circ} ~ \mathrm{N}$' for y in lat])
    ax.set_ylabel('$\\mathrm{Latitude}$')
Ejemplo n.º 2
0
def build_proj_rotate(m, from_proj, to_proj):
    all_pts = [m.pts.copy()]
    for d in range(3):
        moved = m.pts.copy()
        moved[:, d] += 1.0
        all_pts.append(moved)

    all_pts = np.concatenate(all_pts)
    lonlatz = collect_dem.project(all_pts[:, 0],
                                  all_pts[:, 1],
                                  all_pts[:, 2],
                                  from_proj,
                                  inverse=True)
    to_coords = collect_dem.project(lonlatz[:, 0], lonlatz[:, 1],
                                    lonlatz[:, 2], to_proj)

    npts = m.pts.shape[0]
    to_pts = to_coords[:npts]
    from_to_dirs = [
        to_coords[((d + 1) * npts):((d + 2) * npts)] - to_pts for d in range(3)
    ]
    all_dirs = np.array(from_to_dirs)
    dir_map = np.swapaxes(np.swapaxes(all_dirs, 0, 1), 1, 2)
    dir_map[m.tris].shape

    proj_rotate = scipy.sparse.dok_matrix((m.n_dofs(), m.n_dofs()))
    dir_map_tris = dir_map[m.tris]
    for i in range(m.tris.shape[0]):
        for b in range(3):
            for d1 in range(3):
                for d2 in range(3):
                    proj_rotate[i * 9 + b * 3 + d1,
                                i * 9 + b * 3 + d2] = dir_map_tris[i, b, d1,
                                                                   d2]
    return proj_rotate
Ejemplo n.º 3
0
def set_surf_elevations(m, n_dem_interp_pts, zoom, proj):
    surf_pt_idxs = m.get_pt_idxs('surf')
    lonlat_pts = collect_dem.project(m.pts[:,0], m.pts[:,1], m.pts[:,2], proj, inverse = True)
    bounds = collect_dem.get_dem_bounds(lonlat_pts)
    proj_dem = collect_dem.project(*collect_dem.get_dem(zoom, bounds, n_dem_interp_pts), proj)
    new_m = copy.copy(m)
    new_m.pts[surf_pt_idxs,2] = scipy.interpolate.griddata(
        (proj_dem[:,0], proj_dem[:,1]), proj_dem[:,2],
        (m.pts[surf_pt_idxs,0], m.pts[surf_pt_idxs,1])
    )
    return new_m
Ejemplo n.º 4
0
def to_sphere_xyz(m, proj):
    lonlatz = collect_dem.project(m.pts[:, 0],
                                  m.pts[:, 1],
                                  m.pts[:, 2],
                                  proj,
                                  inverse=True)
    xyz_sphere = collect_dem.project(lonlatz[:, 0], lonlatz[:, 1],
                                     lonlatz[:, 2], 'ellps')
    m_xyz = copy.copy(m)
    m_xyz.pts = xyz_sphere
    return m_xyz
Ejemplo n.º 5
0
def moment_analysis(m, inverse_soln, proj):
    slip = inverse_soln[0].reshape((-1, 2))
    total_slip = np.sqrt(np.sum(slip**2, axis=1))
    total_slip_m = total_slip / 100.0

    from tectosaur.ops.mass_op import MassOp
    fault_mass = MassOp(2, m.pts, m.get_tris('fault'))
    tri_potency = fault_mass.dot(
        np.concatenate(
            (total_slip_m,
             np.zeros(total_slip.shape[0] * 2))))[:total_slip.shape[0]]
    potency = np.sum(tri_potency)
    avg_tri_potency = np.sum(tri_potency.reshape((-1, 3)), axis=1)

    mu = 30e9
    M0 = potency * mu
    M = magnitude(M0)
    print('potency: ' + str(potency))
    print('M0: ' + str(M0))
    print('M: ' + str(M))

    tri_centers = np.mean(m.get_tri_pts('fault'), axis=1)
    tri_lonlat = collect_dem.project(tri_centers[:, 0],
                                     tri_centers[:, 1],
                                     tri_centers[:, 2],
                                     proj,
                                     inverse=True)
    surf_elev = collect_dem.get_pt_elevations(tri_lonlat, 5)

    tri_depth = surf_elev - tri_centers[:, 2]
    avg_tri_moment = avg_tri_potency * mu
    return tri_depth, avg_tri_moment