def main():
    fault = data.to_world(data.to_xyz(data.fault))
    fault = shared_array(fault)

    # Initalize output file...
    output = h5py.File('bootstrap.hdf5', 'w')
    group = output.create_group('IndependentBootstrap')
    group.attrs['alpha'] = data.alpha

    pool = multiprocessing.Pool()

    for hor in data.horizons:
        print hor.name

        horxyz = data.to_world(data.to_xyz(hor))
        # Use a shared array...
        horxyz = shared_array(horxyz)

        # Run in parallel...
        slip, var = parallel_bootstrap_slip(fault, horxyz, data.alpha, 
                                pool=pool, numruns=200, numsamples=10000)
        # Save results...
        hor_group = group.create_group(hor.name)
        hor_group.create_dataset('slip', data=slip)
        hor_group.create_dataset('variance', data=var)

    output.close()
Esempio n. 2
0
def optimize_individual_alpha():
    """Find the best shear angle for each horizon using a grid search."""
    fault = data.to_world(data.to_xyz(data.fault))
    alphas = range(-80, 85, 5)

    for hor in data.horizons:
        update(hor.name + ': ')
        xyz = data.to_world(data.to_xyz(hor))[::50]

        roughness = []
        for i, alpha in enumerate(alphas):
            update('%i ' % (len(alphas) - i)) 
            slip, metric = invert(fault, xyz, alpha)
            roughness.append(metric)

        update('\n')

        fig, ax = plt.subplots()
        ax.plot(alphas, roughness)
        ax.set_title(hor.name)
        ax.set_ylabel('Misfit (m)')
        ax.set_xlabel('Shear angle (degrees)')
        fig.savefig('optimize_alpha_individual_%s.pdf'%hor.name)

    plt.show()
Esempio n. 3
0
def optimize_single_alpha():
    """Find the single shear angle that best flattens all horizons using a grid
    search."""
    fault = data.to_world(data.to_xyz(data.fault))
    alphas = range(-80, 85, 5)

    roughness = []
    for alpha in alphas:
        update('Alpha = %i: ' % alpha)

        rough = 0
        for i, hor in enumerate(data.horizons):
            xyz = data.to_world(data.to_xyz(hor))[::50]
            update('%i ' % (len(data.horizons) - i))
            slip, metric = invert(fault, xyz, alpha)
            rough += metric

        update('\n')
        roughness.append(rough)

    fig, ax = plt.subplots()
    ax.plot(alphas, roughness)
    ax.set_title('Optimizing Shear Angle')
    ax.set_ylabel('Summed misfit (m)')
    ax.set_xlabel('Shear angle (degrees)')
    fig.savefig('optimize_single_alpha.pdf')

    plt.show()
def optimize_single_alpha():
    """Find the single shear angle that best flattens all horizons using a grid
    search."""
    fault = data.to_world(data.to_xyz(data.fault))
    alphas = range(-80, 85, 5)

    roughness = []
    for alpha in alphas:
        update('Alpha = %i: ' % alpha)

        rough = 0
        for i, hor in enumerate(data.horizons):
            xyz = data.to_world(data.to_xyz(hor))[::50]
            update('%i ' % (len(data.horizons) - i))
            slip, metric = invert(fault, xyz, alpha)
            rough += metric

        update('\n')
        roughness.append(rough)

    fig, ax = plt.subplots()
    ax.plot(alphas, roughness)
    ax.set_title('Optimizing Shear Angle')
    ax.set_ylabel('Summed misfit (m)')
    ax.set_xlabel('Shear angle (degrees)')
    fig.savefig('optimize_single_alpha.pdf')

    plt.show()
def optimize_individual_alpha():
    """Find the best shear angle for each horizon using a grid search."""
    fault = data.to_world(data.to_xyz(data.fault))
    alphas = range(-80, 85, 5)

    for hor in data.horizons:
        update(hor.name + ': ')
        xyz = data.to_world(data.to_xyz(hor))[::50]

        roughness = []
        for i, alpha in enumerate(alphas):
            update('%i ' % (len(alphas) - i))
            slip, metric = invert(fault, xyz, alpha)
            roughness.append(metric)

        update('\n')

        fig, ax = plt.subplots()
        ax.plot(alphas, roughness)
        ax.set_title(hor.name)
        ax.set_ylabel('Misfit (m)')
        ax.set_xlabel('Shear angle (degrees)')
        fig.savefig('optimize_alpha_individual_%s.pdf' % hor.name)

    plt.show()
def main():
    fault = data.to_world(data.to_xyz(data.fault))
    fault = shared_array(fault)

    # Initalize output file...
    output = h5py.File('bootstrap.hdf5', 'w')
    group = output.create_group('IndependentBootstrap')
    group.attrs['alpha'] = data.alpha

    pool = multiprocessing.Pool()

    for hor in data.horizons:
        print hor.name

        horxyz = data.to_world(data.to_xyz(hor))
        # Use a shared array...
        horxyz = shared_array(horxyz)

        # Run in parallel...
        slip, var = parallel_bootstrap_slip(fault,
                                            horxyz,
                                            data.alpha,
                                            pool=pool,
                                            numruns=200,
                                            numsamples=10000)
        # Save results...
        hor_group = group.create_group(hor.name)
        hor_group.create_dataset('slip', data=slip)
        hor_group.create_dataset('variance', data=var)

    output.close()
