Beispiel #1
0
def parameters_sph(N,coord):
    '''
    Makes the transformation from Cartesian Coordinates to Intensity, Declination
    and Inclination
    
    input
    
    N: int - number of prisms
    
    coord: list - list of Cartesian Coordinates of the parameters
    
    return
    
    mag_sph: array - Matrix with shape (N x 3) containing each row with the values of 
    intensity, declination and inclination.
    '''
    
    mag_cart = []
    for i in range(N):
        mag_cart.append(np.array([coord[3*i],coord[3*i+1],coord[3*i+2]]))
        
        
    mag_spheric = []
    for i in range(N):
        aux = vec2ang(mag_cart[i])
        if (aux[2] > 180.):
            aux[2] -= 360.
        if (aux[2] <= -180.):
            aux[2] += 360.
        mag_spheric.append(aux)
    mag_sph = np.array(mag_spheric)
    return mag_sph
def test_confocal_triaxial_ellipsoids():
    "Confocal bodies with properly scaled suscep produce the same field"
    # Reference ellipsoid
    a, b, c = 900., 500., 100.  # semi-axes
    chi = 1.2  # reference susceptibility
    ellipsoid = TriaxialEllipsoid(0., 0., 1500., a, b, c, 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 = triaxial_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)
    c_confocal = np.sqrt(c*c + u)
    xc = ellipsoid.x
    yc = ellipsoid.y
    zc = ellipsoid.z
    strike = ellipsoid.strike
    dip = ellipsoid.dip
    rake = ellipsoid.rake
    confocal_ellipsoid = TriaxialEllipsoid(xc, yc, zc,
                                           a_confocal, b_confocal, c_confocal,
                                           strike, dip, rake,
                                           {'susceptibility angles':
                                            [0., 0., 0.]})
    n11, n22, n33 = triaxial_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 = triaxial_ellipsoid.magnetization(confocal_ellipsoid, B0,
                                                    inc, dec, demag=True)
    moment_confocal = volume_confocal*mag_confocal
    # Total-field anomalies
    tf = triaxial_ellipsoid.tf(x, y, z, [ellipsoid], B0, inc, dec)
    tf_confocal = triaxial_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)
def jrd_cartesiano(inten, inc, dec, ellipsoids):
    inc = np.deg2rad(inc)
    dec = np.deg2rad(dec)
    lt, mt, nt = lmnn_v(dec, inc)
    Ft = []
    JR = []
    JRD = []
    JRD_carte = []
    JRD_ang = []
    for i in range(len(ellipsoids)):
        Ft.append(
            F_e(inten, lt, mt, nt, ellipsoids[i].mcon[0, 0],
                ellipsoids[i].mcon[1, 0], ellipsoids[i].mcon[2, 0],
                ellipsoids[i].mcon[0, 1], ellipsoids[i].mcon[1, 1],
                ellipsoids[i].mcon[2, 1], ellipsoids[i].mcon[0, 2],
                ellipsoids[i].mcon[1, 2], ellipsoids[i].mcon[2, 2]))
        JR.append(JR_e(ellipsoids[i].km, ellipsoids[i].JN, Ft[i]))
        JRD.append(
            JRD_e(ellipsoids[i].km, ellipsoids[i].N1, ellipsoids[i].N2,
                  ellipsoids[i].N3, JR[i]))
        JRD_carte.append((ellipsoids[i].mconT).dot(JRD[i]))
        JRD_ang.append(utils.vec2ang(JRD_carte[i]))
    return JRD_ang
