def test_totalfield_sphere():
    '''
    This test compare the results obtained by both function that calculates the total field anomaly due to a solid sphere. The model has the same dimensions, magnetization intensity and also the same pair for inclination and declination. We use the function from Fatiando a Terra in order to compare with our function.
    '''
    incf = 30.
    decf = 30.
    incs = 60.
    decs = 45.
    magnetization = 2.345

    # Modelo para o Fatiando
    xp, yp, zp = gridder.regular((-1000, 1000, -1000, 1000), (200, 200),
                                 z=-345.)
    model = [
        mesher.Sphere(
            -100., 400., 550., 380.,
            {'magnetization': utils.ang2vec(magnetization, incs, decs)})
    ]
    tf = sphere.tf(xp, yp, zp, model, incf, decf)
    tf = tf.reshape(200, 200)

    # Modelo para minha funcao
    x, y = numpy.meshgrid(numpy.linspace(-1000., 1000., 200),
                          numpy.linspace(-1000., 1000., 200))
    z = -345. * numpy.ones((200, 200))
    mymodel = [-100., 400., 550., 380., magnetization]
    mytf = sphere_tfa(y, x, z, mymodel, incf, decf, incs, decs)

    assert_almost_equal(tf, mytf, decimal=5)
示例#2
0
def anomag_model(coords,radii=1.5e3,inc=50, dec=-30):
    
    model =[]
    for coord, radius in zip(coords, radii):
  
        model_tmp = mesher.Sphere(x=coord[0], y=coord[1], z=coord[2], radius=radius,
                      props={'magnetization': utils.ang2vec(1, inc=50, dec=-30)})
            
        model.append(model_tmp)
    
    return model
示例#3
0
def dipolesrand(N, seed,n,deg_dec,deg_inc,std,mag,raio,Lx,Ly,Lz):
    '''
    Generates a set of spheres randomly distribuited within the model
    
    input
    
    N: int - number of prisms
        
    s: int - seed value
    
    n: int - number of magnetized spheres
    
    deg_dec: float - mean value of the declination (degrees)
    
    deg_inc: float - mean value of inclination (degrees)
    
    std: float - standard deviation of the declination and inclination (degrees)
    
    mag: float - magnetization intensity of each sphere (A/m)
    
    raio: float - radius of each sphere (m)  
    
    Lx,Ly,Lz: int - prisms dimensions (m)
    
    return
    
    modelrand: list of geometrical objects using the library Fatiando a Terra.
    '''
    np.random.seed(seed=seed)
    sizex = Lx
    sizey = Ly
    sizez = Lz
    L = N*sizex
    R = raio
    Coordx = np.random.uniform(-0.5*L+R,+0.5*L-R,n) 
    Coordy = np.random.uniform(-0.5*sizey+R,+0.5*sizey-R,n) 
    Coordz = np.random.uniform(-0.5*sizez+R,+0.5*sizez-R,n)
    Dec_rand = np.random.normal(deg_dec, std,n)
    Inc_rand = np.random.normal(deg_inc, std,n)
    
    magrand = []
    for i in range(n):
        magrand.append(ang2vec(mag,Inc_rand[i],Dec_rand[i]))
    
    modelrand = []
    for i in range(n):
        modelrand.append(mesher.Sphere(Coordx[i], Coordy[i], Coordz[i], R , {'magnetization': magrand[i]})) 

    return modelrand,Coordx,Coordy,Coordz
def test_gz_sphere():
    '''
    This test compare the results obtained by both function that calculates the vertical gravitational attraction due to a solid sphere. The model has the same dimensions and same value for the density. We use the function from Fatiando a Terra in order to compare with our function.
    '''

    density = 1500.

    # Modelo para o Fatiando
    xp, yp, zp = gridder.regular((-1000, 1000, -1000, 1000), (200, 200),
                                 z=-345.)
    model = [mesher.Sphere(-100., 400., 550., 380., {'density': density})]
    gz = sphere.gz(xp, yp, zp, model)
    gz = gz.reshape(200, 200)

    # Modelo para minha funcao
    x, y = numpy.meshgrid(numpy.linspace(-1000., 1000., 200),
                          numpy.linspace(-1000., 1000., 200))
    z = -345. * numpy.ones((200, 200))
    mymodel = [-100., 400., 550., 380., density]
    mygz = sphere_gz(y, x, z, mymodel)

    assert_almost_equal(gz, mygz, decimal=5)