def main():
    fault = geoprobe.swfault('/data/nankai/data/swFaults/jdk_oos_splay_large_area_depth.swf')

    faultxyz = data.to_world(data.to_xyz(data.fault))

    horxyz = data.to_world(data.to_xyz(data.horizons[0]))[::100]

    slip = invert_slip(faultxyz, horxyz, alpha=data.alpha)

    azimuth = np.degrees(np.arctan2(*slip[::-1]))
    azimuth = 90 - azimuth
    mag = np.linalg.norm(slip) / 1000

    f = FaultModel(fault, horxyz, origxyz=horxyz, ve=3, azimuth=azimuth, 
                   slip=mag, alpha=data.alpha, calc_fault=faultxyz)
    f.configure_traits()
    def __init__(self, fault, horxyz, origxyz=None, ve=2, calc_fault=None, 
                **kwargs):
        self.ve = ve
        self.origxyz = origxyz

        self.fault = fault
        if calc_fault is None:
            self.faultxyz = data.to_world(data.to_xyz(fault))
        else:
            self.faultxyz = calc_fault
        self.horxyz = horxyz

        HasTraits.__init__(self, **kwargs)
def main():
    fault = geoprobe.swfault(
        '/data/nankai/data/swFaults/jdk_oos_splay_large_area_depth.swf')

    faultxyz = data.to_world(data.to_xyz(data.fault))

    horxyz = data.to_world(data.to_xyz(data.horizons[0]))[::100]

    slip = invert_slip(faultxyz, horxyz, alpha=data.alpha)

    azimuth = np.degrees(np.arctan2(*slip[::-1]))
    azimuth = 90 - azimuth
    mag = np.linalg.norm(slip) / 1000

    f = FaultModel(fault,
                   horxyz,
                   origxyz=horxyz,
                   ve=3,
                   azimuth=azimuth,
                   slip=mag,
                   alpha=data.alpha,
                   calc_fault=faultxyz)
    f.configure_traits()
    def __init__(self,
                 fault,
                 horxyz,
                 origxyz=None,
                 ve=2,
                 calc_fault=None,
                 **kwargs):
        self.ve = ve
        self.origxyz = origxyz

        self.fault = fault
        if calc_fault is None:
            self.faultxyz = data.to_world(data.to_xyz(fault))
        else:
            self.faultxyz = calc_fault
        self.horxyz = horxyz

        HasTraits.__init__(self, **kwargs)
                Group(
                    '_', 'azimuth', 'slip', 'alpha',
                    ),
                resizable=True,
                )

def triangles(fault):
    if isinstance(fault, basestring):
        fault = geoprobe.swfault(fault)
    # Iterate through triangles in internal coords and select those inside 
    # outline the non-convex outline of the fault...
    xyz = fault._internal_xyz
    rotated_tri = LinearNDInterpolator(xyz[:,:2], xyz[:,-1])
    rotated_xyz = fault._internal_xyz
    rotated_outline = Polygon(fault._rotated_outline)

    def inside_outline(tri):
        return rotated_outline.contains(Polygon(rotated_xyz[tri]))

    triangles = rotated_tri.tri.vertices
    return np.array([tri for tri in triangles if inside_outline(tri)])


if __name__ == '__main__':
    fault = geoprobe.swfault('/data/nankai/data/swFaults/jdk_oos_splay_large_area_depth.swf')
    hor = data.horizons[0]
    horxyz = data.to_world(data.to_xyz(hor))[::100]

    plot = FaultModel(fault, horxyz)
    plot.configure_traits()
import numpy as np
import matplotlib.pyplot as plt

from fault_kinematics.homogeneous_simple_shear import inclined_shear
from fault_kinematics.homogeneous_simple_shear import invert_slip

import data
import utilities

fault = data.to_xyz(data.fault)
fault = data.to_world(fault)

models = [[0, 0]]

i = 0
for hor in data.horizons[::-1]:
    print hor.name
    # Downsample horizon for faster solution...
    xyz = data.to_xyz(hor)[::50,:]
    xyz = data.to_world(xyz)

    # Move this horizon to the last horizon's best fit offset.
    # Following the path of all previous horizons...
    for model in models:
        dx, dy = model
        xyz = inclined_shear(fault, xyz, (dx,dy), data.alpha)

    model = invert_slip(fault, xyz, data.alpha, guess=(0,0))
    models.append(model)
    i += 1
Esempio n. 13
0
from fault_kinematics.homogeneous_simple_shear import invert_slip
import utilities
import data