def elipsoide(a, b, h, alfa, delta, X, Y, Z, xc, yc, declinacao, inclinacao,
              intensidade, declinacaoT, inclinacaoT, intensidadeT, km):
    '''
    Calcula as tres componentes do campo magnetico de um elipsoide.
    
    a: escalar - semi eixo maior
    b: escalar - semi eixo intermediario
    c: escalar - semi eixo menor
    h: escalar -  profundidade
    alfa: escalar - azimute do elipsoide em relacao ao "a"
    delta: escalar - inclinacao do elipsoide em relacao ao "a"
    gamma: escalar - angulo entre o semi eixo "b" e a projecao do centro do elipsoide no plano xy
    X: matriz - malha do eixo x
    Y: matriz - malha do eixo y
    Z: matriz - malha do eixo z
    xc: escalar - posicao x do centro do elipsoide
    yc: escalar - posicao y do centro do elipsoide
    J: vetor - magnetizacao do corpo
    '''

    # Calculo de parametros de direcao
    l1 = l1_v(alfa, delta)
    l2 = l2_v(alfa, delta)
    l3 = l3_v(alfa, delta)

    m1 = m1_v(alfa, delta)
    m2 = m2_v(alfa, delta)
    m3 = m3_v(alfa, delta)

    n1 = n1_v(delta)
    n2 = n2_v(delta)
    n3 = n3_v(delta)

    ln = ln_v(declinacao, inclinacao)
    mn = mn_v(declinacao, inclinacao)
    nn = nn_v(inclinacao)

    lt = ln_v(declinacaoT, inclinacaoT)
    mt = mn_v(declinacaoT, inclinacaoT)
    nt = nn_v(inclinacaoT)

    # Magnetizacoes nas coordenadas do elipsoide
    F = F_e(intensidadeT, lt, mt, nt, l1, l2, l3, m1, m2, m3, n1, n2, n3)
    JN = JN_e(intensidade, ln, mn, nn, l1, l2, l3, m1, m2, m3, n1, n2, n3)
    N1, N2 = N_desmag(a, b)
    JR = JR_e(km, JN, F)
    JRD = JRD_e(km, N1, N2, F, JR)
    mcon = np.array([[l1, m1, n1], [l2, m2, n2], [l3, m3, n3]])
    mconT = (mcon).T
    JRD_carte = (mconT).dot(JRD)
    JRD_ang = utils.vec2ang(JRD_carte)
    print JRD_ang

    # Coordenadas Cartesianas elipsoide
    x1 = x1_e(X, Y, Z, xc, yc, h, l1, m1, n1)
    x2 = x2_e(X, Y, Z, xc, yc, h, l2, m2, n2)
    x3 = x3_e(X, Y, Z, xc, yc, h, l3, m3, n3)

    # Calculos auxiliares
    r = r_e(x1, x2, x3)
    delta = delta_e(r, a, b, x1, x2, x3)

    # Raizes da equacao cubica
    lamb = lamb_e(r, a, b, delta)

    # Derivadas de lambda em relacao as posicoes
    dlambx1 = dlambx1_e(a, b, x1, x2, x3, lamb, r, delta)
    dlambx2 = dlambx2_e(a, b, x1, x2, x3, lamb, r, delta)
    dlambx3 = dlambx3_e(a, b, x1, x2, x3, lamb, r, delta)

    # Calculos auxiliares do campo
    f1 = f1_e(a, b, x1, x2, x3, lamb, JRD)
    tang = tang_e(a, b, lamb)
    f2 = f2_e(a, b, lamb, tang)

    # Problema Direto (Calcular o campo externo nas coordenadas do elipsoide)
    B1 = B1_e(dlambx1, JRD, f1, f2, tang, a, b, lamb)
    B2 = B2_e(dlambx2, JRD, f1, f2)
    B3 = B3_e(dlambx3, JRD, f1, f2)

    # Problema Direto (Calcular o campo externo nas coordenadas geograficas)
    Bx = Bx_c(B1, B2, B3, l1, l2, l3)
    By = By_c(B1, B2, B3, m1, m2, m3)
    Bz = Bz_c(B1, B2, B3, n1, n2, n3)

    #Constante magnetica SI
    ctemag = 1.

    # Problema Direto (Calcular o campo externo nas coordenadas geograficas no SI)
    Bx = Bx * ctemag
    By = By * ctemag
    Bz = Bz * ctemag

    return Bx, By, Bz