示例#5
0
"""
from __future__ import print_function
from fatiando.gravmag import sphere, transform, euler
from fatiando import gridder, utils, mesher
import matplotlib.pyplot as plt
import numpy as np

# Make some synthetic magnetic data to test our Euler deconvolution.
# The regional field
inc, dec = -45, 0
# Make a model of two spheres magnetized by induction only
model = [
    mesher.Sphere(x=-1000,
                  y=-1000,
                  z=1500,
                  radius=1000,
                  props={'magnetization': utils.ang2vec(2, inc, dec)}),
    mesher.Sphere(x=1000,
                  y=1500,
                  z=1000,
                  radius=1000,
                  props={'magnetization': utils.ang2vec(1, inc, dec)})
]
# Generate some magnetic data from the model
shape = (100, 100)
area = [-5000, 5000, -5000, 5000]
x, y, z = gridder.regular(area, shape, z=-150)
data = sphere.tf(x, y, z, model, inc, dec)

# We also need the derivatives of our data
"""
GravMag: Forward modeling of the gravity anomaly and the gzz component of the
gravity gradient tensor using spheres (calculate on random points)
"""
from fatiando import mesher, gridder, utils, gravmag
from fatiando.vis import mpl

spheres = [mesher.Sphere(0, 0, 2000, 1000, {'density': 1000})]
# Create a set of points at 100m height
area = (-5000, 5000, -5000, 5000)
xp, yp, zp = gridder.scatter(area, 500, z=-100)
# Calculate the anomaly
gz = utils.contaminate(gravmag.sphere.gz(xp, yp, zp, spheres), 0.1)
gzz = utils.contaminate(gravmag.sphere.gzz(xp, yp, zp, spheres), 5.0)
# Plot
shape = (100, 100)
mpl.figure()
mpl.title("gz (mGal)")
mpl.axis('scaled')
mpl.plot(yp * 0.001, xp * 0.001, '.k')
mpl.contourf(yp * 0.001, xp * 0.001, gz, shape, 15, interp=True)
mpl.colorbar()
mpl.xlabel('East y (km)')
mpl.ylabel('North x (km)')
mpl.figure()
mpl.title("gzz (Eotvos)")
mpl.axis('scaled')
mpl.plot(yp * 0.001, xp * 0.001, '.k')
mpl.contourf(yp * 0.001, xp * 0.001, gzz, shape, 15, interp=True)
mpl.colorbar()
mpl.xlabel('East y (km)')
from __future__ import division, print_function
from fatiando import mesher, gridder, utils
from fatiando.gravmag import sphere
import matplotlib.pyplot as plt
import numpy as np

# Create a model using geometric objects from fatiando.mesher
# Each model element has a dictionary with its physical properties.
# The spheres have different total magnetization vectors (total = induced +
# remanent + any other effects). Notice that the magnetization has to be a
# vector. Function utils.ang2vec converts intensity, inclination, and
# declination into a 3 component vector for easier handling.
model = [
    mesher.Sphere(x=10e3,
                  y=10e3,
                  z=2e3,
                  radius=1.5e3,
                  props={'magnetization': utils.ang2vec(1, inc=50, dec=-30)}),
    mesher.Sphere(x=20e3,
                  y=20e3,
                  z=2e3,
                  radius=1.5e3,
                  props={'magnetization': utils.ang2vec(1, inc=-70, dec=30)})
]

# Set the inclination and declination of the geomagnetic field.
inc, dec = -10, 13
# Create a regular grid at a constant height
shape = (300, 300)
area = [0, 30e3, 0, 30e3]
x, y, z = gridder.regular(area, shape, z=-10)
"""
GravMag: 3D forward modeling of total-field magnetic anomaly using spheres
"""
from fatiando import mesher, gridder, gravmag, utils
from fatiando.vis import mpl

# Set the inclination and declination of the regional field
inc, dec = -30, 45
# Create a sphere model
spheres = [
    # One with induced magnetization
    mesher.Sphere(0, 2000, 600, 500, {'magnetization': 5}),
    # and one with remanent
    mesher.Sphere(0, -2000, 600, 500,
                  {'magnetization': utils.ang2vec(10, 70, -50)})
]  # induced + remanet
# Create a regular grid at 100m height
shape = (100, 100)
area = (-5000, 5000, -5000, 5000)
xp, yp, zp = gridder.regular(area, shape, z=-100)
# Calculate the anomaly for a given regional field
tf = gravmag.sphere.tf(xp, yp, zp, spheres, inc, dec)
# Plot
mpl.figure()
mpl.title("Total-field anomaly (nT)")
mpl.axis('scaled')
mpl.contourf(yp, xp, tf, shape, 15)
mpl.colorbar()
mpl.xlabel('East y (km)')
mpl.ylabel('North x (km)')
mpl.m2km()
coordinates.

"""
from __future__ import division, print_function
from fatiando import mesher, gridder, utils
from fatiando.gravmag import sphere
import matplotlib.pyplot as plt
import numpy as np

# Create a model using geometric objects from fatiando.mesher
# Each model element has a dictionary with its physical properties.
# We'll use two spheres with opposite density contrast values.
model = [
    mesher.Sphere(x=10e3,
                  y=10e3,
                  z=1.5e3,
                  radius=1.5e3,
                  props={'density': 500}),
    mesher.Sphere(x=20e3,
                  y=20e3,
                  z=1.5e3,
                  radius=1.5e3,
                  props={'density': -500})
]

# Create a regular grid at a constant height
shape = (300, 300)
area = [0, 30e3, 0, 30e3]
x, y, z = gridder.regular(area, shape, z=-100)

fields = [
GravMag: Use the DipoleMagDir class to estimate the magnetization direction
of dipoles with known centers
"""
import numpy

from fatiando import mesher, gridder
from fatiando.utils import ang2vec, vec2ang, contaminate
from fatiando.gravmag import sphere
from fatiando.vis import mpl
from fatiando.gravmag.magdir import DipoleMagDir
from fatiando.constants import CM

# Make noise-corrupted synthetic data
inc, dec = -10.0, -15.0  # inclination and declination of the Geomagnetic Field
model = [
    mesher.Sphere(3000, 3000, 1000, 1000,
                  {'magnetization': ang2vec(6.0, -20.0, -10.0)}),
    mesher.Sphere(7000, 7000, 1000, 1000,
                  {'magnetization': ang2vec(10.0, 3.0, -67.0)})
]
area = (0, 10000, 0, 10000)
x, y, z = gridder.scatter(area, 1000, z=-150, seed=0)
tf = contaminate(sphere.tf(x, y, z, model, inc, dec), 5.0, seed=0)

# Give the centers of the dipoles
centers = [[3000, 3000, 1000], [7000, 7000, 1000]]

# Estimate the magnetization vectors
solver = DipoleMagDir(x, y, z, tf, inc, dec, centers).fit()

# Print the estimated and true dipole monents, inclinations and declinations
print 'Estimated magnetization (intensity, inclination, declination)'