def forced_direction_inversion(fault, xyz, alpha, azimuth, **kwargs):
    azimuth = np.radians(90 - azimuth)
    dx, dy = np.cos(azimuth), np.sin(azimuth)
    direc = [[dx, dy], [dx, dy]]
    return invert_slip(fault, xyz, alpha, direc=direc, **kwargs)

def planar_variance(xyz):
    vecs, vals = geoprobe.utilities.principal_axes(*xyz.T, return_eigvals=True)
    return vals[-1]

fault = data.to_world(data.to_xyz(data.fault))

slips = [(0,0)]
guess = (0,0)

heaves = [(0,0,0)]
planar_variances = []
variances = []

for i, hor in enumerate(data.horizons[::-1]):
    print hor.name
    xyz = data.to_xyz(hor)[::50]
    xyz = data.to_world(xyz)

    slip, metric = invert_slip(fault, xyz, alpha=data.alpha, guess=guess, 
                               overlap_thresh=1, return_metric=True)
        ),
        resizable=True,
    )


def triangles(fault):
    if isinstance(fault, basestring):
        fault = geoprobe.swfault(fault)
    # Iterate through triangles in internal coords and select those inside
    # outline the non-convex outline of the fault...
    xyz = fault._internal_xyz
    rotated_tri = LinearNDInterpolator(xyz[:, :2], xyz[:, -1])
    rotated_xyz = fault._internal_xyz
    rotated_outline = Polygon(fault._rotated_outline)

    def inside_outline(tri):
        return rotated_outline.contains(Polygon(rotated_xyz[tri]))

    triangles = rotated_tri.tri.vertices
    return np.array([tri for tri in triangles if inside_outline(tri)])


if __name__ == '__main__':
    fault = geoprobe.swfault(
        '/data/nankai/data/swFaults/jdk_oos_splay_large_area_depth.swf')
    hor = data.horizons[0]
    horxyz = data.to_world(data.to_xyz(hor))[::100]

    plot = FaultModel(fault, horxyz)
    plot.configure_traits()
Esempio n. 15
0
import geoprobe
import data
import utilities

from fault_kinematics import homogeneous_simple_shear

from process_bootstrap_results import get_result, load

fault = data.to_world(data.to_xyz(data.fault))
alpha = data.alpha

f, group = load()

for hor in data.horizons:
    print hor.name
    xyz = data.to_world(data.to_xyz(hor))

    slip = get_result(hor.name, group)

    restored = homogeneous_simple_shear.inclined_shear(fault, xyz, slip, alpha)

    print 'Resampling...'
    restored = data.to_model(restored)
    restored = utilities.grid_xyz(restored)
    new_hor = geoprobe.horizon(*restored.T)
    new_hor.write('restored_horizons/' + hor.name + '.hzn')

f.close()

def forced_direction_inversion(fault, xyz, alpha, azimuth, **kwargs):
    azimuth = np.radians(90 - azimuth)
    dx, dy = np.cos(azimuth), np.sin(azimuth)
    direc = [[dx, dy], [dx, dy]]
    return invert_slip(fault, xyz, alpha, direc=direc, **kwargs)

def visualize(slip, faultxyz, horxyz):
    fault = geoprobe.swfault('/data/nankai/data/swFaults/jdk_oos_splay_large_area_depth.swf')

    azimuth = np.degrees(np.arctan2(*slip[::-1]))
    azimuth = 90 - azimuth
    mag = np.linalg.norm(slip) / 1000

    f = FaultModel(fault, horxyz, origxyz=horxyz, ve=3, azimuth=azimuth, 
                   slip=mag, alpha=data.alpha, calc_fault=faultxyz)
    f.configure_traits()

fault = data.world_xyz(data.fault)
for i, hor in enumerate(data.horizons[::-1]):
    print hor.name
    xyz = data.to_world(data.to_xyz(hor))[::50]

    slip, metric = invert_slip(fault, xyz, alpha=data.alpha, guess=(0,0), 
                               overlap_thresh=1, return_metric=True)
#    slip, metric = forced_direction_inversion(fault, xyz, data.alpha, data.fault_strike+90,
#                                              guess=guess, return_metric=True)

    visualize(slip, fault, xyz)

import numpy as np
import matplotlib.pyplot as plt

from fault_kinematics.homogeneous_simple_shear import inclined_shear
from fault_kinematics.homogeneous_simple_shear import invert_slip

import data
import utilities

fault = data.to_xyz(data.fault)
fault = data.to_world(fault)

models = [[0, 0]]

i = 0
for hor in data.horizons[::-1]:
    print hor.name
    # Downsample horizon for faster solution...
    xyz = data.to_xyz(hor)[::50, :]
    xyz = data.to_world(xyz)

    # Move this horizon to the last horizon's best fit offset.
    # Following the path of all previous horizons...
    for model in models:
        dx, dy = model
        xyz = inclined_shear(fault, xyz, (dx, dy), data.alpha)

    model = invert_slip(fault, xyz, data.alpha, guess=(0, 0))
    models.append(model)
    i += 1