def test_confocal_oblate_ellipsoids():
    "Confocal bodies with properly scaled suscep produce the same field"
    # Reference ellipsoid
    a, b, = 400., 1000.  # semi-axes
    chi = 1.2  # reference susceptibility
    ellipsoid = OblateEllipsoid(
        0., 0., 1500., a, b, 45., 10., -30., {
            'principal susceptibilities': [chi, chi, chi],
            'susceptibility angles': [0., 0., 0.]
        })
    # Intensity of the local-geomagnetic field (in nT)
    B0 = 23500.
    # Direction parallel to the semi-axis a
    _, inc, dec = utils.vec2ang(ellipsoid.transf_matrix.T[0])
    # Magnetic moment of the reference ellipsoid
    volume = ellipsoid.volume
    mag = oblate_ellipsoid.magnetization(ellipsoid, B0, inc, dec, demag=True)
    moment = volume * mag
    # Confocal ellipsoid
    u = 2.0e6
    a_confocal = np.sqrt(a * a + u)
    b_confocal = np.sqrt(b * b + u)
    xc = ellipsoid.x
    yc = ellipsoid.y
    zc = ellipsoid.z
    strike = ellipsoid.strike
    dip = ellipsoid.dip
    rake = ellipsoid.rake
    confocal_ellipsoid = OblateEllipsoid(
        xc, yc, zc, a_confocal, b_confocal, strike, dip, rake,
        {'susceptibility angles': [0., 0., 0.]})
    n11, n22 = oblate_ellipsoid.demag_factors(confocal_ellipsoid)
    H0 = B0 / (4 * np.pi * 100)
    volume_confocal = confocal_ellipsoid.volume
    # Equivalent susceptibility
    moment_norm = np.sqrt(np.sum(moment * moment))
    chi_confocal = moment_norm / (volume_confocal * H0 - n11 * moment_norm)
    confocal_ellipsoid.addprop('principal susceptibilities',
                               [chi_confocal, chi_confocal, chi_confocal])
    # Magnetic moment of the confocal ellipsoid
    mag_confocal = oblate_ellipsoid.magnetization(confocal_ellipsoid,
                                                  B0,
                                                  inc,
                                                  dec,
                                                  demag=True)
    moment_confocal = volume_confocal * mag_confocal
    # Total-field anomalies
    tf = oblate_ellipsoid.tf(x, y, z, [ellipsoid], B0, inc, dec)
    tf_confocal = oblate_ellipsoid.tf(x, y, z, [confocal_ellipsoid], B0, inc,
                                      dec)
    # Comparison between the moments and total-field anomalies
    assert_almost_equal(moment, moment_confocal, decimal=5)
    assert_almost_equal(tf, tf_confocal, decimal=12)
예제 #2
0
def test_oblate_ellipsoid_principal_susceptibilities_signal():
    'principal susceptibilities must be all positive'
    e = OblateEllipsoid(x=1, y=2, z=3, small_axis=4, large_axis=6,
                        strike=10, dip=20, rake=30,
                        props={'remanent magnetization': [10, 25, 40],
                               'principal susceptibilities': [0.562, 0.485,
                                                              0.9],
                               'susceptibility angles': [19, -14, 100]})
    with raises(AssertionError):
        e.susceptibility_tensor
예제 #3
0
def test_oblate_ellipsoid_susceptibility_tensor_symm():
    'susceptibility tensor must be symmetric'
    e = OblateEllipsoid(x=1, y=2, z=3,
                        small_axis=4, large_axis=6,
                        strike=10, dip=20, rake=30,
                        props={'remanent magnetization': [10, 25, 40],
                               'principal susceptibilities': [0.562, 0.485,
                                                              0.25],
                               'susceptibility angles': [-240, 71, -2]})
    assert_almost_equal(e.susceptibility_tensor, e.susceptibility_tensor.T,
                        decimal=15)
예제 #4
0
def test_oblate_ellipsoid_principal_susceptibilities_fmt():
    'principal susceptibilities must be a list containing 3 elements'
    e = OblateEllipsoid(x=1, y=2, z=3,
                        small_axis=4, large_axis=6,
                        strike=10, dip=20, rake=30,
                        props={'remanent magnetization': [10, 25, 40],
                               'principal susceptibilities': [0.562, 0.485],
                               'susceptibility angles': [90, 0, 0]})

    with raises(AssertionError):
        e.susceptibility_tensor
예제 #5
0
def test_oblate_ellipsoid_copy():
    'Check the elements of a duplicated ellipsoid'
    orig = OblateEllipsoid(1, 2, 3, 4, 6, 10, 20, 30, {
        'remanent magnetization': [3, -2, 40],
        'susceptibility tensor': [0.562, 0.485, 0.25,
                                  90, 34, 0]})
    cp = orig.copy()
    assert orig is not cp
    assert orig.x == cp.x
    assert orig.y == cp.y
    assert orig.z == cp.z
    assert orig.small_axis == cp.small_axis
    assert orig.large_axis == cp.large_axis
    assert orig.props == cp.props

    cp.x = 4
    cp.y = 6
    cp.z = 7
    cp.props['remanent magnetization'] = [100, -40, -25]
    assert orig.x != cp.x
    assert orig.y != cp.y
    assert orig.z != cp.z
    assert orig.props['remanent magnetization'] != \
        cp.props['remanent magnetization']
inc = 2
dec = -27

gm = 1000  # geometrical factor
area = [-5. * gm, 5. * gm, -5. * gm, 5. * gm]
x, y, z = gridder.scatter(area, 300, z=0.)
axis_ref = gm  # reference semi-axis

# Oblate ellipsoids used for testing
model = [
    OblateEllipsoid(x=-3 * gm,
                    y=-3 * gm,
                    z=3 * axis_ref,
                    small_axis=0.6 * axis_ref,
                    large_axis=axis_ref,
                    strike=78,
                    dip=92,
                    rake=135,
                    props={
                        'principal susceptibilities': [0.7, 0.7, 0.7],
                        'susceptibility angles': [90., 47., 13.]
                    }),
    OblateEllipsoid(x=-gm,
                    y=-gm,
                    z=2.4 * axis_ref,
                    small_axis=0.3 * axis_ref,
                    large_axis=1.1 * axis_ref,
                    strike=4,
                    dip=10,
                    rake=5,
                    props={
                        'principal susceptibilities': [0.2, 0.15, 0.05],