Beispiel #5
0
def elipsoide(xp, yp, zp, inten, inc, dec, ellipsoids):
    '''
    Calcula as tres componentes do campo magnetico de um elipsoide.
    
    a: escalar - semi eixo maior
    b: escalar - semi eixo intermediario
    c: escalar - semi eixo menor
    h: escalar -  profundidade
    alfa: escalar - azimute do elipsoide em relacao ao "a"
    delta: escalar - inclinacao do elipsoide em relacao ao "a"
    gamma: escalar - angulo entre o semi eixo "b" e a projecao do centro do elipsoide no plano xy
    xp: matriz - malha do eixo x
    yp: matriz - malha do eixo y
    zp: matriz - malha do eixo z
    xc: escalar - posicao x do centro do elipsoide
    yc: escalar - posicao y do centro do elipsoide
    J: vetor - magnetizacao do corpo
    '''

    # Calculo de parametros de direcao
    #l1 = l1_v (ellipsoids.alfa, ellipsoids.delta)
    #l2 = l2_v (ellipsoids.alfa, ellipsoids.delta, ellipsoids.gamma)
    #l3 = l3_v (ellipsoids.alfa, ellipsoids.delta, ellipsoids.gamma)

    #m1 = m1_v (ellipsoids.alfa, ellipsoids.delta)
    #m2 = m2_v (ellipsoids.alfa, ellipsoids.delta, ellipsoids.gamma)
    #m3 = m3_v (ellipsoids.alfa, ellipsoids.delta, ellipsoids.gamma)

    #n1 = n1_v (ellipsoids.delta)
    #n2 = n2_v (ellipsoids.delta, ellipsoids.gamma)
    #n3 = n3_v (ellipsoids.delta, ellipsoids.gamma)

    #ln = ln_v (ellipsoids.props['remanence'][2], ellipsoids.props['remanence'][1])
    #mn = mn_v (ellipsoids.props['remanence'][2], ellipsoids.props['remanence'][1])
    #nn = nn_v (ellipsoids.props['remanence'][1])

    #mcon = np.array([[l1, m1, n1],[l2, m2, n2],[l3, m3, n3]])
    #mconT = mcon.T
    #print mconT

    lt = ln_v(dec, inc)
    mt = mn_v(dec, inc)
    nt = nn_v(inc)
    #print l1,m1,n1
    #print l2,m2,n2
    #print l3,m3,n3
    # Coordenadas Cartesianas elipsoide
    x1 = x1_e(xp, yp, zp, ellipsoids.xc, ellipsoids.yc, ellipsoids.zc,
              ellipsoids.l1, ellipsoids.m1, ellipsoids.n1)
    x2 = x2_e(xp, yp, zp, ellipsoids.xc, ellipsoids.yc, ellipsoids.zc,
              ellipsoids.l2, ellipsoids.m2, ellipsoids.n2)
    x3 = x3_e(xp, yp, zp, ellipsoids.xc, ellipsoids.yc, ellipsoids.zc,
              ellipsoids.l3, ellipsoids.m3, ellipsoids.n3)

    # Calculos auxiliares
    p0 = p0_e(ellipsoids.a, ellipsoids.b, ellipsoids.c, x1, x2, x3)
    p1 = p1_e(ellipsoids.a, ellipsoids.b, ellipsoids.c, x1, x2, x3)
    p2 = p2_e(ellipsoids.a, ellipsoids.b, ellipsoids.c, x1, x2, x3)
    p = p_e(p1, p2)
    q = q_e(p0, p1, p2)
    teta = teta_e(p, q)

    # Raizes da equacao cubica
    lamb = lamb_e(p, teta, p2)

    # Calculo de parametros para as integrais
    F, E, F2, E2, k, teta_linha = parametros_integrais(ellipsoids.a,
                                                       ellipsoids.b,
                                                       ellipsoids.c, lamb)

    # Magnetizacoes nas coordenadas do elipsoide
    #k_dec = np.array([[ellipsoids.props['k1'][2]],[ellipsoids.props['k2'][2]],[ellipsoids.props['k3'][2]]])
    #k_int = np.array([[ellipsoids.props['k1'][0]],[ellipsoids.props['k2'][0]],[ellipsoids.props['k3'][0]]])
    #k_inc = np.array([[ellipsoids.props['k1'][1]],[ellipsoids.props['k2'][1]],[ellipsoids.props['k3'][1]]])
    #if ellipsoids.props['k1'][0] == ellipsoids.props['k2'][0] and ellipsoids.props['k1'][0] == ellipsoids.props['k3'][0]:
    #    km = k_matrix2 (k_int,l1,l2,l3,m1,m2,m3,n1,n2,n3)
    #else:
    #    Lr = Lr_v (k_dec, k_inc)
    #    Mr = Mr_v (k_dec, k_inc)
    #    Nr = Nr_v (k_inc)
    #    km = k_matrix (k_int,Lr,Mr,Nr,l1,l2,l3,m1,m2,m3,n1,n2,n3)
    Ft = F_e(inten, lt, mt, nt, ellipsoids.l1, ellipsoids.l2, ellipsoids.l3,
             ellipsoids.m1, ellipsoids.m2, ellipsoids.m3, ellipsoids.n1,
             ellipsoids.n2, ellipsoids.n3)
    JN = JN_e(ellipsoids.props['remanence'][0], ellipsoids.ln, ellipsoids.mn,
              ellipsoids.nn, ellipsoids.l1, ellipsoids.l2, ellipsoids.l3,
              ellipsoids.m1, ellipsoids.m2, ellipsoids.m3, ellipsoids.n1,
              ellipsoids.n2, ellipsoids.n3)
    N1, N2, N3 = N_desmag(ellipsoids.a, ellipsoids.b, ellipsoids.c, F2, E2)
    JR = JR_e(ellipsoids.km, JN, Ft)
    JRD = JRD_e(ellipsoids.km, N1, N2, N3, JR)
    JRD_carte = (ellipsoids.mconT).dot(JRD)
    JRD_ang = utils.vec2ang(JRD_carte)
    #print Ft
    #print JN
    #print JRD
    #print N1,N2,N3
    #print JRD_ang

    # Derivadas de lambda em relacao as posicoes
    dlambx1 = dlambx1_e(ellipsoids.a, ellipsoids.b, ellipsoids.c, x1, x2, x3,
                        lamb)
    dlambx2 = dlambx2_e(ellipsoids.a, ellipsoids.b, ellipsoids.c, x1, x2, x3,
                        lamb)
    dlambx3 = dlambx3_e(ellipsoids.a, ellipsoids.b, ellipsoids.c, x1, x2, x3,
                        lamb)

    # Calculo das integrais
    A, B, C = integrais_elipticas(ellipsoids.a, ellipsoids.b, ellipsoids.c, k,
                                  teta_linha, F, E)

    # Geometria para o calculo de B (eixo do elipsoide)
    cte = cte_m(ellipsoids.a, ellipsoids.b, ellipsoids.c, lamb)
    V1, V2, V3 = v_e(ellipsoids.a, ellipsoids.b, ellipsoids.c, x1, x2, x3,
                     lamb)

    # Calculo matriz geometria para B1
    m11 = (cte * dlambx1 * V1) - A
    m12 = cte * dlambx1 * V2
    m13 = cte * dlambx1 * V3

    # Calculo matriz geometria para B2
    m21 = cte * dlambx2 * V1
    m22 = (cte * dlambx2 * V2) - B
    m23 = cte * dlambx2 * V3

    # Calculo matriz geometria para B3
    m31 = cte * dlambx3 * V1
    m32 = cte * dlambx3 * V2
    m33 = (cte * dlambx3 * V3) - C

    # Problema Direto (Calcular o campo externo nas coordenadas do elipsoide)
    B1 = B1_e(m11, m12, m13, JRD, ellipsoids.a, ellipsoids.b, ellipsoids.c)
    B2 = B2_e(m21, m22, m23, JRD, ellipsoids.a, ellipsoids.b, ellipsoids.c)
    B3 = B3_e(m31, m32, m33, JRD, ellipsoids.a, ellipsoids.b, ellipsoids.c)

    #constante = constante_nova (a,b,c,lamb,JRD,x1,x2,x3)
    #B1 = B1_novo (constante,dlambx1,a,b,c,JRD,A)
    #B2 = B2_novo (constante,dlambx2,a,b,c,JRD,B)
    #B3 = B3_novo (constante,dlambx3,a,b,c,JRD,C)

    # Problema Direto (Calcular o campo externo nas coordenadas geograficas)
    Bx = Bx_c(B1, B2, B3, ellipsoids.l1, ellipsoids.l2, ellipsoids.l3)
    By = By_c(B1, B2, B3, ellipsoids.m1, ellipsoids.m2, ellipsoids.m3)
    Bz = Bz_c(B1, B2, B3, ellipsoids.n1, ellipsoids.n2, ellipsoids.n3)

    return Bx, By, Bz, JRD_ang
