def test_pole_reduce(): "gravmag.transform pole reduction matches analytical solution" # Use remanent magnetization sinc, sdec = -70, 30 model = [Prism(-100, 100, -500, 500, 0, 100, {'density': 1000, 'magnetization': utils.ang2vec(5, sinc, sdec)})] # Use low latitudes to make sure that there are no problems with FFT # instability. inc, dec = -60, -15 shape = (50, 50) x, y, z = gridder.regular([-2000, 2000, -2000, 2000], shape, z=-100) data = prism.tf(x, y, z, model, inc, dec) pole = transform.reduce_to_pole(x, y, data, shape, inc, dec, sinc, sdec) pole_true = prism.tf(x, y, z, model, -90, 0, pmag=utils.ang2vec(5, -90, 0)) npt.assert_allclose(pole, pole_true, atol=10, rtol=0.01)
def test_pole_reduce(): "gravmag.transform pole reduction matches analytical solution" # Use remanent magnetization sinc, sdec = -70, 30 model = [ Prism(-100, 100, -500, 500, 0, 100, { 'density': 1000, 'magnetization': utils.ang2vec(5, sinc, sdec) }) ] # Use low latitudes to make sure that there are no problems with FFT # instability. inc, dec = -60, -15 shape = (50, 50) x, y, z = gridder.regular([-2000, 2000, -2000, 2000], shape, z=-100) data = prism.tf(x, y, z, model, inc, dec) pole = transform.reduce_to_pole(x, y, data, shape, inc, dec, sinc, sdec) pole_true = prism.tf(x, y, z, model, -90, 0, pmag=utils.ang2vec(5, -90, 0)) npt.assert_allclose(pole, pole_true, atol=10, rtol=0.01)
# Direction of the Geomagnetic field inc, dec = -60, 0 # Make a model with only induced magnetization model = [ mesher.Prism(-100, 100, -100, 100, 0, 2000, {'magnetization': utils.ang2vec(10, inc, dec)}) ] area = (-5000, 5000, -5000, 5000) shape = (100, 100) z0 = -500 x, y, z = gridder.regular(area, shape, z=z0) tf = utils.contaminate(prism.tf(x, y, z, model, inc, dec), 1, seed=0) # Reduce to the pole using FFT. Since there is only induced magnetization, the # magnetization direction (sinc and sdec) is the same as the geomagnetic field pole = transform.reduce_to_pole(x, y, tf, shape, inc, dec, sinc=inc, sdec=dec) # Calculate the true value at the pole for comparison true = prism.tf(x, y, z, model, 90, 0, pmag=utils.ang2vec(10, 90, 0)) fig, axes = mpl.subplots(1, 3, figsize=(14, 4)) for ax in axes: ax.set_aspect('equal') mpl.sca(axes[0]) mpl.title("Original total field anomaly") mpl.contourf(y, x, tf, shape, 30, cmap=mpl.cm.RdBu_r) mpl.colorbar(pad=0).set_label('nT') mpl.m2km() mpl.sca(axes[1]) mpl.title("True value at pole") mpl.contourf(y, x, true, shape, 30, cmap=mpl.cm.RdBu_r) mpl.colorbar(pad=0).set_label('nT')
from fatiando.vis import mpl # Direction of the Geomagnetic field inc, dec = -60, 0 # Make a model with only induced magnetization model = [mesher.Prism(-100, 100, -100, 100, 0, 2000, {'magnetization': utils.ang2vec(10, inc, dec)})] area = (-5000, 5000, -5000, 5000) shape = (100, 100) z0 = -500 x, y, z = gridder.regular(area, shape, z=z0) tf = utils.contaminate(prism.tf(x, y, z, model, inc, dec), 1, seed=0) # Reduce to the pole using FFT. Since there is only induced magnetization, the # magnetization direction (sinc and sdec) is the same as the geomagnetic field pole = transform.reduce_to_pole(x, y, tf, shape, inc, dec, sinc=inc, sdec=dec) # Calculate the true value at the pole for comparison true = prism.tf(x, y, z, model, 90, 0, pmag=utils.ang2vec(10, 90, 0)) fig, axes = mpl.subplots(1, 3, figsize=(14, 4)) for ax in axes: ax.set_aspect('equal') mpl.sca(axes[0]) mpl.title("Original total field anomaly") mpl.contourf(y, x, tf, shape, 30, cmap=mpl.cm.RdBu_r) mpl.colorbar(pad=0).set_label('nT') mpl.m2km() mpl.sca(axes[1]) mpl.title("True value at pole") mpl.contourf(y, x, true, shape, 30, cmap=mpl.cm.RdBu_r) mpl.colorbar(pad=0).set_label('nT')
from fatiando import gridder, utils # Create some synthetic magnetic data with a total magnetization that is # different from the geomagnetic field (so there is remanent magnetization or # some demagnetizing effect) inc, dec = -60, 23 # Geomagnetic field direction sinc, sdec = -30, -20 # Source magnetization direction mag = utils.ang2vec(1, sinc, sdec) 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 = prism.tf(x, y, z, model, inc, dec) # Reduce to the pole data_at_pole = transform.reduce_to_pole(x, y, data, shape, inc, dec, sinc, sdec) # Make some plots plt.figure(figsize=(8, 6)) ax = plt.subplot(1, 2, 1) ax.set_title('Original data') ax.set_aspect('equal') tmp = ax.tricontourf(y/1000, x/1000, data, 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 import gridder, utils # Create some synthetic magnetic data with a total magnetization that is # different from the geomagnetic field (so there is remanent magnetization or # some demagnetizing effect) inc, dec = -60, 23 # Geomagnetic field direction sinc, sdec = -30, -20 # Source magnetization direction mag = utils.ang2vec(1, sinc, sdec) 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 = prism.tf(x, y, z, model, inc, dec) # Reduce to the pole data_at_pole = transform.reduce_to_pole(x, y, data, shape, inc, dec, sinc, sdec) # Make some plots plt.figure(figsize=(8, 6)) ax = plt.subplot(1, 2, 1) ax.set_title('Original data') ax.set_aspect('equal') tmp = ax.tricontourf(y / 1000, x / 1000, data, 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)