def test_gz():
    "polyprism.gz against prism"
    resprism = prism.gz(xp, yp, zp, prismmodel)
    respoly = polyprism.gz(xp, yp, zp, model)
    diff = np.abs(resprism - respoly)
    errormsg = 'max diff: %g | max polyprism: %g | max prism: %g' % (
        max(diff), max(respoly), max(resprism))
    assert np.all(diff <= precision), errormsg
Exemple #2
0
def test_gz():
    "polyprism.gz against prism"
    resprism = prism.gz(xp, yp, zp, prismmodel)
    respoly = polyprism.gz(xp, yp, zp, model)
    diff = np.abs(resprism - respoly)
    errormsg = 'max diff: %g | max polyprism: %g | max prism: %g' % (
        max(diff), max(respoly), max(resprism))
    assert np.all(diff <= precision), errormsg
bounds = [-10000, 10000, -10000, 10000, 0, 10000]
vertices = [[-4948.97959184, -6714.64019851],
            [-2448.97959184, -3141.43920596],
            [2448.97959184, 312.65508685],
            [6938.7755102, 5394.54094293],
            [4846.93877551, 6228.28784119],
            [2653.06122449, 3409.4292804],
            [-3520.40816327, -1434.24317618],
            [-6632.65306122, -6079.4044665]]
model = [PolygonalPrism(vertices, 1000, 4000, {'density': 1000})]
# and generate synthetic data from it
shape = (20, 20)
area = bounds[0:4]
xp, yp, zp = gridder.regular(area, shape, z=-1)
noise = 0.1  # 0.1 mGal noise
gz = utils.contaminate(polyprism.gz(xp, yp, zp, model), noise)

# Create a mesh
mesh = PrismMesh(bounds, (25, 50, 50))
# Wrap the data so that harvester can read it
data = [harvester.Gz(xp, yp, zp, gz)]
# Plot the data and pick the location of the seeds
mpl.figure()
mpl.suptitle("Pick the seeds (polygon is the true source)")
mpl.axis('scaled')
levels = mpl.contourf(yp, xp, gz, shape, 12)
mpl.colorbar()
mpl.polygon(model[0], xy2ne=True)
mpl.xlabel('Horizontal coordinate y (km)')
mpl.ylabel('Horizontal coordinate x (km)')
seedx, seedy = mpl.pick_points(area, mpl.gca(), xy2ne=True).T
area = bounds[:4]
depths = [0, 1000, 2000, 3000, 4000]
model = []
for i in range(1, len(depths)):
    axes = mpl.figure().gca()
    mpl.axis('scaled')
    for p in model:
        mpl.polygon(p, '.-k', xy2ne=True)
    model.append(
        mesher.PolygonalPrism(
            mpl.draw_polygon(area, axes, xy2ne=True),
            depths[i - 1], depths[i], {'density':500}))
# Calculate the effect
shape = (100, 100)
xp, yp, zp = gridder.regular(area, shape, z=-1)
gz = polyprism.gz(xp, yp, zp, model)
# and plot it
mpl.figure()
mpl.axis('scaled')
mpl.title("gz produced by prism model (mGal)")
mpl.contourf(yp, xp, gz, shape, 20)
mpl.colorbar()
for p in model:
    mpl.polygon(p, '.-k', xy2ne=True)
mpl.set_area(area)
mpl.show()
# Show the model
myv.figure()
myv.polyprisms(model, 'density')
myv.axes(myv.outline(bounds), ranges=[i*0.001 for i in bounds])
myv.show()
def test_gz_numpy():
    "polyprism.gz cython vs numpy implementation"
    cy = polyprism.gz(xp, yp, zp, model)
    py = _polyprism_numpy.gz(xp, yp, zp, model)
    diff = np.abs(py - cy)
    assert np.all(diff <= precision), 'max diff: %g' % (max(diff))
Exemple #6
0
def test_gz_numpy():
    "polyprism.gz cython vs numpy implementation"
    cy = polyprism.gz(xp, yp, zp, model)
    py = _polyprism_numpy.gz(xp, yp, zp, model)
    diff = np.abs(py - cy)
    assert np.all(diff <= precision), 'max diff: %g' % (max(diff))
Exemple #7
0
bounds = [-10000, 10000, -10000, 10000, 0, 10000]
vertices = [[-4948.97959184, -6714.64019851],
            [-2448.97959184, -3141.43920596],
            [2448.97959184,   312.65508685],
            [6938.7755102,  5394.54094293],
            [4846.93877551,  6228.28784119],
            [2653.06122449,  3409.4292804],
            [-3520.40816327, -1434.24317618],
            [-6632.65306122, -6079.4044665]]
model = [PolygonalPrism(vertices, 1000, 4000, {'density': 1000})]
# and generate synthetic data from it
shape = (20, 20)
area = bounds[0:4]
xp, yp, zp = gridder.regular(area, shape, z=-1)
noise = 0.1  # 0.1 mGal noise
gz = utils.contaminate(polyprism.gz(xp, yp, zp, model), noise)

# Create a mesh
mesh = PrismMesh(bounds, (25, 50, 50))
# Wrap the data so that harvester can read it
data = [harvester.Gz(xp, yp, zp, gz)]
# Plot the data and pick the location of the seeds
mpl.figure()
mpl.suptitle("Pick the seeds (polygon is the true source)")
mpl.axis('scaled')
levels = mpl.contourf(yp, xp, gz, shape, 12)
mpl.colorbar()
mpl.polygon(model[0], xy2ne=True)
mpl.xlabel('Horizontal coordinate y (km)')
mpl.ylabel('Horizontal coordinate x (km)')
seedx, seedy = mpl.pick_points(area, mpl.gca(), xy2ne=True).T
Exemple #8
0
area = bounds[:4]
depths = [0, 1000, 2000, 3000, 4000]
model = []
for i in range(1, len(depths)):
    axes = mpl.figure().gca()
    mpl.axis('scaled')
    for p in model:
        mpl.polygon(p, '.-k', xy2ne=True)
    model.append(
        mesher.PolygonalPrism(
            mpl.draw_polygon(area, axes, xy2ne=True),
            depths[i - 1], depths[i], {'density': 500}))
# Calculate the effect
shape = (100, 100)
xp, yp, zp = gridder.regular(area, shape, z=-1)
gz = polyprism.gz(xp, yp, zp, model)
# and plot it
mpl.figure()
mpl.axis('scaled')
mpl.title("gz produced by prism model (mGal)")
mpl.contourf(yp, xp, gz, shape, 20)
mpl.colorbar()
for p in model:
    mpl.polygon(p, '.-k', xy2ne=True)
mpl.set_area(area)
mpl.show()
# Show the model
myv.figure()
myv.polyprisms(model, 'density')
myv.axes(myv.outline(bounds), ranges=[i * 0.001 for i in bounds])
myv.show()