def elipsoide (xp,yp,zp,inten,inc,dec,ellipsoids):
    '''
    Calcula as tres componentes do campo magnetico de um elipsoide.
    
    a: escalar - semi eixo maior
    b: escalar - semi eixo intermediario
    c: escalar - semi eixo menor
    h: escalar -  profundidade
    alfa: escalar - azimute do elipsoide em relacao ao "a"
    delta: escalar - inclinacao do elipsoide em relacao ao "a"
    gamma: escalar - angulo entre o semi eixo "b" e a projecao do centro do elipsoide no plano xy
    xp: matriz - malha do eixo x
    yp: matriz - malha do eixo y
    zp: matriz - malha do eixo z
    xc: escalar - posicao x do centro do elipsoide
    yc: escalar - posicao y do centro do elipsoide
    J: vetor - magnetizacao do corpo
    '''
    
    # Calculo do vetor de magnetizacao resultante
    lt = ln_v (dec, inc)
    mt = mn_v (dec, inc)
    nt = nn_v (inc)
    Ft = F_e (inten,lt,mt,nt,ellipsoids.l1,ellipsoids.l2,ellipsoids.l3,ellipsoids.m1,ellipsoids.m2,ellipsoids.m3,ellipsoids.n1,ellipsoids.n2,ellipsoids.n3)
    JR = JR_e (ellipsoids.km,ellipsoids.JN,Ft)
    JRD = JRD_e (ellipsoids.km,ellipsoids.N1,ellipsoids.N2,ellipsoids.N3,JR)
    JRD_carte = (ellipsoids.mconT).dot(JRD)
    JRD_ang = utils.vec2ang(JRD_carte)
    #print JRD_ang
        
    # Derivadas de lambda em relacao as posicoes
    dlambx1 = dlambx1_e (ellipsoids.a,ellipsoids.b,ellipsoids.c,ellipsoids.x1,ellipsoids.x2,ellipsoids.x3,ellipsoids.lamb)
    dlambx2 = dlambx2_e (ellipsoids.a,ellipsoids.b,ellipsoids.c,ellipsoids.x1,ellipsoids.x2,ellipsoids.x3,ellipsoids.lamb)
    dlambx3 = dlambx3_e (ellipsoids.a,ellipsoids.b,ellipsoids.c,ellipsoids.x1,ellipsoids.x2,ellipsoids.x3,ellipsoids.lamb)
    #print dlambx1,dlambx2,dlambx3
    
    # Calculo das integrais
    A, B, C = integrais_elipticas(ellipsoids.a,ellipsoids.b,ellipsoids.c,ellipsoids.k,ellipsoids.teta_linha,ellipsoids.F,ellipsoids.E)
    
    # Geometria para o calculo de B (eixo do elipsoide)
    cte = cte_m (ellipsoids.a,ellipsoids.b,ellipsoids.c,ellipsoids.lamb)
    V1, V2, V3 = v_e (ellipsoids.a,ellipsoids.b,ellipsoids.c,ellipsoids.x1,ellipsoids.x2,ellipsoids.x3,ellipsoids.lamb)
    
    # Calculo matriz geometria para B1
    m11 = (cte*dlambx1*V1) - A
    m12 = cte*dlambx1*V2
    m13 = cte*dlambx1*V3

    # Calculo matriz geometria para B2
    m21 = cte*dlambx2*V1
    m22 = (cte*dlambx2*V2) - B
    m23 = cte*dlambx2*V3

    # Calculo matriz geometria para B3
    m31 = cte*dlambx3*V1
    m32 = cte*dlambx3*V2
    m33 = (cte*dlambx3*V3) - C
    
    # Problema Direto (Calcular o campo externo nas coordenadas do elipsoide)
    B1 = B1_e (m11,m12,m13,JRD,ellipsoids.a,ellipsoids.b,ellipsoids.c)
    B2 = B2_e (m21,m22,m23,JRD,ellipsoids.a,ellipsoids.b,ellipsoids.c)
    B3 = B3_e (m31,m32,m33,JRD,ellipsoids.a,ellipsoids.b,ellipsoids.c)
    
    # Problema Direto (Calcular o campo externo nas coordenadas geograficas)
    Bx = Bx_c (B1,B2,B3,ellipsoids.l1,ellipsoids.l2,ellipsoids.l3)
    By = By_c (B1,B2,B3,ellipsoids.m1,ellipsoids.m2,ellipsoids.m3)
    Bz = Bz_c (B1,B2,B3,ellipsoids.n1,ellipsoids.n2,ellipsoids.n3)
    
    return Bx,By,Bz
