def test_tilt_analytical_derivatives(): "gravmag.transform tilt returns same values given analytical derivatives" model = [Prism(-100, 100, -100, 100, 0, 100, {'density': 1000})] shape = (400, 400) x, y, z = gridder.regular([-10000, 10000, -10000, 10000], shape, z=-100) data = utils.mgal2si(prism.gz(x, y, z, model)) dx = utils.eotvos2si(prism.gxz(x, y, z, model)) dy = utils.eotvos2si(prism.gyz(x, y, z, model)) dz = utils.eotvos2si(prism.gzz(x, y, z, model)) tilt_analytical = transform.tilt(x, y, data, shape, dx, dy, dz) tilt_numerical = transform.tilt(x, y, data, shape) npt.assert_allclose(tilt_numerical, tilt_analytical, rtol=0.10)
def test_tilt_sane_values(): "gravmag.transform tilt returns sane values, between -90 and 90 degrees" inc, dec = 90, 0 mag = utils.ang2vec(200, inc, dec) model = [Prism(-500, 500, -500, 500, 0, 2000, {'magnetization': mag})] shape = (300, 300) x, y, z = gridder.regular([-10000, 10000, -10000, 10000], shape, z=-100) data = prism.tf(x, y, z, model, inc, dec) tilt = np.degrees(transform.tilt(x, y, data, shape)) assert tilt.max() < 90, \ "Maximum tilt greater than 90: {}".format(tilt.max()) assert tilt.min > -90, \ "Minimum tilt less than -90: {}".format(tilt.min())
from fatiando.gravmag import prism, transform from fatiando.mesher import Prism from fatiando import gridder, utils # Create some synthetic magnetic data. We'll assume the data is already reduced # to the pole. inc, dec = 90, 0 mag = utils.ang2vec(1, inc, dec) model = [Prism(-1500, 1500, -500, 500, 0, 2000, {'magnetization': mag})] area = (-7e3, 7e3, -7e3, 7e3) shape = (100, 100) x, y, z = gridder.regular(area, shape, z=-300) data_at_pole = prism.tf(x, y, z, model, inc, dec) # Calculate the tilt tilt = transform.tilt(x, y, data_at_pole, shape) # Make some plots plt.figure(figsize=(8, 6)) ax = plt.subplot(1, 2, 1) ax.set_title('Original data at the pole') ax.set_aspect('equal') tmp = ax.tricontourf(y / 1000, x / 1000, data_at_pole, 30, cmap='RdBu_r') plt.colorbar(tmp, pad=0.1, aspect=30, orientation='horizontal').set_label('nT') ax.set_xlabel('y (km)') ax.set_ylabel('x (km)') ax.set_xlim(area[2] / 1000, area[3] / 1000) ax.set_ylim(area[0] / 1000, area[1] / 1000) ax = plt.subplot(1, 2, 2)
from fatiando.gravmag import prism, transform from fatiando.mesher import Prism from fatiando import gridder, utils # Create some synthetic magnetic data. We'll assume the data is already reduced # to the pole. inc, dec = 90, 0 mag = utils.ang2vec(1, inc, dec) model = [Prism(-1500, 1500, -500, 500, 0, 2000, {'magnetization': mag})] area = (-7e3, 7e3, -7e3, 7e3) shape = (100, 100) x, y, z = gridder.regular(area, shape, z=-300) data_at_pole = prism.tf(x, y, z, model, inc, dec) # Calculate the tilt tilt = transform.tilt(x, y, data_at_pole, shape) # Make some plots plt.figure(figsize=(8, 6)) ax = plt.subplot(1, 2, 1) ax.set_title('Original data at the pole') ax.set_aspect('equal') tmp = ax.tricontourf(y/1000, x/1000, data_at_pole, 30, cmap='RdBu_r') plt.colorbar(tmp, pad=0.1, aspect=30, orientation='horizontal').set_label('nT') ax.set_xlabel('y (km)') ax.set_ylabel('x (km)') ax.set_xlim(area[2]/1000, area[3]/1000) ax.set_ylim(area[0]/1000, area[1]/1000) ax = plt.subplot(1, 2, 2)