def elipsoide(xp, yp, zp, inten, inc, dec, ellipsoids):
    '''
    Calcula as tres componentes do campo magnetico de um elipsoide.
    
    a: escalar - semi eixo maior
    b: escalar - semi eixo intermediario
    c: escalar - semi eixo menor
    h: escalar -  profundidade
    alfa: escalar - azimute do elipsoide em relacao ao "a"
    delta: escalar - inclinacao do elipsoide em relacao ao "a"
    gamma: escalar - angulo entre o semi eixo "b" e a projecao do centro do elipsoide no plano xy
    xp: matriz - malha do eixo x
    yp: matriz - malha do eixo y
    zp: matriz - malha do eixo z
    xc: escalar - posicao x do centro do elipsoide
    yc: escalar - posicao y do centro do elipsoide
    J: vetor - magnetizacao do corpo
    '''

    # Calculo do vetor de magnetizacao resultante
    lt, mt, nt = lmnn_v(dec, inc)
    Ft = F_e(inten, lt, mt, nt, ellipsoids.mcon[0, 0], ellipsoids.mcon[1, 0],
             ellipsoids.mcon[2, 0], ellipsoids.mcon[0, 1],
             ellipsoids.mcon[1, 1], ellipsoids.mcon[2, 1],
             ellipsoids.mcon[0, 2], ellipsoids.mcon[1, 2], ellipsoids.mcon[2,
                                                                           2])
    JR = JR_e(ellipsoids.km, ellipsoids.JN, Ft)
    JRD = JRD_e(ellipsoids.km, ellipsoids.N1, ellipsoids.N2, ellipsoids.N3, JR)
    JRD_carte = (ellipsoids.mconT).dot(JRD)
    JRD_ang = utils.vec2ang(JRD_carte)

    # Problema Direto (Calcular o campo externo nas coordenadas do elipsoide)
    if ellipsoids.axis[0] > ellipsoids.axis[1] and ellipsoids.axis[
            1] > ellipsoids.axis[2]:
        B1 = B1_e(ellipsoids.m11, ellipsoids.m12, ellipsoids.m13, JRD,
                  ellipsoids.axis[0], ellipsoids.axis[1], ellipsoids.axis[2])
        B2 = B2_e(ellipsoids.m21, ellipsoids.m22, ellipsoids.m23, JRD,
                  ellipsoids.axis[0], ellipsoids.axis[1], ellipsoids.axis[2])
        B3 = B3_e(ellipsoids.m31, ellipsoids.m32, ellipsoids.m33, JRD,
                  ellipsoids.axis[0], ellipsoids.axis[1], ellipsoids.axis[2])

    if ellipsoids.axis[1] == ellipsoids.axis[
            2] and ellipsoids.axis[0] > ellipsoids.axis[1]:
        f1 = f1_PO(ellipsoids.axis[0], ellipsoids.axis[1], ellipsoids.x1,
                   ellipsoids.x2, ellipsoids.x3, ellipsoids.lamb, JRD)
        log = log_P(ellipsoids.axis[0], ellipsoids.axis[1], ellipsoids.lamb)
        f2 = f2_P(ellipsoids.axis[0], ellipsoids.axis[1], ellipsoids.lamb, log)
        B1 = B1_P(ellipsoids.dlambx1, JRD, f1, f2, log, ellipsoids.axis[0],
                  ellipsoids.axis[1], ellipsoids.lamb)
        B2 = B2_PO(ellipsoids.dlambx2, JRD, f1, f2)
        B3 = B3_PO(ellipsoids.dlambx3, JRD, f1, f2)
        #print f1

    if ellipsoids.axis[1] == ellipsoids.axis[
            2] and ellipsoids.axis[0] < ellipsoids.axis[1]:
        f1 = f1_PO(ellipsoids.axis[0], ellipsoids.axis[1], ellipsoids.x1,
                   ellipsoids.x2, ellipsoids.x3, ellipsoids.lamb, JRD)
        arctang = arctang_O(ellipsoids.axis[0], ellipsoids.axis[1],
                            ellipsoids.lamb)
        f2 = f2_O(ellipsoids.axis[0], ellipsoids.axis[1], arctang,
                  ellipsoids.lamb)
        B1 = B1_O(ellipsoids.dlambx1, JRD, f1, f2, arctang, ellipsoids.axis[0],
                  ellipsoids.axis[1], ellipsoids.lamb)
        B2 = B2_PO(ellipsoids.dlambx2, JRD, f1, f2)
        B3 = B3_PO(ellipsoids.dlambx3, JRD, f1, f2)
        #print np.max(np.abs([np.max(B3), np.min(B3)]))

    # Problema Direto (Calcular o campo externo nas coordenadas geograficas)
    Bx = Bx_c(B1, B2, B3, ellipsoids.mcon[0, 0], ellipsoids.mcon[1, 0],
              ellipsoids.mcon[2, 0])
    By = By_c(B1, B2, B3, ellipsoids.mcon[0, 1], ellipsoids.mcon[1, 1],
              ellipsoids.mcon[2, 1])
    Bz = Bz_c(B1, B2, B3, ellipsoids.mcon[0, 2], ellipsoids.mcon[1, 2],
              ellipsoids.mcon[2, 2])

    return Bx, By, Bz